@azure/storage-common 12.4.1 → 12.6.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/StorageResponseFormat.d.ts +22 -0
- package/dist/browser/StorageResponseFormat.d.ts.map +1 -0
- package/dist/browser/StorageResponseFormat.js +20 -0
- package/dist/browser/StorageResponseFormat.js.map +1 -0
- package/dist/browser/StructuredMessageEncodingStream-browser.d.mts.map +1 -1
- package/dist/browser/StructuredMessageEncodingStream-browser.mjs +1 -2
- package/dist/browser/StructuredMessageEncodingStream-browser.mjs.map +1 -1
- package/dist/browser/crc64.js +6 -93
- package/dist/browser/indexPlatform-browser.d.mts +2 -0
- package/dist/browser/indexPlatform-browser.d.mts.map +1 -1
- package/dist/browser/indexPlatform-browser.mjs +2 -0
- package/dist/browser/indexPlatform-browser.mjs.map +1 -1
- package/dist/browser/package.json +6 -1
- package/dist/browser/policies/StorageRedirectRangeHeaderPolicy.d.ts +10 -0
- package/dist/browser/policies/StorageRedirectRangeHeaderPolicy.d.ts.map +1 -0
- package/dist/browser/policies/StorageRedirectRangeHeaderPolicy.js +22 -0
- package/dist/browser/policies/StorageRedirectRangeHeaderPolicy.js.map +1 -0
- package/dist/browser/policies/StorageRequestFailureDetailsParserPolicy.d.ts.map +1 -1
- package/dist/browser/policies/StorageRequestFailureDetailsParserPolicy.js +12 -0
- package/dist/browser/policies/StorageRequestFailureDetailsParserPolicy.js.map +1 -1
- package/dist/browser/policies/StorageRetryPolicy.d.ts.map +1 -1
- package/dist/browser/policies/StorageRetryPolicy.js +2 -3
- package/dist/browser/policies/StorageRetryPolicy.js.map +1 -1
- package/dist/browser/policies/StorageRetryPolicyV2.d.ts.map +1 -1
- package/dist/browser/policies/StorageRetryPolicyV2.js +28 -0
- package/dist/browser/policies/StorageRetryPolicyV2.js.map +1 -1
- package/dist/browser/utils/constants.d.ts.map +1 -1
- package/dist/browser/utils/constants.js +1 -1
- package/dist/browser/utils/constants.js.map +1 -1
- package/dist/browser/utils/utils.common.d.ts.map +1 -1
- package/dist/browser/utils/utils.common.js +5 -9
- package/dist/browser/utils/utils.common.js.map +1 -1
- package/dist/commonjs/BufferScheduler.d.ts.map +1 -1
- package/dist/commonjs/BufferScheduler.js +24 -7
- package/dist/commonjs/BufferScheduler.js.map +2 -2
- package/dist/commonjs/BuffersStream.d.ts.map +1 -1
- package/dist/commonjs/BuffersStream.js +0 -1
- package/dist/commonjs/BuffersStream.js.map +2 -2
- package/dist/commonjs/StorageResponseFormat.d.ts +22 -0
- package/dist/commonjs/StorageResponseFormat.d.ts.map +1 -0
- package/dist/commonjs/StorageResponseFormat.js +41 -0
- package/dist/commonjs/StorageResponseFormat.js.map +7 -0
- package/dist/commonjs/crc64.js +6 -134
- package/dist/commonjs/indexPlatform.d.ts +3 -0
- package/dist/commonjs/indexPlatform.d.ts.map +1 -1
- package/dist/commonjs/indexPlatform.js +7 -0
- package/dist/commonjs/indexPlatform.js.map +2 -2
- package/dist/commonjs/package.json +6 -1
- package/dist/commonjs/policies/SharedKeySigning.d.ts +32 -0
- package/dist/commonjs/policies/SharedKeySigning.d.ts.map +1 -0
- package/dist/commonjs/policies/SharedKeySigning.js +125 -0
- package/dist/commonjs/policies/SharedKeySigning.js.map +7 -0
- package/dist/commonjs/policies/StorageRedirectRangeHeaderPolicy.d.ts +10 -0
- package/dist/commonjs/policies/StorageRedirectRangeHeaderPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/StorageRedirectRangeHeaderPolicy.js +42 -0
- package/dist/commonjs/policies/StorageRedirectRangeHeaderPolicy.js.map +7 -0
- package/dist/commonjs/policies/StorageRequestFailureDetailsParserPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/StorageRequestFailureDetailsParserPolicy.js +6 -0
- package/dist/commonjs/policies/StorageRequestFailureDetailsParserPolicy.js.map +2 -2
- package/dist/commonjs/policies/StorageRetryPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/StorageRetryPolicy.js +1 -1
- package/dist/commonjs/policies/StorageRetryPolicy.js.map +2 -2
- package/dist/commonjs/policies/StorageRetryPolicyV2.d.ts.map +1 -1
- package/dist/commonjs/policies/StorageRetryPolicyV2.js +16 -0
- package/dist/commonjs/policies/StorageRetryPolicyV2.js.map +2 -2
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicy.d.ts +0 -28
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicy.d.ts.map +1 -1
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicy.js +10 -94
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicy.js.map +2 -2
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicyV2.d.ts.map +1 -1
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicyV2.js +2 -76
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicyV2.js.map +2 -2
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/commonjs/utils/constants.d.ts.map +1 -1
- package/dist/commonjs/utils/constants.js +1 -1
- package/dist/commonjs/utils/constants.js.map +1 -1
- package/dist/commonjs/utils/utils.common.d.ts.map +1 -1
- package/dist/commonjs/utils/utils.common.js +11 -9
- package/dist/commonjs/utils/utils.common.js.map +2 -2
- package/dist/esm/BufferScheduler.d.ts.map +1 -1
- package/dist/esm/BufferScheduler.js +29 -7
- package/dist/esm/BufferScheduler.js.map +1 -1
- package/dist/esm/BuffersStream.d.ts.map +1 -1
- package/dist/esm/BuffersStream.js +0 -1
- package/dist/esm/BuffersStream.js.map +1 -1
- package/dist/esm/StorageResponseFormat.d.ts +22 -0
- package/dist/esm/StorageResponseFormat.d.ts.map +1 -0
- package/dist/esm/StorageResponseFormat.js +20 -0
- package/dist/esm/StorageResponseFormat.js.map +1 -0
- package/dist/esm/crc64.js +6 -156
- package/dist/esm/indexPlatform.d.ts +3 -0
- package/dist/esm/indexPlatform.d.ts.map +1 -1
- package/dist/esm/indexPlatform.js +3 -0
- package/dist/esm/indexPlatform.js.map +1 -1
- package/dist/esm/package.json +6 -1
- package/dist/esm/policies/SharedKeySigning.d.ts +32 -0
- package/dist/esm/policies/SharedKeySigning.d.ts.map +1 -0
- package/dist/esm/policies/SharedKeySigning.js +156 -0
- package/dist/esm/policies/SharedKeySigning.js.map +1 -0
- package/dist/esm/policies/StorageRedirectRangeHeaderPolicy.d.ts +10 -0
- package/dist/esm/policies/StorageRedirectRangeHeaderPolicy.d.ts.map +1 -0
- package/dist/esm/policies/StorageRedirectRangeHeaderPolicy.js +22 -0
- package/dist/esm/policies/StorageRedirectRangeHeaderPolicy.js.map +1 -0
- package/dist/esm/policies/StorageRequestFailureDetailsParserPolicy.d.ts.map +1 -1
- package/dist/esm/policies/StorageRequestFailureDetailsParserPolicy.js +12 -0
- package/dist/esm/policies/StorageRequestFailureDetailsParserPolicy.js.map +1 -1
- package/dist/esm/policies/StorageRetryPolicy.d.ts.map +1 -1
- package/dist/esm/policies/StorageRetryPolicy.js +2 -3
- package/dist/esm/policies/StorageRetryPolicy.js.map +1 -1
- package/dist/esm/policies/StorageRetryPolicyV2.d.ts.map +1 -1
- package/dist/esm/policies/StorageRetryPolicyV2.js +28 -0
- package/dist/esm/policies/StorageRetryPolicyV2.js.map +1 -1
- package/dist/esm/policies/StorageSharedKeyCredentialPolicy.d.ts +0 -28
- package/dist/esm/policies/StorageSharedKeyCredentialPolicy.d.ts.map +1 -1
- package/dist/esm/policies/StorageSharedKeyCredentialPolicy.js +9 -105
- package/dist/esm/policies/StorageSharedKeyCredentialPolicy.js.map +1 -1
- package/dist/esm/policies/StorageSharedKeyCredentialPolicyV2.d.ts.map +1 -1
- package/dist/esm/policies/StorageSharedKeyCredentialPolicyV2.js +2 -101
- package/dist/esm/policies/StorageSharedKeyCredentialPolicyV2.js.map +1 -1
- package/dist/esm/utils/constants.d.ts.map +1 -1
- package/dist/esm/utils/constants.js +1 -1
- package/dist/esm/utils/constants.js.map +1 -1
- package/dist/esm/utils/utils.common.d.ts.map +1 -1
- package/dist/esm/utils/utils.common.js +5 -9
- package/dist/esm/utils/utils.common.js.map +1 -1
- package/dist/react-native/StorageResponseFormat.d.ts +22 -0
- package/dist/react-native/StorageResponseFormat.d.ts.map +1 -0
- package/dist/react-native/StorageResponseFormat.js +20 -0
- package/dist/react-native/StorageResponseFormat.js.map +1 -0
- package/dist/react-native/crc64.js +6 -93
- package/dist/react-native/indexPlatform-browser.d.mts +2 -0
- package/dist/react-native/indexPlatform-browser.d.mts.map +1 -1
- package/dist/react-native/indexPlatform-browser.mjs +2 -0
- package/dist/react-native/indexPlatform-browser.mjs.map +1 -1
- package/dist/react-native/package.json +6 -1
- package/dist/react-native/policies/StorageRedirectRangeHeaderPolicy.d.ts +10 -0
- package/dist/react-native/policies/StorageRedirectRangeHeaderPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/StorageRedirectRangeHeaderPolicy.js +22 -0
- package/dist/react-native/policies/StorageRedirectRangeHeaderPolicy.js.map +1 -0
- package/dist/react-native/policies/StorageRequestFailureDetailsParserPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/StorageRequestFailureDetailsParserPolicy.js +12 -0
- package/dist/react-native/policies/StorageRequestFailureDetailsParserPolicy.js.map +1 -1
- package/dist/react-native/policies/StorageRetryPolicy.d.ts.map +1 -1
- package/dist/react-native/policies/StorageRetryPolicy.js +2 -3
- package/dist/react-native/policies/StorageRetryPolicy.js.map +1 -1
- package/dist/react-native/policies/StorageRetryPolicyV2.d.ts.map +1 -1
- package/dist/react-native/policies/StorageRetryPolicyV2.js +28 -0
- package/dist/react-native/policies/StorageRetryPolicyV2.js.map +1 -1
- package/dist/react-native/utils/constants.d.ts.map +1 -1
- package/dist/react-native/utils/constants.js +1 -1
- package/dist/react-native/utils/constants.js.map +1 -1
- package/dist/react-native/utils/utils.common.d.ts.map +1 -1
- package/dist/react-native/utils/utils.common.js +5 -9
- package/dist/react-native/utils/utils.common.js.map +1 -1
- package/package.json +14 -14
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Specifies the format the service should use to return list results.
|
|
3
|
+
*/
|
|
4
|
+
export declare const StorageResponseFormat: {
|
|
5
|
+
/**
|
|
6
|
+
* Default. Currently maps to {@link StorageResponseFormat.Arrow}, but may be updated in future releases.
|
|
7
|
+
*/
|
|
8
|
+
readonly Auto: "Auto";
|
|
9
|
+
/**
|
|
10
|
+
* Use XML to return list results.
|
|
11
|
+
*/
|
|
12
|
+
readonly Xml: "Xml";
|
|
13
|
+
/**
|
|
14
|
+
* Use Apache Arrow to return list results.
|
|
15
|
+
*/
|
|
16
|
+
readonly Arrow: "Arrow";
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Specifies the format the service should use to return list results.
|
|
20
|
+
*/
|
|
21
|
+
export type StorageResponseFormat = (typeof StorageResponseFormat)[keyof typeof StorageResponseFormat];
|
|
22
|
+
//# sourceMappingURL=StorageResponseFormat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageResponseFormat.d.ts","sourceRoot":"","sources":["../../src/StorageResponseFormat.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,qBAAqB;IAChC;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;CAEK,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC/B,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
/**
|
|
4
|
+
* Specifies the format the service should use to return list results.
|
|
5
|
+
*/
|
|
6
|
+
export const StorageResponseFormat = {
|
|
7
|
+
/**
|
|
8
|
+
* Default. Currently maps to {@link StorageResponseFormat.Arrow}, but may be updated in future releases.
|
|
9
|
+
*/
|
|
10
|
+
Auto: "Auto",
|
|
11
|
+
/**
|
|
12
|
+
* Use XML to return list results.
|
|
13
|
+
*/
|
|
14
|
+
Xml: "Xml",
|
|
15
|
+
/**
|
|
16
|
+
* Use Apache Arrow to return list results.
|
|
17
|
+
*/
|
|
18
|
+
Arrow: "Arrow",
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=StorageResponseFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageResponseFormat.js","sourceRoot":"","sources":["../../src/StorageResponseFormat.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC;;OAEG;IACH,IAAI,EAAE,MAAM;IACZ;;OAEG;IACH,GAAG,EAAE,KAAK;IACV;;OAEG;IACH,KAAK,EAAE,OAAO;CACN,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Specifies the format the service should use to return list results.\n */\nexport const StorageResponseFormat = {\n /**\n * Default. Currently maps to {@link StorageResponseFormat.Arrow}, but may be updated in future releases.\n */\n Auto: \"Auto\",\n /**\n * Use XML to return list results.\n */\n Xml: \"Xml\",\n /**\n * Use Apache Arrow to return list results.\n */\n Arrow: \"Arrow\",\n} as const;\n\n/**\n * Specifies the format the service should use to return list results.\n */\nexport type StorageResponseFormat =\n (typeof StorageResponseFormat)[keyof typeof StorageResponseFormat];\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructuredMessageEncodingStream-browser.d.mts","sourceRoot":"","sources":["../../src/StructuredMessageEncodingStream-browser.mts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,IAAI,eAAe,EAAE,MAAM,2BAA2B,CAAC;AA4DpF,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,eAAe,EACvB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,oBAAoB,EAAE,MAAM,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"StructuredMessageEncodingStream-browser.d.mts","sourceRoot":"","sources":["../../src/StructuredMessageEncodingStream-browser.mts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,IAAI,eAAe,EAAE,MAAM,2BAA2B,CAAC;AA4DpF,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,eAAe,EACvB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,oBAAoB,EAAE,MAAM,CAAA;CAAE,CAAC,CAuClE"}
|
|
@@ -67,9 +67,8 @@ export async function structuredMessageEncoding(source, contentLength) {
|
|
|
67
67
|
};
|
|
68
68
|
}
|
|
69
69
|
if (ArrayBuffer.isView(source)) {
|
|
70
|
-
let encoding = undefined;
|
|
71
70
|
if (source.buffer instanceof ArrayBuffer) {
|
|
72
|
-
encoding = await BrowserStream(new Blob([source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength)]), contentLength);
|
|
71
|
+
const encoding = await BrowserStream(new Blob([source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength)]), contentLength);
|
|
73
72
|
return {
|
|
74
73
|
body: encoding.content,
|
|
75
74
|
encodedContentLength: encoding.encodedContentLength,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructuredMessageEncodingStream-browser.mjs","sourceRoot":"","sources":["../../src/StructuredMessageEncodingStream-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,KAAK,UAAU,IAAI,CACjB,MAAmC,EACnC,UAA2C,EAC3C,cAAsE;IAEtE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IAE5C,IAAI,KAAK,EAAE,CAAC;QACV,qDAAqD;QACrD,cAAc,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC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,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,MAAuB,EACvB,aAAqB;IAErB,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO;YACL,IAAI,EAAE,MAAM;YACZ,oBAAoB,EAAE,aAAa;SACpC,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,YAAY,IAAI,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;QAC5D,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,OAAO;YACtB,oBAAoB,EAAE,QAAQ,CAAC,oBAAoB;SACpD,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,YAAY,WAAW,EAAE,CAAC;QAChE,MAAM,QAAQ,GAAG,MAAM,aAAa,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;QAExE,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,OAAO;YACtB,oBAAoB,EAAE,QAAQ,CAAC,oBAAoB;SACpD,CAAC;IACJ,CAAC;
|
|
1
|
+
{"version":3,"file":"StructuredMessageEncodingStream-browser.mjs","sourceRoot":"","sources":["../../src/StructuredMessageEncodingStream-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,KAAK,UAAU,IAAI,CACjB,MAAmC,EACnC,UAA2C,EAC3C,cAAsE;IAEtE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;IAE5C,IAAI,KAAK,EAAE,CAAC;QACV,qDAAqD;QACrD,cAAc,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;IACD,2DAA2D;IAC3D,IAAI,IAAI,EAAE,CAA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.\n\nimport type { RequestBodyType as HttpRequestBody } from \"@azure/core-rest-pipeline\";\nimport { StructuredMessageEncoding } from \"./StructuredMessageEncoding.js\";\n\nasync function pump(\n reader: ReadableStreamDefaultReader,\n controller: ReadableStreamDefaultController,\n encodingStream: { stream: StructuredMessageEncoding; closed: boolean },\n): Promise<void> {\n const { done, value } = await reader.read();\n\n if (value) {\n // Enqueue the next data chunk into our target stream\n encodingStream.stream.sourceDataHandler(value);\n }\n // When no more data needs to be consumed, close the stream\n if (done) {\n if (!encodingStream.closed) {\n encodingStream.closed = true;\n controller.close();\n }\n return;\n }\n}\n\nasync function BrowserStream(\n source: Blob | ReadableStream<Uint8Array>,\n contentLength: number,\n): Promise<{ content: Blob; encodedContentLength: number }> {\n const sourceStream = source instanceof Blob ? source.stream() : source;\n const reader = sourceStream.getReader();\n\n let encodingStream: { stream: StructuredMessageEncoding; closed: boolean } | undefined =\n undefined;\n const stream = new ReadableStream({\n start(controller) {\n encodingStream = {\n stream: new StructuredMessageEncoding((data) => {\n controller.enqueue(data);\n }, contentLength),\n closed: false,\n };\n },\n pull(controller) {\n pump(reader, controller, encodingStream!)\n .then(() => {\n return;\n })\n .catch((err) => {\n controller.error(err);\n });\n },\n });\n\n const response = new Response(stream);\n return {\n content: await response.blob(),\n encodedContentLength: encodingStream!.stream.messageLength,\n };\n}\n\nexport async function structuredMessageEncoding(\n source: HttpRequestBody,\n contentLength: number,\n): Promise<{ body: HttpRequestBody; encodedContentLength: number }> {\n if (source === null) {\n return {\n body: source,\n encodedContentLength: contentLength,\n };\n }\n\n if (source instanceof Blob) {\n const encoding = await BrowserStream(source, contentLength);\n return {\n body: encoding.content,\n encodedContentLength: encoding.encodedContentLength,\n };\n }\n\n if (typeof source === \"string\" || source instanceof ArrayBuffer) {\n const encoding = await BrowserStream(new Blob([source]), contentLength);\n\n return {\n body: encoding.content,\n encodedContentLength: encoding.encodedContentLength,\n };\n }\n if (ArrayBuffer.isView(source)) {\n if (source.buffer instanceof ArrayBuffer) {\n const encoding = await BrowserStream(\n new Blob([source.buffer.slice(source.byteOffset, source.byteOffset + source.byteLength)]),\n contentLength,\n );\n\n return {\n body: encoding.content,\n encodedContentLength: encoding.encodedContentLength,\n };\n }\n }\n\n throw new Error(\"The specified request body type is not supported for CRC64 checksum\");\n}\n"]}
|
package/dist/browser/crc64.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
|
|
4
|
-
// ESM compatibility block omitted in browsers build as it is NodeJS only.
|
|
5
|
-
|
|
6
4
|
var NativeCRC64 = (() => {
|
|
7
5
|
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
|
8
|
-
if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename;
|
|
9
6
|
return (
|
|
10
7
|
function(NativeCRC64) {
|
|
11
8
|
NativeCRC64 = NativeCRC64 || {};
|
|
@@ -111,11 +108,10 @@ function logExceptionOnExit(e) {
|
|
|
111
108
|
|
|
112
109
|
if (ENVIRONMENT_IS_NODE) {
|
|
113
110
|
if (typeof process == 'undefined' || !process.release || process.release.name !== 'node') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
// The wasm is base64-embedded (see `binaryInString`) and loaded via `getBinary()`,
|
|
112
|
+
// so the Node fs/path read hooks emitted by Emscripten are never exercised and
|
|
113
|
+
// have been removed. This keeps the file free of Node built-in imports so it can be
|
|
114
|
+
// consumed as-is by web bundlers and by ESM-to-CommonJS bundlers (see issue #39057).
|
|
119
115
|
if (process['argv'].length > 1) {
|
|
120
116
|
thisProgram = process['argv'][1].replace(/\\/g, '/');
|
|
121
117
|
}
|
|
@@ -154,26 +150,6 @@ if (ENVIRONMENT_IS_SHELL) {
|
|
|
154
150
|
|
|
155
151
|
if ((typeof process == 'object' && typeof require === 'function') || typeof window == 'object' || typeof importScripts == 'function') throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
|
|
156
152
|
|
|
157
|
-
if (typeof read != 'undefined') {
|
|
158
|
-
read_ = function shell_read(f) {
|
|
159
|
-
return read(f);
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
readBinary = function readBinary(f) {
|
|
164
|
-
let data;
|
|
165
|
-
if (typeof readbuffer == 'function') {
|
|
166
|
-
return new Uint8Array(readbuffer(f));
|
|
167
|
-
}
|
|
168
|
-
data = read(f, 'binary');
|
|
169
|
-
assert(typeof data == 'object');
|
|
170
|
-
return data;
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
readAsync = function readAsync(f, onload, onerror) {
|
|
174
|
-
setTimeout(() => onload(readBinary(f)), 0);
|
|
175
|
-
};
|
|
176
|
-
|
|
177
153
|
if (typeof scriptArgs != 'undefined') {
|
|
178
154
|
arguments_ = scriptArgs;
|
|
179
155
|
} else if (typeof arguments != 'undefined') {
|
|
@@ -200,72 +176,9 @@ if (ENVIRONMENT_IS_SHELL) {
|
|
|
200
176
|
// Node.js workers are detected as a combination of ENVIRONMENT_IS_WORKER and
|
|
201
177
|
// ENVIRONMENT_IS_NODE.
|
|
202
178
|
if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) {
|
|
203
|
-
if (ENVIRONMENT_IS_WORKER) { // Check worker, not web, since window could be polyfilled
|
|
204
|
-
scriptDirectory = self.location.href;
|
|
205
|
-
} else if (typeof document != 'undefined' && document.currentScript) { // web
|
|
206
|
-
scriptDirectory = document.currentScript.src;
|
|
207
|
-
}
|
|
208
|
-
// When MODULARIZE, this JS may be executed later, after document.currentScript
|
|
209
|
-
// is gone, so we saved it, and we use it here instead of any other info.
|
|
210
|
-
if (_scriptDir) {
|
|
211
|
-
scriptDirectory = _scriptDir;
|
|
212
|
-
}
|
|
213
|
-
// blob urls look like blob:http://site.com/etc/etc and we cannot infer anything from them.
|
|
214
|
-
// otherwise, slice off the final part of the url to find the script directory.
|
|
215
|
-
// if scriptDirectory does not contain a slash, lastIndexOf will return -1,
|
|
216
|
-
// and scriptDirectory will correctly be replaced with an empty string.
|
|
217
|
-
// If scriptDirectory contains a query (starting with ?) or a fragment (starting with #),
|
|
218
|
-
// they are removed because they could contain a slash.
|
|
219
|
-
if (scriptDirectory.indexOf('blob:') !== 0) {
|
|
220
|
-
scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf('/')+1);
|
|
221
|
-
} else {
|
|
222
|
-
scriptDirectory = '';
|
|
223
|
-
}
|
|
224
|
-
|
|
225
179
|
if (!(typeof window == 'object' || typeof importScripts == 'function')) throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)');
|
|
226
|
-
|
|
227
|
-
//
|
|
228
|
-
// be done differently.
|
|
229
|
-
{
|
|
230
|
-
// include: web_or_worker_shell_read.js
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
read_ = (url) => {
|
|
234
|
-
var xhr = new XMLHttpRequest();
|
|
235
|
-
xhr.open('GET', url, false);
|
|
236
|
-
xhr.send(null);
|
|
237
|
-
return xhr.responseText;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
if (ENVIRONMENT_IS_WORKER) {
|
|
241
|
-
readBinary = (url) => {
|
|
242
|
-
var xhr = new XMLHttpRequest();
|
|
243
|
-
xhr.open('GET', url, false);
|
|
244
|
-
xhr.responseType = 'arraybuffer';
|
|
245
|
-
xhr.send(null);
|
|
246
|
-
return new Uint8Array(/** @type{!ArrayBuffer} */(xhr.response));
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
readAsync = (url, onload, onerror) => {
|
|
251
|
-
var xhr = new XMLHttpRequest();
|
|
252
|
-
xhr.open('GET', url, true);
|
|
253
|
-
xhr.responseType = 'arraybuffer';
|
|
254
|
-
xhr.onload = () => {
|
|
255
|
-
if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0
|
|
256
|
-
onload(xhr.response);
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
onerror();
|
|
260
|
-
};
|
|
261
|
-
xhr.onerror = onerror;
|
|
262
|
-
xhr.send(null);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// end include: web_or_worker_shell_read.js
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
setWindowTitle = (title) => document.title = title;
|
|
180
|
+
// The XHR-based read hooks emitted by Emscripten are unused because the wasm is
|
|
181
|
+
// base64-embedded; they have been removed so the file contains no DOM/XHR I/O.
|
|
269
182
|
} else
|
|
270
183
|
{
|
|
271
184
|
throw new Error('environment detection error');
|
|
@@ -6,6 +6,7 @@ export * from "./StructuredMessageDecodingStream-browser.mjs";
|
|
|
6
6
|
export * from "./StorageCRC64Calculator.js";
|
|
7
7
|
export { getCachedDefaultHttpClient } from "./cache.js";
|
|
8
8
|
export type * from "./interfaces-browser.mjs";
|
|
9
|
+
export * from "./StorageResponseFormat.js";
|
|
9
10
|
export * from "./StorageBrowserPolicyFactory.js";
|
|
10
11
|
export * from "./credentials/AnonymousCredential.js";
|
|
11
12
|
export * from "./credentials/Credential.js";
|
|
@@ -18,6 +19,7 @@ export * from "./policies/StorageBrowserPolicyV2-browser.mjs";
|
|
|
18
19
|
export * from "./policies/StorageCorrectContentLengthPolicy-browser.mjs";
|
|
19
20
|
export * from "./policies/StorageRetryPolicyV2.js";
|
|
20
21
|
export * from "./policies/StorageSharedKeyCredentialPolicyV2-browser.mjs";
|
|
22
|
+
export * from "./policies/StorageRedirectRangeHeaderPolicy.js";
|
|
21
23
|
export * from "./policies/StorageRequestFailureDetailsParserPolicy.js";
|
|
22
24
|
export * from "./credentials/UserDelegationKeyCredential-browser.mjs";
|
|
23
25
|
export type { UserDelegationKey } from "./credentials/UserDelegationKey.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexPlatform-browser.d.mts","sourceRoot":"","sources":["../../src/indexPlatform-browser.mts"],"names":[],"mappings":"AAGA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,mBAAmB,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"indexPlatform-browser.d.mts","sourceRoot":"","sources":["../../src/indexPlatform-browser.mts"],"names":[],"mappings":"AAGA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,mBAAmB,sBAAsB,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kDAAkD,CAAC;AAEjE,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,cAAc,yCAAyC,CAAC;AACxD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,sDAAsD,CAAC;AACrE,cAAc,oCAAoC,CAAC;AACnD,cAAc,uDAAuD,CAAC;AACtE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,wDAAwD,CAAC;AACvE,cAAc,mDAAmD,CAAC;AAClE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAG5E,MAAM,MAAM,QAAQ,GAAG,KAAK,CAAC"}
|
|
@@ -7,6 +7,7 @@ export * from "./StructuredMessageEncodingStream-browser.mjs";
|
|
|
7
7
|
export * from "./StructuredMessageDecodingStream-browser.mjs";
|
|
8
8
|
export * from "./StorageCRC64Calculator.js";
|
|
9
9
|
export { getCachedDefaultHttpClient } from "./cache.js";
|
|
10
|
+
export * from "./StorageResponseFormat.js";
|
|
10
11
|
export * from "./StorageBrowserPolicyFactory.js";
|
|
11
12
|
export * from "./credentials/AnonymousCredential.js";
|
|
12
13
|
export * from "./credentials/Credential.js";
|
|
@@ -19,6 +20,7 @@ export * from "./policies/StorageBrowserPolicyV2-browser.mjs";
|
|
|
19
20
|
export * from "./policies/StorageCorrectContentLengthPolicy-browser.mjs";
|
|
20
21
|
export * from "./policies/StorageRetryPolicyV2.js";
|
|
21
22
|
export * from "./policies/StorageSharedKeyCredentialPolicyV2-browser.mjs";
|
|
23
|
+
export * from "./policies/StorageRedirectRangeHeaderPolicy.js";
|
|
22
24
|
export * from "./policies/StorageRequestFailureDetailsParserPolicy.js";
|
|
23
25
|
export * from "./credentials/UserDelegationKeyCredential-browser.mjs";
|
|
24
26
|
//# sourceMappingURL=indexPlatform-browser.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indexPlatform-browser.mjs","sourceRoot":"","sources":["../../src/indexPlatform-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"indexPlatform-browser.mjs","sourceRoot":"","sources":["../../src/indexPlatform-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,6BAA6B,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAExD,cAAc,4BAA4B,CAAC;AAE3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kDAAkD,CAAC;AAEjE,cAAc,gCAAgC,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,cAAc,yCAAyC,CAAC;AACxD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,sDAAsD,CAAC;AACrE,cAAc,oCAAoC,CAAC;AACnD,cAAc,uDAAuD,CAAC;AACtE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,wDAAwD,CAAC;AACvE,cAAc,mDAAmD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport * from \"#platform/BufferScheduler\";\nexport * from \"#platform/bufferHelpers\";\nexport { createBlobFromData } from \"./bufferHelpers.common.js\";\nexport * from \"#platform/StructuredMessageEncodingStream\";\nexport * from \"#platform/StructuredMessageDecodingStream\";\nexport * from \"./StorageCRC64Calculator.js\";\nexport { getCachedDefaultHttpClient } from \"./cache.js\";\nexport type * from \"#platform/interfaces\";\nexport * from \"./StorageResponseFormat.js\";\n\nexport * from \"./StorageBrowserPolicyFactory.js\";\nexport * from \"./credentials/AnonymousCredential.js\";\nexport * from \"./credentials/Credential.js\";\nexport * from \"#platform/credentials/StorageSharedKeyCredential\";\n\nexport * from \"./StorageRetryPolicyFactory.js\";\nexport { BaseRequestPolicy } from \"./policies/RequestPolicy.js\";\nexport * from \"./policies/AnonymousCredentialPolicy.js\";\nexport * from \"./policies/CredentialPolicy.js\";\nexport * from \"#platform/policies/StorageBrowserPolicyV2\";\nexport * from \"#platform/policies/StorageCorrectContentLengthPolicy\";\nexport * from \"./policies/StorageRetryPolicyV2.js\";\nexport * from \"#platform/policies/StorageSharedKeyCredentialPolicyV2\";\nexport * from \"./policies/StorageRedirectRangeHeaderPolicy.js\";\nexport * from \"./policies/StorageRequestFailureDetailsParserPolicy.js\";\nexport * from \"#platform/credentials/UserDelegationKeyCredential\";\nexport type { UserDelegationKey } from \"./credentials/UserDelegationKey.js\";\n\n// Readable is Node.js only - export a never type for browser builds\nexport type Readable = never;\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PipelinePolicy } from "@azure/core-rest-pipeline";
|
|
2
|
+
/**
|
|
3
|
+
* Redirects the "range" header to "x-ms-range" for Azure Storage requests as the latter is preferred.
|
|
4
|
+
*/
|
|
5
|
+
export declare const storageRedirectRangeHeaderPolicyName = "storageRedirectRangeHeaderPolicy";
|
|
6
|
+
/**
|
|
7
|
+
* StorageRedirectRangeHeaderPolicy
|
|
8
|
+
*/
|
|
9
|
+
export declare function storageRedirectRangeHeaderPolicy(): PipelinePolicy;
|
|
10
|
+
//# sourceMappingURL=StorageRedirectRangeHeaderPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageRedirectRangeHeaderPolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/StorageRedirectRangeHeaderPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAIV,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,oCAAoC,qCAAqC,CAAC;AAEvF;;GAEG;AACH,wBAAgB,gCAAgC,IAAI,cAAc,CAWjE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
/**
|
|
4
|
+
* Redirects the "range" header to "x-ms-range" for Azure Storage requests as the latter is preferred.
|
|
5
|
+
*/
|
|
6
|
+
export const storageRedirectRangeHeaderPolicyName = "storageRedirectRangeHeaderPolicy";
|
|
7
|
+
/**
|
|
8
|
+
* StorageRedirectRangeHeaderPolicy
|
|
9
|
+
*/
|
|
10
|
+
export function storageRedirectRangeHeaderPolicy() {
|
|
11
|
+
return {
|
|
12
|
+
name: storageRedirectRangeHeaderPolicyName,
|
|
13
|
+
async sendRequest(request, next) {
|
|
14
|
+
if (request.headers.has("range")) {
|
|
15
|
+
request.headers.set("x-ms-range", request.headers.get("range"));
|
|
16
|
+
request.headers.delete("range");
|
|
17
|
+
}
|
|
18
|
+
return next(request);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=StorageRedirectRangeHeaderPolicy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageRedirectRangeHeaderPolicy.js","sourceRoot":"","sources":["../../../src/policies/StorageRedirectRangeHeaderPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,kCAAkC,CAAC;AAEvF;;GAEG;AACH,MAAM,UAAU,gCAAgC;IAC9C,OAAO;QACL,IAAI,EAAE,oCAAoC;QAC1C,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;gBACjC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAE,CAAC,CAAC;gBACjE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAClC,CAAC;YACD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n PipelinePolicy,\n} from \"@azure/core-rest-pipeline\";\n\n/**\n * Redirects the \"range\" header to \"x-ms-range\" for Azure Storage requests as the latter is preferred.\n */\nexport const storageRedirectRangeHeaderPolicyName = \"storageRedirectRangeHeaderPolicy\";\n\n/**\n * StorageRedirectRangeHeaderPolicy\n */\nexport function storageRedirectRangeHeaderPolicy(): PipelinePolicy {\n return {\n name: storageRedirectRangeHeaderPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n if (request.headers.has(\"range\")) {\n request.headers.set(\"x-ms-range\", request.headers.get(\"range\")!);\n request.headers.delete(\"range\");\n }\n return next(request);\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageRequestFailureDetailsParserPolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/StorageRequestFailureDetailsParserPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAIV,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,4CAA4C,6CACb,CAAC;AAE7C;;GAEG;AACH,wBAAgB,wCAAwC,IAAI,cAAc,
|
|
1
|
+
{"version":3,"file":"StorageRequestFailureDetailsParserPolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/StorageRequestFailureDetailsParserPolicy.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAIV,cAAc,EACf,MAAM,2BAA2B,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,4CAA4C,6CACb,CAAC;AAE7C;;GAEG;AACH,wBAAgB,wCAAwC,IAAI,cAAc,CA2CzE"}
|
|
@@ -13,6 +13,18 @@ export function storageRequestFailureDetailsParserPolicy() {
|
|
|
13
13
|
async sendRequest(request, next) {
|
|
14
14
|
try {
|
|
15
15
|
const response = await next(request);
|
|
16
|
+
if (response.status === 400 &&
|
|
17
|
+
response.bodyAsText?.includes("<Error><Code>InvalidHeaderValue</Code>") &&
|
|
18
|
+
response.bodyAsText.includes("<HeaderName>x-ms-version</HeaderName>")) {
|
|
19
|
+
// replace the error message with a more user-friendly one that includes a link to documentation
|
|
20
|
+
/* example response text:
|
|
21
|
+
`<?xml version="1.0" encoding="utf-8"?>
|
|
22
|
+
<Error><Code>InvalidHeaderValue</Code><Message>The value for one of the HTTP headers is not in the correct format.
|
|
23
|
+
RequestId:e5ea566c-101e-001c-1ec4-acf180000000
|
|
24
|
+
Time:2026-03-05T17:24:34.6688015Z</Message><HeaderName>x-ms-version</HeaderName><HeaderValue>3025-01-01</HeaderValue></Error>`
|
|
25
|
+
*/
|
|
26
|
+
response.bodyAsText = response.bodyAsText.replace(/<Message>.*<\/Message>/s, "<Message>The provided service version is not enabled on this storage account. Please see https://learn.microsoft.com/rest/api/storageservices/versioning-for-the-azure-storage-services for additional information.</Message>");
|
|
27
|
+
}
|
|
16
28
|
return response;
|
|
17
29
|
}
|
|
18
30
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageRequestFailureDetailsParserPolicy.js","sourceRoot":"","sources":["../../../src/policies/StorageRequestFailureDetailsParserPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC;;GAEG;AACH,MAAM,CAAC,MAAM,4CAA4C,GACvD,0CAA0C,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,wCAAwC;IACtD,OAAO;QACL,IAAI,EAAE,4CAA4C;QAClD,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;gBACrC,OAAO,QAAQ,CAAC;YAClB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IACE,OAAO,GAAG,KAAK,QAAQ;oBACvB,GAAG,KAAK,IAAI;oBACX,GAAW,CAAC,QAAQ;oBACpB,GAAW,CAAC,QAAQ,CAAC,UAAU,EAChC,CAAC;oBACD,IACG,GAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,KAAK,oBAAoB;wBAC7D,GAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,KAAK,cAAc,EAC9D,CAAC;wBACA,GAAW,CAAC,OAAO;4BAClB,8MAA8M,CAAC;oBACnN,CAAC;gBACH,CAAC;gBACD,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n PipelinePolicy,\n} from \"@azure/core-rest-pipeline\";\n\n/**\n * The programmatic identifier of the StorageRequestFailureDetailsParserPolicy.\n */\nexport const storageRequestFailureDetailsParserPolicyName =\n \"storageRequestFailureDetailsParserPolicy\";\n\n/**\n * StorageRequestFailureDetailsParserPolicy\n */\nexport function storageRequestFailureDetailsParserPolicy(): PipelinePolicy {\n return {\n name: storageRequestFailureDetailsParserPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n try {\n const response = await next(request);\n return response;\n } catch (err) {\n if (\n typeof err === \"object\" &&\n err !== null &&\n (err as any).response &&\n (err as any).response.parsedBody\n ) {\n if (\n (err as any).response.parsedBody.code === \"InvalidHeaderValue\" &&\n (err as any).response.parsedBody.HeaderName === \"x-ms-version\"\n ) {\n (err as any).message =\n \"The provided service version is not enabled on this storage account. Please see https://learn.microsoft.com/rest/api/storageservices/versioning-for-the-azure-storage-services for additional information.\\n\";\n }\n }\n throw err;\n }\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"StorageRequestFailureDetailsParserPolicy.js","sourceRoot":"","sources":["../../../src/policies/StorageRequestFailureDetailsParserPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC;;GAEG;AACH,MAAM,CAAC,MAAM,4CAA4C,GACvD,0CAA0C,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,wCAAwC;IACtD,OAAO;QACL,IAAI,EAAE,4CAA4C;QAClD,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC;gBACrC,IACE,QAAQ,CAAC,MAAM,KAAK,GAAG;oBACvB,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,wCAAwC,CAAC;oBACvE,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,uCAAuC,CAAC,EACrE,CAAC;oBACD,gGAAgG;oBAChG;;;;;sBAKE;oBACF,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC,OAAO,CAC/C,yBAAyB,EACzB,+NAA+N,CAChO,CAAC;gBACJ,CAAC;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IACE,OAAO,GAAG,KAAK,QAAQ;oBACvB,GAAG,KAAK,IAAI;oBACX,GAAW,CAAC,QAAQ;oBACpB,GAAW,CAAC,QAAQ,CAAC,UAAU,EAChC,CAAC;oBACD,IACG,GAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,KAAK,oBAAoB;wBAC7D,GAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,KAAK,cAAc,EAC9D,CAAC;wBACA,GAAW,CAAC,OAAO;4BAClB,8MAA8M,CAAC;oBACnN,CAAC;gBACH,CAAC;gBACD,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n PipelinePolicy,\n} from \"@azure/core-rest-pipeline\";\n\n/**\n * The programmatic identifier of the StorageRequestFailureDetailsParserPolicy.\n */\nexport const storageRequestFailureDetailsParserPolicyName =\n \"storageRequestFailureDetailsParserPolicy\";\n\n/**\n * StorageRequestFailureDetailsParserPolicy\n */\nexport function storageRequestFailureDetailsParserPolicy(): PipelinePolicy {\n return {\n name: storageRequestFailureDetailsParserPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n try {\n const response = await next(request);\n if (\n response.status === 400 &&\n response.bodyAsText?.includes(\"<Error><Code>InvalidHeaderValue</Code>\") &&\n response.bodyAsText.includes(\"<HeaderName>x-ms-version</HeaderName>\")\n ) {\n // replace the error message with a more user-friendly one that includes a link to documentation\n /* example response text:\n `<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Error><Code>InvalidHeaderValue</Code><Message>The value for one of the HTTP headers is not in the correct format.\nRequestId:e5ea566c-101e-001c-1ec4-acf180000000\nTime:2026-03-05T17:24:34.6688015Z</Message><HeaderName>x-ms-version</HeaderName><HeaderValue>3025-01-01</HeaderValue></Error>`\n */\n response.bodyAsText = response.bodyAsText.replace(\n /<Message>.*<\\/Message>/s,\n \"<Message>The provided service version is not enabled on this storage account. Please see https://learn.microsoft.com/rest/api/storageservices/versioning-for-the-azure-storage-services for additional information.</Message>\",\n );\n }\n return response;\n } catch (err) {\n if (\n typeof err === \"object\" &&\n err !== null &&\n (err as any).response &&\n (err as any).response.parsedBody\n ) {\n if (\n (err as any).response.parsedBody.code === \"InvalidHeaderValue\" &&\n (err as any).response.parsedBody.HeaderName === \"x-ms-version\"\n ) {\n (err as any).message =\n \"The provided service version is not enabled on this storage account. Please see https://learn.microsoft.com/rest/api/storageservices/versioning-for-the-azure-storage-services for additional information.\\n\";\n }\n }\n throw err;\n }\n },\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageRetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/StorageRetryPolicy.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,IAAI,oBAAoB,EAChD,oBAAoB,EACpB,eAAe,IAAI,WAAW,EAC9B,cAAc,IAAI,qBAAqB,EACxC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAM3E;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,CAAC,EAAE,mBAAmB,GAAG,oBAAoB,CAM9F;AAcD;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,iBAAiB;IACvD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAsB;IAEnD;;;;;;OAMG;gBAED,UAAU,EAAE,aAAa,EACzB,OAAO,EAAE,oBAAoB,EAC7B,YAAY,GAAE,mBAA2C;IAyC3D;;;;OAIG;IACU,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAI9E;;;;;;;;;OASG;cACa,kBAAkB,CAChC,OAAO,EAAE,WAAW,EACpB,eAAe,EAAE,OAAO,EACxB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,qBAAqB,CAAC;IA0CjC;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,CACnB,cAAc,EAAE,OAAO,EACvB,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,qBAAqB,EAChC,GAAG,CAAC,EAAE,SAAS,GACd,OAAO;
|
|
1
|
+
{"version":3,"file":"StorageRetryPolicy.d.ts","sourceRoot":"","sources":["../../../src/policies/StorageRetryPolicy.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,IAAI,oBAAoB,EAChD,oBAAoB,EACpB,eAAe,IAAI,WAAW,EAC9B,cAAc,IAAI,qBAAqB,EACxC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAM3E;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,CAAC,EAAE,mBAAmB,GAAG,oBAAoB,CAM9F;AAcD;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,iBAAiB;IACvD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAsB;IAEnD;;;;;;OAMG;gBAED,UAAU,EAAE,aAAa,EACzB,OAAO,EAAE,oBAAoB,EAC7B,YAAY,GAAE,mBAA2C;IAyC3D;;;;OAIG;IACU,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAI9E;;;;;;;;;OASG;cACa,kBAAkB,CAChC,OAAO,EAAE,WAAW,EACpB,eAAe,EAAE,OAAO,EACxB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,qBAAqB,CAAC;IA0CjC;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,CACnB,cAAc,EAAE,OAAO,EACvB,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,qBAAqB,EAChC,GAAG,CAAC,EAAE,SAAS,GACd,OAAO;IA8EV;;;;;;OAMG;YACW,KAAK;CA0BpB"}
|
|
@@ -116,7 +116,7 @@ export class StorageRetryPolicy extends BaseRequestPolicy {
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
await this.delay(isPrimaryRetry, attempt, request.abortSignal);
|
|
119
|
-
return this.attemptSendRequest(request, secondaryHas404,
|
|
119
|
+
return this.attemptSendRequest(request, secondaryHas404, attempt + 1);
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
122
|
* Decide whether to retry according to last HTTP response and retry counters.
|
|
@@ -128,8 +128,7 @@ export class StorageRetryPolicy extends BaseRequestPolicy {
|
|
|
128
128
|
*/
|
|
129
129
|
shouldRetry(isPrimaryRetry, attempt, response, err) {
|
|
130
130
|
if (attempt >= this.retryOptions.maxTries) {
|
|
131
|
-
logger.info(`RetryPolicy: Attempt(s) ${attempt} >= maxTries ${this.retryOptions
|
|
132
|
-
.maxTries}, no further try.`);
|
|
131
|
+
logger.info(`RetryPolicy: Attempt(s) ${attempt} >= maxTries ${this.retryOptions.maxTries}, no further try.`);
|
|
133
132
|
return false;
|
|
134
133
|
}
|
|
135
134
|
// Handle network failures, you may need to customize the list when you implement
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageRetryPolicy.js","sourceRoot":"","sources":["../../../src/policies/StorageRetryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAQrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAIvD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAkC;IACtE,OAAO;QACL,MAAM,EAAE,CAAC,UAAyB,EAAE,OAA6B,EAAsB,EAAE;YACvF,OAAO,IAAI,kBAAkB,CAAC,UAAU,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QACnE,CAAC;KACF,CAAC;AACJ,CAAC;AAED,wCAAwC;AAC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AM;gBACR,KAAK,sBAAsB,CAAC,KAAK;oBAC/B,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,cAAe,CAAC;oBAClD,MAAM;YACV,CAAC;QACH,CAAC;aAAM,CAAC;YACN,aAAa,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC;QACvC,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,0BAA0B,aAAa,IAAI,CAAC,CAAC;QACzD,OAAO,KAAK,CAAC,aAAa,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC;IAC9D,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport { AbortError } from \"@azure/abort-controller\";\nimport type {\n RequestPolicy,\n RequestPolicyOptionsLike as RequestPolicyOptions,\n RequestPolicyFactory,\n WebResourceLike as WebResource,\n CompatResponse as HttpOperationResponse,\n} from \"@azure/core-http-compat\";\nimport { BaseRequestPolicy } from \"./RequestPolicy.js\";\nimport type { RestError } from \"@azure/core-rest-pipeline\";\n\nimport type { StorageRetryOptions } from \"../StorageRetryPolicyFactory.js\";\nimport { HeaderConstants, URLConstants } from \"../utils/constants.js\";\nimport { delay, setURLHost, setURLParameter } from \"../utils/utils.common.js\";\nimport { logger } from \"../log.js\";\nimport { StorageRetryPolicyType } from \"./StorageRetryPolicyType.js\";\n\n/**\n * A factory method used to generated a RetryPolicy factory.\n *\n * @param retryOptions -\n */\nexport function NewRetryPolicyFactory(retryOptions?: StorageRetryOptions): RequestPolicyFactory {\n return {\n create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions): StorageRetryPolicy => {\n return new StorageRetryPolicy(nextPolicy, options, retryOptions);\n },\n };\n}\n\n// Default values of StorageRetryOptions\nconst DEFAULT_RETRY_OPTIONS: StorageRetryOptions = {\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};\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 class StorageRetryPolicy extends BaseRequestPolicy {\n /**\n * RetryOptions.\n */\n private readonly retryOptions: StorageRetryOptions;\n\n /**\n * Creates an instance of RetryPolicy.\n *\n * @param nextPolicy -\n * @param options -\n * @param retryOptions -\n */\n constructor(\n nextPolicy: RequestPolicy,\n options: RequestPolicyOptions,\n retryOptions: StorageRetryOptions = DEFAULT_RETRY_OPTIONS,\n ) {\n super(nextPolicy, options);\n\n // Initialize retry options\n this.retryOptions = {\n retryPolicyType: retryOptions.retryPolicyType\n ? retryOptions.retryPolicyType\n : DEFAULT_RETRY_OPTIONS.retryPolicyType,\n\n maxTries:\n retryOptions.maxTries && retryOptions.maxTries >= 1\n ? Math.floor(retryOptions.maxTries)\n : DEFAULT_RETRY_OPTIONS.maxTries,\n\n tryTimeoutInMs:\n retryOptions.tryTimeoutInMs && retryOptions.tryTimeoutInMs >= 0\n ? retryOptions.tryTimeoutInMs\n : DEFAULT_RETRY_OPTIONS.tryTimeoutInMs,\n\n retryDelayInMs:\n retryOptions.retryDelayInMs && retryOptions.retryDelayInMs >= 0\n ? Math.min(\n retryOptions.retryDelayInMs,\n retryOptions.maxRetryDelayInMs\n ? retryOptions.maxRetryDelayInMs\n : DEFAULT_RETRY_OPTIONS.maxRetryDelayInMs!,\n )\n : DEFAULT_RETRY_OPTIONS.retryDelayInMs,\n\n maxRetryDelayInMs:\n retryOptions.maxRetryDelayInMs && retryOptions.maxRetryDelayInMs >= 0\n ? retryOptions.maxRetryDelayInMs\n : DEFAULT_RETRY_OPTIONS.maxRetryDelayInMs,\n\n secondaryHost: retryOptions.secondaryHost\n ? retryOptions.secondaryHost\n : DEFAULT_RETRY_OPTIONS.secondaryHost,\n };\n }\n\n /**\n * Sends request.\n *\n * @param request -\n */\n public async sendRequest(request: WebResource): Promise<HttpOperationResponse> {\n return this.attemptSendRequest(request, false, 1);\n }\n\n /**\n * Decide and perform next retry. Won't mutate request parameter.\n *\n * @param request -\n * @param secondaryHas404 - 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 * @param attempt - How many retries has been attempted to performed, starting from 1, which includes\n * the attempt will be performed by this method call.\n */\n protected async attemptSendRequest(\n request: WebResource,\n secondaryHas404: boolean,\n attempt: number,\n ): Promise<HttpOperationResponse> {\n const newRequest: WebResource = request.clone();\n\n const isPrimaryRetry =\n secondaryHas404 ||\n !this.retryOptions.secondaryHost ||\n !(request.method === \"GET\" || request.method === \"HEAD\" || request.method === \"OPTIONS\") ||\n attempt % 2 === 1;\n\n if (!isPrimaryRetry) {\n newRequest.url = setURLHost(newRequest.url, this.retryOptions.secondaryHost!);\n }\n\n // Set the server-side timeout query parameter \"timeout=[seconds]\"\n if (this.retryOptions.tryTimeoutInMs) {\n newRequest.url = setURLParameter(\n newRequest.url,\n URLConstants.Parameters.TIMEOUT,\n Math.floor(this.retryOptions.tryTimeoutInMs! / 1000).toString(),\n );\n }\n\n let response: HttpOperationResponse | undefined;\n try {\n logger.info(`RetryPolicy: =====> Try=${attempt} ${isPrimaryRetry ? \"Primary\" : \"Secondary\"}`);\n response = await this._nextPolicy.sendRequest(newRequest);\n if (!this.shouldRetry(isPrimaryRetry, attempt, response)) {\n return response;\n }\n\n secondaryHas404 = secondaryHas404 || (!isPrimaryRetry && response.status === 404);\n } catch (err: any) {\n logger.error(`RetryPolicy: Caught error, message: ${err.message}, code: ${err.code}`);\n if (!this.shouldRetry(isPrimaryRetry, attempt, response, err)) {\n throw err;\n }\n }\n\n await this.delay(isPrimaryRetry, attempt, request.abortSignal);\n return this.attemptSendRequest(request, secondaryHas404, ++attempt);\n }\n\n /**\n * Decide whether to retry according to last HTTP response and retry counters.\n *\n * @param isPrimaryRetry -\n * @param attempt -\n * @param response -\n * @param err -\n */\n protected shouldRetry(\n isPrimaryRetry: boolean,\n attempt: number,\n response?: HttpOperationResponse,\n err?: RestError,\n ): boolean {\n if (attempt >= this.retryOptions.maxTries!) {\n logger.info(\n `RetryPolicy: Attempt(s) ${attempt} >= maxTries ${this.retryOptions\n .maxTries!}, no further try.`,\n );\n return false;\n }\n\n // Handle network failures, you may need to customize the list when you implement\n // your own http client\n const retriableErrors = [\n \"ETIMEDOUT\",\n \"ESOCKETTIMEDOUT\",\n \"ECONNREFUSED\",\n \"ECONNRESET\",\n \"ENOENT\",\n \"ENOTFOUND\",\n \"TIMEOUT\",\n \"EPIPE\",\n \"REQUEST_SEND_ERROR\", // For default xhr based http client provided in ms-rest-js\n ];\n if (err) {\n for (const retriableError of retriableErrors) {\n if (\n err.name.toUpperCase().includes(retriableError) ||\n err.message.toUpperCase().includes(retriableError) ||\n (err.code && err.code.toString().toUpperCase() === retriableError)\n ) {\n logger.info(`RetryPolicy: Network error ${retriableError} found, will retry.`);\n return true;\n }\n }\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 || err) {\n const statusCode = response ? response.status : err ? err.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 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 case \"InternalError\":\n case \"OperationTimedOut\":\n case \"ServerBusy\":\n return true;\n }\n }\n }\n }\n\n if (err?.code === \"PARSE_ERROR\" && err?.message.startsWith(`Error \"Error: Unclosed root tag`)) {\n logger.info(\n \"RetryPolicy: Incomplete XML response likely due to service timeout, will retry.\",\n );\n return true;\n }\n\n return false;\n }\n\n /**\n * Delay a calculated time between retries.\n *\n * @param isPrimaryRetry -\n * @param attempt -\n * @param abortSignal -\n */\n private async delay(\n isPrimaryRetry: boolean,\n attempt: number,\n abortSignal?: AbortSignalLike,\n ): Promise<void> {\n let delayTimeInMs: number = 0;\n\n if (isPrimaryRetry) {\n switch (this.retryOptions.retryPolicyType) {\n case StorageRetryPolicyType.EXPONENTIAL:\n delayTimeInMs = Math.min(\n (Math.pow(2, attempt - 1) - 1) * this.retryOptions.retryDelayInMs!,\n this.retryOptions.maxRetryDelayInMs!,\n );\n break;\n case StorageRetryPolicyType.FIXED:\n delayTimeInMs = this.retryOptions.retryDelayInMs!;\n break;\n }\n } else {\n delayTimeInMs = Math.random() * 1000;\n }\n\n logger.info(`RetryPolicy: Delay for ${delayTimeInMs}ms`);\n return delay(delayTimeInMs, abortSignal, RETRY_ABORT_ERROR);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"StorageRetryPolicy.js","sourceRoot":"","sources":["../../../src/policies/StorageRetryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAQrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAIvD,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAkC;IACtE,OAAO;QACL,MAAM,EAAE,CAAC,UAAyB,EAAE,OAA6B,EAAsB,EAAE;YACvF,OAAO,IAAI,kB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,CAAC,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,cAAe,EAClE,IAAI,CAAC,YAAY,CAAC,iBAAkB,CACrC,CAAC;oBACF,MAAM;gBACR,KAAK,sBAAsB,CAAC,KAAK;oBAC/B,aAAa,GAAG,IAAI,CAAC,YAAY,CAAC,cAAe,CAAC;oBAClD,MAAM;YACV,CAAC;QACH,CAAC;aAAM,CAAC;YACN,aAAa,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC;QACvC,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,0BAA0B,aAAa,IAAI,CAAC,CAAC;QACzD,OAAO,KAAK,CAAC,aAAa,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC;IAC9D,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { AbortSignalLike } from \"@azure/abort-controller\";\nimport { AbortError } from \"@azure/abort-controller\";\nimport type {\n RequestPolicy,\n RequestPolicyOptionsLike as RequestPolicyOptions,\n RequestPolicyFactory,\n WebResourceLike as WebResource,\n CompatResponse as HttpOperationResponse,\n} from \"@azure/core-http-compat\";\nimport { BaseRequestPolicy } from \"./RequestPolicy.js\";\nimport type { RestError } from \"@azure/core-rest-pipeline\";\n\nimport type { StorageRetryOptions } from \"../StorageRetryPolicyFactory.js\";\nimport { HeaderConstants, URLConstants } from \"../utils/constants.js\";\nimport { delay, setURLHost, setURLParameter } from \"../utils/utils.common.js\";\nimport { logger } from \"../log.js\";\nimport { StorageRetryPolicyType } from \"./StorageRetryPolicyType.js\";\n\n/**\n * A factory method used to generated a RetryPolicy factory.\n *\n * @param retryOptions -\n */\nexport function NewRetryPolicyFactory(retryOptions?: StorageRetryOptions): RequestPolicyFactory {\n return {\n create: (nextPolicy: RequestPolicy, options: RequestPolicyOptions): StorageRetryPolicy => {\n return new StorageRetryPolicy(nextPolicy, options, retryOptions);\n },\n };\n}\n\n// Default values of StorageRetryOptions\nconst DEFAULT_RETRY_OPTIONS: StorageRetryOptions = {\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};\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 class StorageRetryPolicy extends BaseRequestPolicy {\n /**\n * RetryOptions.\n */\n private readonly retryOptions: StorageRetryOptions;\n\n /**\n * Creates an instance of RetryPolicy.\n *\n * @param nextPolicy -\n * @param options -\n * @param retryOptions -\n */\n constructor(\n nextPolicy: RequestPolicy,\n options: RequestPolicyOptions,\n retryOptions: StorageRetryOptions = DEFAULT_RETRY_OPTIONS,\n ) {\n super(nextPolicy, options);\n\n // Initialize retry options\n this.retryOptions = {\n retryPolicyType: retryOptions.retryPolicyType\n ? retryOptions.retryPolicyType\n : DEFAULT_RETRY_OPTIONS.retryPolicyType,\n\n maxTries:\n retryOptions.maxTries && retryOptions.maxTries >= 1\n ? Math.floor(retryOptions.maxTries)\n : DEFAULT_RETRY_OPTIONS.maxTries,\n\n tryTimeoutInMs:\n retryOptions.tryTimeoutInMs && retryOptions.tryTimeoutInMs >= 0\n ? retryOptions.tryTimeoutInMs\n : DEFAULT_RETRY_OPTIONS.tryTimeoutInMs,\n\n retryDelayInMs:\n retryOptions.retryDelayInMs && retryOptions.retryDelayInMs >= 0\n ? Math.min(\n retryOptions.retryDelayInMs,\n retryOptions.maxRetryDelayInMs\n ? retryOptions.maxRetryDelayInMs\n : DEFAULT_RETRY_OPTIONS.maxRetryDelayInMs!,\n )\n : DEFAULT_RETRY_OPTIONS.retryDelayInMs,\n\n maxRetryDelayInMs:\n retryOptions.maxRetryDelayInMs && retryOptions.maxRetryDelayInMs >= 0\n ? retryOptions.maxRetryDelayInMs\n : DEFAULT_RETRY_OPTIONS.maxRetryDelayInMs,\n\n secondaryHost: retryOptions.secondaryHost\n ? retryOptions.secondaryHost\n : DEFAULT_RETRY_OPTIONS.secondaryHost,\n };\n }\n\n /**\n * Sends request.\n *\n * @param request -\n */\n public async sendRequest(request: WebResource): Promise<HttpOperationResponse> {\n return this.attemptSendRequest(request, false, 1);\n }\n\n /**\n * Decide and perform next retry. Won't mutate request parameter.\n *\n * @param request -\n * @param secondaryHas404 - 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 * @param attempt - How many retries has been attempted to performed, starting from 1, which includes\n * the attempt will be performed by this method call.\n */\n protected async attemptSendRequest(\n request: WebResource,\n secondaryHas404: boolean,\n attempt: number,\n ): Promise<HttpOperationResponse> {\n const newRequest: WebResource = request.clone();\n\n const isPrimaryRetry =\n secondaryHas404 ||\n !this.retryOptions.secondaryHost ||\n !(request.method === \"GET\" || request.method === \"HEAD\" || request.method === \"OPTIONS\") ||\n attempt % 2 === 1;\n\n if (!isPrimaryRetry) {\n newRequest.url = setURLHost(newRequest.url, this.retryOptions.secondaryHost!);\n }\n\n // Set the server-side timeout query parameter \"timeout=[seconds]\"\n if (this.retryOptions.tryTimeoutInMs) {\n newRequest.url = setURLParameter(\n newRequest.url,\n URLConstants.Parameters.TIMEOUT,\n Math.floor(this.retryOptions.tryTimeoutInMs! / 1000).toString(),\n );\n }\n\n let response: HttpOperationResponse | undefined;\n try {\n logger.info(`RetryPolicy: =====> Try=${attempt} ${isPrimaryRetry ? \"Primary\" : \"Secondary\"}`);\n response = await this._nextPolicy.sendRequest(newRequest);\n if (!this.shouldRetry(isPrimaryRetry, attempt, response)) {\n return response;\n }\n\n secondaryHas404 = secondaryHas404 || (!isPrimaryRetry && response.status === 404);\n } catch (err: any) {\n logger.error(`RetryPolicy: Caught error, message: ${err.message}, code: ${err.code}`);\n if (!this.shouldRetry(isPrimaryRetry, attempt, response, err)) {\n throw err;\n }\n }\n\n await this.delay(isPrimaryRetry, attempt, request.abortSignal);\n return this.attemptSendRequest(request, secondaryHas404, attempt + 1);\n }\n\n /**\n * Decide whether to retry according to last HTTP response and retry counters.\n *\n * @param isPrimaryRetry -\n * @param attempt -\n * @param response -\n * @param err -\n */\n protected shouldRetry(\n isPrimaryRetry: boolean,\n attempt: number,\n response?: HttpOperationResponse,\n err?: RestError,\n ): boolean {\n if (attempt >= this.retryOptions.maxTries!) {\n logger.info(\n `RetryPolicy: Attempt(s) ${attempt} >= maxTries ${\n this.retryOptions.maxTries!\n }, no further try.`,\n );\n return false;\n }\n\n // Handle network failures, you may need to customize the list when you implement\n // your own http client\n const retriableErrors = [\n \"ETIMEDOUT\",\n \"ESOCKETTIMEDOUT\",\n \"ECONNREFUSED\",\n \"ECONNRESET\",\n \"ENOENT\",\n \"ENOTFOUND\",\n \"TIMEOUT\",\n \"EPIPE\",\n \"REQUEST_SEND_ERROR\", // For default xhr based http client provided in ms-rest-js\n ];\n if (err) {\n for (const retriableError of retriableErrors) {\n if (\n err.name.toUpperCase().includes(retriableError) ||\n err.message.toUpperCase().includes(retriableError) ||\n (err.code && err.code.toString().toUpperCase() === retriableError)\n ) {\n logger.info(`RetryPolicy: Network error ${retriableError} found, will retry.`);\n return true;\n }\n }\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 || err) {\n const statusCode = response ? response.status : err ? err.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 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 case \"InternalError\":\n case \"OperationTimedOut\":\n case \"ServerBusy\":\n return true;\n }\n }\n }\n }\n\n if (err?.code === \"PARSE_ERROR\" && err?.message.startsWith(`Error \"Error: Unclosed root tag`)) {\n logger.info(\n \"RetryPolicy: Incomplete XML response likely due to service timeout, will retry.\",\n );\n return true;\n }\n\n return false;\n }\n\n /**\n * Delay a calculated time between retries.\n *\n * @param isPrimaryRetry -\n * @param attempt -\n * @param abortSignal -\n */\n private async delay(\n isPrimaryRetry: boolean,\n attempt: number,\n abortSignal?: AbortSignalLike,\n ): Promise<void> {\n let delayTimeInMs: number = 0;\n\n if (isPrimaryRetry) {\n switch (this.retryOptions.retryPolicyType) {\n case StorageRetryPolicyType.EXPONENTIAL:\n delayTimeInMs = Math.min(\n (Math.pow(2, attempt - 1) - 1) * this.retryOptions.retryDelayInMs!,\n this.retryOptions.maxRetryDelayInMs!,\n );\n break;\n case StorageRetryPolicyType.FIXED:\n delayTimeInMs = this.retryOptions.retryDelayInMs!;\n break;\n }\n } else {\n delayTimeInMs = Math.random() * 1000;\n }\n\n logger.info(`RetryPolicy: Delay for ${delayTimeInMs}ms`);\n return delay(delayTimeInMs, abortSignal, RETRY_ABORT_ERROR);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageRetryPolicyV2.d.ts","sourceRoot":"","sources":["../../../src/policies/StorageRetryPolicyV2.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,cAAc,EAIf,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAA0B,KAAK,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAKnG;;GAEG;AACH,eAAO,MAAM,sBAAsB,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"StorageRetryPolicyV2.d.ts","sourceRoot":"","sources":["../../../src/policies/StorageRetryPolicyV2.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,cAAc,EAIf,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAA0B,KAAK,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAKnG;;GAEG;AACH,eAAO,MAAM,sBAAsB,uBAAuB,CAAC;AAwD3D;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,mBAAwB,GAAG,cAAc,CAkKpF"}
|
|
@@ -32,6 +32,31 @@ const retriableErrors = [
|
|
|
32
32
|
"REQUEST_SEND_ERROR",
|
|
33
33
|
];
|
|
34
34
|
const RETRY_ABORT_ERROR = new AbortError("The operation was aborted.");
|
|
35
|
+
/**
|
|
36
|
+
* Releases the body of a response that is dropped for a retry. A streamed body that is never read
|
|
37
|
+
* keeps its connection busy until the server closes it. Node.js bodies are drained rather than
|
|
38
|
+
* destroyed, so the connection can be reused; error bodies are small. Errors while releasing a body
|
|
39
|
+
* are logged and don't stop the retry.
|
|
40
|
+
*
|
|
41
|
+
* The parameters name only the members used here, because each platform build types only its own
|
|
42
|
+
* body kind.
|
|
43
|
+
*/
|
|
44
|
+
async function releaseResponseBody(nodeBody, browserBody) {
|
|
45
|
+
if (nodeBody) {
|
|
46
|
+
// Nothing else reads a dropped body, and Node.js throws an "error" event that has no listener
|
|
47
|
+
// as an uncaught exception.
|
|
48
|
+
nodeBody.on("error", (e) => {
|
|
49
|
+
logger.warning(`RetryPolicy: Failed to drain the response body: ${getErrorMessage(e)}`);
|
|
50
|
+
});
|
|
51
|
+
nodeBody.resume();
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
await browserBody?.cancel();
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
logger.warning(`RetryPolicy: Failed to cancel the response body: ${getErrorMessage(e)}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
35
60
|
/**
|
|
36
61
|
* Retry policy with exponential retry and linear retry implemented.
|
|
37
62
|
*/
|
|
@@ -150,6 +175,9 @@ export function storageRetryPolicy(options = {}) {
|
|
|
150
175
|
}
|
|
151
176
|
retryAgain = shouldRetry({ isPrimaryRetry, attempt, response, error });
|
|
152
177
|
if (retryAgain) {
|
|
178
|
+
if (response) {
|
|
179
|
+
await releaseResponseBody(response.readableStreamBody, response.browserStreamBody);
|
|
180
|
+
}
|
|
153
181
|
await delay(calculateDelay(isPrimaryRetry, attempt), request.abortSignal, RETRY_ABORT_ERROR);
|
|
154
182
|
}
|
|
155
183
|
attempt++;
|