@azure/storage-file-share 12.25.0-alpha.20240823.1 → 12.25.0-alpha.20240827.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. package/dist/index.js +47 -47
  2. package/dist/index.js.map +1 -1
  3. package/dist-esm/storage-blob/src/BatchResponse.js +1 -1
  4. package/dist-esm/storage-blob/src/BatchResponse.js.map +1 -1
  5. package/dist-esm/storage-blob/src/BatchResponseParser.js +1 -1
  6. package/dist-esm/storage-blob/src/BatchResponseParser.js.map +1 -1
  7. package/dist-esm/storage-blob/src/BatchUtils.js +1 -1
  8. package/dist-esm/storage-blob/src/BatchUtils.js.map +1 -1
  9. package/dist-esm/storage-blob/src/BlobBatch.js +1 -1
  10. package/dist-esm/storage-blob/src/BlobBatch.js.map +1 -1
  11. package/dist-esm/storage-blob/src/BlobBatchClient.js +1 -1
  12. package/dist-esm/storage-blob/src/BlobBatchClient.js.map +1 -1
  13. package/dist-esm/storage-blob/src/BlobDownloadResponse.js +1 -1
  14. package/dist-esm/storage-blob/src/BlobDownloadResponse.js.map +1 -1
  15. package/dist-esm/storage-blob/src/BlobLeaseClient.js +1 -1
  16. package/dist-esm/storage-blob/src/BlobLeaseClient.js.map +1 -1
  17. package/dist-esm/storage-blob/src/BlobQueryResponse.js +1 -1
  18. package/dist-esm/storage-blob/src/BlobQueryResponse.js.map +1 -1
  19. package/dist-esm/storage-blob/src/BlobServiceClient.js +1 -1
  20. package/dist-esm/storage-blob/src/BlobServiceClient.js.map +1 -1
  21. package/dist-esm/storage-blob/src/Clients.js +1 -1
  22. package/dist-esm/storage-blob/src/Clients.js.map +1 -1
  23. package/dist-esm/storage-blob/src/ContainerClient.js.map +1 -1
  24. package/dist-esm/storage-blob/src/PageBlobRangeResponse.js +1 -1
  25. package/dist-esm/storage-blob/src/PageBlobRangeResponse.js.map +1 -1
  26. package/dist-esm/storage-blob/src/Pipeline.js +1 -1
  27. package/dist-esm/storage-blob/src/Pipeline.js.map +1 -1
  28. package/dist-esm/storage-blob/src/Range.js +1 -1
  29. package/dist-esm/storage-blob/src/Range.js.map +1 -1
  30. package/dist-esm/storage-blob/src/StorageBrowserPolicyFactory.js +1 -1
  31. package/dist-esm/storage-blob/src/StorageBrowserPolicyFactory.js.map +1 -1
  32. package/dist-esm/storage-blob/src/StorageClient.js +1 -1
  33. package/dist-esm/storage-blob/src/StorageClient.js.map +1 -1
  34. package/dist-esm/storage-blob/src/StorageContextClient.js +1 -1
  35. package/dist-esm/storage-blob/src/StorageContextClient.js.map +1 -1
  36. package/dist-esm/storage-blob/src/StorageRetryPolicyFactory.js +1 -1
  37. package/dist-esm/storage-blob/src/StorageRetryPolicyFactory.js.map +1 -1
  38. package/dist-esm/storage-blob/src/credentials/AnonymousCredential.js +1 -1
  39. package/dist-esm/storage-blob/src/credentials/AnonymousCredential.js.map +1 -1
  40. package/dist-esm/storage-blob/src/credentials/Credential.js +1 -1
  41. package/dist-esm/storage-blob/src/credentials/Credential.js.map +1 -1
  42. package/dist-esm/storage-blob/src/credentials/StorageSharedKeyCredential.browser.js +1 -1
  43. package/dist-esm/storage-blob/src/credentials/StorageSharedKeyCredential.browser.js.map +1 -1
  44. package/dist-esm/storage-blob/src/credentials/StorageSharedKeyCredential.js +1 -1
  45. package/dist-esm/storage-blob/src/credentials/StorageSharedKeyCredential.js.map +1 -1
  46. package/dist-esm/storage-blob/src/credentials/UserDelegationKeyCredential.browser.js +1 -1
  47. package/dist-esm/storage-blob/src/credentials/UserDelegationKeyCredential.browser.js.map +1 -1
  48. package/dist-esm/storage-blob/src/credentials/UserDelegationKeyCredential.js +1 -1
  49. package/dist-esm/storage-blob/src/credentials/UserDelegationKeyCredential.js.map +1 -1
  50. package/dist-esm/storage-blob/src/generatedModels.js +1 -1
  51. package/dist-esm/storage-blob/src/generatedModels.js.map +1 -1
  52. package/dist-esm/storage-blob/src/index.js +1 -1
  53. package/dist-esm/storage-blob/src/index.js.map +1 -1
  54. package/dist-esm/storage-blob/src/log.js +1 -1
  55. package/dist-esm/storage-blob/src/log.js.map +1 -1
  56. package/dist-esm/storage-blob/src/models.js +1 -1
  57. package/dist-esm/storage-blob/src/models.js.map +1 -1
  58. package/dist-esm/storage-blob/src/policies/AnonymousCredentialPolicy.js +1 -1
  59. package/dist-esm/storage-blob/src/policies/AnonymousCredentialPolicy.js.map +1 -1
  60. package/dist-esm/storage-blob/src/policies/CredentialPolicy.js +1 -1
  61. package/dist-esm/storage-blob/src/policies/CredentialPolicy.js.map +1 -1
  62. package/dist-esm/storage-blob/src/policies/RequestPolicy.js +1 -1
  63. package/dist-esm/storage-blob/src/policies/RequestPolicy.js.map +1 -1
  64. package/dist-esm/storage-blob/src/policies/StorageBrowserPolicy.js +1 -1
  65. package/dist-esm/storage-blob/src/policies/StorageBrowserPolicy.js.map +1 -1
  66. package/dist-esm/storage-blob/src/policies/StorageBrowserPolicyV2.js +1 -1
  67. package/dist-esm/storage-blob/src/policies/StorageBrowserPolicyV2.js.map +1 -1
  68. package/dist-esm/storage-blob/src/policies/StorageCorrectContentLengthPolicy.browser.js +1 -1
  69. package/dist-esm/storage-blob/src/policies/StorageCorrectContentLengthPolicy.browser.js.map +1 -1
  70. package/dist-esm/storage-blob/src/policies/StorageCorrectContentLengthPolicy.js +1 -1
  71. package/dist-esm/storage-blob/src/policies/StorageCorrectContentLengthPolicy.js.map +1 -1
  72. package/dist-esm/storage-blob/src/policies/StorageRetryPolicy.js +1 -1
  73. package/dist-esm/storage-blob/src/policies/StorageRetryPolicy.js.map +1 -1
  74. package/dist-esm/storage-blob/src/policies/StorageRetryPolicyV2.js +1 -1
  75. package/dist-esm/storage-blob/src/policies/StorageRetryPolicyV2.js.map +1 -1
  76. package/dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicy.js +1 -1
  77. package/dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicy.js.map +1 -1
  78. package/dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicyV2.browser.js +1 -1
  79. package/dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicyV2.browser.js.map +1 -1
  80. package/dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicyV2.js +1 -1
  81. package/dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicyV2.js.map +1 -1
  82. package/dist-esm/storage-blob/src/pollers/BlobStartCopyFromUrlPoller.js +1 -1
  83. package/dist-esm/storage-blob/src/pollers/BlobStartCopyFromUrlPoller.js.map +1 -1
  84. package/dist-esm/storage-blob/src/sas/AccountSASPermissions.js +1 -1
  85. package/dist-esm/storage-blob/src/sas/AccountSASPermissions.js.map +1 -1
  86. package/dist-esm/storage-blob/src/sas/AccountSASResourceTypes.js +1 -1
  87. package/dist-esm/storage-blob/src/sas/AccountSASResourceTypes.js.map +1 -1
  88. package/dist-esm/storage-blob/src/sas/AccountSASServices.js +1 -1
  89. package/dist-esm/storage-blob/src/sas/AccountSASServices.js.map +1 -1
  90. package/dist-esm/storage-blob/src/sas/AccountSASSignatureValues.js +1 -1
  91. package/dist-esm/storage-blob/src/sas/AccountSASSignatureValues.js.map +1 -1
  92. package/dist-esm/storage-blob/src/sas/BlobSASPermissions.js +1 -1
  93. package/dist-esm/storage-blob/src/sas/BlobSASPermissions.js.map +1 -1
  94. package/dist-esm/storage-blob/src/sas/BlobSASSignatureValues.js +1 -1
  95. package/dist-esm/storage-blob/src/sas/BlobSASSignatureValues.js.map +1 -1
  96. package/dist-esm/storage-blob/src/sas/ContainerSASPermissions.js +1 -1
  97. package/dist-esm/storage-blob/src/sas/ContainerSASPermissions.js.map +1 -1
  98. package/dist-esm/storage-blob/src/sas/SASQueryParameters.js +1 -1
  99. package/dist-esm/storage-blob/src/sas/SASQueryParameters.js.map +1 -1
  100. package/dist-esm/storage-blob/src/sas/SasIPRange.js +1 -1
  101. package/dist-esm/storage-blob/src/sas/SasIPRange.js.map +1 -1
  102. package/dist-esm/storage-blob/src/utils/Batch.js +1 -1
  103. package/dist-esm/storage-blob/src/utils/Batch.js.map +1 -1
  104. package/dist-esm/storage-blob/src/utils/BlobQuickQueryStream.js +1 -1
  105. package/dist-esm/storage-blob/src/utils/BlobQuickQueryStream.js.map +1 -1
  106. package/dist-esm/storage-blob/src/utils/Mutex.js +1 -1
  107. package/dist-esm/storage-blob/src/utils/Mutex.js.map +1 -1
  108. package/dist-esm/storage-blob/src/utils/RetriableReadableStream.js +1 -1
  109. package/dist-esm/storage-blob/src/utils/RetriableReadableStream.js.map +1 -1
  110. package/dist-esm/storage-blob/src/utils/SharedKeyComparator.js +1 -1
  111. package/dist-esm/storage-blob/src/utils/SharedKeyComparator.js.map +1 -1
  112. package/dist-esm/storage-blob/src/utils/cache.js +1 -1
  113. package/dist-esm/storage-blob/src/utils/cache.js.map +1 -1
  114. package/dist-esm/storage-blob/src/utils/constants.js +1 -1
  115. package/dist-esm/storage-blob/src/utils/constants.js.map +1 -1
  116. package/dist-esm/storage-blob/src/utils/tracing.js +1 -1
  117. package/dist-esm/storage-blob/src/utils/tracing.js.map +1 -1
  118. package/dist-esm/storage-blob/src/utils/utils.common.js +1 -1
  119. package/dist-esm/storage-blob/src/utils/utils.common.js.map +1 -1
  120. package/dist-esm/storage-blob/src/utils/utils.node.js +1 -1
  121. package/dist-esm/storage-blob/src/utils/utils.node.js.map +1 -1
  122. package/dist-esm/storage-file-share/src/AccountSASPermissions.js +1 -1
  123. package/dist-esm/storage-file-share/src/AccountSASPermissions.js.map +1 -1
  124. package/dist-esm/storage-file-share/src/AccountSASResourceTypes.js +1 -1
  125. package/dist-esm/storage-file-share/src/AccountSASResourceTypes.js.map +1 -1
  126. package/dist-esm/storage-file-share/src/AccountSASServices.js +1 -1
  127. package/dist-esm/storage-file-share/src/AccountSASServices.js.map +1 -1
  128. package/dist-esm/storage-file-share/src/AccountSASSignatureValues.js +1 -1
  129. package/dist-esm/storage-file-share/src/AccountSASSignatureValues.js.map +1 -1
  130. package/dist-esm/storage-file-share/src/Clients.js +1 -1
  131. package/dist-esm/storage-file-share/src/Clients.js.map +1 -1
  132. package/dist-esm/storage-file-share/src/FileDownloadResponse.browser.js +1 -1
  133. package/dist-esm/storage-file-share/src/FileDownloadResponse.browser.js.map +1 -1
  134. package/dist-esm/storage-file-share/src/FileDownloadResponse.js +1 -1
  135. package/dist-esm/storage-file-share/src/FileDownloadResponse.js.map +1 -1
  136. package/dist-esm/storage-file-share/src/FileSASPermissions.js +1 -1
  137. package/dist-esm/storage-file-share/src/FileSASPermissions.js.map +1 -1
  138. package/dist-esm/storage-file-share/src/FileSASSignatureValues.js +1 -1
  139. package/dist-esm/storage-file-share/src/FileSASSignatureValues.js.map +1 -1
  140. package/dist-esm/storage-file-share/src/FileSystemAttributes.js +1 -1
  141. package/dist-esm/storage-file-share/src/FileSystemAttributes.js.map +1 -1
  142. package/dist-esm/storage-file-share/src/Pipeline.js +1 -1
  143. package/dist-esm/storage-file-share/src/Pipeline.js.map +1 -1
  144. package/dist-esm/storage-file-share/src/Range.js +1 -1
  145. package/dist-esm/storage-file-share/src/Range.js.map +1 -1
  146. package/dist-esm/storage-file-share/src/SASQueryParameters.js +1 -1
  147. package/dist-esm/storage-file-share/src/SASQueryParameters.js.map +1 -1
  148. package/dist-esm/storage-file-share/src/SasIPRange.js +1 -1
  149. package/dist-esm/storage-file-share/src/SasIPRange.js.map +1 -1
  150. package/dist-esm/storage-file-share/src/ShareClientInternal.js +1 -1
  151. package/dist-esm/storage-file-share/src/ShareClientInternal.js.map +1 -1
  152. package/dist-esm/storage-file-share/src/ShareSASPermissions.js +1 -1
  153. package/dist-esm/storage-file-share/src/ShareSASPermissions.js.map +1 -1
  154. package/dist-esm/storage-file-share/src/ShareServiceClient.js +1 -1
  155. package/dist-esm/storage-file-share/src/ShareServiceClient.js.map +1 -1
  156. package/dist-esm/storage-file-share/src/StorageClient.js +1 -1
  157. package/dist-esm/storage-file-share/src/StorageClient.js.map +1 -1
  158. package/dist-esm/storage-file-share/src/StorageContextClient.js +1 -1
  159. package/dist-esm/storage-file-share/src/StorageContextClient.js.map +1 -1
  160. package/dist-esm/storage-file-share/src/StorageRetryPolicyFactory.js +1 -1
  161. package/dist-esm/storage-file-share/src/StorageRetryPolicyFactory.js.map +1 -1
  162. package/dist-esm/storage-file-share/src/generatedModels.js +1 -1
  163. package/dist-esm/storage-file-share/src/generatedModels.js.map +1 -1
  164. package/dist-esm/storage-file-share/src/index.browser.js +1 -1
  165. package/dist-esm/storage-file-share/src/index.browser.js.map +1 -1
  166. package/dist-esm/storage-file-share/src/index.js +1 -1
  167. package/dist-esm/storage-file-share/src/index.js.map +1 -1
  168. package/dist-esm/storage-file-share/src/log.js +1 -1
  169. package/dist-esm/storage-file-share/src/log.js.map +1 -1
  170. package/dist-esm/storage-file-share/src/models.js +1 -1
  171. package/dist-esm/storage-file-share/src/models.js.map +1 -1
  172. package/dist-esm/storage-file-share/src/policies/StorageRetryPolicy.js +1 -1
  173. package/dist-esm/storage-file-share/src/policies/StorageRetryPolicy.js.map +1 -1
  174. package/dist-esm/storage-file-share/src/policies/StorageRetryPolicyV2.js +1 -1
  175. package/dist-esm/storage-file-share/src/policies/StorageRetryPolicyV2.js.map +1 -1
  176. package/dist-esm/storage-file-share/src/utils/Batch.js +1 -1
  177. package/dist-esm/storage-file-share/src/utils/Batch.js.map +1 -1
  178. package/dist-esm/storage-file-share/src/utils/BufferScheduler.js +1 -1
  179. package/dist-esm/storage-file-share/src/utils/BufferScheduler.js.map +1 -1
  180. package/dist-esm/storage-file-share/src/utils/RetriableReadableStream.js +1 -1
  181. package/dist-esm/storage-file-share/src/utils/RetriableReadableStream.js.map +1 -1
  182. package/dist-esm/storage-file-share/src/utils/constants.js +1 -1
  183. package/dist-esm/storage-file-share/src/utils/constants.js.map +1 -1
  184. package/dist-esm/storage-file-share/src/utils/tracing.js +1 -1
  185. package/dist-esm/storage-file-share/src/utils/tracing.js.map +1 -1
  186. package/dist-esm/storage-file-share/src/utils/utils.browser.js +1 -1
  187. package/dist-esm/storage-file-share/src/utils/utils.browser.js.map +1 -1
  188. package/dist-esm/storage-file-share/src/utils/utils.common.js +1 -1
  189. package/dist-esm/storage-file-share/src/utils/utils.common.js.map +1 -1
  190. package/dist-esm/storage-file-share/src/utils/utils.node.js +1 -1
  191. package/dist-esm/storage-file-share/src/utils/utils.node.js.map +1 -1
  192. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"StorageRetryPolicyV2.js","sourceRoot":"","sources":["../../../../src/policies/StorageRetryPolicyV2.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAKL,WAAW,EACX,SAAS,GACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAE3D;;GAEG;AACH,MAAM,CAAN,IAAY,sBASX;AATD,WAAY,sBAAsB;IAChC;;OAEG;IACH,iFAAW,CAAA;IACX;;OAEG;IACH,qEAAK,CAAA;AACP,CAAC,EATW,sBAAsB,KAAtB,sBAAsB,QASjC;AAED,wCAAwC;AACxC,MAAM,qBAAqB,GAAG;IAC5B,iBAAiB,EAAE,GAAG,GAAG,IAAI;IAC7B,QAAQ,EAAE,CAAC;IACX,cAAc,EAAE,CAAC,GAAG,IAAI;IACxB,eAAe,EAAE,sBAAsB,CAAC,WAAW;IACnD,aAAa,EAAE,EAAE;IACjB,cAAc,EAAE,SAAS,EAAE,2CAA2C;CAC9D,CAAC;AAEX,MAAM,eAAe,GAAG;IACtB,WAAW;IACX,iBAAiB;IACjB,cAAc;IACd,YAAY;IACZ,QAAQ;IACR,WAAW;IACX,SAAS;IACT,OAAO;I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the MIT license.\n\nimport { AbortError } from \"@azure/abort-controller\";\nimport {\n PipelinePolicy,\n PipelineRequest,\n SendRequest,\n PipelineResponse,\n isRestError,\n RestError,\n} from \"@azure/core-rest-pipeline\";\nimport { getErrorMessage } from \"@azure/core-util\";\nimport { StorageRetryOptions } from \"../StorageRetryPolicyFactory\";\nimport { URLConstants } from \"../utils/constants\";\nimport { delay, setURLParameter } from \"../utils/utils.common\";\nimport { logger } from \"../log\";\n\n/**\n * Name of the {@link storageRetryPolicy}\n */\nexport const storageRetryPolicyName = \"storageRetryPolicy\";\n\n/**\n * RetryPolicy types.\n */\nexport enum StorageRetryPolicyType {\n /**\n * Exponential retry. Retry time delay grows exponentially.\n */\n EXPONENTIAL,\n /**\n * Linear retry. Retry time delay grows linearly.\n */\n FIXED,\n}\n\n// Default values of StorageRetryOptions\nconst DEFAULT_RETRY_OPTIONS = {\n maxRetryDelayInMs: 120 * 1000,\n maxTries: 4,\n retryDelayInMs: 4 * 1000,\n retryPolicyType: StorageRetryPolicyType.EXPONENTIAL,\n secondaryHost: \"\",\n tryTimeoutInMs: undefined, // Use server side default timeout strategy\n} as const;\n\nconst retriableErrors = [\n \"ETIMEDOUT\",\n \"ESOCKETTIMEDOUT\",\n \"ECONNREFUSED\",\n \"ECONNRESET\",\n \"ENOENT\",\n \"ENOTFOUND\",\n \"TIMEOUT\",\n \"EPIPE\",\n \"REQUEST_SEND_ERROR\",\n] as const;\n\nconst RETRY_ABORT_ERROR = new AbortError(\"The operation was aborted.\");\n\n/**\n * Retry policy with exponential retry and linear retry implemented.\n */\nexport function storageRetryPolicy(options: StorageRetryOptions = {}): PipelinePolicy {\n const retryPolicyType = options.retryPolicyType ?? DEFAULT_RETRY_OPTIONS.retryPolicyType;\n const maxTries = options.maxTries ?? DEFAULT_RETRY_OPTIONS.maxTries;\n const retryDelayInMs = options.retryDelayInMs ?? DEFAULT_RETRY_OPTIONS.retryDelayInMs;\n const maxRetryDelayInMs = options.maxRetryDelayInMs ?? DEFAULT_RETRY_OPTIONS.maxRetryDelayInMs;\n const tryTimeoutInMs = options.tryTimeoutInMs ?? DEFAULT_RETRY_OPTIONS.tryTimeoutInMs;\n\n function shouldRetry({\n isPrimaryRetry,\n attempt,\n response,\n error,\n }: {\n isPrimaryRetry: boolean;\n attempt: number;\n response?: PipelineResponse;\n error?: RestError;\n }): boolean {\n if (attempt >= maxTries) {\n logger.info(`RetryPolicy: Attempt(s) ${attempt} >= maxTries ${maxTries}, no further try.`);\n return false;\n }\n if (error) {\n for (const retriableError of retriableErrors) {\n if (\n error.name.toUpperCase().includes(retriableError) ||\n error.message.toUpperCase().includes(retriableError) ||\n (error.code && error.code.toString().toUpperCase() === retriableError)\n ) {\n logger.info(`RetryPolicy: Network error ${retriableError} found, will retry.`);\n return true;\n }\n }\n if (\n error?.code === \"PARSE_ERROR\" &&\n error?.message.startsWith(`Error \"Error: Unclosed root tag`)\n ) {\n logger.info(\n \"RetryPolicy: Incomplete XML response likely due to service timeout, will retry.\",\n );\n return true;\n }\n }\n // If attempt was against the secondary & it returned a StatusNotFound (404), then\n // the resource was not found. This may be due to replication delay. So, in this\n // case, we'll never try the secondary again for this operation.\n if (response || error) {\n const statusCode = response?.status ?? error?.statusCode ?? 0;\n if (!isPrimaryRetry && statusCode === 404) {\n logger.info(`RetryPolicy: Secondary access with 404, will retry.`);\n return true;\n }\n\n // Server internal error or server timeout\n if (statusCode === 503 || statusCode === 500) {\n logger.info(`RetryPolicy: Will retry for status code ${statusCode}.`);\n return true;\n }\n }\n\n // [Copy source error code] Feature is pending on service side, skip retry on copy source error for now.\n // if (response) {\n // // Retry select Copy Source Error Codes.\n // if (response?.status >= 400) {\n // const copySourceError = response.headers.get(HeaderConstants.X_MS_CopySourceErrorCode);\n // if (copySourceError !== undefined) {\n // switch (copySourceError)\n // {\n // case \"InternalError\":\n // case \"OperationTimedOut\":\n // case \"ServerBusy\":\n // return true;\n // }\n // }\n // }\n // }\n\n return false;\n }\n function calculateDelay(isPrimaryRetry: boolean, attempt: number): number {\n let delayTimeInMs = 0;\n\n if (isPrimaryRetry) {\n switch (retryPolicyType) {\n case StorageRetryPolicyType.EXPONENTIAL:\n delayTimeInMs = Math.min(\n (Math.pow(2, attempt - 1) - 1) * retryDelayInMs,\n maxRetryDelayInMs,\n );\n break;\n case StorageRetryPolicyType.FIXED:\n delayTimeInMs = retryDelayInMs;\n break;\n }\n } else {\n delayTimeInMs = Math.random() * 1000;\n }\n\n logger.info(`RetryPolicy: Delay for ${delayTimeInMs}ms`);\n return delayTimeInMs;\n }\n return {\n name: storageRetryPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n // Set the server-side timeout query parameter \"timeout=[seconds]\"\n if (tryTimeoutInMs) {\n request.url = setURLParameter(\n request.url,\n URLConstants.Parameters.TIMEOUT,\n String(Math.floor(tryTimeoutInMs / 1000)),\n );\n }\n const primaryUrl = request.url;\n let secondaryHas404 = false;\n let attempt = 1;\n let retryAgain = true;\n let response: PipelineResponse | undefined;\n let error: RestError | undefined;\n while (retryAgain) {\n const isPrimaryRetry: boolean = true;\n request.url = primaryUrl;\n response = undefined;\n error = undefined;\n try {\n logger.info(\n `RetryPolicy: =====> Try=${attempt} ${isPrimaryRetry ? \"Primary\" : \"Secondary\"}`,\n );\n response = await next(request);\n secondaryHas404 = secondaryHas404 || (!isPrimaryRetry && response.status === 404);\n } catch (e: unknown) {\n if (isRestError(e)) {\n logger.error(`RetryPolicy: Caught error, message: ${e.message}, code: ${e.code}`);\n error = e;\n } else {\n logger.error(`RetryPolicy: Caught error, message: ${getErrorMessage(e)}`);\n throw e;\n }\n }\n retryAgain = shouldRetry({ isPrimaryRetry, attempt, response, error });\n if (retryAgain) {\n await delay(\n calculateDelay(isPrimaryRetry, attempt),\n request.abortSignal,\n RETRY_ABORT_ERROR,\n );\n }\n attempt++;\n }\n if (response) {\n return response;\n }\n throw error ?? new RestError(\"RetryPolicy failed without known error.\");\n },\n };\n}\n"]}
