@fluidframework/driver-utils 1.2.7 → 2.0.0-dev.1.3.0.96595

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.
Files changed (63) hide show
  1. package/.mocharc.js +12 -0
  2. package/dist/documentStorageServiceProxy.d.ts +2 -2
  3. package/dist/documentStorageServiceProxy.d.ts.map +1 -1
  4. package/dist/documentStorageServiceProxy.js +2 -2
  5. package/dist/documentStorageServiceProxy.js.map +1 -1
  6. package/dist/messageRecognition.d.ts +38 -22
  7. package/dist/messageRecognition.d.ts.map +1 -1
  8. package/dist/messageRecognition.js +48 -23
  9. package/dist/messageRecognition.js.map +1 -1
  10. package/dist/network.d.ts +15 -1
  11. package/dist/network.d.ts.map +1 -1
  12. package/dist/network.js +22 -1
  13. package/dist/network.js.map +1 -1
  14. package/dist/packageVersion.d.ts +1 -1
  15. package/dist/packageVersion.d.ts.map +1 -1
  16. package/dist/packageVersion.js +1 -1
  17. package/dist/packageVersion.js.map +1 -1
  18. package/dist/parallelRequests.d.ts +14 -2
  19. package/dist/parallelRequests.d.ts.map +1 -1
  20. package/dist/parallelRequests.js +21 -7
  21. package/dist/parallelRequests.js.map +1 -1
  22. package/dist/readAndParse.d.ts +9 -4
  23. package/dist/readAndParse.d.ts.map +1 -1
  24. package/dist/readAndParse.js +9 -4
  25. package/dist/readAndParse.js.map +1 -1
  26. package/dist/runWithRetry.d.ts +9 -5
  27. package/dist/runWithRetry.d.ts.map +1 -1
  28. package/dist/runWithRetry.js.map +1 -1
  29. package/lib/documentStorageServiceProxy.d.ts +2 -2
  30. package/lib/documentStorageServiceProxy.d.ts.map +1 -1
  31. package/lib/documentStorageServiceProxy.js +2 -2
  32. package/lib/documentStorageServiceProxy.js.map +1 -1
  33. package/lib/messageRecognition.d.ts +38 -22
  34. package/lib/messageRecognition.d.ts.map +1 -1
  35. package/lib/messageRecognition.js +46 -22
  36. package/lib/messageRecognition.js.map +1 -1
  37. package/lib/network.d.ts +15 -1
  38. package/lib/network.d.ts.map +1 -1
  39. package/lib/network.js +19 -0
  40. package/lib/network.js.map +1 -1
  41. package/lib/packageVersion.d.ts +1 -1
  42. package/lib/packageVersion.d.ts.map +1 -1
  43. package/lib/packageVersion.js +1 -1
  44. package/lib/packageVersion.js.map +1 -1
  45. package/lib/parallelRequests.d.ts +14 -2
  46. package/lib/parallelRequests.d.ts.map +1 -1
  47. package/lib/parallelRequests.js +21 -7
  48. package/lib/parallelRequests.js.map +1 -1
  49. package/lib/readAndParse.d.ts +9 -4
  50. package/lib/readAndParse.d.ts.map +1 -1
  51. package/lib/readAndParse.js +9 -4
  52. package/lib/readAndParse.js.map +1 -1
  53. package/lib/runWithRetry.d.ts +9 -5
  54. package/lib/runWithRetry.d.ts.map +1 -1
  55. package/lib/runWithRetry.js.map +1 -1
  56. package/package.json +40 -17
  57. package/src/documentStorageServiceProxy.ts +8 -2
  58. package/src/messageRecognition.ts +48 -23
  59. package/src/network.ts +31 -0
  60. package/src/packageVersion.ts +1 -1
  61. package/src/parallelRequests.ts +21 -6
  62. package/src/readAndParse.ts +9 -4
  63. package/src/runWithRetry.ts +9 -5
