@azure/storage-common 12.0.0-beta.2 → 12.0.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/BuffersStream.js +14 -0
- package/dist/browser/BuffersStream.js.map +1 -1
- package/dist/browser/PooledBuffer.js +13 -5
- package/dist/browser/PooledBuffer.js.map +1 -1
- package/dist/browser/StorageBrowserPolicyFactory.d.ts +16 -0
- package/dist/browser/StorageBrowserPolicyFactory.d.ts.map +1 -0
- package/dist/browser/StorageBrowserPolicyFactory.js +19 -0
- package/dist/browser/StorageBrowserPolicyFactory.js.map +1 -0
- package/dist/browser/StorageRetryPolicyFactory.d.ts +66 -0
- package/dist/browser/StorageRetryPolicyFactory.d.ts.map +1 -0
- package/dist/browser/StorageRetryPolicyFactory.js +28 -0
- package/dist/browser/StorageRetryPolicyFactory.js.map +1 -0
- package/dist/browser/credentials/AnonymousCredential.d.ts +19 -0
- package/dist/browser/credentials/AnonymousCredential.d.ts.map +1 -0
- package/dist/browser/credentials/AnonymousCredential.js +22 -0
- package/dist/browser/credentials/AnonymousCredential.js.map +1 -0
- package/dist/browser/credentials/Credential.d.ts +20 -0
- package/dist/browser/credentials/Credential.d.ts.map +1 -0
- package/dist/browser/credentials/Credential.js +18 -0
- package/dist/browser/credentials/Credential.js.map +1 -0
- package/dist/browser/credentials/StorageSharedKeyCredential-browser.d.mts.map +1 -0
- package/dist/browser/credentials/StorageSharedKeyCredential-browser.mjs.map +1 -0
- package/dist/browser/credentials/StorageSharedKeyCredential.d.ts +3 -0
- package/dist/browser/credentials/StorageSharedKeyCredential.js +5 -0
- package/dist/browser/index-browser.d.mts.map +1 -0
- package/dist/browser/index-browser.mjs.map +1 -0
- package/dist/browser/index.d.ts +17 -1
- package/dist/browser/index.js +17 -1
- package/dist/browser/log.d.ts +5 -0
- package/dist/browser/log.d.ts.map +1 -0
- package/dist/browser/log.js +8 -0
- package/dist/browser/log.js.map +1 -0
- package/dist/browser/policies/AnonymousCredentialPolicy.d.ts +15 -0
- package/dist/browser/policies/AnonymousCredentialPolicy.d.ts.map +1 -0
- package/dist/browser/policies/AnonymousCredentialPolicy.js +20 -0
- package/dist/browser/policies/AnonymousCredentialPolicy.js.map +1 -0
- package/dist/browser/policies/CredentialPolicy.d.ts +22 -0
- package/dist/browser/policies/CredentialPolicy.d.ts.map +1 -0
- package/dist/browser/policies/CredentialPolicy.js +29 -0
- package/dist/browser/policies/CredentialPolicy.js.map +1 -0
- package/dist/browser/policies/RequestPolicy.d.ts +45 -0
- package/dist/browser/policies/RequestPolicy.d.ts.map +1 -0
- package/dist/browser/policies/RequestPolicy.js +42 -0
- package/dist/browser/policies/RequestPolicy.js.map +1 -0
- package/dist/browser/policies/StorageBrowserPolicy.d.ts +28 -0
- package/dist/browser/policies/StorageBrowserPolicy.d.ts.map +1 -0
- package/dist/browser/policies/StorageBrowserPolicy.js +47 -0
- package/dist/browser/policies/StorageBrowserPolicy.js.map +1 -0
- package/dist/browser/policies/StorageBrowserPolicyV2.d.ts +11 -0
- package/dist/browser/policies/StorageBrowserPolicyV2.d.ts.map +1 -0
- package/dist/browser/policies/StorageBrowserPolicyV2.js +31 -0
- package/dist/browser/policies/StorageBrowserPolicyV2.js.map +1 -0
- package/dist/browser/policies/StorageCorrectContentLengthPolicy-browser.d.mts.map +1 -0
- package/dist/browser/policies/StorageCorrectContentLengthPolicy-browser.mjs.map +1 -0
- package/dist/browser/policies/StorageCorrectContentLengthPolicy.d.ts +10 -0
- package/dist/browser/policies/StorageCorrectContentLengthPolicy.js +18 -0
- package/dist/browser/policies/StorageRetryPolicy.d.ts +62 -0
- package/dist/browser/policies/StorageRetryPolicy.d.ts.map +1 -0
- package/dist/browser/policies/StorageRetryPolicy.js +220 -0
- package/dist/browser/policies/StorageRetryPolicy.js.map +1 -0
- package/dist/browser/policies/StorageRetryPolicyType.d.ts +14 -0
- package/dist/browser/policies/StorageRetryPolicyType.d.ts.map +1 -0
- package/dist/browser/policies/StorageRetryPolicyType.js +17 -0
- package/dist/browser/policies/StorageRetryPolicyType.js.map +1 -0
- package/dist/browser/policies/StorageRetryPolicyV2.d.ts +11 -0
- package/dist/browser/policies/StorageRetryPolicyV2.d.ts.map +1 -0
- package/dist/browser/policies/StorageRetryPolicyV2.js +165 -0
- package/dist/browser/policies/StorageRetryPolicyV2.js.map +1 -0
- package/dist/browser/policies/StorageSharedKeyCredentialPolicy.d.ts +54 -0
- package/dist/browser/policies/StorageSharedKeyCredentialPolicy.d.ts.map +1 -0
- package/dist/browser/policies/StorageSharedKeyCredentialPolicy.js +145 -0
- package/dist/browser/policies/StorageSharedKeyCredentialPolicy.js.map +1 -0
- package/dist/browser/policies/StorageSharedKeyCredentialPolicyV2-browser.d.mts.map +1 -0
- package/dist/browser/policies/StorageSharedKeyCredentialPolicyV2-browser.mjs.map +1 -0
- package/dist/browser/policies/StorageSharedKeyCredentialPolicyV2.d.ts +17 -0
- package/dist/browser/policies/StorageSharedKeyCredentialPolicyV2.js +18 -0
- package/dist/browser/utils/SharedKeyComparator.d.ts +2 -0
- package/dist/browser/utils/SharedKeyComparator.d.ts.map +1 -0
- package/dist/browser/utils/SharedKeyComparator.js +73 -0
- package/dist/browser/utils/SharedKeyComparator.js.map +1 -0
- package/dist/browser/utils/constants.d.ts +39 -0
- package/dist/browser/utils/constants.d.ts.map +1 -0
- package/dist/browser/utils/constants.js +64 -0
- package/dist/browser/utils/constants.js.map +1 -0
- package/dist/browser/utils/tracing.d.ts +6 -0
- package/dist/browser/utils/tracing.d.ts.map +1 -0
- package/dist/browser/utils/tracing.js +14 -0
- package/dist/browser/utils/tracing.js.map +1 -0
- package/dist/browser/utils/utils.common.d.ts +305 -0
- package/dist/browser/utils/utils.common.d.ts.map +1 -0
- package/dist/browser/utils/utils.common.js +544 -0
- package/dist/browser/utils/utils.common.js.map +1 -0
- package/dist/commonjs/BufferScheduler.js +70 -44
- package/dist/commonjs/BufferScheduler.js.map +1 -1
- package/dist/commonjs/BuffersStream.js +14 -0
- package/dist/commonjs/BuffersStream.js.map +1 -1
- package/dist/commonjs/PooledBuffer.js +13 -5
- package/dist/commonjs/PooledBuffer.js.map +1 -1
- package/dist/commonjs/StorageBrowserPolicyFactory.d.ts +16 -0
- package/dist/commonjs/StorageBrowserPolicyFactory.d.ts.map +1 -0
- package/dist/commonjs/StorageBrowserPolicyFactory.js +23 -0
- package/dist/commonjs/StorageBrowserPolicyFactory.js.map +1 -0
- package/dist/commonjs/StorageRetryPolicyFactory.d.ts +66 -0
- package/dist/commonjs/StorageRetryPolicyFactory.d.ts.map +1 -0
- package/dist/commonjs/StorageRetryPolicyFactory.js +33 -0
- package/dist/commonjs/StorageRetryPolicyFactory.js.map +1 -0
- package/dist/commonjs/credentials/AnonymousCredential.d.ts +19 -0
- package/dist/commonjs/credentials/AnonymousCredential.d.ts.map +1 -0
- package/dist/commonjs/credentials/AnonymousCredential.js +26 -0
- package/dist/commonjs/credentials/AnonymousCredential.js.map +1 -0
- package/dist/commonjs/credentials/Credential.d.ts +20 -0
- package/dist/commonjs/credentials/Credential.d.ts.map +1 -0
- package/dist/commonjs/credentials/Credential.js +22 -0
- package/dist/commonjs/credentials/Credential.js.map +1 -0
- package/dist/commonjs/credentials/StorageSharedKeyCredential.d.ts +38 -0
- package/dist/commonjs/credentials/StorageSharedKeyCredential.d.ts.map +1 -0
- package/dist/commonjs/credentials/StorageSharedKeyCredential.js +52 -0
- package/dist/commonjs/credentials/StorageSharedKeyCredential.js.map +1 -0
- package/dist/commonjs/index.d.ts +17 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +19 -1
- package/dist/commonjs/index.js.map +1 -1
- package/dist/commonjs/log.d.ts +5 -0
- package/dist/commonjs/log.d.ts.map +1 -0
- package/dist/commonjs/log.js +11 -0
- package/dist/commonjs/log.js.map +1 -0
- package/dist/commonjs/policies/AnonymousCredentialPolicy.d.ts +15 -0
- package/dist/commonjs/policies/AnonymousCredentialPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/AnonymousCredentialPolicy.js +24 -0
- package/dist/commonjs/policies/AnonymousCredentialPolicy.js.map +1 -0
- package/dist/commonjs/policies/CredentialPolicy.d.ts +22 -0
- package/dist/commonjs/policies/CredentialPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/CredentialPolicy.js +33 -0
- package/dist/commonjs/policies/CredentialPolicy.js.map +1 -0
- package/dist/commonjs/policies/RequestPolicy.d.ts +45 -0
- package/dist/commonjs/policies/RequestPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/RequestPolicy.js +46 -0
- package/dist/commonjs/policies/RequestPolicy.js.map +1 -0
- package/dist/commonjs/policies/StorageBrowserPolicy.d.ts +28 -0
- package/dist/commonjs/policies/StorageBrowserPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/StorageBrowserPolicy.js +51 -0
- package/dist/commonjs/policies/StorageBrowserPolicy.js.map +1 -0
- package/dist/commonjs/policies/StorageBrowserPolicyV2.d.ts +11 -0
- package/dist/commonjs/policies/StorageBrowserPolicyV2.d.ts.map +1 -0
- package/dist/commonjs/policies/StorageBrowserPolicyV2.js +35 -0
- package/dist/commonjs/policies/StorageBrowserPolicyV2.js.map +1 -0
- package/dist/commonjs/policies/StorageCorrectContentLengthPolicy.d.ts +10 -0
- package/dist/commonjs/policies/StorageCorrectContentLengthPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/StorageCorrectContentLengthPolicy.js +31 -0
- package/dist/commonjs/policies/StorageCorrectContentLengthPolicy.js.map +1 -0
- package/dist/commonjs/policies/StorageRetryPolicy.d.ts +62 -0
- package/dist/commonjs/policies/StorageRetryPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/StorageRetryPolicy.js +225 -0
- package/dist/commonjs/policies/StorageRetryPolicy.js.map +1 -0
- package/dist/commonjs/policies/StorageRetryPolicyType.d.ts +14 -0
- package/dist/commonjs/policies/StorageRetryPolicyType.d.ts.map +1 -0
- package/dist/commonjs/policies/StorageRetryPolicyType.js +20 -0
- package/dist/commonjs/policies/StorageRetryPolicyType.js.map +1 -0
- package/dist/commonjs/policies/StorageRetryPolicyV2.d.ts +11 -0
- package/dist/commonjs/policies/StorageRetryPolicyV2.d.ts.map +1 -0
- package/dist/commonjs/policies/StorageRetryPolicyV2.js +169 -0
- package/dist/commonjs/policies/StorageRetryPolicyV2.js.map +1 -0
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicy.d.ts +54 -0
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicy.d.ts.map +1 -0
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicy.js +149 -0
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicy.js.map +1 -0
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicyV2.d.ts +17 -0
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicyV2.d.ts.map +1 -0
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicyV2.js +136 -0
- package/dist/commonjs/policies/StorageSharedKeyCredentialPolicyV2.js.map +1 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -11
- package/dist/commonjs/utils/SharedKeyComparator.d.ts +2 -0
- package/dist/commonjs/utils/SharedKeyComparator.d.ts.map +1 -0
- package/dist/commonjs/utils/SharedKeyComparator.js +76 -0
- package/dist/commonjs/utils/SharedKeyComparator.js.map +1 -0
- package/dist/commonjs/utils/constants.d.ts +39 -0
- package/dist/commonjs/utils/constants.d.ts.map +1 -0
- package/dist/commonjs/utils/constants.js +67 -0
- package/dist/commonjs/utils/constants.js.map +1 -0
- package/dist/commonjs/utils/tracing.d.ts +6 -0
- package/dist/commonjs/utils/tracing.d.ts.map +1 -0
- package/dist/commonjs/utils/tracing.js +17 -0
- package/dist/commonjs/utils/tracing.js.map +1 -0
- package/dist/commonjs/utils/utils.common.d.ts +305 -0
- package/dist/commonjs/utils/utils.common.d.ts.map +1 -0
- package/dist/commonjs/utils/utils.common.js +573 -0
- package/dist/commonjs/utils/utils.common.js.map +1 -0
- package/dist/esm/BufferScheduler.js +70 -44
- package/dist/esm/BufferScheduler.js.map +1 -1
- package/dist/esm/BuffersStream.js +14 -0
- package/dist/esm/BuffersStream.js.map +1 -1
- package/dist/esm/PooledBuffer.js +13 -5
- package/dist/esm/PooledBuffer.js.map +1 -1
- package/dist/esm/StorageBrowserPolicyFactory.d.ts +16 -0
- package/dist/esm/StorageBrowserPolicyFactory.d.ts.map +1 -0
- package/dist/esm/StorageBrowserPolicyFactory.js +19 -0
- package/dist/esm/StorageBrowserPolicyFactory.js.map +1 -0
- package/dist/esm/StorageRetryPolicyFactory.d.ts +66 -0
- package/dist/esm/StorageRetryPolicyFactory.d.ts.map +1 -0
- package/dist/esm/StorageRetryPolicyFactory.js +28 -0
- package/dist/esm/StorageRetryPolicyFactory.js.map +1 -0
- package/dist/esm/credentials/AnonymousCredential.d.ts +19 -0
- package/dist/esm/credentials/AnonymousCredential.d.ts.map +1 -0
- package/dist/esm/credentials/AnonymousCredential.js +22 -0
- package/dist/esm/credentials/AnonymousCredential.js.map +1 -0
- package/dist/esm/credentials/Credential.d.ts +20 -0
- package/dist/esm/credentials/Credential.d.ts.map +1 -0
- package/dist/esm/credentials/Credential.js +18 -0
- package/dist/esm/credentials/Credential.js.map +1 -0
- package/dist/esm/credentials/StorageSharedKeyCredential.d.ts +38 -0
- package/dist/esm/credentials/StorageSharedKeyCredential.d.ts.map +1 -0
- package/dist/esm/credentials/StorageSharedKeyCredential.js +48 -0
- package/dist/esm/credentials/StorageSharedKeyCredential.js.map +1 -0
- package/dist/esm/index.d.ts +17 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +17 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/log.d.ts +5 -0
- package/dist/esm/log.d.ts.map +1 -0
- package/dist/esm/log.js +8 -0
- package/dist/esm/log.js.map +1 -0
- package/dist/esm/policies/AnonymousCredentialPolicy.d.ts +15 -0
- package/dist/esm/policies/AnonymousCredentialPolicy.d.ts.map +1 -0
- package/dist/esm/policies/AnonymousCredentialPolicy.js +20 -0
- package/dist/esm/policies/AnonymousCredentialPolicy.js.map +1 -0
- package/dist/esm/policies/CredentialPolicy.d.ts +22 -0
- package/dist/esm/policies/CredentialPolicy.d.ts.map +1 -0
- package/dist/esm/policies/CredentialPolicy.js +29 -0
- package/dist/esm/policies/CredentialPolicy.js.map +1 -0
- package/dist/esm/policies/RequestPolicy.d.ts +45 -0
- package/dist/esm/policies/RequestPolicy.d.ts.map +1 -0
- package/dist/esm/policies/RequestPolicy.js +42 -0
- package/dist/esm/policies/RequestPolicy.js.map +1 -0
- package/dist/esm/policies/StorageBrowserPolicy.d.ts +28 -0
- package/dist/esm/policies/StorageBrowserPolicy.d.ts.map +1 -0
- package/dist/esm/policies/StorageBrowserPolicy.js +47 -0
- package/dist/esm/policies/StorageBrowserPolicy.js.map +1 -0
- package/dist/esm/policies/StorageBrowserPolicyV2.d.ts +11 -0
- package/dist/esm/policies/StorageBrowserPolicyV2.d.ts.map +1 -0
- package/dist/esm/policies/StorageBrowserPolicyV2.js +31 -0
- package/dist/esm/policies/StorageBrowserPolicyV2.js.map +1 -0
- package/dist/esm/policies/StorageCorrectContentLengthPolicy.d.ts +10 -0
- package/dist/esm/policies/StorageCorrectContentLengthPolicy.d.ts.map +1 -0
- package/dist/esm/policies/StorageCorrectContentLengthPolicy.js +27 -0
- package/dist/esm/policies/StorageCorrectContentLengthPolicy.js.map +1 -0
- package/dist/esm/policies/StorageRetryPolicy.d.ts +62 -0
- package/dist/esm/policies/StorageRetryPolicy.d.ts.map +1 -0
- package/dist/esm/policies/StorageRetryPolicy.js +220 -0
- package/dist/esm/policies/StorageRetryPolicy.js.map +1 -0
- package/dist/esm/policies/StorageRetryPolicyType.d.ts +14 -0
- package/dist/esm/policies/StorageRetryPolicyType.d.ts.map +1 -0
- package/dist/esm/policies/StorageRetryPolicyType.js +17 -0
- package/dist/esm/policies/StorageRetryPolicyType.js.map +1 -0
- package/dist/esm/policies/StorageRetryPolicyV2.d.ts +11 -0
- package/dist/esm/policies/StorageRetryPolicyV2.d.ts.map +1 -0
- package/dist/esm/policies/StorageRetryPolicyV2.js +165 -0
- package/dist/esm/policies/StorageRetryPolicyV2.js.map +1 -0
- package/dist/esm/policies/StorageSharedKeyCredentialPolicy.d.ts +54 -0
- package/dist/esm/policies/StorageSharedKeyCredentialPolicy.d.ts.map +1 -0
- package/dist/esm/policies/StorageSharedKeyCredentialPolicy.js +145 -0
- package/dist/esm/policies/StorageSharedKeyCredentialPolicy.js.map +1 -0
- package/dist/esm/policies/StorageSharedKeyCredentialPolicyV2.d.ts +17 -0
- package/dist/esm/policies/StorageSharedKeyCredentialPolicyV2.d.ts.map +1 -0
- package/dist/esm/policies/StorageSharedKeyCredentialPolicyV2.js +132 -0
- package/dist/esm/policies/StorageSharedKeyCredentialPolicyV2.js.map +1 -0
- package/dist/esm/utils/SharedKeyComparator.d.ts +2 -0
- package/dist/esm/utils/SharedKeyComparator.d.ts.map +1 -0
- package/dist/esm/utils/SharedKeyComparator.js +73 -0
- package/dist/esm/utils/SharedKeyComparator.js.map +1 -0
- package/dist/esm/utils/constants.d.ts +39 -0
- package/dist/esm/utils/constants.d.ts.map +1 -0
- package/dist/esm/utils/constants.js +64 -0
- package/dist/esm/utils/constants.js.map +1 -0
- package/dist/esm/utils/tracing.d.ts +6 -0
- package/dist/esm/utils/tracing.d.ts.map +1 -0
- package/dist/esm/utils/tracing.js +14 -0
- package/dist/esm/utils/tracing.js.map +1 -0
- package/dist/esm/utils/utils.common.d.ts +305 -0
- package/dist/esm/utils/utils.common.d.ts.map +1 -0
- package/dist/esm/utils/utils.common.js +544 -0
- package/dist/esm/utils/utils.common.js.map +1 -0
- package/dist/react-native/BufferScheduler.js +70 -44
- package/dist/react-native/BufferScheduler.js.map +1 -1
- package/dist/react-native/BuffersStream.js +14 -0
- package/dist/react-native/BuffersStream.js.map +1 -1
- package/dist/react-native/PooledBuffer.js +13 -5
- package/dist/react-native/PooledBuffer.js.map +1 -1
- package/dist/react-native/StorageBrowserPolicyFactory.d.ts +16 -0
- package/dist/react-native/StorageBrowserPolicyFactory.d.ts.map +1 -0
- package/dist/react-native/StorageBrowserPolicyFactory.js +19 -0
- package/dist/react-native/StorageBrowserPolicyFactory.js.map +1 -0
- package/dist/react-native/StorageRetryPolicyFactory.d.ts +66 -0
- package/dist/react-native/StorageRetryPolicyFactory.d.ts.map +1 -0
- package/dist/react-native/StorageRetryPolicyFactory.js +28 -0
- package/dist/react-native/StorageRetryPolicyFactory.js.map +1 -0
- package/dist/react-native/credentials/AnonymousCredential.d.ts +19 -0
- package/dist/react-native/credentials/AnonymousCredential.d.ts.map +1 -0
- package/dist/react-native/credentials/AnonymousCredential.js +22 -0
- package/dist/react-native/credentials/AnonymousCredential.js.map +1 -0
- package/dist/react-native/credentials/Credential.d.ts +20 -0
- package/dist/react-native/credentials/Credential.d.ts.map +1 -0
- package/dist/react-native/credentials/Credential.js +18 -0
- package/dist/react-native/credentials/Credential.js.map +1 -0
- package/dist/react-native/credentials/StorageSharedKeyCredential.d.ts +38 -0
- package/dist/react-native/credentials/StorageSharedKeyCredential.d.ts.map +1 -0
- package/dist/react-native/credentials/StorageSharedKeyCredential.js +48 -0
- package/dist/react-native/credentials/StorageSharedKeyCredential.js.map +1 -0
- package/dist/react-native/index.d.ts +17 -0
- package/dist/react-native/index.d.ts.map +1 -1
- package/dist/react-native/index.js +17 -0
- package/dist/react-native/index.js.map +1 -1
- package/dist/react-native/log.d.ts +5 -0
- package/dist/react-native/log.d.ts.map +1 -0
- package/dist/react-native/log.js +8 -0
- package/dist/react-native/log.js.map +1 -0
- package/dist/react-native/policies/AnonymousCredentialPolicy.d.ts +15 -0
- package/dist/react-native/policies/AnonymousCredentialPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/AnonymousCredentialPolicy.js +20 -0
- package/dist/react-native/policies/AnonymousCredentialPolicy.js.map +1 -0
- package/dist/react-native/policies/CredentialPolicy.d.ts +22 -0
- package/dist/react-native/policies/CredentialPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/CredentialPolicy.js +29 -0
- package/dist/react-native/policies/CredentialPolicy.js.map +1 -0
- package/dist/react-native/policies/RequestPolicy.d.ts +45 -0
- package/dist/react-native/policies/RequestPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/RequestPolicy.js +42 -0
- package/dist/react-native/policies/RequestPolicy.js.map +1 -0
- package/dist/react-native/policies/StorageBrowserPolicy.d.ts +28 -0
- package/dist/react-native/policies/StorageBrowserPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/StorageBrowserPolicy.js +47 -0
- package/dist/react-native/policies/StorageBrowserPolicy.js.map +1 -0
- package/dist/react-native/policies/StorageBrowserPolicyV2.d.ts +11 -0
- package/dist/react-native/policies/StorageBrowserPolicyV2.d.ts.map +1 -0
- package/dist/react-native/policies/StorageBrowserPolicyV2.js +31 -0
- package/dist/react-native/policies/StorageBrowserPolicyV2.js.map +1 -0
- package/dist/react-native/policies/StorageCorrectContentLengthPolicy.d.ts +10 -0
- package/dist/react-native/policies/StorageCorrectContentLengthPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/StorageCorrectContentLengthPolicy.js +27 -0
- package/dist/react-native/policies/StorageCorrectContentLengthPolicy.js.map +1 -0
- package/dist/react-native/policies/StorageRetryPolicy.d.ts +62 -0
- package/dist/react-native/policies/StorageRetryPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/StorageRetryPolicy.js +220 -0
- package/dist/react-native/policies/StorageRetryPolicy.js.map +1 -0
- package/dist/react-native/policies/StorageRetryPolicyType.d.ts +14 -0
- package/dist/react-native/policies/StorageRetryPolicyType.d.ts.map +1 -0
- package/dist/react-native/policies/StorageRetryPolicyType.js +17 -0
- package/dist/react-native/policies/StorageRetryPolicyType.js.map +1 -0
- package/dist/react-native/policies/StorageRetryPolicyV2.d.ts +11 -0
- package/dist/react-native/policies/StorageRetryPolicyV2.d.ts.map +1 -0
- package/dist/react-native/policies/StorageRetryPolicyV2.js +165 -0
- package/dist/react-native/policies/StorageRetryPolicyV2.js.map +1 -0
- package/dist/react-native/policies/StorageSharedKeyCredentialPolicy.d.ts +54 -0
- package/dist/react-native/policies/StorageSharedKeyCredentialPolicy.d.ts.map +1 -0
- package/dist/react-native/policies/StorageSharedKeyCredentialPolicy.js +145 -0
- package/dist/react-native/policies/StorageSharedKeyCredentialPolicy.js.map +1 -0
- package/dist/react-native/policies/StorageSharedKeyCredentialPolicyV2.d.ts +17 -0
- package/dist/react-native/policies/StorageSharedKeyCredentialPolicyV2.d.ts.map +1 -0
- package/dist/react-native/policies/StorageSharedKeyCredentialPolicyV2.js +132 -0
- package/dist/react-native/policies/StorageSharedKeyCredentialPolicyV2.js.map +1 -0
- package/dist/react-native/utils/SharedKeyComparator.d.ts +2 -0
- package/dist/react-native/utils/SharedKeyComparator.d.ts.map +1 -0
- package/dist/react-native/utils/SharedKeyComparator.js +73 -0
- package/dist/react-native/utils/SharedKeyComparator.js.map +1 -0
- package/dist/react-native/utils/constants.d.ts +39 -0
- package/dist/react-native/utils/constants.d.ts.map +1 -0
- package/dist/react-native/utils/constants.js +64 -0
- package/dist/react-native/utils/constants.js.map +1 -0
- package/dist/react-native/utils/tracing.d.ts +6 -0
- package/dist/react-native/utils/tracing.d.ts.map +1 -0
- package/dist/react-native/utils/tracing.js +14 -0
- package/dist/react-native/utils/tracing.js.map +1 -0
- package/dist/react-native/utils/utils.common.d.ts +305 -0
- package/dist/react-native/utils/utils.common.d.ts.map +1 -0
- package/dist/react-native/utils/utils.common.js +544 -0
- package/dist/react-native/utils/utils.common.js.map +1 -0
- package/package.json +15 -9
- package/dist/browser/index.d.ts.map +0 -1
- package/dist/browser/index.js.map +0 -1
|
@@ -28,6 +28,76 @@ const PooledBuffer_js_1 = require("./PooledBuffer.js");
|
|
|
28
28
|
* Outgoing queue shouldn't be empty.
|
|
29
29
|
*/
|
|
30
30
|
class BufferScheduler {
|
|
31
|
+
/**
|
|
32
|
+
* Size of buffers in incoming and outgoing queues. This class will try to align
|
|
33
|
+
* data read from Readable stream into buffer chunks with bufferSize defined.
|
|
34
|
+
*/
|
|
35
|
+
bufferSize;
|
|
36
|
+
/**
|
|
37
|
+
* How many buffers can be created or maintained.
|
|
38
|
+
*/
|
|
39
|
+
maxBuffers;
|
|
40
|
+
/**
|
|
41
|
+
* A Node.js Readable stream.
|
|
42
|
+
*/
|
|
43
|
+
readable;
|
|
44
|
+
/**
|
|
45
|
+
* OutgoingHandler is an async function triggered by BufferScheduler when there
|
|
46
|
+
* are available buffers in outgoing array.
|
|
47
|
+
*/
|
|
48
|
+
outgoingHandler;
|
|
49
|
+
/**
|
|
50
|
+
* An internal event emitter.
|
|
51
|
+
*/
|
|
52
|
+
emitter = new events_1.EventEmitter();
|
|
53
|
+
/**
|
|
54
|
+
* Concurrency of executing outgoingHandlers. (0 lesser than concurrency lesser than or equal to maxBuffers)
|
|
55
|
+
*/
|
|
56
|
+
concurrency;
|
|
57
|
+
/**
|
|
58
|
+
* An internal offset marker to track data offset in bytes of next outgoingHandler.
|
|
59
|
+
*/
|
|
60
|
+
offset = 0;
|
|
61
|
+
/**
|
|
62
|
+
* An internal marker to track whether stream is end.
|
|
63
|
+
*/
|
|
64
|
+
isStreamEnd = false;
|
|
65
|
+
/**
|
|
66
|
+
* An internal marker to track whether stream or outgoingHandler returns error.
|
|
67
|
+
*/
|
|
68
|
+
isError = false;
|
|
69
|
+
/**
|
|
70
|
+
* How many handlers are executing.
|
|
71
|
+
*/
|
|
72
|
+
executingOutgoingHandlers = 0;
|
|
73
|
+
/**
|
|
74
|
+
* Encoding of the input Readable stream which has string data type instead of Buffer.
|
|
75
|
+
*/
|
|
76
|
+
encoding;
|
|
77
|
+
/**
|
|
78
|
+
* How many buffers have been allocated.
|
|
79
|
+
*/
|
|
80
|
+
numBuffers = 0;
|
|
81
|
+
/**
|
|
82
|
+
* Because this class doesn't know how much data every time stream pops, which
|
|
83
|
+
* is defined by highWaterMarker of the stream. So BufferScheduler will cache
|
|
84
|
+
* data received from the stream, when data in unresolvedDataArray exceeds the
|
|
85
|
+
* blockSize defined, it will try to concat a blockSize of buffer, fill into available
|
|
86
|
+
* buffers from incoming and push to outgoing array.
|
|
87
|
+
*/
|
|
88
|
+
unresolvedDataArray = [];
|
|
89
|
+
/**
|
|
90
|
+
* How much data consisted in unresolvedDataArray.
|
|
91
|
+
*/
|
|
92
|
+
unresolvedLength = 0;
|
|
93
|
+
/**
|
|
94
|
+
* The array includes all the available buffers can be used to fill data from stream.
|
|
95
|
+
*/
|
|
96
|
+
incoming = [];
|
|
97
|
+
/**
|
|
98
|
+
* The array (queue) includes all the buffers filled from stream data.
|
|
99
|
+
*/
|
|
100
|
+
outgoing = [];
|
|
31
101
|
/**
|
|
32
102
|
* Creates an instance of BufferScheduler.
|
|
33
103
|
*
|
|
@@ -41,50 +111,6 @@ class BufferScheduler {
|
|
|
41
111
|
* @param encoding - [Optional] Encoding of Readable stream when it's a string stream
|
|
42
112
|
*/
|
|
43
113
|
constructor(readable, bufferSize, maxBuffers, outgoingHandler, concurrency, encoding) {
|
|
44
|
-
/**
|
|
45
|
-
* An internal event emitter.
|
|
46
|
-
*/
|
|
47
|
-
this.emitter = new events_1.EventEmitter();
|
|
48
|
-
/**
|
|
49
|
-
* An internal offset marker to track data offset in bytes of next outgoingHandler.
|
|
50
|
-
*/
|
|
51
|
-
this.offset = 0;
|
|
52
|
-
/**
|
|
53
|
-
* An internal marker to track whether stream is end.
|
|
54
|
-
*/
|
|
55
|
-
this.isStreamEnd = false;
|
|
56
|
-
/**
|
|
57
|
-
* An internal marker to track whether stream or outgoingHandler returns error.
|
|
58
|
-
*/
|
|
59
|
-
this.isError = false;
|
|
60
|
-
/**
|
|
61
|
-
* How many handlers are executing.
|
|
62
|
-
*/
|
|
63
|
-
this.executingOutgoingHandlers = 0;
|
|
64
|
-
/**
|
|
65
|
-
* How many buffers have been allocated.
|
|
66
|
-
*/
|
|
67
|
-
this.numBuffers = 0;
|
|
68
|
-
/**
|
|
69
|
-
* Because this class doesn't know how much data every time stream pops, which
|
|
70
|
-
* is defined by highWaterMarker of the stream. So BufferScheduler will cache
|
|
71
|
-
* data received from the stream, when data in unresolvedDataArray exceeds the
|
|
72
|
-
* blockSize defined, it will try to concat a blockSize of buffer, fill into available
|
|
73
|
-
* buffers from incoming and push to outgoing array.
|
|
74
|
-
*/
|
|
75
|
-
this.unresolvedDataArray = [];
|
|
76
|
-
/**
|
|
77
|
-
* How much data consisted in unresolvedDataArray.
|
|
78
|
-
*/
|
|
79
|
-
this.unresolvedLength = 0;
|
|
80
|
-
/**
|
|
81
|
-
* The array includes all the available buffers can be used to fill data from stream.
|
|
82
|
-
*/
|
|
83
|
-
this.incoming = [];
|
|
84
|
-
/**
|
|
85
|
-
* The array (queue) includes all the buffers filled from stream data.
|
|
86
|
-
*/
|
|
87
|
-
this.outgoing = [];
|
|
88
114
|
if (bufferSize <= 0) {
|
|
89
115
|
throw new RangeError(`bufferSize must be larger than 0, current is ${bufferSize}`);
|
|
90
116
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BufferScheduler.js","sourceRoot":"","sources":["../../src/BufferScheduler.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,mCAAsC;AACtC,uDAAiD;AAWjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,eAAe;IAuF1B;;;;;;;;;;;OAWG;IACH,YACE,QAA+B,EAC/B,UAAkB,EAClB,UAAkB,EAClB,eAAgC,EAChC,WAAmB,EACnB,QAAyB;QAlF3B;;WAEG;QACc,YAAO,GAAiB,IAAI,qBAAY,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;;;;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O,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,MAAoB;QACtC,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;AAtSD,0CAsSC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { EventEmitter } from \"events\";\nimport { PooledBuffer } from \"./PooledBuffer.js\";\n\n/**\n * OutgoingHandler is an async function triggered by BufferScheduler.\n */\nexport declare type OutgoingHandler = (\n body: () => NodeJS.ReadableStream,\n length: number,\n offset?: number,\n) => 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: NodeJS.ReadableStream;\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: PooledBuffer[] = [];\n\n /**\n * The array (queue) includes all the buffers filled from stream data.\n */\n private outgoing: PooledBuffer[] = [];\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 (>0)\n * @param encoding - [Optional] Encoding of Readable stream when it's a string stream\n */\n constructor(\n readable: NodeJS.ReadableStream,\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 const buffer = this.shiftBufferFromUnresolvedDataArray();\n this.outgoingHandler(() => buffer.getReadableStream(), buffer.size, 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): void {\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?: PooledBuffer): PooledBuffer {\n if (!buffer) {\n buffer = new PooledBuffer(this.bufferSize, this.unresolvedDataArray, this.unresolvedLength);\n } else {\n buffer.fill(this.unresolvedDataArray, this.unresolvedLength);\n }\n\n this.unresolvedLength -= buffer.size;\n return buffer;\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: PooledBuffer;\n\n if (this.incoming.length > 0) {\n buffer = this.incoming.shift()!;\n this.shiftBufferFromUnresolvedDataArray(buffer);\n } else {\n if (this.numBuffers < this.maxBuffers) {\n buffer = this.shiftBufferFromUnresolvedDataArray();\n this.numBuffers++;\n } else {\n // No available buffer, wait for buffer returned\n return false;\n }\n }\n\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(): Promise<void> {\n let buffer: PooledBuffer | 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: PooledBuffer): Promise<any> {\n const bufferLength = buffer.size;\n\n this.executingOutgoingHandlers++;\n this.offset += bufferLength;\n\n try {\n await this.outgoingHandler(\n () => buffer.getReadableStream(),\n bufferLength,\n this.offset - bufferLength,\n );\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: PooledBuffer): void {\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/BufferScheduler.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,mCAAsC;AACtC,uDAAiD;AAWjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAa,eAAe;IAC1B;;;OAGG;IACc,UAAU,CAAS;IAEpC;;OAEG;IACc,UAAU,CAAS;IAEpC;;OAEG;IACc,QAAQ,CAAwB;IAEjD;;;OAGG;IACc,eAAe,CAAkB;IAElD;;OAEG;IACc,OAAO,GAAiB,IAAI,qBAAY,EAAE,CAAC;IAE5D;;OAEG;IACc,WAAW,CAAS;IAErC;;OAEG;IACK,MAAM,GAAW,CAAC,CAAC;IAE3B;;OAEG;IACK,WAAW,GAAY,KAAK,CAAC;IAErC;;OAEG;IACK,OAAO,GAAY,KAAK,CAAC;IAEjC;;OAEG;IACK,yBAAyB,GAAW,CAAC,CAAC;IAE9C;;OAEG;IACK,QAAQ,CAAkB;IAElC;;OAEG;IACK,UAAU,GAAW,CAAC,CAAC;IAE/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GAAG,YAAY,CAC3B,CAAC;QACJ,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,MAAoB;QACtC,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;AAtSD,0CAsSC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { EventEmitter } from \"events\";\nimport { PooledBuffer } from \"./PooledBuffer.js\";\n\n/**\n * OutgoingHandler is an async function triggered by BufferScheduler.\n */\nexport declare type OutgoingHandler = (\n body: () => NodeJS.ReadableStream,\n length: number,\n offset?: number,\n) => 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: NodeJS.ReadableStream;\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: PooledBuffer[] = [];\n\n /**\n * The array (queue) includes all the buffers filled from stream data.\n */\n private outgoing: PooledBuffer[] = [];\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 (>0)\n * @param encoding - [Optional] Encoding of Readable stream when it's a string stream\n */\n constructor(\n readable: NodeJS.ReadableStream,\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 const buffer = this.shiftBufferFromUnresolvedDataArray();\n this.outgoingHandler(() => buffer.getReadableStream(), buffer.size, 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): void {\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?: PooledBuffer): PooledBuffer {\n if (!buffer) {\n buffer = new PooledBuffer(this.bufferSize, this.unresolvedDataArray, this.unresolvedLength);\n } else {\n buffer.fill(this.unresolvedDataArray, this.unresolvedLength);\n }\n\n this.unresolvedLength -= buffer.size;\n return buffer;\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: PooledBuffer;\n\n if (this.incoming.length > 0) {\n buffer = this.incoming.shift()!;\n this.shiftBufferFromUnresolvedDataArray(buffer);\n } else {\n if (this.numBuffers < this.maxBuffers) {\n buffer = this.shiftBufferFromUnresolvedDataArray();\n this.numBuffers++;\n } else {\n // No available buffer, wait for buffer returned\n return false;\n }\n }\n\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(): Promise<void> {\n let buffer: PooledBuffer | 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: PooledBuffer): Promise<any> {\n const bufferLength = buffer.size;\n\n this.executingOutgoingHandlers++;\n this.offset += bufferLength;\n\n try {\n await this.outgoingHandler(\n () => buffer.getReadableStream(),\n bufferLength,\n this.offset - bufferLength,\n );\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: PooledBuffer): void {\n this.incoming.push(buffer);\n if (!this.isError && this.resolveData() && !this.isStreamEnd) {\n this.readable.resume();\n }\n }\n}\n"]}
|
|
@@ -8,6 +8,20 @@ const node_stream_1 = require("node:stream");
|
|
|
8
8
|
* This class generates a readable stream from the data in an array of buffers.
|
|
9
9
|
*/
|
|
10
10
|
class BuffersStream extends node_stream_1.Readable {
|
|
11
|
+
buffers;
|
|
12
|
+
byteLength;
|
|
13
|
+
/**
|
|
14
|
+
* The offset of data to be read in the current buffer.
|
|
15
|
+
*/
|
|
16
|
+
byteOffsetInCurrentBuffer;
|
|
17
|
+
/**
|
|
18
|
+
* The index of buffer to be read in the array of buffers.
|
|
19
|
+
*/
|
|
20
|
+
bufferIndex;
|
|
21
|
+
/**
|
|
22
|
+
* The total length of data already read.
|
|
23
|
+
*/
|
|
24
|
+
pushedBytesLength;
|
|
11
25
|
/**
|
|
12
26
|
* Creates an instance of BuffersStream that will emit the data
|
|
13
27
|
* contained in the array of buffers.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuffersStream.js","sourceRoot":"","sources":["../../src/BuffersStream.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAGlC,6CAAuC;AAOvC;;GAEG;AACH,MAAa,aAAc,SAAQ,sBAAQ;
|
|
1
|
+
{"version":3,"file":"BuffersStream.js","sourceRoot":"","sources":["../../src/BuffersStream.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAGlC,6CAAuC;AAOvC;;GAEG;AACH,MAAa,aAAc,SAAQ,sBAAQ;IAwB/B;IACA;IAxBV;;OAEG;IACK,yBAAyB,CAAS;IAE1C;;OAEG;IACK,WAAW,CAAS;IAE5B;;OAEG;IACK,iBAAiB,CAAS;IAElC;;;;;;OAMG;IACH,YACU,OAAiB,EACjB,UAAkB,EAC1B,OAA8B;QAE9B,KAAK,CAAC,OAAO,CAAC,CAAC;QAJP,YAAO,GAAP,OAAO,CAAU;QACjB,eAAU,GAAV,UAAU,CAAQ;QAI1B,IAAI,CAAC,yBAAyB,GAAG,CAAC,CAAC;QACnC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,iBAAiB,GAAG,CAAC,CAAC;QAE3B,4DAA4D;QAC5D,IAAI,aAAa,GAAG,CAAC,CAAC;QACtB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC/B,aAAa,IAAI,GAAG,CAAC,UAAU,CAAC;QAClC,CAAC;QACD,IAAI,aAAa,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;QACrF,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAa;QACxB,IAAI,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAC9C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClB,CAAC;QAED,IAAI,CAAC,IAAI,EAAE,C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,KAAK,6BAA6B,EAAE,CAAC;oBAChD,4DAA4D;oBAC5D,IAAI,CAAC,yBAAyB,GAAG,CAAC,CAAC;oBACnC,IAAI,CAAC,WAAW,EAAE,CAAC;gBACrB,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,yBAAyB,GAAG,GAAG,CAAC;gBACvC,CAAC;gBACD,IAAI,CAAC,iBAAiB,IAAI,SAAS,CAAC;gBACpC,CAAC,IAAI,SAAS,CAAC;YACjB,CAAC;QACH,CAAC;QAED,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;QACvC,CAAC;aAAM,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;CACF;AA/FD,sCA+FC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ReadableOptions } from \"node:stream\";\nimport { Readable } from \"node:stream\";\n\n/**\n * Options to configure the BuffersStream.\n */\nexport interface BuffersStreamOptions extends ReadableOptions {}\n\n/**\n * This class generates a readable stream from the data in an array of buffers.\n */\nexport class BuffersStream extends Readable {\n /**\n * The offset of data to be read in the current buffer.\n */\n private byteOffsetInCurrentBuffer: number;\n\n /**\n * The index of buffer to be read in the array of buffers.\n */\n private bufferIndex: number;\n\n /**\n * The total length of data already read.\n */\n private pushedBytesLength: number;\n\n /**\n * Creates an instance of BuffersStream that will emit the data\n * contained in the array of buffers.\n *\n * @param buffers - Array of buffers containing the data\n * @param byteLength - The total length of data contained in the buffers\n */\n constructor(\n private buffers: Buffer[],\n private byteLength: number,\n options?: BuffersStreamOptions,\n ) {\n super(options);\n this.byteOffsetInCurrentBuffer = 0;\n this.bufferIndex = 0;\n this.pushedBytesLength = 0;\n\n // check byteLength is no larger than buffers[] total length\n let buffersLength = 0;\n for (const buf of this.buffers) {\n buffersLength += buf.byteLength;\n }\n if (buffersLength < this.byteLength) {\n throw new Error(\"Data size shouldn't be larger than the total length of buffers.\");\n }\n }\n\n /**\n * Internal _read() that will be called when the stream wants to pull more data in.\n *\n * @param size - Optional. The size of data to be read\n */\n public _read(size?: number): void {\n if (this.pushedBytesLength >= this.byteLength) {\n this.push(null);\n }\n\n if (!size) {\n size = this.readableHighWaterMark;\n }\n\n const outBuffers: Buffer[] = [];\n let i = 0;\n while (i < size && this.pushedBytesLength < this.byteLength) {\n // The last buffer may be longer than the data it contains.\n const remainingDataInAllBuffers = this.byteLength - this.pushedBytesLength;\n const remainingCapacityInThisBuffer =\n this.buffers[this.bufferIndex].byteLength - this.byteOffsetInCurrentBuffer;\n const remaining = Math.min(remainingCapacityInThisBuffer, remainingDataInAllBuffers);\n if (remaining > size - i) {\n // chunkSize = size - i\n const end = this.byteOffsetInCurrentBuffer + size - i;\n outBuffers.push(this.buffers[this.bufferIndex].slice(this.byteOffsetInCurrentBuffer, end));\n this.pushedBytesLength += size - i;\n this.byteOffsetInCurrentBuffer = end;\n i = size;\n break;\n } else {\n // chunkSize = remaining\n const end = this.byteOffsetInCurrentBuffer + remaining;\n outBuffers.push(this.buffers[this.bufferIndex].slice(this.byteOffsetInCurrentBuffer, end));\n if (remaining === remainingCapacityInThisBuffer) {\n // this.buffers[this.bufferIndex] used up, shift to next one\n this.byteOffsetInCurrentBuffer = 0;\n this.bufferIndex++;\n } else {\n this.byteOffsetInCurrentBuffer = end;\n }\n this.pushedBytesLength += remaining;\n i += remaining;\n }\n }\n\n if (outBuffers.length > 1) {\n this.push(Buffer.concat(outBuffers));\n } else if (outBuffers.length === 1) {\n this.push(outBuffers[0]);\n }\n }\n}\n"]}
|
|
@@ -19,6 +19,19 @@ const maxBufferLength = node_buffer_1.default.constants.MAX_LENGTH;
|
|
|
19
19
|
* assembled from all the data in the internal "buffer".
|
|
20
20
|
*/
|
|
21
21
|
class PooledBuffer {
|
|
22
|
+
/**
|
|
23
|
+
* Internal buffers used to keep the data.
|
|
24
|
+
* Each buffer has a length of the maxBufferLength except last one.
|
|
25
|
+
*/
|
|
26
|
+
buffers = [];
|
|
27
|
+
/**
|
|
28
|
+
* The total size of internal buffers.
|
|
29
|
+
*/
|
|
30
|
+
capacity;
|
|
31
|
+
/**
|
|
32
|
+
* The total size of data contained in internal buffers.
|
|
33
|
+
*/
|
|
34
|
+
_size;
|
|
22
35
|
/**
|
|
23
36
|
* The size of the data contained in the pooled buffers.
|
|
24
37
|
*/
|
|
@@ -26,11 +39,6 @@ class PooledBuffer {
|
|
|
26
39
|
return this._size;
|
|
27
40
|
}
|
|
28
41
|
constructor(capacity, buffers, totalLength) {
|
|
29
|
-
/**
|
|
30
|
-
* Internal buffers used to keep the data.
|
|
31
|
-
* Each buffer has a length of the maxBufferLength except last one.
|
|
32
|
-
*/
|
|
33
|
-
this.buffers = [];
|
|
34
42
|
this.capacity = capacity;
|
|
35
43
|
this._size = 0;
|
|
36
44
|
// allocate
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PooledBuffer.js","sourceRoot":"","sources":["../../src/PooledBuffer.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,yDAAmD;AAEnD,sEAAiC;AAEjC;;GAEG;AAEH,MAAM,eAAe,GAAG,qBAAM,CAAC,SAAS,CAAC,UAAU,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAa,YAAY;
|
|
1
|
+
{"version":3,"file":"PooledBuffer.js","sourceRoot":"","sources":["../../src/PooledBuffer.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,yDAAmD;AAEnD,sEAAiC;AAEjC;;GAEG;AAEH,MAAM,eAAe,GAAG,qBAAM,CAAC,SAAS,CAAC,UAAU,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAa,YAAY;IACvB;;;OAGG;IACK,OAAO,G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ACnC,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;YAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAC/B,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;YAElE,cAAc,IAAI,SAAS,CAAC;YAC5B,YAAY,IAAI,SAAS,CAAC;YAC1B,YAAY,IAAI,SAAS,CAAC;YAC1B,IAAI,YAAY,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;gBACnC,CAAC,EAAE,CAAC;gBACJ,YAAY,GAAG,CAAC,CAAC;YACnB,CAAC;YACD,IAAI,YAAY,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;gBACnC,CAAC,EAAE,CAAC;gBACJ,YAAY,GAAG,CAAC,CAAC;YACnB,CAAC;QACH,CAAC;QAED,mCAAmC;QACnC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACrB,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,iBAAiB;QACtB,OAAO,IAAI,gCAAa,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;CACF;AAhHD,oCAgHC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { BuffersStream } from \"./BuffersStream.js\";\nimport type { Readable } from \"node:stream\";\nimport buffer from \"node:buffer\";\n\n/**\n * maxBufferLength is max size of each buffer in the pooled buffers.\n */\n\nconst maxBufferLength = buffer.constants.MAX_LENGTH;\n\n/**\n * This class provides a buffer container which conceptually has no hard size limit.\n * It accepts a capacity, an array of input buffers and the total length of input data.\n * It will allocate an internal \"buffer\" of the capacity and fill the data in the input buffers\n * into the internal \"buffer\" serially with respect to the total length.\n * Then by calling PooledBuffer.getReadableStream(), you can get a readable stream\n * assembled from all the data in the internal \"buffer\".\n */\nexport class PooledBuffer {\n /**\n * Internal buffers used to keep the data.\n * Each buffer has a length of the maxBufferLength except last one.\n */\n private buffers: Buffer[] = [];\n\n /**\n * The total size of internal buffers.\n */\n private readonly capacity: number;\n\n /**\n * The total size of data contained in internal buffers.\n */\n private _size: number;\n\n /**\n * The size of the data contained in the pooled buffers.\n */\n public get size(): number {\n return this._size;\n }\n\n /**\n * Creates an instance of PooledBuffer with given capacity.\n * Internal buffers are allocated but contains no data.\n * Users may call the {@link PooledBuffer.fill} method to fill this\n * pooled buffer with data.\n *\n * @param capacity - Total capacity of the internal buffers\n */\n constructor(capacity: number);\n\n /**\n * Creates an instance of PooledBuffer with given capacity.\n * Internal buffers are allocated and filled with data in the input buffers serially\n * with respect to the total length.\n *\n * @param capacity - Total capacity of the internal buffers\n * @param buffers - Input buffers containing the data to be filled in the pooled buffer\n * @param totalLength - Total length of the data to be filled in.\n */\n constructor(capacity: number, buffers: Buffer[], totalLength: number);\n constructor(capacity: number, buffers?: Buffer[], totalLength?: number) {\n this.capacity = capacity;\n this._size = 0;\n\n // allocate\n const bufferNum = Math.ceil(capacity / maxBufferLength);\n for (let i = 0; i < bufferNum; i++) {\n let len = i === bufferNum - 1 ? capacity % maxBufferLength : maxBufferLength;\n if (len === 0) {\n len = maxBufferLength;\n }\n this.buffers.push(Buffer.allocUnsafe(len));\n }\n\n if (buffers) {\n this.fill(buffers, totalLength!);\n }\n }\n\n /**\n * Fill the internal buffers with data in the input buffers serially\n * with respect to the total length and the total capacity of the internal buffers.\n * Data copied will be shift out of the input buffers.\n *\n * @param buffers - Input buffers containing the data to be filled in the pooled buffer\n * @param totalLength - Total length of the data to be filled in.\n *\n */\n public fill(buffers: Buffer[], totalLength: number): void {\n this._size = Math.min(this.capacity, totalLength);\n\n let i = 0,\n j = 0,\n targetOffset = 0,\n sourceOffset = 0,\n totalCopiedNum = 0;\n while (totalCopiedNum < this._size) {\n const source = buffers[i];\n const target = this.buffers[j];\n const copiedNum = source.copy(target, targetOffset, sourceOffset);\n\n totalCopiedNum += copiedNum;\n sourceOffset += copiedNum;\n targetOffset += copiedNum;\n if (sourceOffset === source.length) {\n i++;\n sourceOffset = 0;\n }\n if (targetOffset === target.length) {\n j++;\n targetOffset = 0;\n }\n }\n\n // clear copied from source buffers\n buffers.splice(0, i);\n if (buffers.length > 0) {\n buffers[0] = buffers[0].slice(sourceOffset);\n }\n }\n\n /**\n * Get the readable stream assembled from all the data in the internal buffers.\n *\n */\n public getReadableStream(): Readable {\n return new BuffersStream(this.buffers, this.size);\n }\n}\n"]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RequestPolicy, RequestPolicyOptionsLike as RequestPolicyOptions, RequestPolicyFactory } from "@azure/core-http-compat";
|
|
2
|
+
import { StorageBrowserPolicy } from "./policies/StorageBrowserPolicy.js";
|
|
3
|
+
export { StorageBrowserPolicy };
|
|
4
|
+
/**
|
|
5
|
+
* StorageBrowserPolicyFactory is a factory class helping generating StorageBrowserPolicy objects.
|
|
6
|
+
*/
|
|
7
|
+
export declare class StorageBrowserPolicyFactory implements RequestPolicyFactory {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a StorageBrowserPolicyFactory object.
|
|
10
|
+
*
|
|
11
|
+
* @param nextPolicy -
|
|
12
|
+
* @param options -
|
|
13
|
+
*/
|
|
14
|
+
create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): StorageBrowserPolicy;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=StorageBrowserPolicyFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageBrowserPolicyFactory.d.ts","sourceRoot":"","sources":["../../src/StorageBrowserPolicyFactory.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,IAAI,oBAAoB,EAChD,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC;;GAEG;AACH,qBAAa,2BAA4B,YAAW,oBAAoB;IACtE;;;;;OAKG;IACI,MAAM,CAAC,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,oBAAoB,GAAG,oBAAoB;CAG9F"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.StorageBrowserPolicyFactory = exports.StorageBrowserPolicy = void 0;
|
|
6
|
+
const StorageBrowserPolicy_js_1 = require("./policies/StorageBrowserPolicy.js");
|
|
7
|
+
Object.defineProperty(exports, "StorageBrowserPolicy", { enumerable: true, get: function () { return StorageBrowserPolicy_js_1.StorageBrowserPolicy; } });
|
|
8
|
+
/**
|
|
9
|
+
* StorageBrowserPolicyFactory is a factory class helping generating StorageBrowserPolicy objects.
|
|
10
|
+
*/
|
|
11
|
+
class StorageBrowserPolicyFactory {
|
|
12
|
+
/**
|
|
13
|
+
* Creates a StorageBrowserPolicyFactory object.
|
|
14
|
+
*
|
|
15
|
+
* @param nextPolicy -
|
|
16
|
+
* @param options -
|
|
17
|
+
*/
|
|
18
|
+
create(nextPolicy, options) {
|
|
19
|
+
return new StorageBrowserPolicy_js_1.StorageBrowserPolicy(nextPolicy, options);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.StorageBrowserPolicyFactory = StorageBrowserPolicyFactory;
|
|
23
|
+
//# sourceMappingURL=StorageBrowserPolicyFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageBrowserPolicyFactory.js","sourceRoot":"","sources":["../../src/StorageBrowserPolicyFactory.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAOlC,gFAA0E;AACjE,qGADA,8CAAoB,OACA;AAE7B;;GAEG;AACH,MAAa,2BAA2B;IACtC;;;;;OAKG;IACI,MAAM,CAAC,UAAyB,EAAE,OAA6B;QACpE,OAAO,IAAI,8CAAoB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACvD,CAAC;CACF;AAVD,kEAUC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n RequestPolicy,\n RequestPolicyOptionsLike as RequestPolicyOptions,\n RequestPolicyFactory,\n} from \"@azure/core-http-compat\";\nimport { StorageBrowserPolicy } from \"./policies/StorageBrowserPolicy.js\";\nexport { StorageBrowserPolicy };\n\n/**\n * StorageBrowserPolicyFactory is a factory class helping generating StorageBrowserPolicy objects.\n */\nexport class StorageBrowserPolicyFactory implements RequestPolicyFactory {\n /**\n * Creates a StorageBrowserPolicyFactory object.\n *\n * @param nextPolicy -\n * @param options -\n */\n public create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): StorageBrowserPolicy {\n return new StorageBrowserPolicy(nextPolicy, options);\n }\n}\n"]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { RequestPolicy, RequestPolicyOptionsLike as RequestPolicyOptions, RequestPolicyFactory } from "@azure/core-http-compat";
|
|
2
|
+
import { StorageRetryPolicy } from "./policies/StorageRetryPolicy.js";
|
|
3
|
+
import { StorageRetryPolicyType } from "./policies/StorageRetryPolicyType.js";
|
|
4
|
+
export { StorageRetryPolicyType, StorageRetryPolicy };
|
|
5
|
+
/**
|
|
6
|
+
* Storage Blob retry options interface.
|
|
7
|
+
*/
|
|
8
|
+
export interface StorageRetryOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Optional. StorageRetryPolicyType, default is exponential retry policy.
|
|
11
|
+
*/
|
|
12
|
+
readonly retryPolicyType?: StorageRetryPolicyType;
|
|
13
|
+
/**
|
|
14
|
+
* Optional. Max try number of attempts, default is 4.
|
|
15
|
+
* A value of 1 means 1 try and no retries.
|
|
16
|
+
* A value smaller than 1 means default retry number of attempts.
|
|
17
|
+
*/
|
|
18
|
+
readonly maxTries?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Optional. Indicates the maximum time in ms allowed for any single try of an HTTP request.
|
|
21
|
+
* A value of zero or undefined means no default timeout on SDK client, Azure
|
|
22
|
+
* Storage server's default timeout policy will be used.
|
|
23
|
+
*
|
|
24
|
+
* @see https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-blob-service-operations
|
|
25
|
+
*/
|
|
26
|
+
readonly tryTimeoutInMs?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Optional. Specifies the amount of delay to use before retrying an operation (default is 4s or 4 * 1000ms).
|
|
29
|
+
* The delay increases (exponentially or linearly) with each retry up to a maximum specified by
|
|
30
|
+
* maxRetryDelayInMs. If you specify 0, then you must also specify 0 for maxRetryDelayInMs.
|
|
31
|
+
*/
|
|
32
|
+
readonly retryDelayInMs?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Optional. Specifies the maximum delay allowed before retrying an operation (default is 120s or 120 * 1000ms).
|
|
35
|
+
* If you specify 0, then you must also specify 0 for retryDelayInMs.
|
|
36
|
+
*/
|
|
37
|
+
readonly maxRetryDelayInMs?: number;
|
|
38
|
+
/**
|
|
39
|
+
* If a secondaryHost is specified, retries will be tried against this host. If secondaryHost is undefined
|
|
40
|
+
* (the default) then operations are not retried against another host.
|
|
41
|
+
*
|
|
42
|
+
* NOTE: Before setting this field, make sure you understand the issues around
|
|
43
|
+
* reading stale and potentially-inconsistent data at
|
|
44
|
+
* {@link https://learn.microsoft.com/en-us/azure/storage/common/storage-designing-ha-apps-with-ragrs}
|
|
45
|
+
*/
|
|
46
|
+
readonly secondaryHost?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* StorageRetryPolicyFactory is a factory class helping generating {@link StorageRetryPolicy} objects.
|
|
50
|
+
*/
|
|
51
|
+
export declare class StorageRetryPolicyFactory implements RequestPolicyFactory {
|
|
52
|
+
private retryOptions?;
|
|
53
|
+
/**
|
|
54
|
+
* Creates an instance of StorageRetryPolicyFactory.
|
|
55
|
+
* @param retryOptions -
|
|
56
|
+
*/
|
|
57
|
+
constructor(retryOptions?: StorageRetryOptions);
|
|
58
|
+
/**
|
|
59
|
+
* Creates a StorageRetryPolicy object.
|
|
60
|
+
*
|
|
61
|
+
* @param nextPolicy -
|
|
62
|
+
* @param options -
|
|
63
|
+
*/
|
|
64
|
+
create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): StorageRetryPolicy;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=StorageRetryPolicyFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageRetryPolicyFactory.d.ts","sourceRoot":"","sources":["../../src/StorageRetryPolicyFactory.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,IAAI,oBAAoB,EAChD,oBAAoB,EACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAE9E,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,sBAAsB,CAAC;IAElD;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAE3B;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAEjC;;;;OAIG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IAEjC;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAEpC;;;;;;;OAOG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;GAEG;AACH,qBAAa,yBAA0B,YAAW,oBAAoB;IACpE,OAAO,CAAC,YAAY,CAAC,CAAsB;IAE3C;;;OAGG;gBACS,YAAY,CAAC,EAAE,mBAAmB;IAI9C;;;;;OAKG;IACI,MAAM,CAAC,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,oBAAoB,GAAG,kBAAkB;CAG5F"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.StorageRetryPolicyFactory = exports.StorageRetryPolicy = exports.StorageRetryPolicyType = void 0;
|
|
6
|
+
const StorageRetryPolicy_js_1 = require("./policies/StorageRetryPolicy.js");
|
|
7
|
+
Object.defineProperty(exports, "StorageRetryPolicy", { enumerable: true, get: function () { return StorageRetryPolicy_js_1.StorageRetryPolicy; } });
|
|
8
|
+
const StorageRetryPolicyType_js_1 = require("./policies/StorageRetryPolicyType.js");
|
|
9
|
+
Object.defineProperty(exports, "StorageRetryPolicyType", { enumerable: true, get: function () { return StorageRetryPolicyType_js_1.StorageRetryPolicyType; } });
|
|
10
|
+
/**
|
|
11
|
+
* StorageRetryPolicyFactory is a factory class helping generating {@link StorageRetryPolicy} objects.
|
|
12
|
+
*/
|
|
13
|
+
class StorageRetryPolicyFactory {
|
|
14
|
+
retryOptions;
|
|
15
|
+
/**
|
|
16
|
+
* Creates an instance of StorageRetryPolicyFactory.
|
|
17
|
+
* @param retryOptions -
|
|
18
|
+
*/
|
|
19
|
+
constructor(retryOptions) {
|
|
20
|
+
this.retryOptions = retryOptions;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates a StorageRetryPolicy object.
|
|
24
|
+
*
|
|
25
|
+
* @param nextPolicy -
|
|
26
|
+
* @param options -
|
|
27
|
+
*/
|
|
28
|
+
create(nextPolicy, options) {
|
|
29
|
+
return new StorageRetryPolicy_js_1.StorageRetryPolicy(nextPolicy, options, this.retryOptions);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.StorageRetryPolicyFactory = StorageRetryPolicyFactory;
|
|
33
|
+
//# sourceMappingURL=StorageRetryPolicyFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StorageRetryPolicyFactory.js","sourceRoot":"","sources":["../../src/StorageRetryPolicyFactory.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAOlC,4EAAsE;AAGrC,mGAHxB,0CAAkB,OAGwB;AAFnD,oFAA8E;AAErE,uGAFA,kDAAsB,OAEA;AAmD/B;;GAEG;AACH,MAAa,yBAAyB;IAC5B,YAAY,CAAuB;IAE3C;;;OAGG;IACH,YAAY,YAAkC;QAC5C,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,UAAyB,EAAE,OAA6B;QACpE,OAAO,IAAI,0CAAkB,CAAC,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;IACxE,CAAC;CACF;AApBD,8DAoBC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n RequestPolicy,\n RequestPolicyOptionsLike as RequestPolicyOptions,\n RequestPolicyFactory,\n} from \"@azure/core-http-compat\";\nimport { StorageRetryPolicy } from \"./policies/StorageRetryPolicy.js\";\nimport { StorageRetryPolicyType } from \"./policies/StorageRetryPolicyType.js\";\n\nexport { StorageRetryPolicyType, StorageRetryPolicy };\n\n/**\n * Storage Blob retry options interface.\n */\nexport interface StorageRetryOptions {\n /**\n * Optional. StorageRetryPolicyType, default is exponential retry policy.\n */\n readonly retryPolicyType?: StorageRetryPolicyType;\n\n /**\n * Optional. Max try number of attempts, default is 4.\n * A value of 1 means 1 try and no retries.\n * A value smaller than 1 means default retry number of attempts.\n */\n readonly maxTries?: number;\n\n /**\n * Optional. Indicates the maximum time in ms allowed for any single try of an HTTP request.\n * A value of zero or undefined means no default timeout on SDK client, Azure\n * Storage server's default timeout policy will be used.\n *\n * @see https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-blob-service-operations\n */\n readonly tryTimeoutInMs?: number;\n\n /**\n * Optional. Specifies the amount of delay to use before retrying an operation (default is 4s or 4 * 1000ms).\n * The delay increases (exponentially or linearly) with each retry up to a maximum specified by\n * maxRetryDelayInMs. If you specify 0, then you must also specify 0 for maxRetryDelayInMs.\n */\n readonly retryDelayInMs?: number;\n\n /**\n * Optional. Specifies the maximum delay allowed before retrying an operation (default is 120s or 120 * 1000ms).\n * If you specify 0, then you must also specify 0 for retryDelayInMs.\n */\n readonly maxRetryDelayInMs?: number;\n\n /**\n * If a secondaryHost is specified, retries will be tried against this host. If secondaryHost is undefined\n * (the default) then operations are not retried against another host.\n *\n * NOTE: Before setting this field, make sure you understand the issues around\n * reading stale and potentially-inconsistent data at\n * {@link https://learn.microsoft.com/en-us/azure/storage/common/storage-designing-ha-apps-with-ragrs}\n */\n readonly secondaryHost?: string;\n}\n\n/**\n * StorageRetryPolicyFactory is a factory class helping generating {@link StorageRetryPolicy} objects.\n */\nexport class StorageRetryPolicyFactory implements RequestPolicyFactory {\n private retryOptions?: StorageRetryOptions;\n\n /**\n * Creates an instance of StorageRetryPolicyFactory.\n * @param retryOptions -\n */\n constructor(retryOptions?: StorageRetryOptions) {\n this.retryOptions = retryOptions;\n }\n\n /**\n * Creates a StorageRetryPolicy object.\n *\n * @param nextPolicy -\n * @param options -\n */\n public create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): StorageRetryPolicy {\n return new StorageRetryPolicy(nextPolicy, options, this.retryOptions);\n }\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RequestPolicy, RequestPolicyOptionsLike as RequestPolicyOptions } from "@azure/core-http-compat";
|
|
2
|
+
import { AnonymousCredentialPolicy } from "../policies/AnonymousCredentialPolicy.js";
|
|
3
|
+
import { Credential } from "./Credential.js";
|
|
4
|
+
/**
|
|
5
|
+
* AnonymousCredential provides a credentialPolicyCreator member used to create
|
|
6
|
+
* AnonymousCredentialPolicy objects. AnonymousCredentialPolicy is used with
|
|
7
|
+
* HTTP(S) requests that read public resources or for use with Shared Access
|
|
8
|
+
* Signatures (SAS).
|
|
9
|
+
*/
|
|
10
|
+
export declare class AnonymousCredential extends Credential {
|
|
11
|
+
/**
|
|
12
|
+
* Creates an {@link AnonymousCredentialPolicy} object.
|
|
13
|
+
*
|
|
14
|
+
* @param nextPolicy -
|
|
15
|
+
* @param options -
|
|
16
|
+
*/
|
|
17
|
+
create(nextPolicy: RequestPolicy, options: RequestPolicyOptions): AnonymousCredentialPolicy;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=AnonymousCredential.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnonymousCredential.d.ts","sourceRoot":"","sources":["../../../src/credentials/AnonymousCredential.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,wBAAwB,IAAI,oBAAoB,EACjD,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;;GAKG;AACH,qBAAa,mBAAoB,SAAQ,UAAU;IACjD;;;;;OAKG;IACI,MAAM,CACX,UAAU,EAAE,aAAa,EACzB,OAAO,EAAE,oBAAoB,GAC5B,yBAAyB;CAG7B"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.AnonymousCredential = void 0;
|
|
6
|
+
const AnonymousCredentialPolicy_js_1 = require("../policies/AnonymousCredentialPolicy.js");
|
|
7
|
+
const Credential_js_1 = require("./Credential.js");
|
|
8
|
+
/**
|
|
9
|
+
* AnonymousCredential provides a credentialPolicyCreator member used to create
|
|
10
|
+
* AnonymousCredentialPolicy objects. AnonymousCredentialPolicy is used with
|
|
11
|
+
* HTTP(S) requests that read public resources or for use with Shared Access
|
|
12
|
+
* Signatures (SAS).
|
|
13
|
+
*/
|
|
14
|
+
class AnonymousCredential extends Credential_js_1.Credential {
|
|
15
|
+
/**
|
|
16
|
+
* Creates an {@link AnonymousCredentialPolicy} object.
|
|
17
|
+
*
|
|
18
|
+
* @param nextPolicy -
|
|
19
|
+
* @param options -
|
|
20
|
+
*/
|
|
21
|
+
create(nextPolicy, options) {
|
|
22
|
+
return new AnonymousCredentialPolicy_js_1.AnonymousCredentialPolicy(nextPolicy, options);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.AnonymousCredential = AnonymousCredential;
|
|
26
|
+
//# sourceMappingURL=AnonymousCredential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnonymousCredential.js","sourceRoot":"","sources":["../../../src/credentials/AnonymousCredential.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAMlC,2FAAqF;AACrF,mDAA6C;AAE7C;;;;;GAKG;AACH,MAAa,mBAAoB,SAAQ,0BAAU;IACjD;;;;;OAKG;IACI,MAAM,CACX,UAAyB,EACzB,OAA6B;QAE7B,OAAO,IAAI,wDAAyB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;CACF;AAbD,kDAaC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n RequestPolicy,\n RequestPolicyOptionsLike as RequestPolicyOptions,\n} from \"@azure/core-http-compat\";\nimport { AnonymousCredentialPolicy } from \"../policies/AnonymousCredentialPolicy.js\";\nimport { Credential } from \"./Credential.js\";\n\n/**\n * AnonymousCredential provides a credentialPolicyCreator member used to create\n * AnonymousCredentialPolicy objects. AnonymousCredentialPolicy is used with\n * HTTP(S) requests that read public resources or for use with Shared Access\n * Signatures (SAS).\n */\nexport class AnonymousCredential extends Credential {\n /**\n * Creates an {@link AnonymousCredentialPolicy} object.\n *\n * @param nextPolicy -\n * @param options -\n */\n public create(\n nextPolicy: RequestPolicy,\n options: RequestPolicyOptions,\n ): AnonymousCredentialPolicy {\n return new AnonymousCredentialPolicy(nextPolicy, options);\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RequestPolicy, RequestPolicyFactory, RequestPolicyOptionsLike as RequestPolicyOptions } from "@azure/core-http-compat";
|
|
2
|
+
import type { CredentialPolicy } from "../policies/CredentialPolicy.js";
|
|
3
|
+
/**
|
|
4
|
+
* Credential is an abstract class for Azure Storage HTTP requests signing. This
|
|
5
|
+
* class will host an credentialPolicyCreator factory which generates CredentialPolicy.
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class Credential implements RequestPolicyFactory {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a RequestPolicy object.
|
|
10
|
+
*
|
|
11
|
+
* @param _nextPolicy -
|
|
12
|
+
* @param _options -
|
|
13
|
+
*/
|
|
14
|
+
create(_nextPolicy: RequestPolicy, _options: RequestPolicyOptions): RequestPolicy;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A factory function that creates a new CredentialPolicy that uses the provided nextPolicy.
|
|
18
|
+
*/
|
|
19
|
+
export type CredentialPolicyCreator = (nextPolicy: RequestPolicy, options: RequestPolicyOptions) => CredentialPolicy;
|
|
20
|
+
//# sourceMappingURL=Credential.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Credential.d.ts","sourceRoot":"","sources":["../../../src/credentials/Credential.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACpB,wBAAwB,IAAI,oBAAoB,EACjD,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAExE;;;GAGG;AACH,8BAAsB,UAAW,YAAW,oBAAoB;IAC9D;;;;;OAKG;IACI,MAAM,CAAC,WAAW,EAAE,aAAa,EAAE,QAAQ,EAAE,oBAAoB,GAAG,aAAa;CAGzF;AAED;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CACpC,UAAU,EAAE,aAAa,EACzB,OAAO,EAAE,oBAAoB,KAC1B,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.Credential = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* Credential is an abstract class for Azure Storage HTTP requests signing. This
|
|
8
|
+
* class will host an credentialPolicyCreator factory which generates CredentialPolicy.
|
|
9
|
+
*/
|
|
10
|
+
class Credential {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a RequestPolicy object.
|
|
13
|
+
*
|
|
14
|
+
* @param _nextPolicy -
|
|
15
|
+
* @param _options -
|
|
16
|
+
*/
|
|
17
|
+
create(_nextPolicy, _options) {
|
|
18
|
+
throw new Error("Method should be implemented in children classes.");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.Credential = Credential;
|
|
22
|
+
//# sourceMappingURL=Credential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Credential.js","sourceRoot":"","sources":["../../../src/credentials/Credential.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AASlC;;;GAGG;AACH,MAAsB,UAAU;IAC9B;;;;;OAKG;IACI,MAAM,CAAC,WAA0B,EAAE,QAA8B;QACtE,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;CACF;AAVD,gCAUC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n RequestPolicy,\n RequestPolicyFactory,\n RequestPolicyOptionsLike as RequestPolicyOptions,\n} from \"@azure/core-http-compat\";\nimport type { CredentialPolicy } from \"../policies/CredentialPolicy.js\";\n\n/**\n * Credential is an abstract class for Azure Storage HTTP requests signing. This\n * class will host an credentialPolicyCreator factory which generates CredentialPolicy.\n */\nexport abstract class Credential implements RequestPolicyFactory {\n /**\n * Creates a RequestPolicy object.\n *\n * @param _nextPolicy -\n * @param _options -\n */\n public create(_nextPolicy: RequestPolicy, _options: RequestPolicyOptions): RequestPolicy {\n throw new Error(\"Method should be implemented in children classes.\");\n }\n}\n\n/**\n * A factory function that creates a new CredentialPolicy that uses the provided nextPolicy.\n */\nexport type CredentialPolicyCreator = (\n nextPolicy: RequestPolicy,\n options: RequestPolicyOptions,\n) => CredentialPolicy;\n"]}
|