1
+ {"version":3,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AAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;oBAC/B,eAAe,GAAG,eAAe,IAAI,CAAC,CAAC,cAAc,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC;gBACpF,CAAC;gBAAC,OAAO,CAAU,EAAE,CAAC;oBACpB,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;wBACnB,MAAM,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC,OAAO,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;wBAClF,KAAK,GAAG,CAAC,CAAC;oBACZ,CAAC;yBAAM,CAAC;wBACN,MAAM,CAAC,KAAK,CAAC,uCAAuC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;wBAC1E,MAAM,CAAC,CAAC;oBACV,CAAC;gBACH,CAAC;gBACD,UAAU,GAAG,WAAW,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;gBACvE,IAAI,UAAU,EAAE,CAAC;oBACf,MAAM,KAAK,CACT,cAAc,CAAC,cAAc,EAAE,OAAO,CAAC,EACvC,OAAO,CAAC,WAAW,EACnB,iBAAiB,CAClB,CAAC;gBACJ,CAAC;gBACD,OAAO,EAAE,CAAC;YACZ,CAAC;YACD,IAAI,QAAQ,EAAE,CAAC;gBACb,OAAO,QAAQ,CAAC;YAClB,CAAC;YACD,MAAM,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,SAAS,CAAC,yCAAyC,CAAC,CAAC;QAC1E,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortError } from \"@azure/abort-controller\";\nimport {\n PipelinePolicy,\n PipelineRequest,\n SendRequest,\n PipelineResponse,\n isRestError,\n RestError,\n} from \"@azure/core-rest-pipeline\";\nimport { getErrorMessage } from \"@azure/core-util\";\nimport { StorageRetryOptions } from \"../StorageRetryPolicyFactory\";\nimport { URLConstants } from \"../utils/constants\";\nimport { delay, setURLParameter } from \"../utils/utils.common\";\nimport { logger } from \"../log\";\n\n/**\n * Name of the {@link storageRetryPolicy}\n */\nexport const storageRetryPolicyName = \"storageRetryPolicy\";\n\n/**\n * RetryPolicy types.\n */\nexport enum StorageRetryPolicyType {\n /**\n * Exponential retry. Retry time delay grows exponentially.\n */\n EXPONENTIAL,\n /**\n * Linear retry. Retry time delay grows linearly.\n */\n FIXED,\n}\n\n// Default values of StorageRetryOptions\nconst DEFAULT_RETRY_OPTIONS = {\n maxRetryDelayInMs: 120 * 1000,\n maxTries: 4,\n retryDelayInMs: 4 * 1000,\n retryPolicyType: StorageRetryPolicyType.EXPONENTIAL,\n secondaryHost: \"\",\n tryTimeoutInMs: undefined, // Use server side default timeout strategy\n} as const;\n\nconst retriableErrors = [\n \"ETIMEDOUT\",\n \"ESOCKETTIMEDOUT\",\n \"ECONNREFUSED\",\n \"ECONNRESET\",\n \"ENOENT\",\n \"ENOTFOUND\",\n \"TIMEOUT\",\n \"EPIPE\",\n \"REQUEST_SEND_ERROR\",\n] as const;\n\nconst RETRY_ABORT_ERROR = new AbortError(\"The operation was aborted.\");\n\n/**\n * Retry policy with exponential retry and linear retry implemented.\n */\nexport function storageRetryPolicy(options: StorageRetryOptions = {}): PipelinePolicy {\n const retryPolicyType = options.retryPolicyType ?? DEFAULT_RETRY_OPTIONS.retryPolicyType;\n const maxTries = options.maxTries ?? DEFAULT_RETRY_OPTIONS.maxTries;\n const retryDelayInMs = options.retryDelayInMs ?? DEFAULT_RETRY_OPTIONS.retryDelayInMs;\n const maxRetryDelayInMs = options.maxRetryDelayInMs ?? DEFAULT_RETRY_OPTIONS.maxRetryDelayInMs;\n const tryTimeoutInMs = options.tryTimeoutInMs ?? DEFAULT_RETRY_OPTIONS.tryTimeoutInMs;\n\n function shouldRetry({\n isPrimaryRetry,\n attempt,\n response,\n error,\n }: {\n isPrimaryRetry: boolean;\n attempt: number;\n response?: PipelineResponse;\n error?: RestError;\n }): boolean {\n if (attempt >= maxTries) {\n logger.info(`RetryPolicy: Attempt(s) ${attempt} >= maxTries ${maxTries}, no further try.`);\n return false;\n }\n if (error) {\n for (const retriableError of retriableErrors) {\n if (\n error.name.toUpperCase().includes(retriableError) ||\n error.message.toUpperCase().includes(retriableError) ||\n (error.code && error.code.toString().toUpperCase() === retriableError)\n ) {\n logger.info(`RetryPolicy: Network error ${retriableError} found, will retry.`);\n return true;\n }\n }\n if (\n error?.code === \"PARSE_ERROR\" &&\n error?.message.startsWith(`Error \"Error: Unclosed root tag`)\n ) {\n logger.info(\n \"RetryPolicy: Incomplete XML response likely due to service timeout, will retry.\",\n );\n return true;\n }\n }\n // If attempt was against the secondary & it returned a StatusNotFound (404), then\n // the resource was not found. This may be due to replication delay. So, in this\n // case, we'll never try the secondary again for this operation.\n if (response || error) {\n const statusCode = response?.status ?? error?.statusCode ?? 0;\n if (!isPrimaryRetry && statusCode === 404) {\n logger.info(`RetryPolicy: Secondary access with 404, will retry.`);\n return true;\n }\n\n // Server internal error or server timeout\n if (statusCode === 503 || statusCode === 500) {\n logger.info(`RetryPolicy: Will retry for status code ${statusCode}.`);\n return true;\n }\n }\n\n // [Copy source error code] Feature is pending on service side, skip retry on copy source error for now.\n // if (response) {\n // // Retry select Copy Source Error Codes.\n // if (response?.status >= 400) {\n // const copySourceError = response.headers.get(HeaderConstants.X_MS_CopySourceErrorCode);\n // if (copySourceError !== undefined) {\n // switch (copySourceError)\n // {\n // case \"InternalError\":\n // case \"OperationTimedOut\":\n // case \"ServerBusy\":\n // return true;\n // }\n // }\n // }\n // }\n\n return false;\n }\n function calculateDelay(isPrimaryRetry: boolean, attempt: number): number {\n let delayTimeInMs = 0;\n\n if (isPrimaryRetry) {\n switch (retryPolicyType) {\n case StorageRetryPolicyType.EXPONENTIAL:\n delayTimeInMs = Math.min(\n (Math.pow(2, attempt - 1) - 1) * retryDelayInMs,\n maxRetryDelayInMs,\n );\n break;\n case StorageRetryPolicyType.FIXED:\n delayTimeInMs = retryDelayInMs;\n break;\n }\n } else {\n delayTimeInMs = Math.random() * 1000;\n }\n\n logger.info(`RetryPolicy: Delay for ${delayTimeInMs}ms`);\n return delayTimeInMs;\n }\n return {\n name: storageRetryPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n // Set the server-side timeout query parameter \"timeout=[seconds]\"\n if (tryTimeoutInMs) {\n request.url = setURLParameter(\n request.url,\n URLConstants.Parameters.TIMEOUT,\n String(Math.floor(tryTimeoutInMs / 1000)),\n );\n }\n const primaryUrl = request.url;\n let secondaryHas404 = false;\n let attempt = 1;\n let retryAgain = true;\n let response: PipelineResponse | undefined;\n let error: RestError | undefined;\n while (retryAgain) {\n const isPrimaryRetry: boolean = true;\n request.url = primaryUrl;\n response = undefined;\n error = undefined;\n try {\n logger.info(\n `RetryPolicy: =====> Try=${attempt} ${isPrimaryRetry ? \"Primary\" : \"Secondary\"}`,\n );\n response = await next(request);\n secondaryHas404 = secondaryHas404 || (!isPrimaryRetry && response.status === 404);\n } catch (e: unknown) {\n if (isRestError(e)) {\n logger.error(`RetryPolicy: Caught error, message: ${e.message}, code: ${e.code}`);\n error = e;\n } else {\n logger.error(`RetryPolicy: Caught error, message: ${getErrorMessage(e)}`);\n throw e;\n }\n }\n retryAgain = shouldRetry({ isPrimaryRetry, attempt, response, error });\n if (retryAgain) {\n await delay(\n calculateDelay(isPrimaryRetry, attempt),\n request.abortSignal,\n RETRY_ABORT_ERROR,\n );\n }\n attempt++;\n }\n if (response) {\n return response;\n }\n throw error ?? new RestError(\"RetryPolicy failed without known error.\");\n },\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
2
+ // Licensed under the MIT License.
3
3
  // In browser, during webpack or browserify bundling, this module will be replaced by 'events'
4
4
  // https://github.com/Gozala/events
5
5
  import { EventEmitter } from "events";