@@ -1 +1 @@
1
- {"version":3,"file":"parallelRequests.js","sourceRoot":"","sources":["../src/parallelRequests.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,+DAA6E;AAE7E,qEAAmE;AAGnE,uCAA+F;AAC/F,iDAA0E;AAC1E,sFAAsF;AACtF,qDAA+D;AAE/D,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAChC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAIlC;;;;;;;;;;;GAWG;AACH,MAAa,gBAAgB;IAazB,YACI,IAAY,EACJ,EAAsB,EACb,WAAmB,EACnB,MAAwB,EACxB,eAKgF,EAChF,gBAAwC;QATjD,OAAE,GAAF,EAAE,CAAoB;QACb,gBAAW,GAAX,WAAW,CAAQ;QACnB,WAAM,GAAN,MAAM,CAAkB;QACxB,oBAAe,GAAf,eAAe,CA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AC5F,OAAO;QACH,IAAI,EAAE,KAAK,IAAI,EAAE;YACb,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO,CAAC,KAAK,CAAC,CAAC;YACf,OAAO,KAAK,CAAC;QACjB,CAAC;KACJ,CAAC;AACN,CAAC;AARD,wCAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { assert, Deferred, performance } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IDeltasFetchResult, IStream, IStreamResult } from \"@fluidframework/driver-definitions\";\nimport { getRetryDelayFromError, canRetryOnError, createGenericNetworkError } from \"./network\";\nimport { waitForConnectedState, logNetworkFailure } from \"./networkUtils\";\n// For now, this package is versioned and released in unison with the specific drivers\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\nconst MaxFetchDelayInMs = 10000;\nconst MissingFetchDelayInMs = 100;\n\ntype WorkingState = \"working\" | \"done\" | \"canceled\";\n\n/**\n * Helper class to organize parallel fetching of data\n * It can be used to concurrently do many requests, while consuming\n * data in the right order. Take a look at UT for examples.\n * @param concurrency - level of concurrency\n * @param from - starting point of fetching data (inclusive)\n * @param to - ending point of fetching data. exclusive, or undefined if unknown\n * @param payloadSize - batch size\n * @param logger - logger to use\n * @param requestCallback - callback to request batches\n * @returns - Queue that can be used to retrieve data\n */\nexport class ParallelRequests<T> {\n private latestRequested: number;\n private nextToDeliver: number;\n private readonly results: Map<number, T[]> = new Map();\n private workingState: WorkingState = \"working\";\n private requestsInFlight = 0;\n private readonly endEvent = new Deferred<void>();\n private requests = 0;\n private readonly knewTo: boolean;\n\n private get working() { return this.workingState === \"working\"; }\n public get canceled() { return this.workingState === \"canceled\"; }\n\n constructor(\n from: number,\n private to: number | undefined,\n private readonly payloadSize: number,\n private readonly logger: ITelemetryLogger,\n private readonly requestCallback: (\n request: number,\n from: number,\n to: number,\n strongTo: boolean,\n props: ITelemetryProperties) => Promise<{ partial: boolean; cancel: boolean; payload: T[]; }>,\n private readonly responseCallback: (payload: T[]) => void) {\n this.latestRequested = from;\n this.nextToDeliver = from;\n this.knewTo = (to !== undefined);\n }\n\n public cancel() {\n if (this.working) {\n this.workingState = \"canceled\";\n this.endEvent.resolve();\n }\n }\n\n public async run(concurrency: number) {\n assert(concurrency > 0, 0x102 /* \"invalid level of concurrency\" */);\n assert(this.working, 0x103 /* \"trying to parallel run while not working\" */);\n\n let c = concurrency;\n while (c > 0) {\n c--;\n this.addRequest();\n }\n this.dispatch();// will recalculate and trigger this.endEvent if needed\n return this.endEvent.promise;\n }\n\n private done() {\n // We should satisfy request fully.\n assert(this.to !== undefined, 0x104 /* \"undefined end point for parallel fetch\" */);\n assert(this.nextToDeliver >= this.to, 0x105 /* \"unexpected end point for parallel fetch\" */);\n if (this.working) {\n this.workingState = \"done\";\n this.endEvent.resolve();\n }\n }\n\n private fail(error) {\n if (this.working) {\n this.workingState = \"done\";\n this.endEvent.reject(error);\n }\n }\n\n private dispatch() {\n while (this.working) {\n const value = this.results.get(this.nextToDeliver);\n if (value === undefined) {\n break;\n }\n this.results.delete(this.nextToDeliver);\n assert(value.length <= this.payloadSize, 0x1d9 /* \"addRequestCore() should break into smaller chunks\" */);\n this.nextToDeliver += value.length;\n this.responseCallback(value);\n }\n\n // Account for cancellation - state might be not in consistent state on cancelling operation\n if (this.working) {\n if (this.requestsInFlight === 0) {\n // we should have dispatched everything, no matter whether we knew about the end or not.\n // see comment in addRequestCore() around throwing away chunk if it's above this.to\n assert(this.results.size === 0,\n 0x107 /* \"ending dispatch with remaining results to be sent\" */);\n this.done();\n } else if (this.to !== undefined && this.nextToDeliver >= this.to) {\n // Learned about the end and dispatched all the ops up to it.\n // Ignore all the in-flight requests above boundary - unblock caller sooner.\n assert(!this.knewTo, 0x108 /* \"ending results dispatch but knew in advance about more requests\" */);\n this.done();\n }\n }\n }\n\n private getNextChunk() {\n if (!this.working) {\n return undefined;\n }\n\n const from = this.latestRequested;\n if (this.to !== undefined) {\n if (this.to <= from) {\n return undefined;\n }\n }\n\n // this.latestRequested\n // inclusive on the right side! Exclusive on the left.\n this.latestRequested += this.payloadSize;\n\n if (this.to !== undefined) {\n this.latestRequested = Math.min(this.to, this.latestRequested);\n }\n\n assert(from < this.latestRequested, 0x109 /* \"unexpected next chunk position\" */);\n\n return { from, to: this.latestRequested };\n }\n\n private addRequest() {\n const chunk = this.getNextChunk();\n if (chunk === undefined) {\n return;\n }\n this.addRequestCore(chunk.from, chunk.to).catch(this.fail.bind(this));\n }\n\n private async addRequestCore(fromArg: number, toArg: number) {\n assert(this.working, 0x10a /* \"cannot add parallel request while not working\" */);\n\n let from = fromArg;\n let to = toArg;\n\n // to & from are exclusive\n this.requestsInFlight++;\n while (this.working) {\n const requestedLength = to - from;\n assert(requestedLength > 0, 0x10b /* \"invalid parallel request range\" */);\n\n // We should not be wasting time asking for something useless.\n if (this.to !== undefined) {\n assert(from < this.to, 0x10c /* \"invalid parallel request start point\" */);\n assert(to <= this.to, 0x10d /* \"invalid parallel request end point\" */);\n }\n\n this.requests++;\n\n const promise = this.requestCallback(this.requests, from, to, this.to !== undefined, {});\n\n // dispatch any prior received data\n this.dispatch();\n\n const { payload, cancel, partial } = await promise;\n\n if (cancel) {\n this.cancel();\n }\n\n if (this.to !== undefined && from >= this.to) {\n // while we were waiting for response, we learned on what is the boundary\n // We can get here (with actual result!) if situation changed while this request was in\n // flight, i.e. the end was extended over what we learn in some other request\n // While it's useful not to throw this result, this is very corner cases and makes logic\n // (including consistency checks) much harder to write correctly.\n // So for now, we are throwing this result out the window.\n assert(!this.knewTo, 0x10e /* \"should not throw result if we knew about boundary in advance\" */);\n // Learn how often it happens and if it's too wasteful to throw these chunks.\n // If it pops into our view a lot, we would need to reconsider how we approach it.\n // Note that this is not visible to user other than potentially not hitting 100% of\n // what we can in perf domain.\n if (payload.length !== 0) {\n this.logger.sendErrorEvent({\n eventName: \"ParallelRequests_GotExtra\",\n from,\n to,\n end: this.to,\n length: payload.length,\n });\n }\n\n break;\n }\n\n if (this.working) {\n const fromOrig = from;\n const length = payload.length;\n let fullChunk = (requestedLength <= length); // we can possible get more than we asked.\n\n if (length !== 0) {\n // We can get more than we asked for!\n // This can screw up logic in dispatch!\n // So push only batch size, and keep the rest for later - if conditions are favorable, we\n // will be able to use it. If not (parallel request overlapping these ops), it's easier to\n // discard them and wait for another (overlapping) request to come in later.\n if (requestedLength < length) {\n // This is error in a sense that it's not expected and likely points bug in other layer.\n // This layer copes with this situation just fine.\n this.logger.sendTelemetryEvent({\n eventName: \"ParallelRequests_Over\",\n from,\n to,\n length,\n });\n }\n const data = payload.splice(0, requestedLength);\n this.results.set(from, data);\n from += data.length;\n } else {\n // 1. empty (partial) chunks should not be returned by various caching / adapter layers -\n // they should fall back to next layer. This might be important invariant to hold to ensure\n // that we are less likely have bugs where such layer would keep returning empty partial\n // result on each call.\n // 2. Current invariant is that callback does retries until it gets something,\n // with the goal of failing if zero data is retrieved in given amount of time.\n // This is very specific property of storage / ops, so this logic is not here, but given only\n // one user of this class, we assert that to catch issues earlier.\n // These invariant can be relaxed if needed.\n assert(!partial, 0x10f /* \"empty/partial chunks should not be returned by caching\" */);\n assert(!this.knewTo,\n 0x110 /* \"callback should retry until valid fetch before it learns new boundary\" */);\n }\n\n if (!partial && !fullChunk) {\n if (!this.knewTo) {\n if (this.to === undefined || this.to > from) {\n // The END\n this.to = from;\n }\n break;\n }\n // We know that there are more items to be retrieved\n // Can we get partial chunk? Ideally storage indicates that's not a full chunk\n // Note that it's possible that not all ops hit storage yet.\n // We will come back to request more, and if we can't get any more ops soon, it's\n // catastrophic failure (see comment above on responsibility of callback to return something)\n // This layer will just keep trying until it gets full set.\n this.logger.sendPerformanceEvent({\n eventName: \"ParallelRequests_Partial\",\n from: fromOrig,\n to,\n length,\n });\n }\n\n if (to === this.latestRequested) {\n // we can go after full chunk at the end if we received partial chunk, or more than asked\n // Also if we got more than we asked to, we can actually use those ops!\n if (payload.length !== 0) {\n this.results.set(from, payload);\n from += payload.length;\n }\n\n this.latestRequested = from;\n fullChunk = true;\n }\n\n if (fullChunk) {\n const chunk = this.getNextChunk();\n if (chunk === undefined) { break; }\n from = chunk.from;\n to = chunk.to;\n }\n }\n }\n this.requestsInFlight--;\n this.dispatch();\n }\n}\n\n/**\n * Helper queue class to allow async push / pull\n * It's essentially a pipe allowing multiple writers, and single reader\n */\nexport class Queue<T> implements IStream<T> {\n private readonly queue: Promise<IStreamResult<T>>[] = [];\n private deferred: Deferred<IStreamResult<T>> | undefined;\n private done = false;\n\n public pushValue(value: T) {\n this.pushCore(Promise.resolve({ done: false, value }));\n }\n\n public pushError(error: any) {\n this.pushCore(Promise.reject(error));\n this.done = true;\n }\n\n public pushDone() {\n this.pushCore(Promise.resolve({ done: true }));\n this.done = true;\n }\n\n protected pushCore(value: Promise<IStreamResult<T>>) {\n assert(!this.done, 0x112 /* \"cannot push onto queue if done\" */);\n if (this.deferred) {\n assert(this.queue.length === 0, 0x113 /* \"deferred queue should be empty\" */);\n this.deferred.resolve(value);\n this.deferred = undefined;\n } else {\n this.queue.push(value);\n }\n }\n\n public async read(): Promise<IStreamResult<T>> {\n assert(this.deferred === undefined, 0x114 /* \"cannot pop if deferred\" */);\n const value = this.queue.shift();\n if (value !== undefined) {\n return value;\n }\n assert(!this.done, 0x115 /* \"queue should not be done during pop\" */);\n this.deferred = new Deferred<IStreamResult<T>>();\n return this.deferred.promise;\n }\n}\n\n/**\n * Retrieve single batch of ops\n * @param request - request index\n * @param from - inclusive boundary\n * @param to - exclusive boundary\n * @param telemetryEvent - telemetry event used to track consecutive batch of requests\n * @param strongTo - tells if ops in range from...to have to be there and have to be retrieved.\n * If false, returning less ops would mean we reached end of file.\n * @returns - an object with resulting ops and cancellation / partial result flags\n */\nasync function getSingleOpBatch(\n get: (telemetryProps: ITelemetryProperties) => Promise<IDeltasFetchResult>,\n props: ITelemetryProperties,\n strongTo: boolean,\n logger: ITelemetryLogger,\n signal?: AbortSignal,\n fetchReason?: string):\n Promise<{ partial: boolean; cancel: boolean; payload: ISequencedDocumentMessage[]; }> {\n let lastSuccessTime: number | undefined;\n\n let retry: number = 0;\n const deltas: ISequencedDocumentMessage[] = [];\n const nothing = { partial: false, cancel: true, payload: [] };\n\n while (signal?.aborted !== true) {\n retry++;\n let delay = Math.min(MaxFetchDelayInMs, MissingFetchDelayInMs * Math.pow(2, retry));\n const startTime = performance.now();\n\n try {\n // Issue async request for deltas - limit the number fetched to MaxBatchDeltas\n const deltasP = get({ ...props, retry } /* telemetry props */);\n\n const { messages, partialResult } = await deltasP;\n deltas.push(...messages);\n\n const deltasRetrievedLast = messages.length;\n\n if (deltasRetrievedLast !== 0 || !strongTo) {\n return { payload: deltas, cancel: false, partial: partialResult };\n }\n\n // Storage does not have ops we need.\n // Attempt to fetch more deltas. If we didn't receive any in the previous call we up our retry\n // count since something prevented us from seeing those deltas\n\n if (lastSuccessTime === undefined) {\n lastSuccessTime = performance.now();\n } else if (performance.now() - lastSuccessTime > 30000) {\n // If we are connected and receiving proper responses from server, but can't get any ops back,\n // then give up after some time. This likely indicates the issue with ordering service not flushing\n // ops to storage quick enough, and possibly waiting for summaries, while summarizer can't get\n // current as it can't get ops.\n throw createGenericNetworkError(\n // pre-0.58 error message: failedToRetrieveOpsFromStorage:TooManyRetries\n \"Failed to retrieve ops from storage (Too Many Retries)\",\n { canRetry: false },\n {\n retry,\n driverVersion,\n ...props,\n },\n );\n }\n } catch (error) {\n const canRetry = canRetryOnError(error);\n\n lastSuccessTime = undefined;\n\n const retryAfter = getRetryDelayFromError(error);\n\n // This will log to error table only if the error is non-retryable\n logNetworkFailure(\n logger,\n {\n eventName: \"GetDeltas_Error\",\n ...props,\n retry,\n duration: performance.now() - startTime,\n retryAfter,\n fetchReason,\n },\n error);\n\n if (!canRetry) {\n // It's game over scenario.\n throw error;\n }\n\n if (retryAfter !== undefined && retryAfter >= 0) {\n delay = retryAfter;\n }\n }\n\n await waitForConnectedState(delay);\n }\n\n return nothing;\n}\n\nexport function requestOps(\n get: (from: number, to: number, telemetryProps: ITelemetryProperties) => Promise<IDeltasFetchResult>,\n concurrency: number,\n fromTotal: number,\n toTotal: number | undefined,\n payloadSize: number,\n logger: ITelemetryLogger,\n signal?: AbortSignal,\n fetchReason?: string,\n): IStream<ISequencedDocumentMessage[]> {\n let requests = 0;\n let lastFetch: number | undefined;\n let length = 0;\n const queue = new Queue<ISequencedDocumentMessage[]>();\n\n const propsTotal: ITelemetryProperties = {\n fromTotal,\n toTotal,\n };\n\n const telemetryEvent = PerformanceEvent.start(logger, {\n eventName: \"GetDeltas\",\n ...propsTotal,\n fetchReason,\n });\n\n const manager = new ParallelRequests<ISequencedDocumentMessage>(\n fromTotal,\n toTotal,\n payloadSize,\n logger,\n async (request: number, from: number, to: number, strongTo: boolean, propsPerRequest: ITelemetryProperties) => {\n requests++;\n return getSingleOpBatch(\n async (propsAll) => get(from, to, propsAll),\n { request, from, to, ...propsTotal, ...propsPerRequest },\n strongTo,\n logger,\n signal,\n fetchReason,\n );\n },\n (deltas: ISequencedDocumentMessage[]) => {\n // Assert continuing and right start.\n if (lastFetch === undefined) {\n assert(deltas[0].sequenceNumber === fromTotal, 0x26d /* \"wrong start\" */);\n } else {\n assert(deltas[0].sequenceNumber === lastFetch + 1, 0x26e /* \"wrong start\" */);\n }\n lastFetch = deltas[deltas.length - 1].sequenceNumber;\n assert(lastFetch - deltas[0].sequenceNumber + 1 === deltas.length,\n 0x26f /* \"continuous and no duplicates\" */);\n length += deltas.length;\n queue.pushValue(deltas);\n });\n\n // Implement faster cancellation. getSingleOpBatch() checks signal, but only in between\n // waits (up to 10 seconds) and fetches (can take infinite amount of time).\n // While every such case should be improved and take into account signal (and thus cancel immediately),\n // it is beneficial to have catch-all\n const listener = (event: Event) => { manager.cancel(); };\n if (signal !== undefined) {\n signal.addEventListener(\"abort\", listener);\n }\n\n manager.run(concurrency)\n .finally(() => {\n if (signal !== undefined) {\n signal.removeEventListener(\"abort\", listener);\n }\n }).then(() => {\n const props = {\n lastFetch,\n length,\n requests,\n };\n if (manager.canceled) {\n telemetryEvent.cancel({ ...props, error: \"ops request cancelled by client\" });\n } else {\n assert(toTotal === undefined || lastFetch !== undefined && lastFetch >= toTotal - 1,\n 0x270 /* \"All requested ops fetched\" */);\n telemetryEvent.end(props);\n }\n queue.pushDone();\n })\n .catch((error) => {\n telemetryEvent.cancel({\n lastFetch,\n length,\n requests,\n }, error);\n queue.pushError(error);\n });\n\n return queue;\n}\n\nexport const emptyMessageStream: IStream<ISequencedDocumentMessage[]> = {\n read: async () => { return { done: true }; },\n};\n\nexport function streamFromMessages(messagesArg: Promise<ISequencedDocumentMessage[]>):\n IStream<ISequencedDocumentMessage[]> {\n let messages: Promise<ISequencedDocumentMessage[]> | undefined = messagesArg;\n return {\n read: async () => {\n if (messages === undefined) {\n return { done: true };\n }\n const value = await messages;\n messages = undefined;\n return value.length === 0 ? { done: true } : { done: false, value };\n },\n };\n}\n\nexport function streamObserver<T>(stream: IStream<T>, handler: (value: IStreamResult<T>) => void): IStream<T> {\n return {\n read: async () => {\n const value = await stream.read();\n handler(value);\n return value;\n },\n };\n}\n"]}
1
+ {"version":3,"file":"parallelRequests.js","sourceRoot":"","sources":["../src/parallelRequests.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,+DAA6E;AAE7E,qEAAmE;AAGnE,uCAA+F;AAC/F,iDAA0E;AAC1E,sFAAsF;AACtF,qDAA+D;AAE/D,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAChC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAIlC;;;;;;;;;;;GAWG;AACH,MAAa,gBAAgB;IAazB,YACI,IAAY,EACJ,EAAsB,EACb,WAAmB,EACnB,MAAwB,EACxB,eAKgF,EAChF,gBAAwC;QATjD,O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AE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACxE,CAAC;KACJ,CAAC;AACN,CAAC;AAbD,gDAaC;AAED,SAAgB,cAAc,CAAI,MAAkB,EAAE,OAA0C;IAC5F,OAAO;QACH,IAAI,EAAE,KAAK,IAAI,EAAE;YACb,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO,CAAC,KAAK,CAAC,CAAC;YACf,OAAO,KAAK,CAAC;QACjB,CAAC;KACJ,CAAC;AACN,CAAC;AARD,wCAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { assert, Deferred, performance } from \"@fluidframework/common-utils\";\nimport { ITelemetryLogger, ITelemetryProperties } from \"@fluidframework/common-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IDeltasFetchResult, IStream, IStreamResult } from \"@fluidframework/driver-definitions\";\nimport { getRetryDelayFromError, canRetryOnError, createGenericNetworkError } from \"./network\";\nimport { waitForConnectedState, logNetworkFailure } from \"./networkUtils\";\n// For now, this package is versioned and released in unison with the specific drivers\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\n\nconst MaxFetchDelayInMs = 10000;\nconst MissingFetchDelayInMs = 100;\n\ntype WorkingState = \"working\" | \"done\" | \"canceled\";\n\n/**\n * Helper class to organize parallel fetching of data\n * It can be used to concurrently do many requests, while consuming\n * data in the right order. Take a look at UT for examples.\n * @param concurrency - level of concurrency\n * @param from - starting point of fetching data (inclusive)\n * @param to - ending point of fetching data. exclusive, or undefined if unknown\n * @param payloadSize - batch size\n * @param logger - logger to use\n * @param requestCallback - callback to request batches\n * @returns - Queue that can be used to retrieve data\n */\nexport class ParallelRequests<T> {\n private latestRequested: number;\n private nextToDeliver: number;\n private readonly results: Map<number, T[]> = new Map();\n private workingState: WorkingState = \"working\";\n private requestsInFlight = 0;\n private readonly endEvent = new Deferred<void>();\n private requests = 0;\n private readonly knewTo: boolean;\n\n private get working() { return this.workingState === \"working\"; }\n public get canceled() { return this.workingState === \"canceled\"; }\n\n constructor(\n from: number,\n private to: number | undefined,\n private readonly payloadSize: number,\n private readonly logger: ITelemetryLogger,\n private readonly requestCallback: (\n request: number,\n from: number,\n to: number,\n strongTo: boolean,\n props: ITelemetryProperties) => Promise<{ partial: boolean; cancel: boolean; payload: T[]; }>,\n private readonly responseCallback: (payload: T[]) => void) {\n this.latestRequested = from;\n this.nextToDeliver = from;\n this.knewTo = (to !== undefined);\n }\n\n public cancel() {\n if (this.working) {\n this.workingState = \"canceled\";\n this.endEvent.resolve();\n }\n }\n\n public async run(concurrency: number) {\n assert(concurrency > 0, 0x102 /* \"invalid level of concurrency\" */);\n assert(this.working, 0x103 /* \"trying to parallel run while not working\" */);\n\n let c = concurrency;\n while (c > 0) {\n c--;\n this.addRequest();\n }\n this.dispatch();// will recalculate and trigger this.endEvent if needed\n return this.endEvent.promise;\n }\n\n private done() {\n // We should satisfy request fully.\n assert(this.to !== undefined, 0x104 /* \"undefined end point for parallel fetch\" */);\n assert(this.nextToDeliver >= this.to, 0x105 /* \"unexpected end point for parallel fetch\" */);\n if (this.working) {\n this.workingState = \"done\";\n this.endEvent.resolve();\n }\n }\n\n private fail(error) {\n if (this.working) {\n this.workingState = \"done\";\n this.endEvent.reject(error);\n }\n }\n\n private dispatch() {\n while (this.working) {\n const value = this.results.get(this.nextToDeliver);\n if (value === undefined) {\n break;\n }\n this.results.delete(this.nextToDeliver);\n assert(value.length <= this.payloadSize, 0x1d9 /* \"addRequestCore() should break into smaller chunks\" */);\n this.nextToDeliver += value.length;\n this.responseCallback(value);\n }\n\n // Account for cancellation - state might be not in consistent state on cancelling operation\n if (this.working) {\n if (this.requestsInFlight === 0) {\n // we should have dispatched everything, no matter whether we knew about the end or not.\n // see comment in addRequestCore() around throwing away chunk if it's above this.to\n assert(this.results.size === 0,\n 0x107 /* \"ending dispatch with remaining results to be sent\" */);\n this.done();\n } else if (this.to !== undefined && this.nextToDeliver >= this.to) {\n // Learned about the end and dispatched all the ops up to it.\n // Ignore all the in-flight requests above boundary - unblock caller sooner.\n assert(!this.knewTo, 0x108 /* \"ending results dispatch but knew in advance about more requests\" */);\n this.done();\n }\n }\n }\n\n private getNextChunk() {\n if (!this.working) {\n return undefined;\n }\n\n const from = this.latestRequested;\n if (this.to !== undefined) {\n if (this.to <= from) {\n return undefined;\n }\n }\n\n // this.latestRequested\n // inclusive on the right side! Exclusive on the left.\n this.latestRequested += this.payloadSize;\n\n if (this.to !== undefined) {\n this.latestRequested = Math.min(this.to, this.latestRequested);\n }\n\n assert(from < this.latestRequested, 0x109 /* \"unexpected next chunk position\" */);\n\n return { from, to: this.latestRequested };\n }\n\n private addRequest() {\n const chunk = this.getNextChunk();\n if (chunk === undefined) {\n return;\n }\n this.addRequestCore(chunk.from, chunk.to).catch(this.fail.bind(this));\n }\n\n private async addRequestCore(fromArg: number, toArg: number) {\n assert(this.working, 0x10a /* \"cannot add parallel request while not working\" */);\n\n let from = fromArg;\n let to = toArg;\n\n // to & from are exclusive\n this.requestsInFlight++;\n while (this.working) {\n const requestedLength = to - from;\n assert(requestedLength > 0, 0x10b /* \"invalid parallel request range\" */);\n\n // We should not be wasting time asking for something useless.\n if (this.to !== undefined) {\n assert(from < this.to, 0x10c /* \"invalid parallel request start point\" */);\n assert(to <= this.to, 0x10d /* \"invalid parallel request end point\" */);\n }\n\n this.requests++;\n\n const promise = this.requestCallback(this.requests, from, to, this.to !== undefined, {});\n\n // dispatch any prior received data\n this.dispatch();\n\n const { payload, cancel, partial } = await promise;\n\n if (cancel) {\n this.cancel();\n }\n\n if (this.to !== undefined && from >= this.to) {\n // while we were waiting for response, we learned on what is the boundary\n // We can get here (with actual result!) if situation changed while this request was in\n // flight, i.e. the end was extended over what we learn in some other request\n // While it's useful not to throw this result, this is very corner cases and makes logic\n // (including consistency checks) much harder to write correctly.\n // So for now, we are throwing this result out the window.\n assert(!this.knewTo, 0x10e /* \"should not throw result if we knew about boundary in advance\" */);\n // Learn how often it happens and if it's too wasteful to throw these chunks.\n // If it pops into our view a lot, we would need to reconsider how we approach it.\n // Note that this is not visible to user other than potentially not hitting 100% of\n // what we can in perf domain.\n if (payload.length !== 0) {\n this.logger.sendErrorEvent({\n eventName: \"ParallelRequests_GotExtra\",\n from,\n to,\n end: this.to,\n length: payload.length,\n });\n }\n\n break;\n }\n\n if (this.working) {\n const fromOrig = from;\n const length = payload.length;\n let fullChunk = (requestedLength <= length); // we can possible get more than we asked.\n\n if (length !== 0) {\n // We can get more than we asked for!\n // This can screw up logic in dispatch!\n // So push only batch size, and keep the rest for later - if conditions are favorable, we\n // will be able to use it. If not (parallel request overlapping these ops), it's easier to\n // discard them and wait for another (overlapping) request to come in later.\n if (requestedLength < length) {\n // This is error in a sense that it's not expected and likely points bug in other layer.\n // This layer copes with this situation just fine.\n this.logger.sendTelemetryEvent({\n eventName: \"ParallelRequests_Over\",\n from,\n to,\n length,\n });\n }\n const data = payload.splice(0, requestedLength);\n this.results.set(from, data);\n from += data.length;\n } else {\n // 1. empty (partial) chunks should not be returned by various caching / adapter layers -\n // they should fall back to next layer. This might be important invariant to hold to ensure\n // that we are less likely have bugs where such layer would keep returning empty partial\n // result on each call.\n // 2. Current invariant is that callback does retries until it gets something,\n // with the goal of failing if zero data is retrieved in given amount of time.\n // This is very specific property of storage / ops, so this logic is not here, but given only\n // one user of this class, we assert that to catch issues earlier.\n // These invariant can be relaxed if needed.\n assert(!partial, 0x10f /* \"empty/partial chunks should not be returned by caching\" */);\n assert(!this.knewTo,\n 0x110 /* \"callback should retry until valid fetch before it learns new boundary\" */);\n }\n\n if (!partial && !fullChunk) {\n if (!this.knewTo) {\n if (this.to === undefined || this.to > from) {\n // The END\n this.to = from;\n }\n break;\n }\n // We know that there are more items to be retrieved\n // Can we get partial chunk? Ideally storage indicates that's not a full chunk\n // Note that it's possible that not all ops hit storage yet.\n // We will come back to request more, and if we can't get any more ops soon, it's\n // catastrophic failure (see comment above on responsibility of callback to return something)\n // This layer will just keep trying until it gets full set.\n this.logger.sendPerformanceEvent({\n eventName: \"ParallelRequests_Partial\",\n from: fromOrig,\n to,\n length,\n });\n }\n\n if (to === this.latestRequested) {\n // we can go after full chunk at the end if we received partial chunk, or more than asked\n // Also if we got more than we asked to, we can actually use those ops!\n if (payload.length !== 0) {\n this.results.set(from, payload);\n from += payload.length;\n }\n\n this.latestRequested = from;\n fullChunk = true;\n }\n\n if (fullChunk) {\n const chunk = this.getNextChunk();\n if (chunk === undefined) { break; }\n from = chunk.from;\n to = chunk.to;\n }\n }\n }\n this.requestsInFlight--;\n this.dispatch();\n }\n}\n\n/**\n * Helper queue class to allow async push / pull\n * It's essentially a pipe allowing multiple writers, and single reader\n */\nexport class Queue<T> implements IStream<T> {\n private readonly queue: Promise<IStreamResult<T>>[] = [];\n private deferred: Deferred<IStreamResult<T>> | undefined;\n private done = false;\n\n public pushValue(value: T) {\n this.pushCore(Promise.resolve({ done: false, value }));\n }\n\n public pushError(error: any) {\n this.pushCore(Promise.reject(error));\n this.done = true;\n }\n\n public pushDone() {\n this.pushCore(Promise.resolve({ done: true }));\n this.done = true;\n }\n\n protected pushCore(value: Promise<IStreamResult<T>>) {\n assert(!this.done, 0x112 /* \"cannot push onto queue if done\" */);\n if (this.deferred) {\n assert(this.queue.length === 0, 0x113 /* \"deferred queue should be empty\" */);\n this.deferred.resolve(value);\n this.deferred = undefined;\n } else {\n this.queue.push(value);\n }\n }\n\n public async read(): Promise<IStreamResult<T>> {\n assert(this.deferred === undefined, 0x114 /* \"cannot pop if deferred\" */);\n const value = this.queue.shift();\n if (value !== undefined) {\n return value;\n }\n assert(!this.done, 0x115 /* \"queue should not be done during pop\" */);\n this.deferred = new Deferred<IStreamResult<T>>();\n return this.deferred.promise;\n }\n}\n\n/**\n * Retrieve single batch of ops\n * @param request - request index\n * @param from - inclusive boundary\n * @param to - exclusive boundary\n * @param telemetryEvent - telemetry event used to track consecutive batch of requests\n * @param strongTo - tells if ops in range from...to have to be there and have to be retrieved.\n * If false, returning less ops would mean we reached end of file.\n * @param logger - logger object to use to log progress & errors\n * @param signal - cancelation signal\n * @param scenarioName - reason for fetching ops\n * @returns - an object with resulting ops and cancellation / partial result flags\n */\nasync function getSingleOpBatch(\n get: (telemetryProps: ITelemetryProperties) => Promise<IDeltasFetchResult>,\n props: ITelemetryProperties,\n strongTo: boolean,\n logger: ITelemetryLogger,\n signal?: AbortSignal,\n scenarioName?: string):\n Promise<{ partial: boolean; cancel: boolean; payload: ISequencedDocumentMessage[]; }> {\n let lastSuccessTime: number | undefined;\n\n let retry: number = 0;\n const deltas: ISequencedDocumentMessage[] = [];\n const nothing = { partial: false, cancel: true, payload: [] };\n\n while (signal?.aborted !== true) {\n retry++;\n let delay = Math.min(MaxFetchDelayInMs, MissingFetchDelayInMs * Math.pow(2, retry));\n const startTime = performance.now();\n\n try {\n // Issue async request for deltas - limit the number fetched to MaxBatchDeltas\n const deltasP = get({ ...props, retry } /* telemetry props */);\n\n const { messages, partialResult } = await deltasP;\n deltas.push(...messages);\n\n const deltasRetrievedLast = messages.length;\n\n if (deltasRetrievedLast !== 0 || !strongTo) {\n return { payload: deltas, cancel: false, partial: partialResult };\n }\n\n // Storage does not have ops we need.\n // Attempt to fetch more deltas. If we didn't receive any in the previous call we up our retry\n // count since something prevented us from seeing those deltas\n\n if (lastSuccessTime === undefined) {\n lastSuccessTime = performance.now();\n } else if (performance.now() - lastSuccessTime > 30000) {\n // If we are connected and receiving proper responses from server, but can't get any ops back,\n // then give up after some time. This likely indicates the issue with ordering service not flushing\n // ops to storage quick enough, and possibly waiting for summaries, while summarizer can't get\n // current as it can't get ops.\n throw createGenericNetworkError(\n // pre-0.58 error message: failedToRetrieveOpsFromStorage:TooManyRetries\n \"Failed to retrieve ops from storage (Too Many Retries)\",\n { canRetry: false },\n {\n retry,\n driverVersion,\n ...props,\n },\n );\n }\n } catch (error) {\n const canRetry = canRetryOnError(error);\n\n lastSuccessTime = undefined;\n\n const retryAfter = getRetryDelayFromError(error);\n\n // This will log to error table only if the error is non-retryable\n logNetworkFailure(\n logger,\n {\n eventName: \"GetDeltas_Error\",\n ...props,\n retry,\n duration: performance.now() - startTime,\n retryAfter,\n reason: scenarioName,\n },\n error);\n\n if (!canRetry) {\n // It's game over scenario.\n throw error;\n }\n\n if (retryAfter !== undefined && retryAfter >= 0) {\n delay = retryAfter;\n }\n }\n\n await waitForConnectedState(delay);\n }\n\n return nothing;\n}\n\n/**\n * Request ops from storage\n * @param get - Getter callback to get individual batches\n * @param concurrency - Number of concurrent requests to make\n * @param fromTotal - starting sequence number to fetch (inclusive)\n * @param toTotal - max (exclusive) sequence number to fetch\n * @param payloadSize - Payload size\n * @param logger - Logger to log progress and errors\n * @param signal - Cancelation signal\n * @param scenarioName - Reason for fetching ops\n * @returns - Messages fetched\n */\nexport function requestOps(\n get: (from: number, to: number, telemetryProps: ITelemetryProperties) => Promise<IDeltasFetchResult>,\n concurrency: number,\n fromTotal: number,\n toTotal: number | undefined,\n payloadSize: number,\n logger: ITelemetryLogger,\n signal?: AbortSignal,\n scenarioName?: string,\n): IStream<ISequencedDocumentMessage[]> {\n let requests = 0;\n let lastFetch: number | undefined;\n let length = 0;\n const queue = new Queue<ISequencedDocumentMessage[]>();\n\n const propsTotal: ITelemetryProperties = {\n fromTotal,\n toTotal,\n };\n\n const telemetryEvent = PerformanceEvent.start(logger, {\n eventName: \"GetDeltas\",\n ...propsTotal,\n reason: scenarioName,\n });\n\n const manager = new ParallelRequests<ISequencedDocumentMessage>(\n fromTotal,\n toTotal,\n payloadSize,\n logger,\n async (request: number, from: number, to: number, strongTo: boolean, propsPerRequest: ITelemetryProperties) => {\n requests++;\n return getSingleOpBatch(\n async (propsAll) => get(from, to, propsAll),\n { request, from, to, ...propsTotal, ...propsPerRequest },\n strongTo,\n logger,\n signal,\n scenarioName,\n );\n },\n (deltas: ISequencedDocumentMessage[]) => {\n // Assert continuing and right start.\n if (lastFetch === undefined) {\n assert(deltas[0].sequenceNumber === fromTotal, 0x26d /* \"wrong start\" */);\n } else {\n assert(deltas[0].sequenceNumber === lastFetch + 1, 0x26e /* \"wrong start\" */);\n }\n lastFetch = deltas[deltas.length - 1].sequenceNumber;\n assert(lastFetch - deltas[0].sequenceNumber + 1 === deltas.length,\n 0x26f /* \"continuous and no duplicates\" */);\n length += deltas.length;\n queue.pushValue(deltas);\n });\n\n // Implement faster cancellation. getSingleOpBatch() checks signal, but only in between\n // waits (up to 10 seconds) and fetches (can take infinite amount of time).\n // While every such case should be improved and take into account signal (and thus cancel immediately),\n // it is beneficial to have catch-all\n const listener = (event: Event) => { manager.cancel(); };\n if (signal !== undefined) {\n signal.addEventListener(\"abort\", listener);\n }\n\n manager.run(concurrency)\n .finally(() => {\n if (signal !== undefined) {\n signal.removeEventListener(\"abort\", listener);\n }\n }).then(() => {\n const props = {\n lastFetch,\n length,\n requests,\n };\n if (manager.canceled) {\n telemetryEvent.cancel({ ...props, error: \"ops request cancelled by client\" });\n } else {\n assert(toTotal === undefined || lastFetch !== undefined && lastFetch >= toTotal - 1,\n 0x270 /* \"All requested ops fetched\" */);\n telemetryEvent.end(props);\n }\n queue.pushDone();\n })\n .catch((error) => {\n telemetryEvent.cancel({\n lastFetch,\n length,\n requests,\n }, error);\n queue.pushError(error);\n });\n\n return queue;\n}\n\nexport const emptyMessageStream: IStream<ISequencedDocumentMessage[]> = {\n read: async () => { return { done: true }; },\n};\n\nexport function streamFromMessages(messagesArg: Promise<ISequencedDocumentMessage[]>):\n IStream<ISequencedDocumentMessage[]> {\n let messages: Promise<ISequencedDocumentMessage[]> | undefined = messagesArg;\n return {\n read: async () => {\n if (messages === undefined) {\n return { done: true };\n }\n const value = await messages;\n messages = undefined;\n return value.length === 0 ? { done: true } : { done: false, value };\n },\n };\n}\n\nexport function streamObserver<T>(stream: IStream<T>, handler: (value: IStreamResult<T>) => void): IStream<T> {\n return {\n read: async () => {\n const value = await stream.read();\n handler(value);\n return value;\n },\n };\n}\n"]}
@@ -4,11 +4,16 @@
4
4
  */