@@ -1 +1 @@
1
- {"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C;YACvC,IAAI,SAAS,EAAE,CAAC;gBACd,SAAS,EAAE,CAAC;YACd,CAAC;iBAAM,CAAC;gBACN,OAAO;YACT,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// In browser, during webpack or browserify bundling, this module will be replaced by 'events'\n// https://github.com/Gozala/events\nimport { EventEmitter } from \"events\";\n\n/**\n * Operation is an async function to be executed and managed by Batch.\n */\nexport declare type Operation = () => Promise<any>;\n\n/**\n * States for Batch.\n */\nenum BatchStates {\n Good,\n Error,\n}\n\n/**\n * Batch provides basic parallel execution with concurrency limits.\n * Will stop execute left operations when one of the executed operation throws an error.\n * But Batch cannot cancel ongoing operations, you need to cancel them by yourself.\n */\nexport class Batch {\n /**\n * Concurrency. Must be lager than 0.\n */\n private concurrency: number;\n\n /**\n * Number of active operations under execution.\n */\n private actives: number = 0;\n\n /**\n * Number of completed operations under execution.\n */\n private completed: number = 0;\n\n /**\n * Offset of next operation to be executed.\n */\n private offset: number = 0;\n\n /**\n * Operation array to be executed.\n */\n private operations: Operation[] = [];\n\n /**\n * States of Batch. When an error happens, state will turn into error.\n * Batch will stop execute left operations.\n */\n private state: BatchStates = BatchStates.Good;\n\n /**\n * A private emitter used to pass events inside this class.\n */\n private emitter: EventEmitter;\n\n /**\n * Creates an instance of Batch.\n * @param concurrency -\n */\n public constructor(concurrency: number = 5) {\n if (concurrency < 1) {\n throw new RangeError(\"concurrency must be larger than 0\");\n }\n this.concurrency = concurrency;\n this.emitter = new EventEmitter();\n }\n\n /**\n * Add a operation into queue.\n *\n * @param operation -\n */\n public addOperation(operation: Operation): void {\n this.operations.push(async () => {\n try {\n this.actives++;\n await operation();\n this.actives--;\n this.completed++;\n this.parallelExecute();\n } catch (error: any) {\n this.emitter.emit(\"error\", error);\n }\n });\n }\n\n /**\n * Start execute operations in the queue.\n *\n */\n public async do(): Promise<void> {\n if (this.operations.length === 0) {\n return Promise.resolve();\n }\n\n this.parallelExecute();\n\n return new Promise<void>((resolve, reject) => {\n this.emitter.on(\"finish\", resolve);\n\n this.emitter.on(\"error\", (error) => {\n this.state = BatchStates.Error;\n reject(error);\n });\n });\n }\n\n /**\n * Get next operation to be executed. Return null when reaching ends.\n *\n */\n private nextOperation(): Operation | null {\n if (this.offset < this.operations.length) {\n return this.operations[this.offset++];\n }\n return null;\n }\n\n /**\n * Start execute operations. One one the most important difference between\n * this method with do() is that do() wraps as an sync method.\n *\n */\n private parallelExecute(): void {\n if (this.state === BatchStates.Error) {\n return;\n }\n\n if (this.completed >= this.operations.length) {\n this.emitter.emit(\"finish\");\n return;\n }\n\n while (this.actives < this.concurrency) {\n const operation = this.nextOperation();\n if (operation) {\n operation();\n } else {\n return;\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"Batch.js","sourceRoot":"","sources":["../../../../src/utils/Batch.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,8FAA8F;AAC9F,mCAAmC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAOtC;;GAEG;AACH,IAAK,WAGJ;AAHD,WAAK,WAAW;IACd,6CAAI,CAAA;IACJ,+CAAK,CAAA;AACP,CAAC,EAHI,WAAW,KAAX,WAAW,QAGf;AAED;;;;GAIG;AACH,MAAM,OAAO,KAAK;IAqChB;;;OAGG;IACH,YAAmB,cAAsB,CAAC;QAnC1C;;WAEG;QACK,YAAO,GAAW,CAAC,CAAC;QAE5B;;WAEG;QACK,cAAS,GAAW,CAAC,CAAC;QAE9B;;WAEG;QACK,WAAM,GAAW,CAAC,CAAC;QAE3B;;WAEG;QACK,eAAU,GAAgB,EAAE,CAAC;QAErC;;;WAGG;QACK,UAAK,GAAgB,WAAW,CAAC,IAAI,CAAC;QAY5C,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;YACpB,MAAM,IAAI,UAAU,CAAC,mCAAmC,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,CAAC,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CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACK,eAAe;QACrB,IAAI,IAAI,CAAC,KAAK,KAAK,WAAW,CAAC,KAAK,EAAE,CAAC;YACrC,OAAO;QACT,CAAC;QAED,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YAC7C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC5B,OAAO;QACT,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;YACvC,IAAI,SAAS,EAAE,CAAC;gBACd,SAAS,EAAE,CAAC;YACd,CAAC;iBAAM,CAAC;gBACN,OAAO;YACT,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n// In browser, during webpack or browserify bundling, this module will be replaced by 'events'\n// https://github.com/Gozala/events\nimport { EventEmitter } from \"events\";\n\n/**\n * Operation is an async function to be executed and managed by Batch.\n */\nexport declare type Operation = () => Promise<any>;\n\n/**\n * States for Batch.\n */\nenum BatchStates {\n Good,\n Error,\n}\n\n/**\n * Batch provides basic parallel execution with concurrency limits.\n * Will stop execute left operations when one of the executed operation throws an error.\n * But Batch cannot cancel ongoing operations, you need to cancel them by yourself.\n */\nexport class Batch {\n /**\n * Concurrency. Must be lager than 0.\n */\n private concurrency: number;\n\n /**\n * Number of active operations under execution.\n */\n private actives: number = 0;\n\n /**\n * Number of completed operations under execution.\n */\n private completed: number = 0;\n\n /**\n * Offset of next operation to be executed.\n */\n private offset: number = 0;\n\n /**\n * Operation array to be executed.\n */\n private operations: Operation[] = [];\n\n /**\n * States of Batch. When an error happens, state will turn into error.\n * Batch will stop execute left operations.\n */\n private state: BatchStates = BatchStates.Good;\n\n /**\n * A private emitter used to pass events inside this class.\n */\n private emitter: EventEmitter;\n\n /**\n * Creates an instance of Batch.\n * @param concurrency -\n */\n public constructor(concurrency: number = 5) {\n if (concurrency < 1) {\n throw new RangeError(\"concurrency must be larger than 0\");\n }\n this.concurrency = concurrency;\n this.emitter = new EventEmitter();\n }\n\n /**\n * Add a operation into queue.\n *\n * @param operation -\n */\n public addOperation(operation: Operation): void {\n this.operations.push(async () => {\n try {\n this.actives++;\n await operation();\n this.actives--;\n this.completed++;\n this.parallelExecute();\n } catch (error: any) {\n this.emitter.emit(\"error\", error);\n }\n });\n }\n\n /**\n * Start execute operations in the queue.\n *\n */\n public async do(): Promise<void> {\n if (this.operations.length === 0) {\n return Promise.resolve();\n }\n\n this.parallelExecute();\n\n return new Promise<void>((resolve, reject) => {\n this.emitter.on(\"finish\", resolve);\n\n this.emitter.on(\"error\", (error) => {\n this.state = BatchStates.Error;\n reject(error);\n });\n });\n }\n\n /**\n * Get next operation to be executed. Return null when reaching ends.\n *\n */\n private nextOperation(): Operation | null {\n if (this.offset < this.operations.length) {\n return this.operations[this.offset++];\n }\n return null;\n }\n\n /**\n * Start execute operations. One one the most important difference between\n * this method with do() is that do() wraps as an sync method.\n *\n */\n private parallelExecute(): void {\n if (this.state === BatchStates.Error) {\n return;\n }\n\n if (this.completed >= this.operations.length) {\n this.emitter.emit(\"finish\");\n return;\n }\n\n while (this.actives < this.concurrency) {\n const operation = this.nextOperation();\n if (operation) {\n operation();\n } else {\n return;\n }\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
2
+ // Licensed under the MIT License.
3
3
  import { EventEmitter } from "events";
4
4
  /**
5
5
  * This class accepts a Node.js Readable stream as input, and keeps reading data
@@ -1 +1 @@
1
- {"version":3,"file":"BufferScheduler.js","sourceRoot":"","sources":["../../../../src/utils/BufferScheduler.ts"],"names":[],"m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AAC;QACjC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACK,WAAW,CAAC,MAAc;QAChC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YAC7D,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { EventEmitter } from \"events\";\nimport { Readable } from \"stream\";\n\n/**\n * OutgoingHandler is an async function triggered by BufferScheduler.\n */\nexport declare type OutgoingHandler = (buffer: Buffer, offset?: number) => Promise<any>;\n\n/**\n * This class accepts a Node.js Readable stream as input, and keeps reading data\n * from the stream into the internal buffer structure, until it reaches maxBuffers.\n * Every available buffer will try to trigger outgoingHandler.\n *\n * The internal buffer structure includes an incoming buffer array, and a outgoing\n * buffer array. The incoming buffer array includes the \"empty\" buffers can be filled\n * with new incoming data. The outgoing array includes the filled buffers to be\n * handled by outgoingHandler. Every above buffer size is defined by parameter bufferSize.\n *\n * NUM_OF_ALL_BUFFERS = BUFFERS_IN_INCOMING + BUFFERS_IN_OUTGOING + BUFFERS_UNDER_HANDLING\n *\n * NUM_OF_ALL_BUFFERS lesser than or equal to maxBuffers\n *\n * PERFORMANCE IMPROVEMENT TIPS:\n * 1. Input stream highWaterMark is better to set a same value with bufferSize\n * parameter, which will avoid Buffer.concat() operations.\n * 2. Concurrency should set a smaller value than maxBuffers, which is helpful to\n * reduce the possibility when a outgoing handler waits for the stream data.\n * in this situation, outgoing handlers are blocked.\n * Outgoing queue shouldn't be empty.\n */\nexport class BufferScheduler {\n /**\n * Size of buffers in incoming and outgoing queues. This class will try to align\n * data read from Readable stream into buffer chunks with bufferSize defined.\n */\n private readonly bufferSize: number;\n\n /**\n * How many buffers can be created or maintained.\n */\n private readonly maxBuffers: number;\n\n /**\n * A Node.js Readable stream.\n */\n private readonly readable: Readable;\n\n /**\n * OutgoingHandler is an async function triggered by BufferScheduler when there\n * are available buffers in outgoing array.\n */\n private readonly outgoingHandler: OutgoingHandler;\n\n /**\n * An internal event emitter.\n */\n private readonly emitter: EventEmitter = new EventEmitter();\n\n /**\n * Concurrency of executing outgoingHandlers. (0 lesser than concurrency lesser than or equal to maxBuffers)\n */\n private readonly concurrency: number;\n\n /**\n * An internal offset marker to track data offset in bytes of next outgoingHandler.\n */\n private offset: number = 0;\n\n /**\n * An internal marker to track whether stream is end.\n */\n private isStreamEnd: boolean = false;\n\n /**\n * An internal marker to track whether stream or outgoingHandler returns error.\n */\n private isError: boolean = false;\n\n /**\n * How many handlers are executing.\n */\n private executingOutgoingHandlers: number = 0;\n\n /**\n * Encoding of the input Readable stream which has string data type instead of Buffer.\n */\n private encoding?: BufferEncoding;\n\n /**\n * How many buffers have been allocated.\n */\n private numBuffers: number = 0;\n\n /**\n * Because this class doesn't know how much data every time stream pops, which\n * is defined by highWaterMarker of the stream. So BufferScheduler will cache\n * data received from the stream, when data in unresolvedDataArray exceeds the\n * blockSize defined, it will try to concat a blockSize of buffer, fill into available\n * buffers from incoming and push to outgoing array.\n */\n private unresolvedDataArray: Buffer[] = [];\n\n /**\n * How much data consisted in unresolvedDataArray.\n */\n private unresolvedLength: number = 0;\n\n /**\n * The array includes all the available buffers can be used to fill data from stream.\n */\n private incoming: Buffer[] = [];\n\n /**\n * The array (queue) includes all the buffers filled from stream data.\n */\n private outgoing: Buffer[] = [];\n\n /**\n * Creates an instance of BufferScheduler.\n *\n * @param readable - A Node.js Readable stream\n * @param bufferSize - Buffer size of every maintained buffer\n * @param maxBuffers - How many buffers can be allocated\n * @param outgoingHandler - An async function scheduled to be\n * triggered when a buffer fully filled\n * with stream data\n * @param concurrency - Concurrency of executing outgoingHandlers (greater than 0)\n * @param encoding - [Optional] Encoding of Readable stream when it's a string stream\n */\n constructor(\n readable: Readable,\n bufferSize: number,\n maxBuffers: number,\n outgoingHandler: OutgoingHandler,\n concurrency: number,\n encoding?: BufferEncoding,\n ) {\n if (bufferSize <= 0) {\n throw new RangeError(`bufferSize must be larger than 0, current is ${bufferSize}`);\n }\n\n if (maxBuffers <= 0) {\n throw new RangeError(`maxBuffers must be larger than 0, current is ${maxBuffers}`);\n }\n\n if (concurrency <= 0) {\n throw new RangeError(`concurrency must be larger than 0, current is ${concurrency}`);\n }\n\n this.bufferSize = bufferSize;\n this.maxBuffers = maxBuffers;\n this.readable = readable;\n this.outgoingHandler = outgoingHandler;\n this.concurrency = concurrency;\n this.encoding = encoding;\n }\n\n /**\n * Start the scheduler, will return error when stream of any of the outgoingHandlers\n * returns error.\n *\n */\n public async do(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n this.readable.on(\"data\", (data) => {\n data = typeof data === \"string\" ? Buffer.from(data, this.encoding) : data;\n this.appendUnresolvedData(data);\n\n if (!this.resolveData()) {\n this.readable.pause();\n }\n });\n\n this.readable.on(\"error\", (err) => {\n this.emitter.emit(\"error\", err);\n });\n\n this.readable.on(\"end\", () => {\n this.isStreamEnd = true;\n this.emitter.emit(\"checkEnd\");\n });\n\n this.emitter.on(\"error\", (err) => {\n this.isError = true;\n this.readable.pause();\n reject(err);\n });\n\n this.emitter.on(\"checkEnd\", () => {\n if (this.outgoing.length > 0) {\n this.triggerOutgoingHandlers();\n return;\n }\n\n if (this.isStreamEnd && this.executingOutgoingHandlers === 0) {\n if (this.unresolvedLength > 0 && this.unresolvedLength < this.bufferSize) {\n this.outgoingHandler(this.shiftBufferFromUnresolvedDataArray(), this.offset)\n .then(resolve)\n .catch(reject);\n } else if (this.unresolvedLength >= this.bufferSize) {\n return;\n } else {\n resolve();\n }\n }\n });\n });\n }\n\n /**\n * Insert a new data into unresolved array.\n *\n * @param data -\n */\n private appendUnresolvedData(data: Buffer) {\n this.unresolvedDataArray.push(data);\n this.unresolvedLength += data.length;\n }\n\n /**\n * Try to shift a buffer with size in blockSize. The buffer returned may be less\n * than blockSize when data in unresolvedDataArray is less than bufferSize.\n *\n */\n private shiftBufferFromUnresolvedDataArray(): Buffer {\n if (this.unresolvedLength >= this.bufferSize) {\n if (this.bufferSize === this.unresolvedDataArray[0].length) {\n this.unresolvedLength -= this.bufferSize;\n return this.unresolvedDataArray.shift()!;\n }\n\n // Lazy concat because Buffer.concat highly drops performance\n let merged = Buffer.concat(this.unresolvedDataArray, this.unresolvedLength);\n const buffer = merged.slice(0, this.bufferSize);\n merged = merged.slice(this.bufferSize);\n this.unresolvedDataArray = [merged];\n this.unresolvedLength -= buffer.length;\n return buffer;\n } else if (this.unresolvedLength > 0) {\n const merged = Buffer.concat(this.unresolvedDataArray, this.unresolvedLength);\n this.unresolvedDataArray = [];\n this.unresolvedLength = 0;\n return merged;\n } else {\n return Buffer.allocUnsafe(0);\n }\n }\n\n /**\n * Resolve data in unresolvedDataArray. For every buffer with size in blockSize\n * shifted, it will try to get (or allocate a buffer) from incoming, and fill it,\n * then push it into outgoing to be handled by outgoing handler.\n *\n * Return false when available buffers in incoming are not enough, else true.\n *\n * @returns Return false when buffers in incoming are not enough, else true.\n */\n private resolveData(): boolean {\n while (this.unresolvedLength >= this.bufferSize) {\n let buffer: Buffer;\n\n if (this.incoming.length > 0) {\n buffer = this.incoming.shift()!;\n } else {\n if (this.numBuffers < this.maxBuffers) {\n buffer = Buffer.allocUnsafe(this.bufferSize);\n this.numBuffers++;\n } else {\n // No available buffer, wait for buffer returned\n return false;\n }\n }\n\n buffer.fill(this.shiftBufferFromUnresolvedDataArray());\n this.outgoing.push(buffer);\n this.triggerOutgoingHandlers();\n }\n return true;\n }\n\n /**\n * Try to trigger a outgoing handler for every buffer in outgoing. Stop when\n * concurrency reaches.\n */\n private async triggerOutgoingHandlers() {\n let buffer: Buffer | undefined;\n do {\n if (this.executingOutgoingHandlers >= this.concurrency) {\n return;\n }\n\n buffer = this.outgoing.shift();\n if (buffer) {\n this.triggerOutgoingHandler(buffer);\n }\n } while (buffer);\n }\n\n /**\n * Trigger a outgoing handler for a buffer shifted from outgoing.\n *\n * @param buffer -\n */\n private async triggerOutgoingHandler(buffer: Buffer): Promise<any> {\n const bufferLength = buffer.length;\n\n this.executingOutgoingHandlers++;\n this.offset += bufferLength;\n\n try {\n await this.outgoingHandler(buffer, this.offset - bufferLength);\n } catch (err: any) {\n this.emitter.emit(\"error\", err);\n return;\n }\n\n this.executingOutgoingHandlers--;\n this.reuseBuffer(buffer);\n this.emitter.emit(\"checkEnd\");\n }\n\n /**\n * Return buffer used by outgoing handler into incoming.\n *\n * @param buffer -\n */\n private reuseBuffer(buffer: Buffer) {\n this.incoming.push(buffer);\n if (!this.isError && this.resolveData() && !this.isStreamEnd) {\n this.readable.resume();\n }\n }\n}\n"]}
1
+ {"version":3,"file":"BufferScheduler.js","sourceRoot":"","sources":["../../../../src/utils/BufferScheduler.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAQtC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,eAAe;IAuF1B;;;;;;;;;;;OAWG;IACH,YACE,QAAkB,EAClB,UAAkB,EAClB,UAAkB,EAClB,eAAgC,EAChC,WAAmB,EACnB,QAAyB;QAlF3B;;WAEG;QACc,YAAO,GAAiB,IAAI,YAAY,EAAE,CAAC;QAO5D;;WAEG;QACK,WAAM,GAAW,CAAC,CAAC;QAE3B;;WAEG;QACK,gBAAW,GAAY,KAAK,CAAC;QAErC;;WAEG;QACK,YAAO,GAAY,KAAK,CAAC;QAEjC;;WAEG;QACK,8BAAyB,GAAW,CAAC,CAAC;QAO9C;;WAEG;QACK,eAAU,GAAW,CAAC,CAAC;QAE/B;;;;;;WAMG;QACK,wBAAmB,GAAa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,CAAC;YAED,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;YAC/B,IAAI,MAAM,EAAE,CAAC;gBACX,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;YACtC,CAAC;QACH,CAAC,QAAQ,MAAM,EAAE;IACnB,CAAC;IAED;;;;OAIG;IACK,KAAK,CAAC,sBAAsB,CAAC,MAAc;QACjD,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;QAEnC,IAAI,CAAC,yBAAyB,EAAE,CAAC;QACjC,IAAI,CAAC,MAAM,IAAI,YAAY,CAAC;QAE5B,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,CAAC;QACjE,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YAChC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,yBAAyB,EAAE,CAAC;QACjC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACK,WAAW,CAAC,MAAc;QAChC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YAC7D,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { EventEmitter } from \"events\";\nimport { Readable } from \"stream\";\n\n/**\n * OutgoingHandler is an async function triggered by BufferScheduler.\n */\nexport declare type OutgoingHandler = (buffer: Buffer, offset?: number) => Promise<any>;\n\n/**\n * This class accepts a Node.js Readable stream as input, and keeps reading data\n * from the stream into the internal buffer structure, until it reaches maxBuffers.\n * Every available buffer will try to trigger outgoingHandler.\n *\n * The internal buffer structure includes an incoming buffer array, and a outgoing\n * buffer array. The incoming buffer array includes the \"empty\" buffers can be filled\n * with new incoming data. The outgoing array includes the filled buffers to be\n * handled by outgoingHandler. Every above buffer size is defined by parameter bufferSize.\n *\n * NUM_OF_ALL_BUFFERS = BUFFERS_IN_INCOMING + BUFFERS_IN_OUTGOING + BUFFERS_UNDER_HANDLING\n *\n * NUM_OF_ALL_BUFFERS lesser than or equal to maxBuffers\n *\n * PERFORMANCE IMPROVEMENT TIPS:\n * 1. Input stream highWaterMark is better to set a same value with bufferSize\n * parameter, which will avoid Buffer.concat() operations.\n * 2. Concurrency should set a smaller value than maxBuffers, which is helpful to\n * reduce the possibility when a outgoing handler waits for the stream data.\n * in this situation, outgoing handlers are blocked.\n * Outgoing queue shouldn't be empty.\n */\nexport class BufferScheduler {\n /**\n * Size of buffers in incoming and outgoing queues. This class will try to align\n * data read from Readable stream into buffer chunks with bufferSize defined.\n */\n private readonly bufferSize: number;\n\n /**\n * How many buffers can be created or maintained.\n */\n private readonly maxBuffers: number;\n\n /**\n * A Node.js Readable stream.\n */\n private readonly readable: Readable;\n\n /**\n * OutgoingHandler is an async function triggered by BufferScheduler when there\n * are available buffers in outgoing array.\n */\n private readonly outgoingHandler: OutgoingHandler;\n\n /**\n * An internal event emitter.\n */\n private readonly emitter: EventEmitter = new EventEmitter();\n\n /**\n * Concurrency of executing outgoingHandlers. (0 lesser than concurrency lesser than or equal to maxBuffers)\n */\n private readonly concurrency: number;\n\n /**\n * An internal offset marker to track data offset in bytes of next outgoingHandler.\n */\n private offset: number = 0;\n\n /**\n * An internal marker to track whether stream is end.\n */\n private isStreamEnd: boolean = false;\n\n /**\n * An internal marker to track whether stream or outgoingHandler returns error.\n */\n private isError: boolean = false;\n\n /**\n * How many handlers are executing.\n */\n private executingOutgoingHandlers: number = 0;\n\n /**\n * Encoding of the input Readable stream which has string data type instead of Buffer.\n */\n private encoding?: BufferEncoding;\n\n /**\n * How many buffers have been allocated.\n */\n private numBuffers: number = 0;\n\n /**\n * Because this class doesn't know how much data every time stream pops, which\n * is defined by highWaterMarker of the stream. So BufferScheduler will cache\n * data received from the stream, when data in unresolvedDataArray exceeds the\n * blockSize defined, it will try to concat a blockSize of buffer, fill into available\n * buffers from incoming and push to outgoing array.\n */\n private unresolvedDataArray: Buffer[] = [];\n\n /**\n * How much data consisted in unresolvedDataArray.\n */\n private unresolvedLength: number = 0;\n\n /**\n * The array includes all the available buffers can be used to fill data from stream.\n */\n private incoming: Buffer[] = [];\n\n /**\n * The array (queue) includes all the buffers filled from stream data.\n */\n private outgoing: Buffer[] = [];\n\n /**\n * Creates an instance of BufferScheduler.\n *\n * @param readable - A Node.js Readable stream\n * @param bufferSize - Buffer size of every maintained buffer\n * @param maxBuffers - How many buffers can be allocated\n * @param outgoingHandler - An async function scheduled to be\n * triggered when a buffer fully filled\n * with stream data\n * @param concurrency - Concurrency of executing outgoingHandlers (greater than 0)\n * @param encoding - [Optional] Encoding of Readable stream when it's a string stream\n */\n constructor(\n readable: Readable,\n bufferSize: number,\n maxBuffers: number,\n outgoingHandler: OutgoingHandler,\n concurrency: number,\n encoding?: BufferEncoding,\n ) {\n if (bufferSize <= 0) {\n throw new RangeError(`bufferSize must be larger than 0, current is ${bufferSize}`);\n }\n\n if (maxBuffers <= 0) {\n throw new RangeError(`maxBuffers must be larger than 0, current is ${maxBuffers}`);\n }\n\n if (concurrency <= 0) {\n throw new RangeError(`concurrency must be larger than 0, current is ${concurrency}`);\n }\n\n this.bufferSize = bufferSize;\n this.maxBuffers = maxBuffers;\n this.readable = readable;\n this.outgoingHandler = outgoingHandler;\n this.concurrency = concurrency;\n this.encoding = encoding;\n }\n\n /**\n * Start the scheduler, will return error when stream of any of the outgoingHandlers\n * returns error.\n *\n */\n public async do(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n this.readable.on(\"data\", (data) => {\n data = typeof data === \"string\" ? Buffer.from(data, this.encoding) : data;\n this.appendUnresolvedData(data);\n\n if (!this.resolveData()) {\n this.readable.pause();\n }\n });\n\n this.readable.on(\"error\", (err) => {\n this.emitter.emit(\"error\", err);\n });\n\n this.readable.on(\"end\", () => {\n this.isStreamEnd = true;\n this.emitter.emit(\"checkEnd\");\n });\n\n this.emitter.on(\"error\", (err) => {\n this.isError = true;\n this.readable.pause();\n reject(err);\n });\n\n this.emitter.on(\"checkEnd\", () => {\n if (this.outgoing.length > 0) {\n this.triggerOutgoingHandlers();\n return;\n }\n\n if (this.isStreamEnd && this.executingOutgoingHandlers === 0) {\n if (this.unresolvedLength > 0 && this.unresolvedLength < this.bufferSize) {\n this.outgoingHandler(this.shiftBufferFromUnresolvedDataArray(), this.offset)\n .then(resolve)\n .catch(reject);\n } else if (this.unresolvedLength >= this.bufferSize) {\n return;\n } else {\n resolve();\n }\n }\n });\n });\n }\n\n /**\n * Insert a new data into unresolved array.\n *\n * @param data -\n */\n private appendUnresolvedData(data: Buffer) {\n this.unresolvedDataArray.push(data);\n this.unresolvedLength += data.length;\n }\n\n /**\n * Try to shift a buffer with size in blockSize. The buffer returned may be less\n * than blockSize when data in unresolvedDataArray is less than bufferSize.\n *\n */\n private shiftBufferFromUnresolvedDataArray(): Buffer {\n if (this.unresolvedLength >= this.bufferSize) {\n if (this.bufferSize === this.unresolvedDataArray[0].length) {\n this.unresolvedLength -= this.bufferSize;\n return this.unresolvedDataArray.shift()!;\n }\n\n // Lazy concat because Buffer.concat highly drops performance\n let merged = Buffer.concat(this.unresolvedDataArray, this.unresolvedLength);\n const buffer = merged.slice(0, this.bufferSize);\n merged = merged.slice(this.bufferSize);\n this.unresolvedDataArray = [merged];\n this.unresolvedLength -= buffer.length;\n return buffer;\n } else if (this.unresolvedLength > 0) {\n const merged = Buffer.concat(this.unresolvedDataArray, this.unresolvedLength);\n this.unresolvedDataArray = [];\n this.unresolvedLength = 0;\n return merged;\n } else {\n return Buffer.allocUnsafe(0);\n }\n }\n\n /**\n * Resolve data in unresolvedDataArray. For every buffer with size in blockSize\n * shifted, it will try to get (or allocate a buffer) from incoming, and fill it,\n * then push it into outgoing to be handled by outgoing handler.\n *\n * Return false when available buffers in incoming are not enough, else true.\n *\n * @returns Return false when buffers in incoming are not enough, else true.\n */\n private resolveData(): boolean {\n while (this.unresolvedLength >= this.bufferSize) {\n let buffer: Buffer;\n\n if (this.incoming.length > 0) {\n buffer = this.incoming.shift()!;\n } else {\n if (this.numBuffers < this.maxBuffers) {\n buffer = Buffer.allocUnsafe(this.bufferSize);\n this.numBuffers++;\n } else {\n // No available buffer, wait for buffer returned\n return false;\n }\n }\n\n buffer.fill(this.shiftBufferFromUnresolvedDataArray());\n this.outgoing.push(buffer);\n this.triggerOutgoingHandlers();\n }\n return true;\n }\n\n /**\n * Try to trigger a outgoing handler for every buffer in outgoing. Stop when\n * concurrency reaches.\n */\n private async triggerOutgoingHandlers() {\n let buffer: Buffer | undefined;\n do {\n if (this.executingOutgoingHandlers >= this.concurrency) {\n return;\n }\n\n buffer = this.outgoing.shift();\n if (buffer) {\n this.triggerOutgoingHandler(buffer);\n }\n } while (buffer);\n }\n\n /**\n * Trigger a outgoing handler for a buffer shifted from outgoing.\n *\n * @param buffer -\n */\n private async triggerOutgoingHandler(buffer: Buffer): Promise<any> {\n const bufferLength = buffer.length;\n\n this.executingOutgoingHandlers++;\n this.offset += bufferLength;\n\n try {\n await this.outgoingHandler(buffer, this.offset - bufferLength);\n } catch (err: any) {\n this.emitter.emit(\"error\", err);\n return;\n }\n\n this.executingOutgoingHandlers--;\n this.reuseBuffer(buffer);\n this.emitter.emit(\"checkEnd\");\n }\n\n /**\n * Return buffer used by outgoing handler into incoming.\n *\n * @param buffer -\n */\n private reuseBuffer(buffer: Buffer) {\n this.incoming.push(buffer);\n if (!this.isError && this.resolveData() && !this.isStreamEnd) {\n this.readable.resume();\n }\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
2
+ // Licensed under the MIT License.
3
3
  import { AbortError } from "@azure/abort-controller";
4
4
  import { Readable } from "stream";
5
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"RetriableReadableStream.js","sourceRoot":"","sources":["../../../../src/utils/RetriableReadableStream.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AA2BlC;;;;GAIG;AACH,MAAM,OAAO,uBAAwB,SAAQ,QAAQ;IAWnD;;;;;;;;;OASG;IACH,YACE,MAA6B,EAC7B,MAA4B,EAC5B,MAAc,EACd,KAAa,EACb,UAA0C,EAAE;QAE5C,KAAK,EAAE,CAAC;QAtBF,YAAO,GAAW,CAAC,CAAC;QAuDpB,sBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE;YAC3C,IAAI,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;gBACnC,IAAI,CAAC,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;gBAC3C,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;gBACpB,IAAI,CAAC,uBAAuB,EAAE,CAAC;gBAC9B,IAAI,CAAC,MAAmB,CAAC,OAAO,EAAE,CAAC;gBACpC,OAAO;YACT,CAAC;YAED,eAAe;YACf,2EAA2E;YAC3E,KAAK;YACL,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;YAC3B,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACpB,IAAI,CAAC,UAAU,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;YAC7D,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,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AC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;QACtD,oBAAoB;QACpB,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACvD,CAAC;IAEO,yBAAyB;QAC/B,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QAC3D,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAChE,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAClE,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACnE,CAAC;IA+ED,QAAQ,CAAC,KAAmB,EAAE,QAAiC;QAC7D,iDAAiD;QACjD,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAChC,IAAI,CAAC,MAAmB,CAAC,OAAO,EAAE,CAAC;QAEpC,QAAQ,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortError } from \"@azure/abort-controller\";\nimport { TransferProgressEvent } from \"@azure/core-rest-pipeline\";\nimport { Readable } from \"stream\";\n\nexport type ReadableStreamGetter = (offset: number) => Promise<NodeJS.ReadableStream>;\n\nexport interface RetriableReadableStreamOptions {\n /**\n * Max retry count (greater than or equal to 0), undefined or invalid value means no retry\n */\n maxRetryRequests?: number;\n\n /**\n * Read progress event handler\n */\n onProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Debug purpose only. Used to inject an unexpected end to existing internal stream,\n * to test stream retry works well or not.\n *\n * When assign it to true, for next incoming \"data\" event of internal stream,\n * RetriableReadableStream will try to emit an \"end\" event to existing internal\n * stream to force it end and start retry from the breaking point.\n * The value will then update to \"undefined\", once the injection works.\n */\n doInjectErrorOnce?: boolean;\n}\n\n/**\n * ONLY AVAILABLE IN NODE.JS RUNTIME.\n *\n * A Node.js ReadableStream will internally retry when internal ReadableStream unexpected ends.\n */\nexport class RetriableReadableStream extends Readable {\n private start: number;\n private offset: number;\n private end: number;\n private getter: ReadableStreamGetter;\n private source: NodeJS.ReadableStream;\n private retries: number = 0;\n private maxRetryRequests: number;\n private onProgress?: (progress: TransferProgressEvent) => void;\n private options: RetriableReadableStreamOptions;\n\n /**\n * Creates an instance of RetriableReadableStream.\n *\n * @param source - The current ReadableStream returned from getter\n * @param getter - A method calling downloading request returning\n * a new ReadableStream from specified offset\n * @param offset - Offset position in original data source to read\n * @param count - How much data in original data source to read\n * @param options -\n */\n public constructor(\n source: NodeJS.ReadableStream,\n getter: ReadableStreamGetter,\n offset: number,\n count: number,\n options: RetriableReadableStreamOptions = {},\n ) {\n super();\n this.getter = getter;\n this.source = source;\n this.start = offset;\n this.offset = offset;\n this.end = offset + count - 1;\n this.maxRetryRequests =\n options.maxRetryRequests && options.maxRetryRequests >= 0 ? options.maxRetryRequests : 0;\n this.onProgress = options.onProgress;\n this.options = options;\n\n this.setSourceEventHandlers();\n }\n\n public _read(): void {\n this.source.resume();\n }\n\n private setSourceEventHandlers() {\n this.source.on(\"data\", this.sourceDataHandler);\n this.source.on(\"end\", this.sourceErrorOrEndHandler);\n this.source.on(\"error\", this.sourceErrorOrEndHandler);\n // needed for Node14\n this.source.on(\"aborted\", this.sourceAbortedHandler);\n }\n\n private removeSourceEventHandlers() {\n this.source.removeListener(\"data\", this.sourceDataHandler);\n this.source.removeListener(\"end\", this.sourceErrorOrEndHandler);\n this.source.removeListener(\"error\", this.sourceErrorOrEndHandler);\n this.source.removeListener(\"aborted\", this.sourceAbortedHandler);\n }\n\n private sourceDataHandler = (data: Buffer) => {\n if (this.options.doInjectErrorOnce) {\n this.options.doInjectErrorOnce = undefined;\n this.source.pause();\n this.sourceErrorOrEndHandler();\n (this.source as Readable).destroy();\n return;\n }\n\n // console.log(\n // `Offset: ${this.offset}, Received ${data.length} from internal stream`\n // );\n this.offset += data.length;\n if (this.onProgress) {\n this.onProgress({ loadedBytes: this.offset - this.start });\n }\n if (!this.push(data)) {\n this.source.pause();\n }\n };\n\n private sourceAbortedHandler = () => {\n const abortError = new AbortError(\"The operation was aborted.\");\n this.destroy(abortError);\n };\n\n private sourceErrorOrEndHandler = (err?: Error) => {\n if (err && err.name === \"AbortError\") {\n this.destroy(err);\n return;\n }\n\n // console.log(\n // `Source stream emits end or error, offset: ${\n // this.offset\n // }, dest end : ${this.end}`\n // );\n this.removeSourceEventHandlers();\n if (this.offset - 1 === this.end) {\n this.push(null);\n } else if (this.offset <= this.end) {\n // console.log(\n // `retries: ${this.retries}, max retries: ${this.maxRetries}`\n // );\n if (this.retries < this.maxRetryRequests) {\n this.retries += 1;\n this.getter(this.offset)\n .then((newSource) => {\n this.source = newSource;\n this.setSourceEventHandlers();\n return;\n })\n .catch((error) => {\n this.destroy(error);\n });\n } else {\n this.destroy(\n new Error(\n `Data corruption failure: received less data than required and reached maxRetires limitation. Received data offset: ${\n this.offset - 1\n }, data needed offset: ${this.end}, retries: ${this.retries}, max retries: ${\n this.maxRetryRequests\n }`,\n ),\n );\n }\n } else {\n this.destroy(\n new Error(\n `Data corruption failure: Received more data than original request, data needed offset is ${\n this.end\n }, received offset: ${this.offset - 1}`,\n ),\n );\n }\n };\n\n _destroy(error: Error | null, callback: (error?: Error) => void): void {\n // remove listener from source and release source\n this.removeSourceEventHandlers();\n (this.source as Readable).destroy();\n\n callback(error === null ? undefined : error);\n }\n}\n"]}
1
+ {"version":3,"file":"RetriableReadableStream.js","sourceRoot":"","sources":["../../../../src/utils/RetriableReadableStream.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,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AAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAChE,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAClE,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACnE,CAAC;IA+ED,QAAQ,CAAC,KAAmB,EAAE,QAAiC;QAC7D,iDAAiD;QACjD,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAChC,IAAI,CAAC,MAAmB,CAAC,OAAO,EAAE,CAAC;QAEpC,QAAQ,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortError } from \"@azure/abort-controller\";\nimport { TransferProgressEvent } from \"@azure/core-rest-pipeline\";\nimport { Readable } from \"stream\";\n\nexport type ReadableStreamGetter = (offset: number) => Promise<NodeJS.ReadableStream>;\n\nexport interface RetriableReadableStreamOptions {\n /**\n * Max retry count (greater than or equal to 0), undefined or invalid value means no retry\n */\n maxRetryRequests?: number;\n\n /**\n * Read progress event handler\n */\n onProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Debug purpose only. Used to inject an unexpected end to existing internal stream,\n * to test stream retry works well or not.\n *\n * When assign it to true, for next incoming \"data\" event of internal stream,\n * RetriableReadableStream will try to emit an \"end\" event to existing internal\n * stream to force it end and start retry from the breaking point.\n * The value will then update to \"undefined\", once the injection works.\n */\n doInjectErrorOnce?: boolean;\n}\n\n/**\n * ONLY AVAILABLE IN NODE.JS RUNTIME.\n *\n * A Node.js ReadableStream will internally retry when internal ReadableStream unexpected ends.\n */\nexport class RetriableReadableStream extends Readable {\n private start: number;\n private offset: number;\n private end: number;\n private getter: ReadableStreamGetter;\n private source: NodeJS.ReadableStream;\n private retries: number = 0;\n private maxRetryRequests: number;\n private onProgress?: (progress: TransferProgressEvent) => void;\n private options: RetriableReadableStreamOptions;\n\n /**\n * Creates an instance of RetriableReadableStream.\n *\n * @param source - The current ReadableStream returned from getter\n * @param getter - A method calling downloading request returning\n * a new ReadableStream from specified offset\n * @param offset - Offset position in original data source to read\n * @param count - How much data in original data source to read\n * @param options -\n */\n public constructor(\n source: NodeJS.ReadableStream,\n getter: ReadableStreamGetter,\n offset: number,\n count: number,\n options: RetriableReadableStreamOptions = {},\n ) {\n super();\n this.getter = getter;\n this.source = source;\n this.start = offset;\n this.offset = offset;\n this.end = offset + count - 1;\n this.maxRetryRequests =\n options.maxRetryRequests && options.maxRetryRequests >= 0 ? options.maxRetryRequests : 0;\n this.onProgress = options.onProgress;\n this.options = options;\n\n this.setSourceEventHandlers();\n }\n\n public _read(): void {\n this.source.resume();\n }\n\n private setSourceEventHandlers() {\n this.source.on(\"data\", this.sourceDataHandler);\n this.source.on(\"end\", this.sourceErrorOrEndHandler);\n this.source.on(\"error\", this.sourceErrorOrEndHandler);\n // needed for Node14\n this.source.on(\"aborted\", this.sourceAbortedHandler);\n }\n\n private removeSourceEventHandlers() {\n this.source.removeListener(\"data\", this.sourceDataHandler);\n this.source.removeListener(\"end\", this.sourceErrorOrEndHandler);\n this.source.removeListener(\"error\", this.sourceErrorOrEndHandler);\n this.source.removeListener(\"aborted\", this.sourceAbortedHandler);\n }\n\n private sourceDataHandler = (data: Buffer) => {\n if (this.options.doInjectErrorOnce) {\n this.options.doInjectErrorOnce = undefined;\n this.source.pause();\n this.sourceErrorOrEndHandler();\n (this.source as Readable).destroy();\n return;\n }\n\n // console.log(\n // `Offset: ${this.offset}, Received ${data.length} from internal stream`\n // );\n this.offset += data.length;\n if (this.onProgress) {\n this.onProgress({ loadedBytes: this.offset - this.start });\n }\n if (!this.push(data)) {\n this.source.pause();\n }\n };\n\n private sourceAbortedHandler = () => {\n const abortError = new AbortError(\"The operation was aborted.\");\n this.destroy(abortError);\n };\n\n private sourceErrorOrEndHandler = (err?: Error) => {\n if (err && err.name === \"AbortError\") {\n this.destroy(err);\n return;\n }\n\n // console.log(\n // `Source stream emits end or error, offset: ${\n // this.offset\n // }, dest end : ${this.end}`\n // );\n this.removeSourceEventHandlers();\n if (this.offset - 1 === this.end) {\n this.push(null);\n } else if (this.offset <= this.end) {\n // console.log(\n // `retries: ${this.retries}, max retries: ${this.maxRetries}`\n // );\n if (this.retries < this.maxRetryRequests) {\n this.retries += 1;\n this.getter(this.offset)\n .then((newSource) => {\n this.source = newSource;\n this.setSourceEventHandlers();\n return;\n })\n .catch((error) => {\n this.destroy(error);\n });\n } else {\n this.destroy(\n new Error(\n `Data corruption failure: received less data than required and reached maxRetires limitation. Received data offset: ${\n this.offset - 1\n }, data needed offset: ${this.end}, retries: ${this.retries}, max retries: ${\n this.maxRetryRequests\n }`,\n ),\n );\n }\n } else {\n this.destroy(\n new Error(\n `Data corruption failure: Received more data than original request, data needed offset is ${\n this.end\n }, received offset: ${this.offset - 1}`,\n ),\n );\n }\n };\n\n _destroy(error: Error | null, callback: (error?: Error) => void): void {\n // remove listener from source and release source\n this.removeSourceEventHandlers();\n (this.source as Readable).destroy();\n\n callback(error === null ? undefined : error);\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
2
+ // Licensed under the MIT License.
3
3
  export const SDK_VERSION = "12.25.0-beta.2";
4
4
  export const SERVICE_VERSION = "2024-11-04";
5
5
  export const FILE_MAX_SIZE_BYTES = 4 * 1024 * 1024 * 1024 * 1024; // 4TB
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,WAAW,GAAW,gBAAgB,CAAC;AACpD,MAAM,CAAC,MAAM,eAAe,GAAW,YAAY,CAAC;AAEpD,MAAM,CAA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AAY;IACZ,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,QAAQ;IACR,SAAS;CACV,CAAC;AAEF,iDAAiD;AACjD,wGAAwG;AACxG,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;CACR,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport const SDK_VERSION: string = \"12.25.0-beta.2\";\nexport const SERVICE_VERSION: string = \"2024-11-04\";\n\nexport const FILE_MAX_SIZE_BYTES: number = 4 * 1024 * 1024 * 1024 * 1024; // 4TB\nexport const FILE_RANGE_MAX_SIZE_BYTES: number = 4 * 1024 * 1024; // 4MB\nexport const DEFAULT_MAX_DOWNLOAD_RETRY_REQUESTS: number = 5;\nexport const DEFAULT_HIGH_LEVEL_CONCURRENCY: number = 5;\nexport const REQUEST_TIMEOUT: number = 100 * 1000; // In ms\n/**\n * The OAuth scope to use with Azure Storage.\n */\nexport const StorageOAuthScopes: string | string[] = \"https://storage.azure.com/.default\";\n\nexport const URLConstants = {\n Parameters: {\n FORCE_BROWSER_NO_CACHE: \"_\",\n SHARE_SNAPSHOT: \"sharesnapshot\",\n SIGNATURE: \"sig\",\n TIMEOUT: \"timeout\",\n },\n};\n\nexport const HttpUrlConnection = {\n HTTP_CONFLICT: 409,\n HTTP_NOT_FOUND: 404,\n HTTP_PRECON_FAILED: 412,\n HTTP_RANGE_NOT_SATISFIABLE: 416,\n};\n\nexport const HeaderConstants = {\n AUTHORIZATION: \"authorization\",\n AUTHORIZATION_SCHEME: \"Bearer\",\n CONTENT_ENCODING: \"content-encoding\",\n CONTENT_LANGUAGE: \"content-language\",\n CONTENT_LENGTH: \"content-length\",\n CONTENT_MD5: \"content-md5\",\n CONTENT_TYPE: \"content-type\",\n COOKIE: \"Cookie\",\n DATE: \"date\",\n IF_MATCH: \"if-match\",\n IF_MODIFIED_SINCE: \"if-modified-since\",\n IF_NONE_MATCH: \"if-none-match\",\n IF_UNMODIFIED_SINCE: \"if-unmodified-since\",\n PREFIX_FOR_STORAGE: \"x-ms-\",\n RANGE: \"Range\",\n USER_AGENT: \"User-Agent\",\n X_MS_CLIENT_REQUEST_ID: \"x-ms-client-request-id\",\n X_MS_COPY_SOURCE: \"x-ms-copy-source\",\n X_MS_CopySourceErrorCode: \"x-ms-copy-source-error-code\",\n X_MS_DATE: \"x-ms-date\",\n};\n\nexport const ETagNone = \"\";\nexport const ETagAny = \"*\";\nexport const FileAttributesPreserve = \"Preserve\";\nexport const FileAttributesNone = \"None\";\n\nexport const StorageFileLoggingAllowedHeaderNames = [\n \"Access-Control-Allow-Origin\",\n \"Cache-Control\",\n \"Content-Length\",\n \"Content-Type\",\n \"Date\",\n \"Request-Id\",\n \"traceparent\",\n \"Transfer-Encoding\",\n \"User-Agent\",\n \"x-ms-client-request-id\",\n \"x-ms-date\",\n \"x-ms-error-code\",\n \"x-ms-request-id\",\n \"x-ms-return-client-request-id\",\n \"x-ms-version\",\n \"Accept-Ranges\",\n \"Content-Disposition\",\n \"Content-Encoding\",\n \"Content-Language\",\n \"Content-MD5\",\n \"Content-Range\",\n \"ETag\",\n \"Last-Modified\",\n \"Server\",\n \"Vary\",\n \"x-ms-content-crc64\",\n \"x-ms-copy-action\",\n \"x-ms-copy-completion-time\",\n \"x-ms-copy-id\",\n \"x-ms-copy-progress\",\n \"x-ms-copy-status\",\n \"x-ms-has-immutability-policy\",\n \"x-ms-has-legal-hold\",\n \"x-ms-lease-state\",\n \"x-ms-lease-status\",\n \"x-ms-range\",\n \"x-ms-request-server-encrypted\",\n \"x-ms-server-encrypted\",\n \"x-ms-snapshot\",\n \"x-ms-source-range\",\n \"x-ms-cache-control\",\n \"x-ms-content-disposition\",\n \"x-ms-content-encoding\",\n \"x-ms-content-language\",\n \"x-ms-content-length\",\n \"x-ms-content-md5\",\n \"x-ms-content-type\",\n \"x-ms-copy-source-error-code\",\n \"x-ms-copy-source-status-code\",\n \"x-ms-file-attributes\",\n \"x-ms-file-change-time\",\n \"x-ms-file-creation-time\",\n \"x-ms-file-id\",\n \"x-ms-file-last-write-time\",\n \"x-ms-file-parent-id\",\n \"x-ms-handle-id\",\n \"x-ms-number-of-handles-closed\",\n \"x-ms-recursive\",\n \"x-ms-share-quota\",\n \"x-ms-type\",\n \"x-ms-write\",\n];\n\nexport const StorageFileLoggingAllowedQueryParameters = [\n \"comp\",\n \"maxresults\",\n \"rscc\",\n \"rscd\",\n \"rsce\",\n \"rscl\",\n \"rsct\",\n \"se\",\n \"si\",\n \"sip\",\n \"sp\",\n \"spr\",\n \"sr\",\n \"srt\",\n \"ss\",\n \"st\",\n \"sv\",\n \"copyid\",\n \"restype\",\n];\n\n/// List of ports used for path style addressing.\n/// Path style addressing means that storage account is put in URI's Path segment in instead of in host.\nexport const PathStylePorts = [\n \"10000\",\n \"10001\",\n \"10002\",\n \"10003\",\n \"10004\",\n \"10100\",\n \"10101\",\n \"10102\",\n \"10103\",\n \"10104\",\n \"11000\",\n \"11001\",\n \"11002\",\n \"11003\",\n \"11004\",\n \"11100\",\n \"11101\",\n \"11102\",\n \"11103\",\n \"11104\",\n];\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,WAAW,GAAW,gBAAgB,CAAC;AACpD,MAAM,CAAC,MAAM,eAAe,GAAW,YAAY,CAAC;AAEpD,MAAM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ACN,YAAY;IACZ,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,QAAQ;IACR,SAAS;CACV,CAAC;AAEF,iDAAiD;AACjD,wGAAwG;AACxG,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;CACR,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport const SDK_VERSION: string = \"12.25.0-beta.2\";\nexport const SERVICE_VERSION: string = \"2024-11-04\";\n\nexport const FILE_MAX_SIZE_BYTES: number = 4 * 1024 * 1024 * 1024 * 1024; // 4TB\nexport const FILE_RANGE_MAX_SIZE_BYTES: number = 4 * 1024 * 1024; // 4MB\nexport const DEFAULT_MAX_DOWNLOAD_RETRY_REQUESTS: number = 5;\nexport const DEFAULT_HIGH_LEVEL_CONCURRENCY: number = 5;\nexport const REQUEST_TIMEOUT: number = 100 * 1000; // In ms\n/**\n * The OAuth scope to use with Azure Storage.\n */\nexport const StorageOAuthScopes: string | string[] = \"https://storage.azure.com/.default\";\n\nexport const URLConstants = {\n Parameters: {\n FORCE_BROWSER_NO_CACHE: \"_\",\n SHARE_SNAPSHOT: \"sharesnapshot\",\n SIGNATURE: \"sig\",\n TIMEOUT: \"timeout\",\n },\n};\n\nexport const HttpUrlConnection = {\n HTTP_CONFLICT: 409,\n HTTP_NOT_FOUND: 404,\n HTTP_PRECON_FAILED: 412,\n HTTP_RANGE_NOT_SATISFIABLE: 416,\n};\n\nexport const HeaderConstants = {\n AUTHORIZATION: \"authorization\",\n AUTHORIZATION_SCHEME: \"Bearer\",\n CONTENT_ENCODING: \"content-encoding\",\n CONTENT_LANGUAGE: \"content-language\",\n CONTENT_LENGTH: \"content-length\",\n CONTENT_MD5: \"content-md5\",\n CONTENT_TYPE: \"content-type\",\n COOKIE: \"Cookie\",\n DATE: \"date\",\n IF_MATCH: \"if-match\",\n IF_MODIFIED_SINCE: \"if-modified-since\",\n IF_NONE_MATCH: \"if-none-match\",\n IF_UNMODIFIED_SINCE: \"if-unmodified-since\",\n PREFIX_FOR_STORAGE: \"x-ms-\",\n RANGE: \"Range\",\n USER_AGENT: \"User-Agent\",\n X_MS_CLIENT_REQUEST_ID: \"x-ms-client-request-id\",\n X_MS_COPY_SOURCE: \"x-ms-copy-source\",\n X_MS_CopySourceErrorCode: \"x-ms-copy-source-error-code\",\n X_MS_DATE: \"x-ms-date\",\n};\n\nexport const ETagNone = \"\";\nexport const ETagAny = \"*\";\nexport const FileAttributesPreserve = \"Preserve\";\nexport const FileAttributesNone = \"None\";\n\nexport const StorageFileLoggingAllowedHeaderNames = [\n \"Access-Control-Allow-Origin\",\n \"Cache-Control\",\n \"Content-Length\",\n \"Content-Type\",\n \"Date\",\n \"Request-Id\",\n \"traceparent\",\n \"Transfer-Encoding\",\n \"User-Agent\",\n \"x-ms-client-request-id\",\n \"x-ms-date\",\n \"x-ms-error-code\",\n \"x-ms-request-id\",\n \"x-ms-return-client-request-id\",\n \"x-ms-version\",\n \"Accept-Ranges\",\n \"Content-Disposition\",\n \"Content-Encoding\",\n \"Content-Language\",\n \"Content-MD5\",\n \"Content-Range\",\n \"ETag\",\n \"Last-Modified\",\n \"Server\",\n \"Vary\",\n \"x-ms-content-crc64\",\n \"x-ms-copy-action\",\n \"x-ms-copy-completion-time\",\n \"x-ms-copy-id\",\n \"x-ms-copy-progress\",\n \"x-ms-copy-status\",\n \"x-ms-has-immutability-policy\",\n \"x-ms-has-legal-hold\",\n \"x-ms-lease-state\",\n \"x-ms-lease-status\",\n \"x-ms-range\",\n \"x-ms-request-server-encrypted\",\n \"x-ms-server-encrypted\",\n \"x-ms-snapshot\",\n \"x-ms-source-range\",\n \"x-ms-cache-control\",\n \"x-ms-content-disposition\",\n \"x-ms-content-encoding\",\n \"x-ms-content-language\",\n \"x-ms-content-length\",\n \"x-ms-content-md5\",\n \"x-ms-content-type\",\n \"x-ms-copy-source-error-code\",\n \"x-ms-copy-source-status-code\",\n \"x-ms-file-attributes\",\n \"x-ms-file-change-time\",\n \"x-ms-file-creation-time\",\n \"x-ms-file-id\",\n \"x-ms-file-last-write-time\",\n \"x-ms-file-parent-id\",\n \"x-ms-handle-id\",\n \"x-ms-number-of-handles-closed\",\n \"x-ms-recursive\",\n \"x-ms-share-quota\",\n \"x-ms-type\",\n \"x-ms-write\",\n];\n\nexport const StorageFileLoggingAllowedQueryParameters = [\n \"comp\",\n \"maxresults\",\n \"rscc\",\n \"rscd\",\n \"rsce\",\n \"rscl\",\n \"rsct\",\n \"se\",\n \"si\",\n \"sip\",\n \"sp\",\n \"spr\",\n \"sr\",\n \"srt\",\n \"ss\",\n \"st\",\n \"sv\",\n \"copyid\",\n \"restype\",\n];\n\n/// List of ports used for path style addressing.\n/// Path style addressing means that storage account is put in URI's Path segment in instead of in host.\nexport const PathStylePorts = [\n \"10000\",\n \"10001\",\n \"10002\",\n \"10003\",\n \"10004\",\n \"10100\",\n \"10101\",\n \"10102\",\n \"10103\",\n \"10104\",\n \"11000\",\n \"11001\",\n \"11002\",\n \"11003\",\n \"11004\",\n \"11100\",\n \"11101\",\n \"11102\",\n \"11103\",\n \"11104\",\n];\n"]}
@@ -1,5 +1,5 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
2
+ // Licensed under the MIT License.
3
3
  import { createTracingClient } from "@azure/core-tracing";
4
4
  import { SDK_VERSION } from "./constants";
5
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../../../src/utils/tracing.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC;IAC/C,WAAW,EAAE,2BAA2B;IACxC,cAAc,EAAE,WAAW;IAC3B,SAAS,EAAE,mBAAmB;CAC/B,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createTracingClient } from \"@azure/core-tracing\";\nimport { SDK_VERSION } from \"./constants\";\n\n/**\n * Creates a span using the global tracer.\n * @internal\n */\nexport const tracingClient = createTracingClient({\n packageName: \"@azure/storage-file-share\",\n packageVersion: SDK_VERSION,\n namespace: \"Microsoft.Storage\",\n});\n"]}
1
+ {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../../../src/utils/tracing.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC;IAC/C,WAAW,EAAE,2BAA2B;IACxC,cAAc,EAAE,WAAW;IAC3B,SAAS,EAAE,mBAAmB;CAC/B,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createTracingClient } from \"@azure/core-tracing\";\nimport { SDK_VERSION } from \"./constants\";\n\n/**\n * Creates a span using the global tracer.\n * @internal\n */\nexport const tracingClient = createTracingClient({\n packageName: \"@azure/storage-file-share\",\n packageVersion: SDK_VERSION,\n namespace: \"Microsoft.Storage\",\n});\n"]}
@@ -1,5 +1,5 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
2
+ // Licensed under the MIT License.
3
3
  /**
4
4
  * Convert a Browser Blob object into ArrayBuffer.
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"utils.browser.js","sourceRoot":"","sources":["../../../../src/utils/utils.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAU;IAChD,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;IACpC,OAAO,IAAI,OAAO,CAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAClD,UAAU,CAAC,SAAS,GAAG,CAAC,EAAO,EAAE,EAAE;YACjC,OAAO,CAAC,EAAE,CAAC,MAAO,CAAC,MAAM,CAAC,CAAC;QAC7B,CAAC,CAAC;QACF,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC;QAC5B,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,WAAW;AACb,CAAC;AAED,MAAM,UAAU,qBAAqB;IACnC,WAAW;AACb,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,SAAS,IAAI;IACjC,WAAW;AACb,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,gBAAgB;IACzD,WAAW;AACb,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Convert a Browser Blob object into ArrayBuffer.\n *\n * @param blob -\n */\nexport async function blobToArrayBuffer(blob: Blob): Promise<ArrayBuffer> {\n const fileReader = new FileReader();\n return new Promise<ArrayBuffer>((resolve, reject) => {\n fileReader.onloadend = (ev: any) => {\n resolve(ev.target!.result);\n };\n fileReader.onerror = reject;\n fileReader.readAsArrayBuffer(blob);\n });\n}\n\nexport function streamToBuffer(): void {\n /* empty */\n}\n\nexport function readStreamToLocalFile(): void {\n /* empty */\n}\n\nexport const fsStat = function stat(): void {\n /* empty */\n};\n\nexport const fsCreateReadStream = function createReadStream(): void {\n /* empty */\n};\n"]}
1
+ {"version":3,"file":"utils.browser.js","sourceRoot":"","sources":["../../../../src/utils/utils.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,IAAU;IAChD,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;IACpC,OAAO,IAAI,OAAO,CAAc,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAClD,UAAU,CAAC,SAAS,GAAG,CAAC,EAAO,EAAE,EAAE;YACjC,OAAO,CAAC,EAAE,CAAC,MAAO,CAAC,MAAM,CAAC,CAAC;QAC7B,CAAC,CAAC;QACF,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC;QAC5B,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,WAAW;AACb,CAAC;AAED,MAAM,UAAU,qBAAqB;IACnC,WAAW;AACb,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,SAAS,IAAI;IACjC,WAAW;AACb,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,gBAAgB;IACzD,WAAW;AACb,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Convert a Browser Blob object into ArrayBuffer.\n *\n * @param blob -\n */\nexport async function blobToArrayBuffer(blob: Blob): Promise<ArrayBuffer> {\n const fileReader = new FileReader();\n return new Promise<ArrayBuffer>((resolve, reject) => {\n fileReader.onloadend = (ev: any) => {\n resolve(ev.target!.result);\n };\n fileReader.onerror = reject;\n fileReader.readAsArrayBuffer(blob);\n });\n}\n\nexport function streamToBuffer(): void {\n /* empty */\n}\n\nexport function readStreamToLocalFile(): void {\n /* empty */\n}\n\nexport const fsStat = function stat(): void {\n /* empty */\n};\n\nexport const fsCreateReadStream = function createReadStream(): void {\n /* empty */\n};\n"]}
@@ -1,5 +1,5 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
2
+ // Licensed under the MIT License.
3
3
  import { createHttpHeaders } from "@azure/core-rest-pipeline";
4
4
  import { HeaderConstants, PathStylePorts, URLConstants } from "./constants";
5
5
  import { isNode } from "@azure/core-util";
@@ -1 +1 @@
1
- {"version":3,"file":"utils.common.js","sourceRoot":"","sources":["../../../../src/utils/utils.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAe,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAe3E,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAE/B,IAAI,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC;IAC9B,IAAI,GAAG,IAAI,IAAI,GAAG,CAAC;IAEnB,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IACpB,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC;IAE1B,OAAO,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC;AAUD,SAAS,oBAAoB,CAC3B,gBAAwB,EACxB,QAM2B;IAE3B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7C,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAA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IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,oCAAoC,CAClD,gBAA6C;IAE7C,MAAM,eAAe,mCAChB,gBAAgB,KACnB,UAAU,EAAE,gBAAgB,CAAC,UAAU;YACrC,CAAC,CAAC,gBAAgB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,kBAAkB,EAAE,EAAE;gBACrD,MAAM,UAAU,mCACX,kBAAkB,KACrB,IAAI,EAAE,qBAAqB,CAAC,kBAAkB,CAAC,IAAI,CAAC,GACrD,CAAC;gBACF,OAAO,UAAU,CAAC;YACpB,CAAC,CAAC;YACJ,CAAC,CAAC,SAAS,GACd,CAAC;IAEF,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAyB;IACzD,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,KAA+B;IAC/D,MAAM,mBAAmB,GAAG,KAAwB,CAAC;IACrD,IAAI,mBAAmB,CAAC,YAAY,CAAC,KAAK,SAAS,EAAE,CAAC;QACpD,OAAO;YACL,UAAU,EAAE,mBAAmB,CAAC,UAAU;YAC1C,MAAM,EAAE,mBAAmB,CAAC,MAAM;SACnC,CAAC;IACJ,CAAC;IAED,OAAO;QACL,UAAU,EAAE,KAAe;KAC5B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { HttpHeaders, createHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport {\n ListFilesAndDirectoriesSegmentResponse as ListFilesAndDirectoriesSegmentResponseInternal,\n ListHandlesResponse as ListHandlesResponseInternal,\n SharePermission,\n StringEncoded,\n} from \"../generated/src/models\";\nimport {\n DirectoryItem,\n FileItem,\n HandleItem,\n ListFilesAndDirectoriesSegmentResponse,\n ListHandlesResponse,\n} from \"../generatedModels\";\nimport { HttpAuthorization } from \"../models\";\nimport { HeaderConstants, PathStylePorts, URLConstants } from \"./constants\";\nimport { isNode } from \"@azure/core-util\";\nimport { HttpHeadersLike, WebResourceLike } from \"@azure/core-http-compat\";\n\n/**\n * Reserved URL characters must be properly escaped for Storage services like Blob or File.\n *\n * ## URL encode and escape strategy for JS SDKs\n *\n * When customers pass a URL string into XXXClient classes constructor, the URL string may already be URL encoded or not.\n * But before sending to Azure Storage server, the URL must be encoded. However, it's hard for a SDK to guess whether the URL\n * string has been encoded or not. We have 2 potential strategies, and chose strategy two for the XXXClient constructors.\n *\n * ### Strategy One: Assume the customer URL string is not encoded, and always encode URL string in SDK.\n *\n * This is what legacy V2 SDK does, simple and works for most of the cases.\n * - When customer URL string is \"http://account.blob.core.windows.net/con/b:\",\n * SDK will encode it to \"http://account.blob.core.windows.net/con/b%3A\" and send to server. A blob named \"b:\" will be created.\n * - When customer URL string is \"http://account.blob.core.windows.net/con/b%3A\",\n * SDK will encode it to \"http://account.blob.core.windows.net/con/b%253A\" and send to server. A blob named \"b%3A\" will be created.\n *\n * But this strategy will make it not possible to create a blob with \"?\" in it's name. Because when customer URL string is\n * \"http://account.blob.core.windows.net/con/blob?name\", the \"?name\" will be treated as URL paramter instead of blob name.\n * If customer URL string is \"http://account.blob.core.windows.net/con/blob%3Fname\", a blob named \"blob%3Fname\" will be created.\n * V2 SDK doesn't have this issue because it doesn't allow customer pass in a full URL, it accepts a separate blob name and encodeURIComponent for it.\n * We cannot accept a SDK cannot create a blob name with \"?\". So we implement strategy two:\n *\n * ### Strategy Two: SDK doesn't assume the URL has been encoded or not. It will just escape the special characters.\n *\n * This is what V10 Blob Go SDK does. It accepts a URL type in Go, and call url.EscapedPath() to escape the special chars unescaped.\n * - When customer URL string is \"http://account.blob.core.windows.net/con/b:\",\n * SDK will escape \":\" like \"http://account.blob.core.windows.net/con/b%3A\" and send to server. A blob named \"b:\" will be created.\n * - When customer URL string is \"http://account.blob.core.windows.net/con/b%3A\",\n * There is no special characters, so send \"http://account.blob.core.windows.net/con/b%3A\" to server. A blob named \"b:\" will be created.\n * - When customer URL string is \"http://account.blob.core.windows.net/con/b%253A\",\n * There is no special characters, so send \"http://account.blob.core.windows.net/con/b%253A\" to server. A blob named \"b%3A\" will be created.\n *\n * This strategy gives us flexibility to create with any special characters. But \"%\" will be treated as a special characters, if the URL string\n * is not encoded, there shouldn't a \"%\" in the URL string, otherwise the URL is not a valid URL.\n * If customer needs to create a blob with \"%\" in it's blob name, use \"%25\" insead of \"%\". Just like above 3rd sample.\n * And following URL strings are invalid:\n * - \"http://account.blob.core.windows.net/con/b%\"\n * - \"http://account.blob.core.windows.net/con/b%2\"\n * - \"http://account.blob.core.windows.net/con/b%G\"\n *\n * Another special character is \"?\", use \"%2F\" to represent a blob name with \"?\" in a URL string.\n *\n * ### Strategy for containerName, blobName or other specific XXXName parameters in methods such as `ContainerClient.getBlobClient(blobName)`\n *\n * We will apply strategy one, and call encodeURIComponent for these parameters like blobName. Because what customers passes in is a plain name instead of a URL.\n *\n * @see https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata\n * @see https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-shares--directories--files--and-metadata\n *\n * @param url -\n */\nexport function escapeURLPath(url: string): string {\n const urlParsed = new URL(url);\n\n let path = urlParsed.pathname;\n path = path || \"/\";\n\n path = escape(path);\n urlParsed.pathname = path;\n\n return urlParsed.toString();\n}\n\nexport interface ConnectionString {\n kind: \"AccountConnString\" | \"SASConnString\";\n url: string;\n accountName: string;\n accountKey?: any;\n accountSas?: string;\n}\n\nfunction getValueInConnString(\n connectionString: string,\n argument:\n | \"FileEndpoint\"\n | \"AccountName\"\n | \"AccountKey\"\n | \"DefaultEndpointsProtocol\"\n | \"EndpointSuffix\"\n | \"SharedAccessSignature\",\n) {\n const elements = connectionString.split(\";\");\n for (const element of elements) {\n if (element.trim().startsWith(argument)) {\n return element.trim().match(argument + \"=(.*)\")![1];\n }\n }\n return \"\";\n}\n\n/**\n * Extracts the parts of an Azure Storage account connection string.\n *\n * @param connectionString - Connection string.\n * @returns String key value pairs of the storage account's url and credentials.\n */\nexport function extractConnectionStringParts(connectionString: string): ConnectionString {\n // Matching FileEndpoint in the Account connection string\n let fileEndpoint = getValueInConnString(connectionString, \"FileEndpoint\");\n // Slicing off '/' at the end if exists\n // (The methods that use `extractConnectionStringParts` expect the url to not have `/` at the end)\n fileEndpoint = fileEndpoint.endsWith(\"/\") ? fileEndpoint.slice(0, -1) : fileEndpoint;\n\n if (\n connectionString.search(\"DefaultEndpointsProtocol=\") !== -1 &&\n connectionString.search(\"AccountKey=\") !== -1\n ) {\n // Account connection string\n\n let defaultEndpointsProtocol = \"\";\n let accountName = \"\";\n let accountKey = Buffer.from(\"accountKey\", \"base64\");\n let endpointSuffix = \"\";\n\n // Get account name and key\n accountName = getValueInConnString(connectionString, \"AccountName\");\n accountKey = Buffer.from(getValueInConnString(connectionString, \"AccountKey\"), \"base64\");\n\n if (!fileEndpoint) {\n // FileEndpoint is not present in the Account connection string\n // Can be obtained from `${defaultEndpointsProtocol}://${accountName}.file.${endpointSuffix}`\n\n defaultEndpointsProtocol = getValueInConnString(connectionString, \"DefaultEndpointsProtocol\");\n const protocol = defaultEndpointsProtocol!.toLowerCase();\n if (protocol !== \"https\" && protocol !== \"http\") {\n throw new Error(\n \"Invalid DefaultEndpointsProtocol in the provided Connection String. Expecting 'https' or 'http'\",\n );\n }\n\n endpointSuffix = getValueInConnString(connectionString, \"EndpointSuffix\");\n if (!endpointSuffix) {\n throw new Error(\"Invalid EndpointSuffix in the provided Connection String\");\n }\n fileEndpoint = `${defaultEndpointsProtocol}://${accountName}.file.${endpointSuffix}`;\n }\n\n if (!accountName) {\n throw new Error(\"Invalid AccountName in the provided Connection String\");\n } else if (accountKey.length === 0) {\n throw new Error(\"Invalid AccountKey in the provided Connection String\");\n }\n\n return {\n kind: \"AccountConnString\",\n url: fileEndpoint,\n accountName,\n accountKey,\n };\n } else {\n // SAS connection string\n const accountSas = getValueInConnString(connectionString, \"SharedAccessSignature\");\n let accountName = getValueInConnString(connectionString, \"AccountName\");\n // if accountName is empty, try to read it from BlobEndpoint\n if (!accountName) {\n accountName = getAccountNameFromUrl(fileEndpoint);\n }\n if (!fileEndpoint) {\n throw new Error(\"Invalid FileEndpoint in the provided SAS Connection String\");\n } else if (!accountSas) {\n throw new Error(\"Invalid SharedAccessSignature in the provided SAS Connection String\");\n }\n\n return { kind: \"SASConnString\", url: fileEndpoint, accountName, accountSas };\n }\n}\n\n/**\n * Internal escape method implemented Strategy Two mentioned in escapeURL() description.\n *\n * @param text -\n */\nfunction escape(text: string): string {\n return encodeURIComponent(text)\n .replace(/%2F/g, \"/\") // Don't escape for \"/\"\n .replace(/'/g, \"%27\") // Escape for \"'\"\n .replace(/\\+/g, \"%20\")\n .replace(/%25/g, \"%\"); // Revert encoded \"%\"\n}\n\n/**\n * Append a string to URL path. Will remove duplicated \"/\" in front of the string\n * when URL path ends with a \"/\".\n *\n * @param url - Source URL string\n * @param name - String to be appended to URL\n * @returns An updated URL string\n */\nexport function appendToURLPath(url: string, name: string): string {\n const urlParsed = new URL(url);\n\n let path = urlParsed.pathname;\n path = path ? (path.endsWith(\"/\") ? `${path}${name}` : `${path}/${name}`) : name;\n urlParsed.pathname = path;\n\n return urlParsed.toString();\n}\n\n/**\n * Append a string to URL query.\n *\n * @param url - Source URL string.\n * @param queryParts - String to be appended to the URL query.\n * @returns An updated URL string.\n */\nexport function appendToURLQuery(url: string, queryParts: string): string {\n const urlParsed = new URL(url);\n\n let query = urlParsed.search;\n if (query) {\n query += \"&\" + queryParts;\n } else {\n query = queryParts;\n }\n\n urlParsed.search = query;\n return urlParsed.toString();\n}\n\n/**\n * Set URL parameter name and value. If name exists in URL parameters, old value\n * will be replaced by name key. If not provide value, the parameter will be deleted.\n *\n * @param url - Source URL string\n * @param name - Parameter name\n * @param value - Parameter value\n * @returns An updated URL string\n */\nexport function setURLParameter(url: string, name: string, value?: string): string {\n const urlParsed = new URL(url);\n const encodedName = encodeURIComponent(name);\n const encodedValue = value ? encodeURIComponent(value) : undefined;\n // mutating searchParams will change the encoding, so we have to do this ourselves\n const searchString = urlParsed.search === \"\" ? \"?\" : urlParsed.search;\n\n const searchPieces: string[] = [];\n\n for (const pair of searchString.slice(1).split(\"&\")) {\n if (pair) {\n const [key] = pair.split(\"=\", 2);\n if (key !== encodedName) {\n searchPieces.push(pair);\n }\n }\n }\n if (encodedValue) {\n searchPieces.push(`${encodedName}=${encodedValue}`);\n }\n\n urlParsed.search = searchPieces.length ? `?${searchPieces.join(\"&\")}` : \"\";\n\n return urlParsed.toString();\n}\n\n/**\n * Get URL parameter by name.\n *\n * @param url -\n * @param name -\n */\nexport function getURLParameter(url: string, name: string): string | string[] | undefined {\n const urlParsed = new URL(url);\n return urlParsed.searchParams.get(name) ?? undefined;\n}\n\n/**\n * Set URL host.\n *\n * @param url - Source URL string\n * @param host - New host string\n * @returns An updated URL string\n */\nexport function setURLHost(url: string, host: string): string {\n const urlParsed = new URL(url);\n urlParsed.hostname = host;\n return urlParsed.toString();\n}\n\n/**\n * Get URL path from an URL string.\n *\n * @param url - Source URL string\n */\nexport function getURLPath(url: string): string | undefined {\n try {\n const urlParsed = new URL(url);\n return urlParsed.pathname;\n } catch (e) {\n return undefined;\n }\n}\n\n/**\n * Get URL query key value pairs from an URL string.\n *\n * @param url -\n */\nexport function getURLQueries(url: string): { [key: string]: string } {\n let queryString = new URL(url).search;\n if (!queryString) {\n return {};\n }\n\n queryString = queryString.trim();\n queryString = queryString.startsWith(\"?\") ? queryString.substring(1) : queryString;\n\n let querySubStrings: string[] = queryString.split(\"&\");\n querySubStrings = querySubStrings.filter((value: string) => {\n const indexOfEqual = value.indexOf(\"=\");\n const lastIndexOfEqual = value.lastIndexOf(\"=\");\n return (\n indexOfEqual > 0 && indexOfEqual === lastIndexOfEqual && lastIndexOfEqual < value.length - 1\n );\n });\n\n const queries: { [key: string]: string } = {};\n for (const querySubString of querySubStrings) {\n const splitResults = querySubString.split(\"=\");\n const key: string = splitResults[0];\n const value: string = splitResults[1];\n queries[key] = value;\n }\n\n return queries;\n}\n\n/**\n * Rounds a date off to seconds.\n *\n * @param date -\n * @param withMilliseconds - If true, YYYY-MM-DDThh:mm:ss.fffffffZ will be returned;\n * If false, YYYY-MM-DDThh:mm:ssZ will be returned.\n * @returns Date string in ISO8061 format, with or without 7 milliseconds component\n */\nexport function truncatedISO8061Date(date: Date, withMilliseconds: boolean = true): string {\n // Date.toISOString() will return like \"2018-10-29T06:34:36.139Z\"\n const dateString = date.toISOString();\n\n return withMilliseconds\n ? dateString.substring(0, dateString.length - 1) + \"0000\" + \"Z\"\n : dateString.substring(0, dateString.length - 5) + \"Z\";\n}\n\n/**\n * Base64 encode.\n *\n * @param content -\n */\nexport function base64encode(content: string): string {\n return !isNode ? btoa(content) : Buffer.from(content).toString(\"base64\");\n}\n\n/**\n * Base64 decode.\n *\n * @param encodedString -\n */\nexport function base64decode(encodedString: string): string {\n return !isNode ? atob(encodedString) : Buffer.from(encodedString, \"base64\").toString();\n}\n\n/**\n * Delay specified time interval.\n *\n * @param timeInMs -\n * @param aborter -\n * @param abortError -\n */\nexport async function delay(\n timeInMs: number,\n aborter?: AbortSignalLike,\n abortError?: Error,\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n /* eslint-disable-next-line prefer-const */\n let timeout: any;\n\n const abortHandler = () => {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n reject(abortError);\n };\n\n const resolveHandler = () => {\n if (aborter !== undefined) {\n aborter.removeEventListener(\"abort\", abortHandler);\n }\n resolve();\n };\n\n /* eslint-disable-next-line prefer-const */\n timeout = setTimeout(resolveHandler, timeInMs);\n if (aborter !== undefined) {\n aborter.addEventListener(\"abort\", abortHandler);\n }\n });\n}\n\nexport function sanitizeURL(url: string): string {\n let safeURL: string = url;\n if (getURLParameter(safeURL, URLConstants.Parameters.SIGNATURE)) {\n safeURL = setURLParameter(safeURL, URLConstants.Parameters.SIGNATURE, \"*****\");\n }\n\n return safeURL;\n}\n\nexport function sanitizeHeaders(originalHeader: HttpHeaders): HttpHeaders {\n const headers: HttpHeaders = createHttpHeaders();\n for (const [name, value] of originalHeader) {\n if (name.toLowerCase() === HeaderConstants.AUTHORIZATION.toLowerCase()) {\n headers.set(name, \"*****\");\n } else if (name.toLowerCase() === HeaderConstants.X_MS_COPY_SOURCE) {\n headers.set(name, sanitizeURL(value));\n } else {\n headers.set(name, value);\n }\n }\n\n return headers;\n}\n\n/**\n * Extracts account name from the url\n * @param url - url to extract the account name from\n * @returns with the account name\n */\nexport function getAccountNameFromUrl(url: string): string {\n const parsedUrl = new URL(url);\n let accountName;\n try {\n if (parsedUrl.hostname.split(\".\")[1] === \"file\") {\n // `${defaultEndpointsProtocol}://${accountName}.file.${endpointSuffix}`;\n // Slicing off '/' at the end if exists\n url = url.endsWith(\"/\") ? url.slice(0, -1) : url;\n\n accountName = parsedUrl.hostname.split(\".\")[0];\n } else if (isIpEndpointStyle(parsedUrl)) {\n // IPv4/IPv6 address hosts... Example - http://192.0.0.10:10001/devstoreaccount1/\n // Single word domain without a [dot] in the endpoint... Example - http://localhost:10001/devstoreaccount1/\n // .getPath() -> /devstoreaccount1/\n accountName = parsedUrl.pathname.split(\"/\")[1];\n } else {\n // Custom domain case: \"https://customdomain.com/containername/blob\".\n accountName = \"\";\n }\n return accountName;\n } catch (error: any) {\n throw new Error(\"Unable to extract accountName with provided information.\");\n }\n}\n\nexport function isIpEndpointStyle(parsedUrl: URL): boolean {\n const host = parsedUrl.host;\n\n // Case 1: Ipv6, use a broad regex to find out candidates whose host contains two ':'.\n // Case 2: localhost(:port) or host.docker.internal, use broad regex to match port part.\n // Case 3: Ipv4, use broad regex which just check if host contains Ipv4.\n // For valid host please refer to https://man7.org/linux/man-pages/man7/hostname.7.html.\n return (\n /^.*:.*:.*$|^(localhost|host.docker.internal)(:[0-9]+)?$|^(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])){3}(:[0-9]+)?$/.test(\n host,\n ) ||\n (Boolean(parsedUrl.port) && PathStylePorts.includes(parsedUrl.port))\n );\n}\n\nexport function getShareNameAndPathFromUrl(url: string): {\n baseName: string;\n shareName: string;\n path: string;\n} {\n // URL may look like the following\n // \"https://myaccount.file.core.windows.net/myshare/mydirectory/file?sasString\";\n // \"https://myaccount.file.core.windows.net/myshare/mydirectory/file\";\n // \"https://myaccount.file.core.windows.net/myshare/mydirectory?sasString\";\n // \"https://myaccount.file.core.windows.net/myshare/mydirectory\";\n // \"https://myaccount.file.core.windows.net/myshare?sasString\";\n // \"https://myaccount.file.core.windows.net/myshare\";\n // IPv4/IPv6 address hosts, Endpoints - `http://187.24.0.1:1000/devstoreaccount1/mydirectory/file`\n // http://localhost:1000/devstoreaccount1/mydirectory/file\n // mydirectory can consist of multiple directories - dir1/dir2/dir3\n\n let shareName;\n let path;\n let baseName;\n\n try {\n const parsedUrl = new URL(url);\n if (parsedUrl.hostname.split(\".\")[1] === \"file\") {\n // \"https://myaccount.file.core.windows.net/myshare/mydirectory/file\";\n // .getPath() -> /myshare/mydirectory/file\n const pathComponents = parsedUrl.pathname.match(\"/([^/]*)(/(.*))?\");\n shareName = pathComponents![1];\n path = pathComponents![3];\n } else if (isIpEndpointStyle(parsedUrl)) {\n // IPv4/IPv6 address hosts... Example - http://187.24.0.1:1000/devstoreaccount1/mydirectory/file\n // Single word domain without a [dot] in the endpoint... Example - http://localhost:1000/devstoreaccount1/mydirectory/file\n // .getPath() -> /devstoreaccount1/mydirectory/file\n const pathComponents = parsedUrl.pathname.match(\"/([^/]*)/([^/]*)(/(.*))?\");\n shareName = pathComponents![2];\n path = pathComponents![4];\n } else {\n // \"https://customdomain.com/myshare/mydirectory/file\";\n // .getPath() -> /myshare/mydirectory/file\n const pathComponents = parsedUrl.pathname.match(\"/([^/]*)(/(.*))?\");\n shareName = pathComponents![1];\n path = pathComponents![3];\n }\n\n // decode the encoded shareName and filePath - to get all the special characters that might be present in it\n shareName = decodeURIComponent(shareName);\n path = decodeURIComponent(path);\n\n // Cast to string is required as TypeScript cannot infer that split() always returns\n // an array with length >= 1\n baseName = path.split(\"/\").pop() as string;\n\n if (!shareName) {\n throw new Error(\"Provided shareName is invalid.\");\n } else {\n return { baseName, shareName, path };\n }\n } catch (error: any) {\n throw new Error(\n \"Unable to extract shareName and filePath/directoryPath with provided information.\",\n );\n }\n}\n\nexport function httpAuthorizationToString(\n httpAuthorization?: HttpAuthorization,\n): string | undefined {\n return httpAuthorization ? httpAuthorization.scheme + \" \" + httpAuthorization.value : undefined;\n}\n\n/**\n * Set URL path.\n *\n * @param url - URL to change path to.\n * @param path - Path to set into the URL.\n */\nexport function setURLPath(url: string, path: string): string {\n const urlParsed = new URL(url);\n urlParsed.pathname = path;\n return urlParsed.toString();\n}\n\n/**\n * Set URL query string.\n *\n * @param url - URL to set query string to.\n * @param queryString - Query string to set to the URL.\n */\nexport function setURLQueries(url: string, queryString: string): string {\n const urlParsed = new URL(url);\n urlParsed.search = queryString;\n return urlParsed.toString();\n}\n\n/**\n * Escape the file or directory name but keep path separator ('/').\n */\nexport function EscapePath(pathName: string): string {\n const split = pathName.split(\"/\");\n for (let i = 0; i < split.length; i++) {\n split[i] = encodeURIComponent(split[i]);\n }\n return split.join(\"/\");\n}\n\n/**\n * A representation of an HTTP response that\n * includes a reference to the request that\n * originated it.\n */\nexport interface HttpResponse {\n /**\n * The headers from the response.\n */\n headers: HttpHeadersLike;\n /**\n * The original request that resulted in this response.\n */\n request: WebResourceLike;\n /**\n * The HTTP status code returned from the service.\n */\n status: number;\n}\n\n/**\n * An object with a _response property that has\n * headers already parsed into a typed object.\n */\nexport interface ResponseWithHeaders<Headers> {\n /**\n * The underlying HTTP response.\n */\n _response: HttpResponse & {\n /**\n * The parsed HTTP response headers.\n */\n parsedHeaders: Headers;\n };\n}\n\n/**\n * An object with a _response property that has body\n * and headers already parsed into known types.\n */\nexport interface ResponseWithBody<Headers, Body> {\n /**\n * The underlying HTTP response.\n */\n _response: HttpResponse & {\n /**\n * The parsed HTTP response headers.\n */\n parsedHeaders: Headers;\n /**\n * The response body as text (string format)\n */\n bodyAsText: string;\n /**\n * The response body as parsed JSON or XML\n */\n parsedBody: Body;\n };\n}\n\n/**\n * An object with a simple _response property.\n */\nexport interface ResponseLike {\n /**\n * The underlying HTTP response.\n */\n _response: HttpResponse;\n}\n\n/**\n * A type that represents an operation result with a known _response property.\n */\nexport type WithResponse<T, Headers = undefined, Body = undefined> = T &\n (Body extends object\n ? ResponseWithBody<Headers, Body>\n : Headers extends object\n ? ResponseWithHeaders<Headers>\n : ResponseLike);\n\n/**\n * A typesafe helper for ensuring that a given response object has\n * the original _response attached.\n * @param response - A response object from calling a client operation\n * @returns The same object, but with known _response property\n */\nexport function assertResponse<T extends object, Headers = undefined, Body = undefined>(\n response: T,\n): WithResponse<T, Headers, Body> {\n if (`_response` in response) {\n return response as WithResponse<T, Headers, Body>;\n }\n\n throw new TypeError(`Unexpected response object ${response}`);\n}\n\nexport function StringEncodedToString(name: StringEncoded): string {\n if (name.encoded) {\n return decodeURIComponent(name.content!);\n } else {\n return name.content!;\n }\n}\n\nexport function ConvertInternalResponseOfListFiles(\n internalResponse: ListFilesAndDirectoriesSegmentResponseInternal,\n): ListFilesAndDirectoriesSegmentResponse {\n const wrappedResponse = {\n ...internalResponse,\n prefix: undefined,\n directoryPath: StringEncodedToString({\n encoded: internalResponse.encoded,\n content: internalResponse.directoryPath,\n }),\n segment: {\n fileItems: internalResponse.segment.fileItems.map((fileItemInternal) => {\n const fileItem: FileItem = {\n ...fileItemInternal,\n name: StringEncodedToString(fileItemInternal.name),\n };\n return fileItem;\n }),\n directoryItems: internalResponse.segment.directoryItems.map((directoryItemInternal) => {\n const directoryItem: DirectoryItem = {\n ...directoryItemInternal,\n name: StringEncodedToString(directoryItemInternal.name),\n };\n return directoryItem;\n }),\n },\n };\n\n delete wrappedResponse.encoded;\n\n const listResponse: ListFilesAndDirectoriesSegmentResponse = wrappedResponse as any;\n\n if (internalResponse.prefix) {\n listResponse.prefix = StringEncodedToString(internalResponse.prefix);\n }\n\n return listResponse;\n}\n\nexport function ConvertInternalResponseOfListHandles(\n internalResponse: ListHandlesResponseInternal,\n): ListHandlesResponse {\n const wrappedResponse: ListHandlesResponse = {\n ...internalResponse,\n handleList: internalResponse.handleList\n ? internalResponse.handleList.map((handleItemInternal) => {\n const handleItem: HandleItem = {\n ...handleItemInternal,\n path: StringEncodedToString(handleItemInternal.path),\n };\n return handleItem;\n })\n : undefined,\n };\n\n return wrappedResponse;\n}\n\n/**\n * A small helper to handle converting an empty string \"\" into undefined\n * This is used in the case of query parameters (like continuation token) where\n * we don't want to send an empty query parameter to the service since the signing\n * policy for shared key will fail.\n * @internal\n */\nexport function removeEmptyString(value: string | undefined): string | undefined {\n return value ? value : undefined;\n}\n\nexport function asSharePermission(value: string | SharePermission): SharePermission {\n const castSharePermission = value as SharePermission;\n if (castSharePermission[\"permission\"] !== undefined) {\n return {\n permission: castSharePermission.permission,\n format: castSharePermission.format,\n };\n }\n\n return {\n permission: value as string,\n };\n}\n"]}
1
+ {"version":3,"file":"utils.common.js","sourceRoot":"","sources":["../../../../src/utils/utils.common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAe,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAe3E,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAG1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC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B,CAAC,MAAM;SACnC,CAAC;IACJ,CAAC;IAED,OAAO;QACL,UAAU,EAAE,KAAe;KAC5B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortSignalLike } from \"@azure/abort-controller\";\nimport { HttpHeaders, createHttpHeaders } from \"@azure/core-rest-pipeline\";\nimport {\n ListFilesAndDirectoriesSegmentResponse as ListFilesAndDirectoriesSegmentResponseInternal,\n ListHandlesResponse as ListHandlesResponseInternal,\n SharePermission,\n StringEncoded,\n} from \"../generated/src/models\";\nimport {\n DirectoryItem,\n FileItem,\n HandleItem,\n ListFilesAndDirectoriesSegmentResponse,\n ListHandlesResponse,\n} from \"../generatedModels\";\nimport { HttpAuthorization } from \"../models\";\nimport { HeaderConstants, PathStylePorts, URLConstants } from \"./constants\";\nimport { isNode } from \"@azure/core-util\";\nimport { HttpHeadersLike, WebResourceLike } from \"@azure/core-http-compat\";\n\n/**\n * Reserved URL characters must be properly escaped for Storage services like Blob or File.\n *\n * ## URL encode and escape strategy for JS SDKs\n *\n * When customers pass a URL string into XXXClient classes constructor, the URL string may already be URL encoded or not.\n * But before sending to Azure Storage server, the URL must be encoded. However, it's hard for a SDK to guess whether the URL\n * string has been encoded or not. We have 2 potential strategies, and chose strategy two for the XXXClient constructors.\n *\n * ### Strategy One: Assume the customer URL string is not encoded, and always encode URL string in SDK.\n *\n * This is what legacy V2 SDK does, simple and works for most of the cases.\n * - When customer URL string is \"http://account.blob.core.windows.net/con/b:\",\n * SDK will encode it to \"http://account.blob.core.windows.net/con/b%3A\" and send to server. A blob named \"b:\" will be created.\n * - When customer URL string is \"http://account.blob.core.windows.net/con/b%3A\",\n * SDK will encode it to \"http://account.blob.core.windows.net/con/b%253A\" and send to server. A blob named \"b%3A\" will be created.\n *\n * But this strategy will make it not possible to create a blob with \"?\" in it's name. Because when customer URL string is\n * \"http://account.blob.core.windows.net/con/blob?name\", the \"?name\" will be treated as URL paramter instead of blob name.\n * If customer URL string is \"http://account.blob.core.windows.net/con/blob%3Fname\", a blob named \"blob%3Fname\" will be created.\n * V2 SDK doesn't have this issue because it doesn't allow customer pass in a full URL, it accepts a separate blob name and encodeURIComponent for it.\n * We cannot accept a SDK cannot create a blob name with \"?\". So we implement strategy two:\n *\n * ### Strategy Two: SDK doesn't assume the URL has been encoded or not. It will just escape the special characters.\n *\n * This is what V10 Blob Go SDK does. It accepts a URL type in Go, and call url.EscapedPath() to escape the special chars unescaped.\n * - When customer URL string is \"http://account.blob.core.windows.net/con/b:\",\n * SDK will escape \":\" like \"http://account.blob.core.windows.net/con/b%3A\" and send to server. A blob named \"b:\" will be created.\n * - When customer URL string is \"http://account.blob.core.windows.net/con/b%3A\",\n * There is no special characters, so send \"http://account.blob.core.windows.net/con/b%3A\" to server. A blob named \"b:\" will be created.\n * - When customer URL string is \"http://account.blob.core.windows.net/con/b%253A\",\n * There is no special characters, so send \"http://account.blob.core.windows.net/con/b%253A\" to server. A blob named \"b%3A\" will be created.\n *\n * This strategy gives us flexibility to create with any special characters. But \"%\" will be treated as a special characters, if the URL string\n * is not encoded, there shouldn't a \"%\" in the URL string, otherwise the URL is not a valid URL.\n * If customer needs to create a blob with \"%\" in it's blob name, use \"%25\" insead of \"%\". Just like above 3rd sample.\n * And following URL strings are invalid:\n * - \"http://account.blob.core.windows.net/con/b%\"\n * - \"http://account.blob.core.windows.net/con/b%2\"\n * - \"http://account.blob.core.windows.net/con/b%G\"\n *\n * Another special character is \"?\", use \"%2F\" to represent a blob name with \"?\" in a URL string.\n *\n * ### Strategy for containerName, blobName or other specific XXXName parameters in methods such as `ContainerClient.getBlobClient(blobName)`\n *\n * We will apply strategy one, and call encodeURIComponent for these parameters like blobName. Because what customers passes in is a plain name instead of a URL.\n *\n * @see https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata\n * @see https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-shares--directories--files--and-metadata\n *\n * @param url -\n */\nexport function escapeURLPath(url: string): string {\n const urlParsed = new URL(url);\n\n let path = urlParsed.pathname;\n path = path || \"/\";\n\n path = escape(path);\n urlParsed.pathname = path;\n\n return urlParsed.toString();\n}\n\nexport interface ConnectionString {\n kind: \"AccountConnString\" | \"SASConnString\";\n url: string;\n accountName: string;\n accountKey?: any;\n accountSas?: string;\n}\n\nfunction getValueInConnString(\n connectionString: string,\n argument:\n | \"FileEndpoint\"\n | \"AccountName\"\n | \"AccountKey\"\n | \"DefaultEndpointsProtocol\"\n | \"EndpointSuffix\"\n | \"SharedAccessSignature\",\n) {\n const elements = connectionString.split(\";\");\n for (const element of elements) {\n if (element.trim().startsWith(argument)) {\n return element.trim().match(argument + \"=(.*)\")![1];\n }\n }\n return \"\";\n}\n\n/**\n * Extracts the parts of an Azure Storage account connection string.\n *\n * @param connectionString - Connection string.\n * @returns String key value pairs of the storage account's url and credentials.\n */\nexport function extractConnectionStringParts(connectionString: string): ConnectionString {\n // Matching FileEndpoint in the Account connection string\n let fileEndpoint = getValueInConnString(connectionString, \"FileEndpoint\");\n // Slicing off '/' at the end if exists\n // (The methods that use `extractConnectionStringParts` expect the url to not have `/` at the end)\n fileEndpoint = fileEndpoint.endsWith(\"/\") ? fileEndpoint.slice(0, -1) : fileEndpoint;\n\n if (\n connectionString.search(\"DefaultEndpointsProtocol=\") !== -1 &&\n connectionString.search(\"AccountKey=\") !== -1\n ) {\n // Account connection string\n\n let defaultEndpointsProtocol = \"\";\n let accountName = \"\";\n let accountKey = Buffer.from(\"accountKey\", \"base64\");\n let endpointSuffix = \"\";\n\n // Get account name and key\n accountName = getValueInConnString(connectionString, \"AccountName\");\n accountKey = Buffer.from(getValueInConnString(connectionString, \"AccountKey\"), \"base64\");\n\n if (!fileEndpoint) {\n // FileEndpoint is not present in the Account connection string\n // Can be obtained from `${defaultEndpointsProtocol}://${accountName}.file.${endpointSuffix}`\n\n defaultEndpointsProtocol = getValueInConnString(connectionString, \"DefaultEndpointsProtocol\");\n const protocol = defaultEndpointsProtocol!.toLowerCase();\n if (protocol !== \"https\" && protocol !== \"http\") {\n throw new Error(\n \"Invalid DefaultEndpointsProtocol in the provided Connection String. Expecting 'https' or 'http'\",\n );\n }\n\n endpointSuffix = getValueInConnString(connectionString, \"EndpointSuffix\");\n if (!endpointSuffix) {\n throw new Error(\"Invalid EndpointSuffix in the provided Connection String\");\n }\n fileEndpoint = `${defaultEndpointsProtocol}://${accountName}.file.${endpointSuffix}`;\n }\n\n if (!accountName) {\n throw new Error(\"Invalid AccountName in the provided Connection String\");\n } else if (accountKey.length === 0) {\n throw new Error(\"Invalid AccountKey in the provided Connection String\");\n }\n\n return {\n kind: \"AccountConnString\",\n url: fileEndpoint,\n accountName,\n accountKey,\n };\n } else {\n // SAS connection string\n const accountSas = getValueInConnString(connectionString, \"SharedAccessSignature\");\n let accountName = getValueInConnString(connectionString, \"AccountName\");\n // if accountName is empty, try to read it from BlobEndpoint\n if (!accountName) {\n accountName = getAccountNameFromUrl(fileEndpoint);\n }\n if (!fileEndpoint) {\n throw new Error(\"Invalid FileEndpoint in the provided SAS Connection String\");\n } else if (!accountSas) {\n throw new Error(\"Invalid SharedAccessSignature in the provided SAS Connection String\");\n }\n\n return { kind: \"SASConnString\", url: fileEndpoint, accountName, accountSas };\n }\n}\n\n/**\n * Internal escape method implemented Strategy Two mentioned in escapeURL() description.\n *\n * @param text -\n */\nfunction escape(text: string): string {\n return encodeURIComponent(text)\n .replace(/%2F/g, \"/\") // Don't escape for \"/\"\n .replace(/'/g, \"%27\") // Escape for \"'\"\n .replace(/\\+/g, \"%20\")\n .replace(/%25/g, \"%\"); // Revert encoded \"%\"\n}\n\n/**\n * Append a string to URL path. Will remove duplicated \"/\" in front of the string\n * when URL path ends with a \"/\".\n *\n * @param url - Source URL string\n * @param name - String to be appended to URL\n * @returns An updated URL string\n */\nexport function appendToURLPath(url: string, name: string): string {\n const urlParsed = new URL(url);\n\n let path = urlParsed.pathname;\n path = path ? (path.endsWith(\"/\") ? `${path}${name}` : `${path}/${name}`) : name;\n urlParsed.pathname = path;\n\n return urlParsed.toString();\n}\n\n/**\n * Append a string to URL query.\n *\n * @param url - Source URL string.\n * @param queryParts - String to be appended to the URL query.\n * @returns An updated URL string.\n */\nexport function appendToURLQuery(url: string, queryParts: string): string {\n const urlParsed = new URL(url);\n\n let query = urlParsed.search;\n if (query) {\n query += \"&\" + queryParts;\n } else {\n query = queryParts;\n }\n\n urlParsed.search = query;\n return urlParsed.toString();\n}\n\n/**\n * Set URL parameter name and value. If name exists in URL parameters, old value\n * will be replaced by name key. If not provide value, the parameter will be deleted.\n *\n * @param url - Source URL string\n * @param name - Parameter name\n * @param value - Parameter value\n * @returns An updated URL string\n */\nexport function setURLParameter(url: string, name: string, value?: string): string {\n const urlParsed = new URL(url);\n const encodedName = encodeURIComponent(name);\n const encodedValue = value ? encodeURIComponent(value) : undefined;\n // mutating searchParams will change the encoding, so we have to do this ourselves\n const searchString = urlParsed.search === \"\" ? \"?\" : urlParsed.search;\n\n const searchPieces: string[] = [];\n\n for (const pair of searchString.slice(1).split(\"&\")) {\n if (pair) {\n const [key] = pair.split(\"=\", 2);\n if (key !== encodedName) {\n searchPieces.push(pair);\n }\n }\n }\n if (encodedValue) {\n searchPieces.push(`${encodedName}=${encodedValue}`);\n }\n\n urlParsed.search = searchPieces.length ? `?${searchPieces.join(\"&\")}` : \"\";\n\n return urlParsed.toString();\n}\n\n/**\n * Get URL parameter by name.\n *\n * @param url -\n * @param name -\n */\nexport function getURLParameter(url: string, name: string): string | string[] | undefined {\n const urlParsed = new URL(url);\n return urlParsed.searchParams.get(name) ?? undefined;\n}\n\n/**\n * Set URL host.\n *\n * @param url - Source URL string\n * @param host - New host string\n * @returns An updated URL string\n */\nexport function setURLHost(url: string, host: string): string {\n const urlParsed = new URL(url);\n urlParsed.hostname = host;\n return urlParsed.toString();\n}\n\n/**\n * Get URL path from an URL string.\n *\n * @param url - Source URL string\n */\nexport function getURLPath(url: string): string | undefined {\n try {\n const urlParsed = new URL(url);\n return urlParsed.pathname;\n } catch (e) {\n return undefined;\n }\n}\n\n/**\n * Get URL query key value pairs from an URL string.\n *\n * @param url -\n */\nexport function getURLQueries(url: string): { [key: string]: string } {\n let queryString = new URL(url).search;\n if (!queryString) {\n return {};\n }\n\n queryString = queryString.trim();\n queryString = queryString.startsWith(\"?\") ? queryString.substring(1) : queryString;\n\n let querySubStrings: string[] = queryString.split(\"&\");\n querySubStrings = querySubStrings.filter((value: string) => {\n const indexOfEqual = value.indexOf(\"=\");\n const lastIndexOfEqual = value.lastIndexOf(\"=\");\n return (\n indexOfEqual > 0 && indexOfEqual === lastIndexOfEqual && lastIndexOfEqual < value.length - 1\n );\n });\n\n const queries: { [key: string]: string } = {};\n for (const querySubString of querySubStrings) {\n const splitResults = querySubString.split(\"=\");\n const key: string = splitResults[0];\n const value: string = splitResults[1];\n queries[key] = value;\n }\n\n return queries;\n}\n\n/**\n * Rounds a date off to seconds.\n *\n * @param date -\n * @param withMilliseconds - If true, YYYY-MM-DDThh:mm:ss.fffffffZ will be returned;\n * If false, YYYY-MM-DDThh:mm:ssZ will be returned.\n * @returns Date string in ISO8061 format, with or without 7 milliseconds component\n */\nexport function truncatedISO8061Date(date: Date, withMilliseconds: boolean = true): string {\n // Date.toISOString() will return like \"2018-10-29T06:34:36.139Z\"\n const dateString = date.toISOString();\n\n return withMilliseconds\n ? dateString.substring(0, dateString.length - 1) + \"0000\" + \"Z\"\n : dateString.substring(0, dateString.length - 5) + \"Z\";\n}\n\n/**\n * Base64 encode.\n *\n * @param content -\n */\nexport function base64encode(content: string): string {\n return !isNode ? btoa(content) : Buffer.from(content).toString(\"base64\");\n}\n\n/**\n * Base64 decode.\n *\n * @param encodedString -\n */\nexport function base64decode(encodedString: string): string {\n return !isNode ? atob(encodedString) : Buffer.from(encodedString, \"base64\").toString();\n}\n\n/**\n * Delay specified time interval.\n *\n * @param timeInMs -\n * @param aborter -\n * @param abortError -\n */\nexport async function delay(\n timeInMs: number,\n aborter?: AbortSignalLike,\n abortError?: Error,\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n /* eslint-disable-next-line prefer-const */\n let timeout: any;\n\n const abortHandler = () => {\n if (timeout !== undefined) {\n clearTimeout(timeout);\n }\n reject(abortError);\n };\n\n const resolveHandler = () => {\n if (aborter !== undefined) {\n aborter.removeEventListener(\"abort\", abortHandler);\n }\n resolve();\n };\n\n /* eslint-disable-next-line prefer-const */\n timeout = setTimeout(resolveHandler, timeInMs);\n if (aborter !== undefined) {\n aborter.addEventListener(\"abort\", abortHandler);\n }\n });\n}\n\nexport function sanitizeURL(url: string): string {\n let safeURL: string = url;\n if (getURLParameter(safeURL, URLConstants.Parameters.SIGNATURE)) {\n safeURL = setURLParameter(safeURL, URLConstants.Parameters.SIGNATURE, \"*****\");\n }\n\n return safeURL;\n}\n\nexport function sanitizeHeaders(originalHeader: HttpHeaders): HttpHeaders {\n const headers: HttpHeaders = createHttpHeaders();\n for (const [name, value] of originalHeader) {\n if (name.toLowerCase() === HeaderConstants.AUTHORIZATION.toLowerCase()) {\n headers.set(name, \"*****\");\n } else if (name.toLowerCase() === HeaderConstants.X_MS_COPY_SOURCE) {\n headers.set(name, sanitizeURL(value));\n } else {\n headers.set(name, value);\n }\n }\n\n return headers;\n}\n\n/**\n * Extracts account name from the url\n * @param url - url to extract the account name from\n * @returns with the account name\n */\nexport function getAccountNameFromUrl(url: string): string {\n const parsedUrl = new URL(url);\n let accountName;\n try {\n if (parsedUrl.hostname.split(\".\")[1] === \"file\") {\n // `${defaultEndpointsProtocol}://${accountName}.file.${endpointSuffix}`;\n // Slicing off '/' at the end if exists\n url = url.endsWith(\"/\") ? url.slice(0, -1) : url;\n\n accountName = parsedUrl.hostname.split(\".\")[0];\n } else if (isIpEndpointStyle(parsedUrl)) {\n // IPv4/IPv6 address hosts... Example - http://192.0.0.10:10001/devstoreaccount1/\n // Single word domain without a [dot] in the endpoint... Example - http://localhost:10001/devstoreaccount1/\n // .getPath() -> /devstoreaccount1/\n accountName = parsedUrl.pathname.split(\"/\")[1];\n } else {\n // Custom domain case: \"https://customdomain.com/containername/blob\".\n accountName = \"\";\n }\n return accountName;\n } catch (error: any) {\n throw new Error(\"Unable to extract accountName with provided information.\");\n }\n}\n\nexport function isIpEndpointStyle(parsedUrl: URL): boolean {\n const host = parsedUrl.host;\n\n // Case 1: Ipv6, use a broad regex to find out candidates whose host contains two ':'.\n // Case 2: localhost(:port) or host.docker.internal, use broad regex to match port part.\n // Case 3: Ipv4, use broad regex which just check if host contains Ipv4.\n // For valid host please refer to https://man7.org/linux/man-pages/man7/hostname.7.html.\n return (\n /^.*:.*:.*$|^(localhost|host.docker.internal)(:[0-9]+)?$|^(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])){3}(:[0-9]+)?$/.test(\n host,\n ) ||\n (Boolean(parsedUrl.port) && PathStylePorts.includes(parsedUrl.port))\n );\n}\n\nexport function getShareNameAndPathFromUrl(url: string): {\n baseName: string;\n shareName: string;\n path: string;\n} {\n // URL may look like the following\n // \"https://myaccount.file.core.windows.net/myshare/mydirectory/file?sasString\";\n // \"https://myaccount.file.core.windows.net/myshare/mydirectory/file\";\n // \"https://myaccount.file.core.windows.net/myshare/mydirectory?sasString\";\n // \"https://myaccount.file.core.windows.net/myshare/mydirectory\";\n // \"https://myaccount.file.core.windows.net/myshare?sasString\";\n // \"https://myaccount.file.core.windows.net/myshare\";\n // IPv4/IPv6 address hosts, Endpoints - `http://187.24.0.1:1000/devstoreaccount1/mydirectory/file`\n // http://localhost:1000/devstoreaccount1/mydirectory/file\n // mydirectory can consist of multiple directories - dir1/dir2/dir3\n\n let shareName;\n let path;\n let baseName;\n\n try {\n const parsedUrl = new URL(url);\n if (parsedUrl.hostname.split(\".\")[1] === \"file\") {\n // \"https://myaccount.file.core.windows.net/myshare/mydirectory/file\";\n // .getPath() -> /myshare/mydirectory/file\n const pathComponents = parsedUrl.pathname.match(\"/([^/]*)(/(.*))?\");\n shareName = pathComponents![1];\n path = pathComponents![3];\n } else if (isIpEndpointStyle(parsedUrl)) {\n // IPv4/IPv6 address hosts... Example - http://187.24.0.1:1000/devstoreaccount1/mydirectory/file\n // Single word domain without a [dot] in the endpoint... Example - http://localhost:1000/devstoreaccount1/mydirectory/file\n // .getPath() -> /devstoreaccount1/mydirectory/file\n const pathComponents = parsedUrl.pathname.match(\"/([^/]*)/([^/]*)(/(.*))?\");\n shareName = pathComponents![2];\n path = pathComponents![4];\n } else {\n // \"https://customdomain.com/myshare/mydirectory/file\";\n // .getPath() -> /myshare/mydirectory/file\n const pathComponents = parsedUrl.pathname.match(\"/([^/]*)(/(.*))?\");\n shareName = pathComponents![1];\n path = pathComponents![3];\n }\n\n // decode the encoded shareName and filePath - to get all the special characters that might be present in it\n shareName = decodeURIComponent(shareName);\n path = decodeURIComponent(path);\n\n // Cast to string is required as TypeScript cannot infer that split() always returns\n // an array with length >= 1\n baseName = path.split(\"/\").pop() as string;\n\n if (!shareName) {\n throw new Error(\"Provided shareName is invalid.\");\n } else {\n return { baseName, shareName, path };\n }\n } catch (error: any) {\n throw new Error(\n \"Unable to extract shareName and filePath/directoryPath with provided information.\",\n );\n }\n}\n\nexport function httpAuthorizationToString(\n httpAuthorization?: HttpAuthorization,\n): string | undefined {\n return httpAuthorization ? httpAuthorization.scheme + \" \" + httpAuthorization.value : undefined;\n}\n\n/**\n * Set URL path.\n *\n * @param url - URL to change path to.\n * @param path - Path to set into the URL.\n */\nexport function setURLPath(url: string, path: string): string {\n const urlParsed = new URL(url);\n urlParsed.pathname = path;\n return urlParsed.toString();\n}\n\n/**\n * Set URL query string.\n *\n * @param url - URL to set query string to.\n * @param queryString - Query string to set to the URL.\n */\nexport function setURLQueries(url: string, queryString: string): string {\n const urlParsed = new URL(url);\n urlParsed.search = queryString;\n return urlParsed.toString();\n}\n\n/**\n * Escape the file or directory name but keep path separator ('/').\n */\nexport function EscapePath(pathName: string): string {\n const split = pathName.split(\"/\");\n for (let i = 0; i < split.length; i++) {\n split[i] = encodeURIComponent(split[i]);\n }\n return split.join(\"/\");\n}\n\n/**\n * A representation of an HTTP response that\n * includes a reference to the request that\n * originated it.\n */\nexport interface HttpResponse {\n /**\n * The headers from the response.\n */\n headers: HttpHeadersLike;\n /**\n * The original request that resulted in this response.\n */\n request: WebResourceLike;\n /**\n * The HTTP status code returned from the service.\n */\n status: number;\n}\n\n/**\n * An object with a _response property that has\n * headers already parsed into a typed object.\n */\nexport interface ResponseWithHeaders<Headers> {\n /**\n * The underlying HTTP response.\n */\n _response: HttpResponse & {\n /**\n * The parsed HTTP response headers.\n */\n parsedHeaders: Headers;\n };\n}\n\n/**\n * An object with a _response property that has body\n * and headers already parsed into known types.\n */\nexport interface ResponseWithBody<Headers, Body> {\n /**\n * The underlying HTTP response.\n */\n _response: HttpResponse & {\n /**\n * The parsed HTTP response headers.\n */\n parsedHeaders: Headers;\n /**\n * The response body as text (string format)\n */\n bodyAsText: string;\n /**\n * The response body as parsed JSON or XML\n */\n parsedBody: Body;\n };\n}\n\n/**\n * An object with a simple _response property.\n */\nexport interface ResponseLike {\n /**\n * The underlying HTTP response.\n */\n _response: HttpResponse;\n}\n\n/**\n * A type that represents an operation result with a known _response property.\n */\nexport type WithResponse<T, Headers = undefined, Body = undefined> = T &\n (Body extends object\n ? ResponseWithBody<Headers, Body>\n : Headers extends object\n ? ResponseWithHeaders<Headers>\n : ResponseLike);\n\n/**\n * A typesafe helper for ensuring that a given response object has\n * the original _response attached.\n * @param response - A response object from calling a client operation\n * @returns The same object, but with known _response property\n */\nexport function assertResponse<T extends object, Headers = undefined, Body = undefined>(\n response: T,\n): WithResponse<T, Headers, Body> {\n if (`_response` in response) {\n return response as WithResponse<T, Headers, Body>;\n }\n\n throw new TypeError(`Unexpected response object ${response}`);\n}\n\nexport function StringEncodedToString(name: StringEncoded): string {\n if (name.encoded) {\n return decodeURIComponent(name.content!);\n } else {\n return name.content!;\n }\n}\n\nexport function ConvertInternalResponseOfListFiles(\n internalResponse: ListFilesAndDirectoriesSegmentResponseInternal,\n): ListFilesAndDirectoriesSegmentResponse {\n const wrappedResponse = {\n ...internalResponse,\n prefix: undefined,\n directoryPath: StringEncodedToString({\n encoded: internalResponse.encoded,\n content: internalResponse.directoryPath,\n }),\n segment: {\n fileItems: internalResponse.segment.fileItems.map((fileItemInternal) => {\n const fileItem: FileItem = {\n ...fileItemInternal,\n name: StringEncodedToString(fileItemInternal.name),\n };\n return fileItem;\n }),\n directoryItems: internalResponse.segment.directoryItems.map((directoryItemInternal) => {\n const directoryItem: DirectoryItem = {\n ...directoryItemInternal,\n name: StringEncodedToString(directoryItemInternal.name),\n };\n return directoryItem;\n }),\n },\n };\n\n delete wrappedResponse.encoded;\n\n const listResponse: ListFilesAndDirectoriesSegmentResponse = wrappedResponse as any;\n\n if (internalResponse.prefix) {\n listResponse.prefix = StringEncodedToString(internalResponse.prefix);\n }\n\n return listResponse;\n}\n\nexport function ConvertInternalResponseOfListHandles(\n internalResponse: ListHandlesResponseInternal,\n): ListHandlesResponse {\n const wrappedResponse: ListHandlesResponse = {\n ...internalResponse,\n handleList: internalResponse.handleList\n ? internalResponse.handleList.map((handleItemInternal) => {\n const handleItem: HandleItem = {\n ...handleItemInternal,\n path: StringEncodedToString(handleItemInternal.path),\n };\n return handleItem;\n })\n : undefined,\n };\n\n return wrappedResponse;\n}\n\n/**\n * A small helper to handle converting an empty string \"\" into undefined\n * This is used in the case of query parameters (like continuation token) where\n * we don't want to send an empty query parameter to the service since the signing\n * policy for shared key will fail.\n * @internal\n */\nexport function removeEmptyString(value: string | undefined): string | undefined {\n return value ? value : undefined;\n}\n\nexport function asSharePermission(value: string | SharePermission): SharePermission {\n const castSharePermission = value as SharePermission;\n if (castSharePermission[\"permission\"] !== undefined) {\n return {\n permission: castSharePermission.permission,\n format: castSharePermission.format,\n };\n }\n\n return {\n permission: value as string,\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
2
+ // Licensed under the MIT License.
3
3
  import * as fs from "fs";
4
4
  import * as util from "util";
5
5
  import { REQUEST_TIMEOUT } from "./constants";