5
5
  import { IDocumentStorageService } from "@fluidframework/driver-definitions";
6
6
  /**
7
- * Read a blob from IDocumentStorageService and JSON.parse it into object of type T
7
+ * Read a blob from {@link @fluidframework/driver-definitions#IDocumentStorageService} and
8
+ * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}
9
+ * it into object of type `T`.
8
10
  *
9
- * @param storage - the IDocumentStorageService to read from
10
- * @param id - the id of the blob to read and parse
11
- * @returns the object that we decoded and JSON.parse
11
+ * @param storage - The `DocumentStorageService` to read from.
12
+ * @param id - The ID of the blob to read and parse.
13
+ *
14
+ * @typeParam T - Output type matching JSON format of inpyt blob data.
15
+ *
16
+ * @returns The object that we decoded and parsed via `JSON.parse`.
12
17
  */
13
18
  export declare function readAndParse<T>(storage: Pick<IDocumentStorageService, "readBlob">, id: string): Promise<T>;
14
19
  //# sourceMappingURL=readAndParse.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"readAndParse.d.ts","sourceRoot":"","sources":["../src/readAndParse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E;;;;;;GAMG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAIhH"}
1
+ {"version":3,"file":"readAndParse.d.ts","sourceRoot":"","sources":["../src/readAndParse.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E;;;;;;;;;;;GAWG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAIhH"}
@@ -7,11 +7,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.readAndParse = void 0;
8
8
  const common_utils_1 = require("@fluidframework/common-utils");
9
9
  /**
10
- * Read a blob from IDocumentStorageService and JSON.parse it into object of type T
10
+ * Read a blob from {@link @fluidframework/driver-definitions#IDocumentStorageService} and
11
+ * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}
12
+ * it into object of type `T`.
11
13
  *
12
- * @param storage - the IDocumentStorageService to read from
13
- * @param id - the id of the blob to read and parse
14
- * @returns the object that we decoded and JSON.parse
14
+ * @param storage - The `DocumentStorageService` to read from.
15
+ * @param id - The ID of the blob to read and parse.
16
+ *
17
+ * @typeParam T - Output type matching JSON format of inpyt blob data.
18
+ *
19
+ * @returns The object that we decoded and parsed via `JSON.parse`.
15
20
  */
16
21
  async function readAndParse(storage, id) {
17
22
  const blob = await storage.readBlob(id);
@@ -1 +1 @@
1
- {"version":3,"file":"readAndParse.js","sourceRoot":"","sources":["../src/readAndParse.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAG9D;;;;;;GAMG;AACI,KAAK,UAAU,YAAY,CAAI,OAAkD,EAAE,EAAU;IAChG,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,IAAA,6BAAc,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAM,CAAC;AACpC,CAAC;AAJD,oCAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluidframework/common-utils\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\n\n/**\n * Read a blob from IDocumentStorageService and JSON.parse it into object of type T\n *\n * @param storage - the IDocumentStorageService to read from\n * @param id - the id of the blob to read and parse\n * @returns the object that we decoded and JSON.parse\n */\nexport async function readAndParse<T>(storage: Pick<IDocumentStorageService, \"readBlob\">, id: string): Promise<T> {\n const blob = await storage.readBlob(id);\n const decoded = bufferToString(blob, \"utf8\");\n return JSON.parse(decoded) as T;\n}\n"]}
1
+ {"version":3,"file":"readAndParse.js","sourceRoot":"","sources":["../src/readAndParse.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAG9D;;;;;;;;;;;GAWG;AACI,KAAK,UAAU,YAAY,CAAI,OAAkD,EAAE,EAAU;IAChG,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,IAAA,6BAAc,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAM,CAAC;AACpC,CAAC;AAJD,oCAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { bufferToString } from \"@fluidframework/common-utils\";\nimport { IDocumentStorageService } from \"@fluidframework/driver-definitions\";\n\n/**\n * Read a blob from {@link @fluidframework/driver-definitions#IDocumentStorageService} and\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse | JSON.parse}\n * it into object of type `T`.\n *\n * @param storage - The `DocumentStorageService` to read from.\n * @param id - The ID of the blob to read and parse.\n *\n * @typeParam T - Output type matching JSON format of inpyt blob data.\n *\n * @returns The object that we decoded and parsed via `JSON.parse`.\n */\nexport async function readAndParse<T>(storage: Pick<IDocumentStorageService, \"readBlob\">, id: string): Promise<T> {\n const blob = await storage.readBlob(id);\n const decoded = bufferToString(blob, \"utf8\");\n return JSON.parse(decoded) as T;\n}\n"]}
@@ -9,14 +9,18 @@ import { ITelemetryLogger } from "@fluidframework/common-definitions";
9
9
  */
10
10
  export interface IProgress {
11
11
  /**
12
- * Abort signal used to cancel operation
13
- * Note that most of the layers do not use this signal yet. We need to change that over time.
12
+ * Abort signal used to cancel operation.
13
+ *
14
+ * @remarks Note that most of the layers do not use this signal yet. We need to change that over time.
14
15
  * Please consult with API documentation / implementation.
15
16
  * Note that number of layers may not check this signal while holding this request in a queue,
16
17
  * so it may take a while it takes effect. This can be improved in the future.
17
- * Layers in question are:
18
- * - driver (RateLimiter)
19
- * - runWithRetry
18
+ *
19
+ * The layers in question are:
20
+ *
21
+ * - driver (RateLimiter)
22
+ *
23
+ * - runWithRetry
20
24
  */
21
25
  cancel?: AbortSignal;
22
26
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"runWithRetry.d.ts","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAOtE;;;GAGG;AACH,MAAM,WAAW,SAAS;IACtB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;;;;;;OAOG;IACH,OAAO,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;CACjD;AAED,wBAAsB,YAAY,CAAC,CAAC,EAChC,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACzC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,SAAS,GACpB,OAAO,CAAC,CAAC,CAAC,CA2DZ"}
1
+ {"version":3,"file":"runWithRetry.d.ts","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAOtE;;;GAGG;AACH,MAAM,WAAW,SAAS;IACtB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soft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { delay, performance } from \"@fluidframework/common-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { canRetryOnError, getRetryDelayFromError } from \"./network\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { NonRetryableError } from \".\";\n\n/**\n * Interface describing an object passed to various network APIs.\n * It allows caller to control cancellation, as well as learn about any delays.\n */\nexport interface IProgress {\n /**\n * Abort signal used to cancel operation\n * Note that most of the layers do not use this signal yet. We need to change that over time.\n * Please consult with API documentation / implementation.\n * Note that number of layers may not check this signal while holding this request in a queue,\n * so it may take a while it takes effect. This can be improved in the future.\n * Layers in question are:\n * - driver (RateLimiter)\n * - runWithRetry\n */\n cancel?: AbortSignal;\n\n /**\n * Called whenever api returns cancellable error and the call is going to be retried.\n * Any exception thrown from this call back result in cancellation of operation\n * and propagation of thrown exception.\n * @param delayInMs - delay before next retry. This value will depend on internal back-off logic,\n * as well as information provided by service (like 429 error asking to wait for some time before retry)\n * @param error - error object returned from the call.\n */\n onRetry?(delayInMs: number, error: any): void;\n}\n\nexport async function runWithRetry<T>(\n api: (cancel?: AbortSignal) => Promise<T>,\n fetchCallName: string,\n logger: ITelemetryLogger,\n progress: IProgress,\n): Promise<T> {\n let result: T | undefined;\n let success = false;\n let retryAfterMs = 1000; // has to be positive!\n let numRetries = 0;\n const startTime = performance.now();\n let lastError: any;\n do {\n try {\n result = await api(progress.cancel);\n success = true;\n } catch (err) {\n // If it is not retriable, then just throw the error.\n if (!canRetryOnError(err)) {\n logger.sendTelemetryEvent({\n eventName: `${fetchCallName}_cancel`,\n retry: numRetries,\n duration: performance.now() - startTime,\n fetchCallName,\n }, err);\n throw err;\n }\n\n if (progress.cancel?.aborted === true) {\n logger.sendTelemetryEvent({\n eventName: `${fetchCallName}_runWithRetryAborted`,\n retry: numRetries,\n duration: performance.now() - startTime,\n fetchCallName,\n }, err);\n throw new NonRetryableError(\n \"runWithRetry was Aborted\",\n DriverErrorType.genericError,\n { driverVersion: pkgVersion, fetchCallName },\n );\n }\n\n numRetries++;\n lastError = err;\n // If the error is throttling error, then wait for the specified time before retrying.\n // If the waitTime is not specified, then we start with retrying immediately to max of 8s.\n retryAfterMs = getRetryDelayFromError(err) ?? Math.min(retryAfterMs * 2, 8000);\n if (progress.onRetry) {\n progress.onRetry(retryAfterMs, err);\n }\n await delay(retryAfterMs);\n }\n } while (!success);\n if (numRetries > 0) {\n logger.sendTelemetryEvent({\n eventName: `${fetchCallName}_lastError`,\n retry: numRetries,\n duration: performance.now() - startTime,\n fetchCallName,\n },\n lastError);\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return result!;\n}\n"]}
1
+ {"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAkE;AAClE,2EAAqE;AACrE,uCAAoE;AACpE,qDAA8C;AAC9C,wBAAsC;AAkC/B,KAAK,UAAU,YAAY,CAC9B,GAAyC,EACzC,aAAqB,EACrB,MAAwB,EACxB,QAAmB;;IAEnB,IAAI,MAAqB,CAAC;IAC1B,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,YAAY,GAAG,IAAI,CAAC,CAAC,sBAAsB;IAC/C,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,MAAM,SAAS,GAAG,0BAAW,CAAC,GAAG,EAAE,CAAC;IACpC,IAAI,SAAc,CAAC;IACnB,GAAG;QACC,IAAI;YACA,MAAM,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACpC,OAAO,GAAG,IAAI,CAAC;SAClB;QAAC,OAAO,GAAG,EAAE;YACV,qDAAqD;YACrD,IAAI,CAAC,IAAA,yBAAe,EAAC,GAAG,CAAC,EAAE;gBACvB,MAAM,CAAC,kBAAkB,CAAC;oBACtB,SAAS,EAAE,GAAG,a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,OAAO,MAAO,CAAC;AACnB,CAAC;AAhED,oCAgEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { delay, performance } from \"@fluidframework/common-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { canRetryOnError, getRetryDelayFromError } from \"./network\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { NonRetryableError } from \".\";\n\n/**\n * Interface describing an object passed to various network APIs.\n * It allows caller to control cancellation, as well as learn about any delays.\n */\nexport interface IProgress {\n /**\n * Abort signal used to cancel operation.\n *\n * @remarks Note that most of the layers do not use this signal yet. We need to change that over time.\n * Please consult with API documentation / implementation.\n * Note that number of layers may not check this signal while holding this request in a queue,\n * so it may take a while it takes effect. This can be improved in the future.\n *\n * The layers in question are:\n *\n * - driver (RateLimiter)\n *\n * - runWithRetry\n */\n cancel?: AbortSignal;\n\n /**\n * Called whenever api returns cancellable error and the call is going to be retried.\n * Any exception thrown from this call back result in cancellation of operation\n * and propagation of thrown exception.\n * @param delayInMs - delay before next retry. This value will depend on internal back-off logic,\n * as well as information provided by service (like 429 error asking to wait for some time before retry)\n * @param error - error object returned from the call.\n */\n onRetry?(delayInMs: number, error: any): void;\n}\n\nexport async function runWithRetry<T>(\n api: (cancel?: AbortSignal) => Promise<T>,\n fetchCallName: string,\n logger: ITelemetryLogger,\n progress: IProgress,\n): Promise<T> {\n let result: T | undefined;\n let success = false;\n let retryAfterMs = 1000; // has to be positive!\n let numRetries = 0;\n const startTime = performance.now();\n let lastError: any;\n do {\n try {\n result = await api(progress.cancel);\n success = true;\n } catch (err) {\n // If it is not retriable, then just throw the error.\n if (!canRetryOnError(err)) {\n logger.sendTelemetryEvent({\n eventName: `${fetchCallName}_cancel`,\n retry: numRetries,\n duration: performance.now() - startTime,\n fetchCallName,\n }, err);\n throw err;\n }\n\n if (progress.cancel?.aborted === true) {\n logger.sendTelemetryEvent({\n eventName: `${fetchCallName}_runWithRetryAborted`,\n retry: numRetries,\n duration: performance.now() - startTime,\n fetchCallName,\n }, err);\n throw new NonRetryableError(\n \"runWithRetry was Aborted\",\n DriverErrorType.genericError,\n { driverVersion: pkgVersion, fetchCallName },\n );\n }\n\n numRetries++;\n lastError = err;\n // If the error is throttling error, then wait for the specified time before retrying.\n // If the waitTime is not specified, then we start with retrying immediately to max of 8s.\n retryAfterMs = getRetryDelayFromError(err) ?? Math.min(retryAfterMs * 2, 8000);\n if (progress.onRetry) {\n progress.onRetry(retryAfterMs, err);\n }\n await delay(retryAfterMs);\n }\n } while (!success);\n if (numRetries > 0) {\n logger.sendTelemetryEvent({\n eventName: `${fetchCallName}_lastError`,\n retry: numRetries,\n duration: performance.now() - startTime,\n fetchCallName,\n },\n lastError);\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return result!;\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IDocumentStorageService, IDocumentStorageServicePolicies, ISummaryContext } from "@fluidframework/driver-definitions";
5
+ import { FetchSource, IDocumentStorageService, IDocumentStorageServicePolicies, ISummaryContext } from "@fluidframework/driver-definitions";
6
6
  import { ICreateBlobResponse, ISnapshotTree, ISummaryHandle, ISummaryTree, IVersion } from "@fluidframework/protocol-definitions";
7
7
  export declare class DocumentStorageServiceProxy implements IDocumentStorageService {
8
8
  protected readonly internalStorageService: IDocumentStorageService;
@@ -12,7 +12,7 @@ export declare class DocumentStorageServiceProxy implements IDocumentStorageServ
12
12
  get repositoryUrl(): string;
13
13
  constructor(internalStorageService: IDocumentStorageService);
14
14
  getSnapshotTree(version?: IVersion, scenarioName?: string): Promise<ISnapshotTree | null>;
15
- getVersions(versionId: string | null, count: number, scenarioName?: string): Promise<IVersion[]>;
15
+ getVersions(versionId: string | null, count: number, scenarioName?: string, fetchSource?: FetchSource): Promise<IVersion[]>;
16
16
  uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string>;
17
17
  downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree>;
18
18
  createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse>;
@@ -1 +1 @@
1
- {"version":3,"file":"documentStorageServiceProxy.d.ts","sourceRoot":"","sources":["../src/documentStorageServiceProxy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,uBAAuB,EACvB,+BAA+B,EAC/B,eAAe,EAClB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACH,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,YAAY,EACZ,QAAQ,EACX,MAAM,sCAAsC,CAAC;AAE9C,qBAAa,2BAA4B,YAAW,uBAAuB;IAe3D,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,uBAAuB;IAd9E,OAAO,CAAC,SAAS,CAA8C;IAE/D,IAAW,QAAQ,CAAC,QAAQ,EAAE,+BAA+B,GAAG,SAAS,EAExE;IAED,IAAW,QAAQ,IAJW,+BAA+B,GAAG,SAAS,CAMxE;IAED,IAAW,aAAa,IAAI,MAAM,CAEjC;gBAE8B,sBAAsB,EAAE,uBAAuB;IAEjE,eAAe,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAIzF,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAIhG,wBAAwB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAI1F,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAI9D,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAA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Q,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAGlE"}
@@ -19,8 +19,8 @@ export class DocumentStorageServiceProxy {
19
19
  async getSnapshotTree(version, scenarioName) {
20
20
  return this.internalStorageService.getSnapshotTree(version, scenarioName);
21
21
  }
22
- async getVersions(versionId, count, scenarioName) {
23
- return this.internalStorageService.getVersions(versionId, count, scenarioName);
22
+ async getVersions(versionId, count, scenarioName, fetchSource) {
23
+ return this.internalStorageService.getVersions(versionId, count, scenarioName, fetchSource);
24
24
  }
25
25
  async uploadSummaryWithContext(summary, context) {
26
26
  return this.internalStorageService.uploadSummaryWithContext(summary, context);
@@ -1 +1 @@
1
- {"version":3,"file":"documentStorageServiceProxy.js","sourceRoot":"","sources":["../src/documentStorageServiceProxy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,MAAM,OAAO,2BAA2B;IAepC,YAA+B,sBAA+C;QAA/C,2BAAsB,GAAtB,sBAAsB,CAAyB;IAAI,CAAC;IAZnF,IAAW,QAAQ,CAAC,QAAqD;QACrE,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAED,IAAW,QAAQ;;QACf,OAAO,MAAA,IAAI,CAAC,SAAS,mCAAI,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAClE,CAAC;IAED,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC;IACrD,CAAC;IAIM,KAAK,CAAC,eAAe,CAAC,OAAkB,EAAE,YAAqB;QAClE,OAAO,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC9E,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,SAAwB,EAAE,KAAa,EAAE,YAAqB;QACnF,OAAO,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;IACnF,CAAC;IAEM,KAAK,CAAC,wBAAwB,CAAC,OAAqB,EAAE,OAAwB;QACjF,OAAO,IAAI,CAAC,sBAAsB,CAAC,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClF,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,MAAsB;QAC/C,OAAO,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC/D,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,IAAqB;QACzC,OAAO,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,MAAc;QAChC,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IDocumentStorageService,\n IDocumentStorageServicePolicies,\n ISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n ICreateBlobResponse,\n ISnapshotTree,\n ISummaryHandle,\n ISummaryTree,\n IVersion,\n} from \"@fluidframework/protocol-definitions\";\n\nexport class DocumentStorageServiceProxy implements IDocumentStorageService {\n private _policies: IDocumentStorageServicePolicies | undefined;\n\n public set policies(policies: IDocumentStorageServicePolicies | undefined) {\n this._policies = policies;\n }\n\n public get policies() {\n return this._policies ?? this.internalStorageService.policies;\n }\n\n public get repositoryUrl(): string {\n return this.internalStorageService.repositoryUrl;\n }\n\n constructor(protected readonly internalStorageService: IDocumentStorageService) { }\n\n public async getSnapshotTree(version?: IVersion, scenarioName?: string): Promise<ISnapshotTree | null> {\n return this.internalStorageService.getSnapshotTree(version, scenarioName);\n }\n\n public async getVersions(versionId: string | null, count: number, scenarioName?: string): Promise<IVersion[]> {\n return this.internalStorageService.getVersions(versionId, count, scenarioName);\n }\n\n public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {\n return this.internalStorageService.uploadSummaryWithContext(summary, context);\n }\n\n public async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n return this.internalStorageService.downloadSummary(handle);\n }\n\n public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n return this.internalStorageService.createBlob(file);\n }\n\n public async readBlob(blobId: string): Promise<ArrayBufferLike> {\n return this.internalStorageService.readBlob(blobId);\n }\n}\n"]}
1
+ {"version":3,"file":"documentStorageServiceProxy.js","sourceRoot":"","sources":["../src/documentStorageServiceProxy.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAgBH,MAAM,OAAO,2BAA2B;IAepC,YAA+B,sBAA+C;QAA/C,2BAAsB,GAAtB,sBAAsB,CAAyB;IAAI,CAAC;IAZnF,IAAW,QAAQ,CAAC,QAAqD;QACrE,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAED,IAAW,QAAQ;;QACf,OAAO,MAAA,IAAI,CAAC,SAAS,mCAAI,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC;IAClE,CAAC;IAED,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC;IACrD,CAAC;IAIM,KAAK,CAAC,eAAe,CAAC,OAAkB,EAAE,YAAqB;QAClE,OAAO,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAC9E,CAAC;IAEM,KAAK,CAAC,WAAW,CACpB,SAAwB,EACxB,KAAa,EACb,YAAqB,EACrB,WAAyB;QAEzB,OAAO,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;IAChG,CAAC;IAEM,KAAK,CAAC,wBAAwB,CAAC,OAAqB,EAAE,OAAwB;QACjF,OAAO,IAAI,CAAC,sBAAsB,CAAC,wBAAwB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAClF,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,MAAsB;QAC/C,OAAO,IAAI,CAAC,sBAAsB,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;IAC/D,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,IAAqB;QACzC,OAAO,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,MAAc;QAChC,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxD,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n FetchSource,\n IDocumentStorageService,\n IDocumentStorageServicePolicies,\n ISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n ICreateBlobResponse,\n ISnapshotTree,\n ISummaryHandle,\n ISummaryTree,\n IVersion,\n} from \"@fluidframework/protocol-definitions\";\n\nexport class DocumentStorageServiceProxy implements IDocumentStorageService {\n private _policies: IDocumentStorageServicePolicies | undefined;\n\n public set policies(policies: IDocumentStorageServicePolicies | undefined) {\n this._policies = policies;\n }\n\n public get policies() {\n return this._policies ?? this.internalStorageService.policies;\n }\n\n public get repositoryUrl(): string {\n return this.internalStorageService.repositoryUrl;\n }\n\n constructor(protected readonly internalStorageService: IDocumentStorageService) { }\n\n public async getSnapshotTree(version?: IVersion, scenarioName?: string): Promise<ISnapshotTree | null> {\n return this.internalStorageService.getSnapshotTree(version, scenarioName);\n }\n\n public async getVersions(\n versionId: string | null,\n count: number,\n scenarioName?: string,\n fetchSource?: FetchSource,\n ): Promise<IVersion[]> {\n return this.internalStorageService.getVersions(versionId, count, scenarioName, fetchSource);\n }\n\n public async uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string> {\n return this.internalStorageService.uploadSummaryWithContext(summary, context);\n }\n\n public async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n return this.internalStorageService.downloadSummary(handle);\n }\n\n public async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n return this.internalStorageService.createBlob(file);\n }\n\n public async readBlob(blobId: string): Promise<ArrayBufferLike> {\n return this.internalStorageService.readBlob(blobId);\n }\n}\n"]}
@@ -4,35 +4,51 @@
4
4
  */
5
5
  import { IDocumentMessage, ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
6
6
  /**
7
+ * Determines whether or not the message type is one of the following:
7
8
  *
8
- * @param message-message
9
- * @returns whether or not the message type is one listed below
10
- * "op"
11
- * "summarize"
12
- * "propose"
13
- * "reject"
14
- * "noop"
9
+ * - {@link @fluidframework/protocol-definitions#MessageType.Operation}
10
+ *
11
+ * - {@link @fluidframework/protocol-definitions#MessageType.Summarize}
12
+ *
13
+ * - {@link @fluidframework/protocol-definitions#MessageType.Propose}
14
+ *
15
+ * - {@link @fluidframework/protocol-definitions#MessageType.Reject}
16
+ *
17
+ * - {@link @fluidframework/protocol-definitions#MessageType2.Accept}
18
+ *
19
+ * - {@link @fluidframework/protocol-definitions#MessageType.NoOp}
15
20
  */
16
21
  export declare function isClientMessage(message: ISequencedDocumentMessage | IDocumentMessage): boolean;
17
22
  /**
18
- *
19
- * @param message-message
20
- * @returns whether or not the message type is one listed below
21
- * "op"
22
- * "summarize"
23
+ * Tells if message was sent by container runtime
24
+ * @privateRemarks ADO #1385: To be moved to container-definitions
25
+ * @returns whether the message is a runtime message
23
26
  */
24
- export declare function isRuntimeMessage(message: ISequencedDocumentMessage | IDocumentMessage): boolean;
27
+ export declare function isRuntimeMessage(message: {
28
+ type: string;
29
+ }): boolean;
25
30
  /**
31
+ * Determines whether or not the message type is one of the following: (legacy)
32
+ *
33
+ * - "component"
34
+ *
35
+ * - "attach"
36
+ *
37
+ * - "chunkedOp"
38
+ *
39
+ * - "blobAttach"
40
+ *
41
+ * - "rejoin"
42
+ *
43
+ * - "alias"
44
+ *
45
+ * - "op"
26
46
  *
27
- * @param message-message
28
- * @returns whether or not the message type is one listed below (legacy)
29
- * "component"
30
- * "attach"
31
- * "chunkedOp"
32
- * "blobAttach"
33
- * "rejoin"
34
- * "alias"
35
- * "op"
47
+ * @deprecated This API should not be used.
36
48
  */
37
49
  export declare function isUnpackedRuntimeMessage(message: ISequencedDocumentMessage): boolean;
50
+ export declare enum MessageType2 {
51
+ Accept = "accept"
52
+ }
53
+ export declare function canBeCoalescedByService(message: ISequencedDocumentMessage | IDocumentMessage): boolean;
38
54
  //# sourceMappingURL=messageRecognition.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"messageRecognition.d.ts","sourceRoot":"","sources":["../src/messageRecognition.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAEhH;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,yBAAyB,GAAG,gBAAgB,GAAG,OAAO,CAY9F;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,yBAAyB,GAAG,gBAAgB,GAAG,OAAO,CAE/F;AAYD;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAKpF"}
1
+ {"version":3,"file":"messageRecognition.d.ts","sourceRoot":"","sources":["../src/messageRecognition.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAe,MAAM,sCAAsC,CAAC;AAEhH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,yBAAyB,GAAG,gBAAgB,GAAG,OAAO,CAc9F;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;CAAE,GAAG,OAAO,CAEpE;AAYD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAKpF;AAID,oBAAY,YAAY;IACpB,MAAM,WAAW;CACpB;AAGD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,yBAAyB,GAAG,gBAAgB,GAAG,OAAO,CAItG"}
@@ -4,14 +4,19 @@
4
4
  */
5
5
  import { MessageType } from "@fluidframework/protocol-definitions";
6
6
  /**
7
+ * Determines whether or not the message type is one of the following:
7
8
  *
8
- * @param message-message
9
- * @returns whether or not the message type is one listed below
10
- * "op"
11
- * "summarize"
12
- * "propose"
13
- * "reject"
14
- * "noop"
9
+ * - {@link @fluidframework/protocol-definitions#MessageType.Operation}
10
+ *
11
+ * - {@link @fluidframework/protocol-definitions#MessageType.Summarize}
12
+ *
13
+ * - {@link @fluidframework/protocol-definitions#MessageType.Propose}
14
+ *
15
+ * - {@link @fluidframework/protocol-definitions#MessageType.Reject}
16
+ *
17
+ * - {@link @fluidframework/protocol-definitions#MessageType2.Accept}
18
+ *
19
+ * - {@link @fluidframework/protocol-definitions#MessageType.NoOp}
15
20
  */
16
21
  export function isClientMessage(message) {
17
22
  if (isRuntimeMessage(message)) {
@@ -21,20 +26,20 @@ export function isClientMessage(message) {
21
26
  case MessageType.Propose:
22
27
  case MessageType.Reject:
23
28
  case MessageType.NoOp:
29
+ case MessageType2.Accept:
30
+ case MessageType.Summarize:
24
31
  return true;
25
32
  default:
26
33
  return false;
27
34
  }
28
35
  }
29
36
  /**
30
- *
31
- * @param message-message
32
- * @returns whether or not the message type is one listed below
33
- * "op"
34
- * "summarize"
37
+ * Tells if message was sent by container runtime
38
+ * @privateRemarks ADO #1385: To be moved to container-definitions
39
+ * @returns whether the message is a runtime message
35
40
  */
36
41
  export function isRuntimeMessage(message) {
37
- return message.type === MessageType.Operation || message.type === MessageType.Summarize;
42
+ return message.type === MessageType.Operation;
38
43
  }
39
44
  var RuntimeMessage;
40
45
  (function (RuntimeMessage) {
@@ -47,16 +52,23 @@ var RuntimeMessage;
47
52
  RuntimeMessage["Operation"] = "op";
48
53
  })(RuntimeMessage || (RuntimeMessage = {}));
49
54
  /**
55
+ * Determines whether or not the message type is one of the following: (legacy)
56
+ *
57
+ * - "component"
50
58
  *
51
- * @param message-message
52
- * @returns whether or not the message type is one listed below (legacy)
53
- * "component"
54
- * "attach"
55
- * "chunkedOp"
56
- * "blobAttach"
57
- * "rejoin"
58
- * "alias"
59
- * "op"
59
+ * - "attach"
60
+ *
61
+ * - "chunkedOp"
62
+ *
63
+ * - "blobAttach"
64
+ *
65
+ * - "rejoin"
66
+ *
67
+ * - "alias"
68
+ *
69
+ * - "op"
70
+ *
71
+ * @deprecated This API should not be used.
60
72
  */
61
73
  export function isUnpackedRuntimeMessage(message) {
62
74
  if (Object.values(RuntimeMessage).includes(message.type)) {
@@ -64,4 +76,16 @@ export function isUnpackedRuntimeMessage(message) {
64
76
  }
65
77
  return false;
66
78
  }
79
+ // ADO #1385: staging code changes across layers.
80
+ // Eventually to be replaced by MessageType.accept
81
+ export var MessageType2;
82
+ (function (MessageType2) {
83
+ MessageType2["Accept"] = "accept";
84
+ })(MessageType2 || (MessageType2 = {}));
85
+ // ADO #1385: To be moved to packages/protocol-base/src/protocol.ts
86
+ export function canBeCoalescedByService(message) {
87
+ // This assumes that in the future relay service may implement coalescing of accept messages,
88
+ // same way it was doing coalescing of immediate noops in the past.
89
+ return message.type === MessageType.NoOp || message.type === MessageType2.Accept;
90
+ }
67
91
  //# sourceMappingURL=messageRecognition.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"messageRecognition.js","sourceRoot":"","sources":["../src/messageRecognition.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAA+C,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAEhH;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,OAAqD;IACjF,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE;QAC3B,OAAO,IAAI,CAAC;KACf;IACD,QAAQ,OAAO,CAAC,IAAI,EAAE;QAClB,KAAK,WAAW,CAAC,OAAO,CAAC;QACzB,KAAK,WAAW,CAAC,MAAM,CAAC;QACxB,KAAK,WAAW,CAAC,IAAI;YACjB,OAAO,IAAI,CAAC;QAChB;YACI,OAAO,KAAK,CAAC;KACpB;AACL,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAqD;IAClF,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,SAAS,CAAC;AAC5F,CAAC;AAED,IAAK,cAQJ;AARD,WAAK,cAAc;IACf,gDAA8B,CAAA;IAC9B,mCAAiB,CAAA;IACjB,yCAAuB,CAAA;IACvB,2CAAyB,CAAA;IACzB,mCAAiB,CAAA;IACjB,iCAAe,CAAA;IACf,kCAAgB,CAAA;AACpB,CAAC,EARI,cAAc,KAAd,cAAc,QAQlB;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAkC;IACvE,IAAK,MAAM,CAAC,MAAM,CAAC,cAAc,CAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACpE,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { IDocumentMessage, ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\n\n/**\n *\n * @param message-message\n * @returns whether or not the message type is one listed below\n * \"op\"\n * \"summarize\"\n * \"propose\"\n * \"reject\"\n * \"noop\"\n */\nexport function isClientMessage(message: ISequencedDocumentMessage | IDocumentMessage): boolean {\n if (isRuntimeMessage(message)) {\n return true;\n }\n switch (message.type) {\n case MessageType.Propose:\n case MessageType.Reject:\n case MessageType.NoOp:\n return true;\n default:\n return false;\n }\n}\n\n/**\n *\n * @param message-message\n * @returns whether or not the message type is one listed below\n * \"op\"\n * \"summarize\"\n */\nexport function isRuntimeMessage(message: ISequencedDocumentMessage | IDocumentMessage): boolean {\n return message.type === MessageType.Operation || message.type === MessageType.Summarize;\n}\n\nenum RuntimeMessage {\n FluidDataStoreOp = \"component\",\n Attach = \"attach\",\n ChunkedOp = \"chunkedOp\",\n BlobAttach = \"blobAttach\",\n Rejoin = \"rejoin\",\n Alias = \"alias\",\n Operation = \"op\",\n}\n\n/**\n *\n * @param message-message\n * @returns whether or not the message type is one listed below (legacy)\n * \"component\"\n * \"attach\"\n * \"chunkedOp\"\n * \"blobAttach\"\n * \"rejoin\"\n * \"alias\"\n * \"op\"\n */\nexport function isUnpackedRuntimeMessage(message: ISequencedDocumentMessage): boolean {\n if ((Object.values(RuntimeMessage) as string[]).includes(message.type)) {\n return true;\n }\n return false;\n}\n"]}
1
+ {"version":3,"file":"messageRecognition.js","sourceRoot":"","sources":["../src/messageRecognition.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAA+C,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAEhH;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,eAAe,CAAC,OAAqD;IACjF,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE;QAC3B,OAAO,IAAI,CAAC;KACf;IACD,QAAQ,OAAO,CAAC,IAAI,EAAE;QAClB,KAAK,WAAW,CAAC,OAAO,CAAC;QACzB,KAAK,WAAW,CAAC,MAAM,CAAC;QACxB,KAAK,WAAW,CAAC,IAAI,CAAC;QACtB,KAAK,YAAY,CAAC,MAAM,CAAC;QACzB,KAAK,WAAW,CAAC,SAAS;YACtB,OAAO,IAAI,CAAC;QAChB;YACI,OAAO,KAAK,CAAC;KACpB;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAA0B;IACvD,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,SAAS,CAAC;AAClD,CAAC;AAED,IAAK,cAQJ;AARD,WAAK,cAAc;IACf,gDAA8B,CAAA;IAC9B,mCAAiB,CAAA;IACjB,yCAAuB,CAAA;IACvB,2CAAyB,CAAA;IACzB,mCAAiB,CAAA;IACjB,iCAAe,CAAA;IACf,kCAAgB,CAAA;AACpB,CAAC,EARI,cAAc,KAAd,cAAc,QAQlB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,wBAAwB,CAAC,OAAkC;IACvE,IAAK,MAAM,CAAC,MAAM,CAAC,cAAc,CAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACpE,OAAO,IAAI,CAAC;KACf;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,iDAAiD;AACjD,kDAAkD;AAClD,MAAM,CAAN,IAAY,YAEX;AAFD,WAAY,YAAY;IACpB,iCAAiB,CAAA;AACrB,CAAC,EAFW,YAAY,KAAZ,YAAY,QAEvB;AAED,mEAAmE;AACnE,MAAM,UAAU,uBAAuB,CAAC,OAAqD;IACzF,6FAA6F;IAC7F,mEAAmE;IACnE,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,MAAM,CAAC;AACrF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { IDocumentMessage, ISequencedDocumentMessage, MessageType } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Determines whether or not the message type is one of the following:\n *\n * - {@link @fluidframework/protocol-definitions#MessageType.Operation}\n *\n * - {@link @fluidframework/protocol-definitions#MessageType.Summarize}\n *\n * - {@link @fluidframework/protocol-definitions#MessageType.Propose}\n *\n * - {@link @fluidframework/protocol-definitions#MessageType.Reject}\n *\n * - {@link @fluidframework/protocol-definitions#MessageType2.Accept}\n *\n * - {@link @fluidframework/protocol-definitions#MessageType.NoOp}\n */\nexport function isClientMessage(message: ISequencedDocumentMessage | IDocumentMessage): boolean {\n if (isRuntimeMessage(message)) {\n return true;\n }\n switch (message.type) {\n case MessageType.Propose:\n case MessageType.Reject:\n case MessageType.NoOp:\n case MessageType2.Accept:\n case MessageType.Summarize:\n return true;\n default:\n return false;\n }\n}\n\n/**\n * Tells if message was sent by container runtime\n * @privateRemarks ADO #1385: To be moved to container-definitions\n * @returns whether the message is a runtime message\n */\nexport function isRuntimeMessage(message: { type: string; }): boolean {\n return message.type === MessageType.Operation;\n}\n\nenum RuntimeMessage {\n FluidDataStoreOp = \"component\",\n Attach = \"attach\",\n ChunkedOp = \"chunkedOp\",\n BlobAttach = \"blobAttach\",\n Rejoin = \"rejoin\",\n Alias = \"alias\",\n Operation = \"op\",\n}\n\n/**\n * Determines whether or not the message type is one of the following: (legacy)\n *\n * - \"component\"\n *\n * - \"attach\"\n *\n * - \"chunkedOp\"\n *\n * - \"blobAttach\"\n *\n * - \"rejoin\"\n *\n * - \"alias\"\n *\n * - \"op\"\n *\n * @deprecated This API should not be used.\n */\nexport function isUnpackedRuntimeMessage(message: ISequencedDocumentMessage): boolean {\n if ((Object.values(RuntimeMessage) as string[]).includes(message.type)) {\n return true;\n }\n return false;\n}\n\n// ADO #1385: staging code changes across layers.\n// Eventually to be replaced by MessageType.accept\nexport enum MessageType2 {\n Accept = \"accept\",\n}\n\n// ADO #1385: To be moved to packages/protocol-base/src/protocol.ts\nexport function canBeCoalescedByService(message: ISequencedDocumentMessage | IDocumentMessage): boolean {\n // This assumes that in the future relay service may implement coalescing of accept messages,\n // same way it was doing coalescing of immediate noops in the past.\n return message.type === MessageType.NoOp || message.type === MessageType2.Accept;\n}\n"]}
package/lib/network.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IThrottlingWarning, IDriverErrorBase, IAuthorizationError, DriverErrorType } from "@fluidframework/driver-definitions";
5
+ import { IThrottlingWarning, IDriverErrorBase, IAuthorizationError, DriverErrorType, ILocationRedirectionError, IResolvedUrl } from "@fluidframework/driver-definitions";
6
6
  import { ITelemetryProperties } from "@fluidframework/common-definitions";
7
7
  import { IFluidErrorBase, LoggingError } from "@fluidframework/telemetry-utils";
8
8
  export declare enum OnlineStatus {
@@ -35,6 +35,14 @@ export declare class GenericNetworkError extends LoggingError implements IDriver
35
35
  readonly errorType = DriverErrorType.genericNetworkError;
36
36
  constructor(message: string, canRetry: boolean, props: DriverErrorTelemetryProps);
37
37
  }
38
+ /**
39
+ * FluidInvalidSchema error class.
40
+ */
41
+ export declare class FluidInvalidSchemaError extends LoggingError implements IDriverErrorBase, IFluidErrorBase {
42
+ readonly errorType = DriverErrorType.fluidInvalidSchema;
43
+ readonly canRetry = false;
44
+ constructor(message: string, props: DriverErrorTelemetryProps);
45
+ }
38
46
  export declare class DeltaStreamConnectionForbiddenError extends LoggingError implements IFluidErrorBase {
39
47
  static readonly errorType: string;
40
48
  readonly errorType: string;
@@ -48,6 +56,12 @@ export declare class AuthorizationError extends LoggingError implements IAuthori
48
56
  readonly canRetry = false;
49
57
  constructor(message: string, claims: string | undefined, tenantId: string | undefined, props: DriverErrorTelemetryProps);
50
58
  }
59
+ export declare class LocationRedirectionError extends LoggingError implements ILocationRedirectionError, IFluidErrorBase {
60
+ readonly redirectUrl: IResolvedUrl;
61
+ readonly errorType = DriverErrorType.locationRedirection;
62
+ readonly canRetry = false;
63
+ constructor(message: string, redirectUrl: IResolvedUrl, props: DriverErrorTelemetryProps);
64
+ }
51
65
  export declare class NetworkErrorBasic<T extends string> extends LoggingError implements IFluidErrorBase {
52
66
  readonly errorType: T;
53
67
  readonly canRetry: boolean;