@azure/storage-file-share 12.26.0-beta.1 → 12.27.0-alpha.20250217.1
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +3 -3
- package/README.md +16 -18
- package/dist/index.js +1428 -431
- package/dist/index.js.map +1 -1
- package/dist-esm/storage-blob/src/BatchResponse.js.map +1 -1
- package/dist-esm/storage-blob/src/BatchResponseParser.js +1 -1
- package/dist-esm/storage-blob/src/BatchResponseParser.js.map +1 -1
- package/dist-esm/storage-blob/src/BatchUtils.js.map +1 -1
- package/dist-esm/storage-blob/src/BlobBatch.js +1 -1
- package/dist-esm/storage-blob/src/BlobBatch.js.map +1 -1
- package/dist-esm/storage-blob/src/BlobBatchClient.js +3 -3
- package/dist-esm/storage-blob/src/BlobBatchClient.js.map +1 -1
- package/dist-esm/storage-blob/src/BlobDownloadResponse.js +1 -1
- package/dist-esm/storage-blob/src/BlobDownloadResponse.js.map +1 -1
- package/dist-esm/storage-blob/src/BlobLeaseClient.js +10 -10
- package/dist-esm/storage-blob/src/BlobLeaseClient.js.map +1 -1
- package/dist-esm/storage-blob/src/BlobQueryResponse.js.map +1 -1
- package/dist-esm/storage-blob/src/BlobServiceClient.js +12 -14
- package/dist-esm/storage-blob/src/BlobServiceClient.js.map +1 -1
- package/dist-esm/storage-blob/src/Clients.js +47 -48
- package/dist-esm/storage-blob/src/Clients.js.map +1 -1
- package/dist-esm/storage-blob/src/ContainerClient.js +20 -21
- package/dist-esm/storage-blob/src/ContainerClient.js.map +1 -1
- package/dist-esm/storage-blob/src/PageBlobRangeResponse.js.map +1 -1
- package/dist-esm/storage-blob/src/Pipeline.js.map +1 -1
- package/dist-esm/storage-blob/src/Range.js.map +1 -1
- package/dist-esm/storage-blob/src/StorageBrowserPolicyFactory.js.map +1 -1
- package/dist-esm/storage-blob/src/StorageClient.js.map +1 -1
- package/dist-esm/storage-blob/src/StorageContextClient.js.map +1 -1
- package/dist-esm/storage-blob/src/StorageRetryPolicyFactory.js.map +1 -1
- package/dist-esm/storage-blob/src/credentials/AnonymousCredential.js.map +1 -1
- package/dist-esm/storage-blob/src/credentials/Credential.js.map +1 -1
- package/dist-esm/storage-blob/src/credentials/StorageSharedKeyCredential.js.map +1 -1
- package/dist-esm/storage-blob/src/credentials/UserDelegationKeyCredential.js +1 -1
- package/dist-esm/storage-blob/src/credentials/UserDelegationKeyCredential.js.map +1 -1
- package/dist-esm/storage-blob/src/generated/src/storageClient.js +1 -1
- package/dist-esm/storage-blob/src/generated/src/storageClient.js.map +1 -1
- package/dist-esm/storage-blob/src/generatedModels.js.map +1 -1
- package/dist-esm/storage-blob/src/models.js +2 -2
- package/dist-esm/storage-blob/src/models.js.map +1 -1
- package/dist-esm/storage-blob/src/policies/AnonymousCredentialPolicy.js.map +1 -1
- package/dist-esm/storage-blob/src/policies/CredentialPolicy.js.map +1 -1
- package/dist-esm/storage-blob/src/policies/RequestPolicy.js.map +1 -1
- package/dist-esm/storage-blob/src/policies/StorageBrowserPolicy.js.map +1 -1
- package/dist-esm/storage-blob/src/policies/StorageBrowserPolicyV2.js.map +1 -1
- package/dist-esm/storage-blob/src/policies/StorageCorrectContentLengthPolicy.browser.js.map +1 -1
- package/dist-esm/storage-blob/src/policies/StorageCorrectContentLengthPolicy.js.map +1 -1
- package/dist-esm/storage-blob/src/policies/StorageRetryPolicy.js.map +1 -1
- package/dist-esm/storage-blob/src/policies/StorageRetryPolicyV2.js +1 -1
- package/dist-esm/storage-blob/src/policies/StorageRetryPolicyV2.js.map +1 -1
- package/dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicy.js +2 -2
- package/dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicy.js.map +1 -1
- package/dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicyV2.browser.js.map +1 -1
- package/dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicyV2.js +2 -2
- package/dist-esm/storage-blob/src/policies/StorageSharedKeyCredentialPolicyV2.js.map +1 -1
- package/dist-esm/storage-blob/src/pollers/BlobStartCopyFromUrlPoller.js.map +1 -1
- package/dist-esm/storage-blob/src/sas/AccountSASPermissions.js +2 -2
- package/dist-esm/storage-blob/src/sas/AccountSASPermissions.js.map +1 -1
- package/dist-esm/storage-blob/src/sas/AccountSASResourceTypes.js +1 -1
- package/dist-esm/storage-blob/src/sas/AccountSASResourceTypes.js.map +1 -1
- package/dist-esm/storage-blob/src/sas/AccountSASSignatureValues.js +1 -1
- package/dist-esm/storage-blob/src/sas/AccountSASSignatureValues.js.map +1 -1
- package/dist-esm/storage-blob/src/sas/BlobSASSignatureValues.js +1 -1
- package/dist-esm/storage-blob/src/sas/BlobSASSignatureValues.js.map +1 -1
- package/dist-esm/storage-blob/src/sas/ContainerSASPermissions.js +1 -1
- package/dist-esm/storage-blob/src/sas/ContainerSASPermissions.js.map +1 -1
- package/dist-esm/storage-blob/src/sas/SASQueryParameters.js.map +1 -1
- package/dist-esm/storage-blob/src/utils/BlobQuickQueryStream.js.map +1 -1
- package/dist-esm/storage-blob/src/utils/RetriableReadableStream.js.map +1 -1
- package/dist-esm/storage-blob/src/utils/cache.js.map +1 -1
- package/dist-esm/storage-blob/src/utils/constants.js +1 -1
- package/dist-esm/storage-blob/src/utils/constants.js.map +1 -1
- package/dist-esm/storage-blob/src/utils/utils.common.js +3 -3
- package/dist-esm/storage-blob/src/utils/utils.common.js.map +1 -1
- package/dist-esm/storage-blob/src/utils/utils.node.js +1 -1
- package/dist-esm/storage-blob/src/utils/utils.node.js.map +1 -1
- package/dist-esm/storage-file-share/src/AccountSASPermissions.js +2 -2
- package/dist-esm/storage-file-share/src/AccountSASPermissions.js.map +1 -1
- package/dist-esm/storage-file-share/src/AccountSASResourceTypes.js +1 -1
- package/dist-esm/storage-file-share/src/AccountSASResourceTypes.js.map +1 -1
- package/dist-esm/storage-file-share/src/AccountSASSignatureValues.js +1 -1
- package/dist-esm/storage-file-share/src/AccountSASSignatureValues.js.map +1 -1
- package/dist-esm/storage-file-share/src/Clients.js +103 -79
- package/dist-esm/storage-file-share/src/Clients.js.map +1 -1
- package/dist-esm/storage-file-share/src/FileDownloadResponse.js +25 -1
- package/dist-esm/storage-file-share/src/FileDownloadResponse.js.map +1 -1
- package/dist-esm/storage-file-share/src/FileSASSignatureValues.js.map +1 -1
- package/dist-esm/storage-file-share/src/FileSystemAttributes.js +1 -1
- package/dist-esm/storage-file-share/src/FileSystemAttributes.js.map +1 -1
- package/dist-esm/storage-file-share/src/Pipeline.js.map +1 -1
- package/dist-esm/storage-file-share/src/Range.js.map +1 -1
- package/dist-esm/storage-file-share/src/SASQueryParameters.js.map +1 -1
- package/dist-esm/storage-file-share/src/ShareClientInternal.js.map +1 -1
- package/dist-esm/storage-file-share/src/ShareSASPermissions.js +1 -1
- package/dist-esm/storage-file-share/src/ShareSASPermissions.js.map +1 -1
- package/dist-esm/storage-file-share/src/ShareServiceClient.js +13 -7
- package/dist-esm/storage-file-share/src/ShareServiceClient.js.map +1 -1
- package/dist-esm/storage-file-share/src/StorageClient.js.map +1 -1
- package/dist-esm/storage-file-share/src/StorageContextClient.js.map +1 -1
- package/dist-esm/storage-file-share/src/StorageRetryPolicyFactory.js.map +1 -1
- package/dist-esm/storage-file-share/src/generated/src/models/index.js +10 -0
- package/dist-esm/storage-file-share/src/generated/src/models/index.js.map +1 -1
- package/dist-esm/storage-file-share/src/generated/src/models/mappers.js +544 -0
- package/dist-esm/storage-file-share/src/generated/src/models/mappers.js.map +1 -1
- package/dist-esm/storage-file-share/src/generated/src/models/parameters.js +108 -3
- package/dist-esm/storage-file-share/src/generated/src/models/parameters.js.map +1 -1
- package/dist-esm/storage-file-share/src/generated/src/operations/directory.js +12 -10
- package/dist-esm/storage-file-share/src/generated/src/operations/directory.js.map +1 -1
- package/dist-esm/storage-file-share/src/generated/src/operations/file.js +125 -10
- package/dist-esm/storage-file-share/src/generated/src/operations/file.js.map +1 -1
- package/dist-esm/storage-file-share/src/generated/src/operationsInterfaces/directory.js.map +1 -1
- package/dist-esm/storage-file-share/src/generated/src/operationsInterfaces/file.js.map +1 -1
- package/dist-esm/storage-file-share/src/generated/src/storageClient.js +2 -2
- package/dist-esm/storage-file-share/src/generated/src/storageClient.js.map +1 -1
- package/dist-esm/storage-file-share/src/generatedModels.js.map +1 -1
- package/dist-esm/storage-file-share/src/index.browser.js +1 -0
- package/dist-esm/storage-file-share/src/index.browser.js.map +1 -1
- package/dist-esm/storage-file-share/src/index.js +1 -0
- package/dist-esm/storage-file-share/src/index.js.map +1 -1
- package/dist-esm/storage-file-share/src/models.js +0 -21
- package/dist-esm/storage-file-share/src/models.js.map +1 -1
- package/dist-esm/storage-file-share/src/policies/StorageRetryPolicy.js.map +1 -1
- package/dist-esm/storage-file-share/src/policies/StorageRetryPolicyV2.js +1 -1
- package/dist-esm/storage-file-share/src/policies/StorageRetryPolicyV2.js.map +1 -1
- package/dist-esm/storage-file-share/src/utils/BufferScheduler.js.map +1 -1
- package/dist-esm/storage-file-share/src/utils/RetriableReadableStream.js.map +1 -1
- package/dist-esm/storage-file-share/src/utils/constants.js +2 -2
- package/dist-esm/storage-file-share/src/utils/constants.js.map +1 -1
- package/dist-esm/storage-file-share/src/utils/utils.common.js +214 -3
- package/dist-esm/storage-file-share/src/utils/utils.common.js.map +1 -1
- package/package.json +11 -15
- package/types/latest/storage-file-share.d.ts +978 -144
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generatedModels.js","sourceRoot":"","sources":["../../../src/generatedModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAmSlC,yEAAyE;AACzE,MAAM,CAAN,IAAY,qBAEX;AAFD,WAAY,qBAAqB;IAC/B,0CAAiB,CAAA;AACnB,CAAC,EAFW,qBAAqB,KAArB,qBAAqB,QAEhC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n DirectoryCreateHeaders,\n DirectoryDeleteHeaders,\n DirectoryGetPropertiesHeaders,\n DirectoryListFilesAndDirectoriesSegmentHeaders,\n DirectoryListHandlesHeaders,\n DirectoryRenameHeaders,\n DirectorySetMetadataHeaders,\n DirectorySetPropertiesHeaders,\n FileAbortCopyHeaders,\n FileCreateHeaders,\n FileDeleteHeaders,\n FileDownloadHeaders,\n FileDownloadResponse,\n FileGetPropertiesHeaders,\n FileGetRangeListHeaders,\n FileListHandlesHeaders,\n FileProperty,\n FileRenameHeaders,\n FileServiceProperties,\n FileSetHttpHeadersHeaders,\n FileSetMetadataHeaders,\n FileStartCopyHeaders,\n FileUploadRangeFromURLHeaders,\n FileUploadRangeHeaders,\n ServiceGetPropertiesHeaders,\n ServiceSetPropertiesHeaders,\n ShareCreateHeaders,\n ShareCreatePermissionHeaders,\n ShareCreateSnapshotHeaders,\n ShareDeleteHeaders,\n ShareFileRangeList,\n ShareGetAccessPolicyHeaders,\n ShareGetPermissionHeaders,\n ShareGetPropertiesHeaders,\n ShareGetStatisticsHeaders,\n SharePermission,\n ShareSetAccessPolicyHeaders,\n ShareSetMetadataHeaders,\n ShareStats,\n} from \"./generated/src/models\";\n\n/** Contains response data for the create operation. */\nexport type DirectoryCreateResponse = WithResponse<DirectoryCreateHeaders, DirectoryCreateHeaders>;\n\n/** Contains response data for the delete operation. */\nexport type DirectoryDeleteResponse = WithResponse<DirectoryDeleteHeaders, DirectoryDeleteHeaders>;\n\n/** Contains response data for the getProperties operation. */\nexport type DirectoryGetPropertiesResponse = WithResponse<\n DirectoryGetPropertiesHeaders,\n DirectoryGetPropertiesHeaders\n>;\n\n/** Contains response data for the listFilesAndDirectoriesSegment operation. */\nexport type DirectoryListFilesAndDirectoriesSegmentResponse = WithResponse<\n DirectoryListFilesAndDirectoriesSegmentHeaders & ListFilesAndDirectoriesSegmentResponse,\n DirectoryListFilesAndDirectoriesSegmentHeaders,\n ListFilesAndDirectoriesSegmentResponse\n>;\n\n/** Contains response data for the listHandles operation. */\nexport type DirectoryListHandlesResponse = WithResponse<\n DirectoryListHandlesHeaders & ListHandlesResponse,\n DirectoryListHandlesHeaders,\n ListHandlesResponse\n>;\n\n/** Contains response data for the setMetadata operation. */\nexport type DirectorySetMetadataResponse = WithResponse<\n DirectorySetMetadataHeaders,\n DirectorySetMetadataHeaders\n>;\n\n/** Contains response data for the setProperties operation. */\nexport type DirectorySetPropertiesResponse = WithResponse<\n DirectorySetPropertiesHeaders,\n DirectorySetPropertiesHeaders\n>;\n\n/** Contains response data for the abortCopy operation. */\nexport type FileAbortCopyResponse = WithResponse<FileAbortCopyHeaders, FileAbortCopyHeaders>;\n\n/** Contains response data for the create operation. */\nexport type FileCreateResponse = WithResponse<FileCreateHeaders, FileCreateHeaders>;\n\n/** Contains response data for the delete operation. */\nexport type FileDeleteResponse = WithResponse<FileDeleteHeaders, FileDeleteHeaders>;\n\n/** Contains response data for the getProperties operation. */\nexport type FileGetPropertiesResponse = WithResponse<\n FileGetPropertiesHeaders,\n FileGetPropertiesHeaders\n>;\n\n/** Contains response data for the listHandles operation. */\nexport type FileListHandlesResponse = WithResponse<\n FileListHandlesHeaders & ListHandlesResponse,\n FileListHandlesHeaders,\n ListHandlesResponse\n>;\n\n/** Contains response data for the setMetadata operation. */\nexport type FileSetMetadataResponse = WithResponse<FileSetMetadataHeaders, FileSetMetadataHeaders>;\n\n/** Contains response data for the startCopy operation. */\nexport type FileStartCopyResponse = WithResponse<FileStartCopyHeaders, FileStartCopyHeaders>;\n\n/** Contains response data for the uploadRange operation. */\nexport type FileUploadRangeResponse = WithResponse<FileUploadRangeHeaders, FileUploadRangeHeaders>;\n\n/** Contains response data for the getProperties operation. */\nexport type ServiceGetPropertiesResponse = WithResponse<\n ServiceGetPropertiesHeaders & FileServiceProperties,\n ServiceGetPropertiesHeaders,\n FileServiceProperties\n>;\n\n/** Contains response data for the setProperties operation. */\nexport type ServiceSetPropertiesResponse = WithResponse<\n ServiceSetPropertiesHeaders,\n ServiceSetPropertiesHeaders\n>;\n\n/** Contains response data for the createPermission operation. */\nexport type ShareCreatePermissionResponse = WithResponse<\n ShareCreatePermissionHeaders,\n ShareCreatePermissionHeaders\n>;\n\n/** Contains response data for the create operation. */\nexport type ShareCreateResponse = WithResponse<ShareCreateHeaders, ShareCreateHeaders>;\n\n/** Contains response data for the createSnapshot operation. */\nexport type ShareCreateSnapshotResponse = WithResponse<\n ShareCreateSnapshotHeaders,\n ShareCreateSnapshotHeaders\n>;\n\n/** Contains response data for the delete operation. */\nexport type ShareDeleteResponse = WithResponse<ShareDeleteHeaders, ShareDeleteHeaders>;\n\n/** Contains response data for the getPermission operation. */\nexport type ShareGetPermissionResponse = WithResponse<\n ShareGetPermissionHeaders & SharePermission,\n ShareGetPermissionHeaders,\n SharePermission\n>;\n\n/** Contains response data for the setAccessPolicy operation. */\nexport type ShareSetAccessPolicyResponse = WithResponse<\n ShareSetAccessPolicyHeaders,\n ShareGetAccessPolicyHeaders\n>;\n\n/** Contains response data for the setMetadata operation. */\nexport type ShareSetMetadataResponse = WithResponse<\n ShareSetMetadataHeaders,\n ShareSetMetadataHeaders\n>;\n\n/** Contains response data for the setProperties operation. */\nexport type ShareSetPropertiesResponse = WithResponse<\n ShareSetPropertiesHeaders,\n ShareSetPropertiesHeaders\n>;\n\n/** Contains response data for the rename operation. */\nexport type DirectoryRenameResponse = WithResponse<DirectoryRenameHeaders, DirectoryRenameHeaders>;\n\n/** Contains response data for the download operation. */\nexport type FileDownloadResponseModel = WithResponse<FileDownloadResponse, FileDownloadHeaders>;\n\n/** Contains response data for the uploadRangeFromURL operation. */\nexport type FileUploadRangeFromURLResponse = WithResponse<\n FileUploadRangeFromURLHeaders,\n FileUploadRangeFromURLHeaders\n>;\n\n/** Contains response data for the getProperties operation. */\nexport type ShareGetPropertiesResponseModel = WithResponse<\n ShareGetPropertiesHeaders,\n ShareGetPropertiesHeaders\n>;\n\n/** Contains response data for the getStatistics operation. */\nexport type ShareGetStatisticsResponseModel = WithResponse<\n ShareGetStatisticsHeaders & ShareStats,\n ShareGetStatisticsHeaders,\n ShareStats\n>;\n\n/** Contains response data for the getRangeList operation. */\nexport type FileGetRangeListDiffResponse = WithResponse<\n FileGetRangeListHeaders & ShareFileRangeList,\n FileGetRangeListHeaders,\n ShareFileRangeList\n>;\n\n/** Contains response data for the setHttpHeaders operation. */\nexport type FileSetHTTPHeadersResponse = WithResponse<\n FileSetHttpHeadersHeaders,\n FileSetHttpHeadersHeaders\n>;\n\n/** Contains response data for the rename operation. */\nexport type FileRenameResponse = WithResponse<FileRenameHeaders, FileRenameHeaders>;\n\n// explicitly exporting types that we need.\n\nexport {\n CopyStatusType,\n DeleteSnapshotsOptionType,\n FileDownloadHeaders,\n FileDownloadOptionalParams,\n FileGetRangeListHeaders,\n FileLastWrittenMode,\n FileServiceProperties,\n FileUploadRangeFromURLOptionalParams,\n PermissionCopyModeType,\n ListSharesIncludeType,\n FileRange as RangeModel,\n ShareGetAccessPolicyHeaders,\n ShareItemInternal,\n SignedIdentifier as SignedIdentifierModel,\n SourceModifiedAccessConditions,\n FileForceCloseHandlesHeaders,\n DirectoryForceCloseHandlesHeaders,\n DirectoryCreateHeaders,\n DirectoryDeleteHeaders,\n DirectoryGetPropertiesHeaders,\n DirectoryListFilesAndDirectoriesSegmentHeaders,\n DirectoryRenameHeaders,\n DirectoryListHandlesHeaders,\n DirectorySetMetadataHeaders,\n DirectorySetPropertiesHeaders,\n FileAbortCopyHeaders,\n FileCreateHeaders,\n FileDeleteHeaders,\n FileGetPropertiesHeaders,\n FilePermissionFormat,\n FileProperty,\n FileListHandlesHeaders,\n FileRenameHeaders,\n CorsRule,\n Metrics,\n FileSetHttpHeadersHeaders as FileSetHTTPHeadersHeaders,\n FileSetMetadataHeaders,\n FileStartCopyHeaders,\n FileUploadRangeFromURLHeaders,\n FileUploadRangeHeaders,\n ServiceGetPropertiesHeaders,\n ListSharesResponse as ListSharesResponseModel,\n RetentionPolicy,\n ServiceListSharesSegmentHeaders,\n ServiceSetPropertiesHeaders,\n ShareCreatePermissionHeaders,\n ShareCreateHeaders,\n ShareCreateSnapshotHeaders,\n ShareDeleteHeaders,\n SharePermission,\n ShareGetPermissionHeaders,\n ShareGetPropertiesHeaders,\n ShareStats,\n ShareGetStatisticsHeaders,\n SharePropertiesInternal,\n ShareSetAccessPolicyHeaders,\n ShareSetMetadataHeaders,\n ShareSetPropertiesHeaders,\n ShareTokenIntent,\n AccessPolicy,\n LeaseAccessConditions,\n LeaseDurationType,\n LeaseStateType,\n LeaseStatusType,\n CopyFileSmbInfo,\n ShareProtocolSettings,\n ShareSmbSettings,\n SmbMultichannel,\n ShareFileRangeList,\n ClearRange,\n ShareAccessTier,\n ShareRootSquash,\n FileDownloadResponse as RawFileDownloadResponse,\n} from \"./generated/src/models\";\n\nimport { ShareSetPropertiesHeaders } from \"./generated/src/models\";\nimport { WithResponse } from \"./utils/utils.common\";\n\n/** Known values of {@link ShareTokenIntent} that the service accepts. */\nexport enum KnownShareTokenIntent {\n Backup = \"backup\",\n}\n\n/**\n * Contains response data for the setQuota operation.\n */\nexport type ShareSetQuotaResponse = WithResponse<ShareSetQuotaHeaders, ShareSetQuotaHeaders>;\n\n/**\n * Defines headers for setQuota operation.\n */\nexport type ShareSetQuotaHeaders = ShareSetPropertiesHeaders;\n\n/** A listed file item. */\nexport interface FileItem {\n name: string;\n fileId?: string;\n /** File properties. */\n properties: FileProperty;\n attributes?: string;\n permissionKey?: string;\n}\n\n/** A listed directory item. */\nexport interface DirectoryItem {\n name: string;\n fileId?: string;\n /** File properties. */\n properties?: FileProperty;\n attributes?: string;\n permissionKey?: string;\n}\n\n/** Abstract for entries that can be listed from Directory. */\nexport interface FilesAndDirectoriesListSegment {\n directoryItems: DirectoryItem[];\n fileItems: FileItem[];\n}\n\n/** An enumeration of directories and files. */\nexport interface ListFilesAndDirectoriesSegmentResponse {\n serviceEndpoint: string;\n shareName: string;\n shareSnapshot?: string;\n directoryPath: string;\n prefix: string;\n marker?: string;\n maxResults?: number;\n /** Abstract for entries that can be listed from Directory. */\n segment: FilesAndDirectoriesListSegment;\n continuationToken: string;\n directoryId?: string;\n}\n\n/** Defines values for AccessRight. */\nexport type ShareFileHandleAccessRights = \"Read\" | \"Write\" | \"Delete\";\n\n/** A listed Azure Storage handle item. */\nexport interface HandleItem {\n /** XSMB service handle ID */\n handleId: string;\n /** File or directory name including full path starting from share root */\n path: string;\n /** FileId uniquely identifies the file or directory. */\n fileId: string;\n /** ParentId uniquely identifies the parent directory of the object. */\n parentId?: string;\n /** SMB session ID in context of which the file handle was opened */\n sessionId: string;\n /** Client IP that opened the handle */\n clientIp: string;\n /** Name of the client machine where the share is being mounted */\n clientName: string;\n /** Time when the session that previously opened the handle has last been reconnected. (UTC) */\n openTime: Date;\n /** Time handle was last connected to (UTC) */\n lastReconnectTime?: Date;\n accessRightList?: ShareFileHandleAccessRights[];\n}\n\n/** An enumeration of handles. */\nexport interface ListHandlesResponse {\n handleList?: HandleItem[];\n continuationToken: string;\n}\n"]}
|
1
|
+
{"version":3,"file":"generatedModels.js","sourceRoot":"","sources":["../../../src/generatedModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAwoBlC,yEAAyE;AACzE,MAAM,CAAN,IAAY,qBAEX;AAFD,WAAY,qBAAqB;IAC/B,0CAAiB,CAAA;AACnB,CAAC,EAFW,qBAAqB,KAArB,qBAAqB,QAEhC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n CopyStatusType,\n DirectoryDeleteHeaders,\n DirectoryListFilesAndDirectoriesSegmentHeaders,\n DirectoryListHandlesHeaders,\n DirectoryRenameHeaders,\n DirectorySetMetadataHeaders,\n FileAbortCopyHeaders,\n FileDeleteHeaders,\n FileGetRangeListHeaders,\n FileListHandlesHeaders,\n FileProperty,\n FileRenameHeaders,\n FileServiceProperties,\n FileSetMetadataHeaders,\n FileStartCopyHeaders,\n FileUploadRangeFromURLHeaders,\n FileUploadRangeHeaders,\n LeaseDurationType,\n LeaseStateType,\n LeaseStatusType,\n NfsFileType,\n ServiceGetPropertiesHeaders,\n ServiceSetPropertiesHeaders,\n ShareCreateHeaders,\n ShareCreatePermissionHeaders,\n ShareCreateSnapshotHeaders,\n ShareDeleteHeaders,\n ShareFileRangeList,\n ShareGetAccessPolicyHeaders,\n ShareGetPermissionHeaders,\n ShareGetPropertiesHeaders,\n ShareGetStatisticsHeaders,\n SharePermission,\n ShareSetAccessPolicyHeaders,\n ShareSetMetadataHeaders,\n ShareStats,\n} from \"./generated/src/models\";\n\nimport type { ShareSetPropertiesHeaders } from \"./generated/src/models\";\nimport { FileDownloadResponse, FileSetHttpHeadersHeaders, NfsFileMode } from \"./models\";\nimport type { WithResponse } from \"./utils/utils.common\";\n\n/** Defines headers for Directory_create operation. */\nexport interface DirectoryCreateHeaders {\n /** The ETag contains a value which represents the version of the directory, in quotes. */\n etag?: string;\n /** Returns the date and time the share was last modified. Any operation that modifies the directory or its properties updates the last modified time. Operations on files do not affect the last modified time of the directory. */\n lastModified?: Date;\n /** This header uniquely identifies the request that was made and can be used for troubleshooting the request. */\n requestId?: string;\n /** Indicates the version of the File service used to execute the request. */\n version?: string;\n /** A UTC date/time value generated by the service that indicates the time at which the response was initiated. */\n date?: Date;\n /** The value of this header is set to true if the contents of the request are successfully encrypted using the specified algorithm, and false otherwise. */\n isServerEncrypted?: boolean;\n /** Key of the permission set for the directory. */\n filePermissionKey?: string;\n /** Attributes set for the directory. */\n fileAttributes?: string;\n /** Creation time for the directory. */\n fileCreatedOn?: Date;\n /** Last write time for the directory. */\n fileLastWriteOn?: Date;\n /** Change time for the directory. */\n fileChangeOn?: Date;\n /** The fileId of the directory. */\n fileId?: string;\n /** The parent fileId of the directory. */\n fileParentId?: string;\n /** NFS only. The mode of the file or directory. */\n fileMode?: NfsFileMode;\n /** NFS only. The owner of the file or directory. */\n owner?: string;\n /** NFS only. The owning group of the file or directory. */\n group?: string;\n /** NFS only. Type of the file or directory. */\n nfsFileType?: NfsFileType;\n /** Error Code */\n errorCode?: string;\n}\n\n/** Contains response data for the create operation. */\nexport type DirectoryCreateResponse = WithResponse<DirectoryCreateHeaders, DirectoryCreateHeaders>;\n\n/** Contains response data for the delete operation. */\nexport type DirectoryDeleteResponse = WithResponse<DirectoryDeleteHeaders, DirectoryDeleteHeaders>;\n\n/** Defines headers for Directory_getProperties operation. */\nexport interface DirectoryGetPropertiesHeaders {\n /** A set of name-value pairs that contain metadata for the directory. */\n metadata?: { [propertyName: string]: string };\n /** The ETag contains a value that you can use to perform operations conditionally, in quotes. */\n etag?: string;\n /** Returns the date and time the Directory was last modified. Operations on files within the directory do not affect the last modified time of the directory. */\n lastModified?: Date;\n /** This header uniquely identifies the request that was made and can be used for troubleshooting the request. */\n requestId?: string;\n /** Indicates the version of the File service used to execute the request. */\n version?: string;\n /** A UTC date/time value generated by the service that indicates the time at which the response was initiated. */\n date?: Date;\n /** The value of this header is set to true if the directory metadata is completely encrypted using the specified algorithm. Otherwise, the value is set to false. */\n isServerEncrypted?: boolean;\n /** Attributes set for the directory. */\n fileAttributes?: string;\n /** Creation time for the directory. */\n fileCreatedOn?: Date;\n /** Last write time for the directory. */\n fileLastWriteOn?: Date;\n /** Change time for the directory. */\n fileChangeOn?: Date;\n /** Key of the permission set for the directory. */\n filePermissionKey?: string;\n /** The fileId of the directory. */\n fileId?: string;\n /** The parent fileId of the directory. */\n fileParentId?: string;\n /** NFS only. The mode of the file or directory. */\n fileMode?: NfsFileMode;\n /** NFS only. The owner of the file or directory. */\n owner?: string;\n /** NFS only. The owning group of the file or directory. */\n group?: string;\n /** NFS only. Type of the file or directory. */\n nfsFileType?: NfsFileType;\n /** Error Code */\n errorCode?: string;\n}\n\n/** Contains response data for the getProperties operation. */\nexport type DirectoryGetPropertiesResponse = WithResponse<\n DirectoryGetPropertiesHeaders,\n DirectoryGetPropertiesHeaders\n>;\n\n/** Contains response data for the listFilesAndDirectoriesSegment operation. */\nexport type DirectoryListFilesAndDirectoriesSegmentResponse = WithResponse<\n DirectoryListFilesAndDirectoriesSegmentHeaders & ListFilesAndDirectoriesSegmentResponse,\n DirectoryListFilesAndDirectoriesSegmentHeaders,\n ListFilesAndDirectoriesSegmentResponse\n>;\n\n/** Contains response data for the listHandles operation. */\nexport type DirectoryListHandlesResponse = WithResponse<\n DirectoryListHandlesHeaders & ListHandlesResponse,\n DirectoryListHandlesHeaders,\n ListHandlesResponse\n>;\n\n/** Contains response data for the setMetadata operation. */\nexport type DirectorySetMetadataResponse = WithResponse<\n DirectorySetMetadataHeaders,\n DirectorySetMetadataHeaders\n>;\n\n/** Defines headers for Directory_setProperties operation. */\nexport interface DirectorySetPropertiesHeaders {\n /** The ETag contains a value which represents the version of the file, in quotes. */\n etag?: string;\n /** This header uniquely identifies the request that was made and can be used for troubleshooting the request. */\n requestId?: string;\n /** Returns the date and time the directory was last modified. Any operation that modifies the directory or its properties updates the last modified time. Operations on files do not affect the last modified time of the directory. */\n lastModified?: Date;\n /** Indicates the version of the File service used to execute the request. */\n version?: string;\n /** A UTC date/time value generated by the service that indicates the time at which the response was initiated. */\n date?: Date;\n /** The value of this header is set to true if the contents of the request are successfully encrypted using the specified algorithm, and false otherwise. */\n isServerEncrypted?: boolean;\n /** Key of the permission set for the directory. */\n filePermissionKey?: string;\n /** Attributes set for the directory. */\n fileAttributes?: string;\n /** Creation time for the directory. */\n fileCreatedOn?: Date;\n /** Last write time for the directory. */\n fileLastWriteOn?: Date;\n /** Change time for the directory. */\n fileChangeOn?: Date;\n /** The fileId of the directory. */\n fileId?: string;\n /** The parent fileId of the directory. */\n fileParentId?: string;\n /** NFS only. The mode of the file or directory. */\n fileMode?: NfsFileMode;\n /** NFS only. The owner of the file or directory. */\n owner?: string;\n /** NFS only. The owning group of the file or directory. */\n group?: string;\n /** Error Code */\n errorCode?: string;\n}\n\n/** Contains response data for the setProperties operation. */\nexport type DirectorySetPropertiesResponse = WithResponse<\n DirectorySetPropertiesHeaders,\n DirectorySetPropertiesHeaders\n>;\n\n/** Contains response data for the abortCopy operation. */\nexport type FileAbortCopyResponse = WithResponse<FileAbortCopyHeaders, FileAbortCopyHeaders>;\n\n/** Defines headers for File_create operation. */\nexport interface FileCreateHeaders {\n /** The ETag contains a value which represents the version of the file, in quotes. */\n etag?: string;\n /** Returns the date and time the share was last modified. Any operation that modifies the directory or its properties updates the last modified time. Operations on files do not affect the last modified time of the directory. */\n lastModified?: Date;\n /** This header uniquely identifies the request that was made and can be used for troubleshooting the request. */\n requestId?: string;\n /** Indicates the version of the File service used to execute the request. */\n version?: string;\n /** A UTC date/time value generated by the service that indicates the time at which the response was initiated. */\n date?: Date;\n /** The value of this header is set to true if the contents of the request are successfully encrypted using the specified algorithm, and false otherwise. */\n isServerEncrypted?: boolean;\n /** Key of the permission set for the file. */\n filePermissionKey?: string;\n /** Attributes set for the file. */\n fileAttributes?: string;\n /** Creation time for the file. */\n fileCreatedOn?: Date;\n /** Last write time for the file. */\n fileLastWriteOn?: Date;\n /** Change time for the file. */\n fileChangeOn?: Date;\n /** The fileId of the file. */\n fileId?: string;\n /** The parent fileId of the file. */\n fileParentId?: string;\n /** NFS only. The mode of the file or directory. */\n fileMode?: NfsFileMode;\n /** NFS only. The owner of the file or directory. */\n owner?: string;\n /** NFS only. The owning group of the file or directory. */\n group?: string;\n /** NFS only. Type of the file or directory. */\n nfsFileType?: NfsFileType;\n /** Error Code */\n errorCode?: string;\n}\n\n/** Contains response data for the create operation. */\nexport type FileCreateResponse = WithResponse<FileCreateHeaders, FileCreateHeaders>;\n\n/** Contains response data for the delete operation. */\nexport type FileDeleteResponse = WithResponse<FileDeleteHeaders, FileDeleteHeaders>;\n\n/** Defines headers for File_createHardLink operation. */\nexport interface FileCreateHardLinkHeaders {\n /** The ETag contains a value which represents the version of the file, in quotes. */\n etag?: string;\n /** Returns the date and time the share was last modified. Any operation that modifies the directory or its properties updates the last modified time. Operations on files do not affect the last modified time of the directory. */\n lastModified?: Date;\n /** This header uniquely identifies the request that was made and can be used for troubleshooting the request. */\n requestId?: string;\n /** Indicates the version of the File service used to execute the request. */\n version?: string;\n /** A UTC date/time value generated by the service that indicates the time at which the response was initiated. */\n date?: Date;\n /** Creation time for the file. */\n fileCreationTime?: Date;\n /** Last write time for the file. */\n fileLastWriteTime?: Date;\n /** Change time for the file. */\n fileChangeTime?: Date;\n /** The fileId of the file. */\n fileId?: string;\n /** The parent fileId of the directory. */\n fileParentId?: string;\n /** If a client request id header is sent in the request, this header will be present in the response with the same value. */\n clientRequestId?: string;\n /** NFS only. The link count of the file or directory. */\n linkCount?: number;\n /** NFS only. The mode of the file or directory. */\n fileMode?: NfsFileMode;\n /** NFS only. The owner of the file or directory. */\n owner?: string;\n /** NFS only. The owning group of the file or directory. */\n group?: string;\n /** NFS only. Type of the file or directory. */\n nfsFileType?: NfsFileType;\n}\n\n/** Contains response data for the create hard link operation. */\nexport type FileCreateHardLinkResponse = WithResponse<\n FileCreateHardLinkHeaders,\n FileCreateHardLinkHeaders\n>;\n\n/** Defines headers for File_getProperties operation. */\nexport interface FileGetPropertiesHeaders {\n /** Returns the date and time the file was last modified. The date format follows RFC 1123. Any operation that modifies the file or its properties updates the last modified time. */\n lastModified?: Date;\n /** A set of name-value pairs associated with this file as user-defined metadata. */\n metadata?: { [propertyName: string]: string };\n /** Returns the type File. Reserved for future use. */\n fileType?: string;\n /** The size of the file in bytes. This header returns the value of the 'x-ms-content-length' header that is stored with the file. */\n contentLength?: number;\n /** The content type specified for the file. The default content type is 'application/octet-stream' */\n contentType?: string;\n /** The ETag contains a value that you can use to perform operations conditionally, in quotes. */\n etag?: string;\n /** If the Content-MD5 header has been set for the file, the Content-MD5 response header is returned so that the client can check for message content integrity. */\n contentMD5?: Uint8Array;\n /** If the Content-Encoding request header has previously been set for the file, the Content-Encoding value is returned in this header. */\n contentEncoding?: string;\n /** If the Cache-Control request header has previously been set for the file, the Cache-Control value is returned in this header. */\n cacheControl?: string;\n /** Returns the value that was specified for the 'x-ms-content-disposition' header and specifies how to process the response. */\n contentDisposition?: string;\n /** Returns the value that was specified for the Content-Language request header. */\n contentLanguage?: string;\n /** This header uniquely identifies the request that was made and can be used for troubleshooting the request. */\n requestId?: string;\n /** Indicates the version of the File service used to execute the request. */\n version?: string;\n /** A UTC date/time value generated by the service that indicates the time at which the response was initiated. */\n date?: Date;\n /** Conclusion time of the last attempted Copy File operation where this file was the destination file. This value can specify the time of a completed, aborted, or failed copy attempt. */\n copyCompletedOn?: Date;\n /** Only appears when x-ms-copy-status is failed or pending. Describes cause of fatal or non-fatal copy operation failure. */\n copyStatusDescription?: string;\n /** String identifier for the last attempted Copy File operation where this file was the destination file. */\n copyId?: string;\n /** Contains the number of bytes copied and the total bytes in the source in the last attempted Copy File operation where this file was the destination file. Can show between 0 and Content-Length bytes copied. */\n copyProgress?: string;\n /** URL up to 2KB in length that specifies the source file used in the last attempted Copy File operation where this file was the destination file. */\n copySource?: string;\n /** State of the copy operation identified by 'x-ms-copy-id'. */\n copyStatus?: CopyStatusType;\n /** The value of this header is set to true if the file data and application metadata are completely encrypted using the specified algorithm. Otherwise, the value is set to false (when the file is unencrypted, or if only parts of the file/application metadata are encrypted). */\n isServerEncrypted?: boolean;\n /** Attributes set for the file. */\n fileAttributes?: string;\n /** Creation time for the file. */\n fileCreatedOn?: Date;\n /** Last write time for the file. */\n fileLastWriteOn?: Date;\n /** Change time for the file. */\n fileChangeOn?: Date;\n /** Key of the permission set for the file. */\n filePermissionKey?: string;\n /** The fileId of the file. */\n fileId?: string;\n /** The parent fileId of the file. */\n fileParentId?: string;\n /** When a file is leased, specifies whether the lease is of infinite or fixed duration. */\n leaseDuration?: LeaseDurationType;\n /** Lease state of the file. */\n leaseState?: LeaseStateType;\n /** The current lease status of the file. */\n leaseStatus?: LeaseStatusType;\n /** NFS only. The mode of the file or directory. */\n fileMode?: NfsFileMode;\n /** NFS only. The owner of the file or directory. */\n owner?: string;\n /** NFS only. The owning group of the file or directory. */\n group?: string;\n /** NFS only. The link count of the file or directory. */\n linkCount?: number;\n /** NFS only. Type of the file or directory. */\n nfsFileType?: NfsFileType;\n /** Error Code */\n errorCode?: string;\n}\n\n/** Contains response data for the getProperties operation. */\nexport type FileGetPropertiesResponse = WithResponse<\n FileGetPropertiesHeaders,\n FileGetPropertiesHeaders\n>;\n\n/** Contains response data for the listHandles operation. */\nexport type FileListHandlesResponse = WithResponse<\n FileListHandlesHeaders & ListHandlesResponse,\n FileListHandlesHeaders,\n ListHandlesResponse\n>;\n\n/** Contains response data for the setMetadata operation. */\nexport type FileSetMetadataResponse = WithResponse<FileSetMetadataHeaders, FileSetMetadataHeaders>;\n\n/** Contains response data for the startCopy operation. */\nexport type FileStartCopyResponse = WithResponse<FileStartCopyHeaders, FileStartCopyHeaders>;\n\n/** Contains response data for the uploadRange operation. */\nexport type FileUploadRangeResponse = WithResponse<FileUploadRangeHeaders, FileUploadRangeHeaders>;\n\n/** Contains response data for the getProperties operation. */\nexport type ServiceGetPropertiesResponse = WithResponse<\n ServiceGetPropertiesHeaders & FileServiceProperties,\n ServiceGetPropertiesHeaders,\n FileServiceProperties\n>;\n\n/** Contains response data for the setProperties operation. */\nexport type ServiceSetPropertiesResponse = WithResponse<\n ServiceSetPropertiesHeaders,\n ServiceSetPropertiesHeaders\n>;\n\n/** Contains response data for the createPermission operation. */\nexport type ShareCreatePermissionResponse = WithResponse<\n ShareCreatePermissionHeaders,\n ShareCreatePermissionHeaders\n>;\n\n/** Contains response data for the create operation. */\nexport type ShareCreateResponse = WithResponse<ShareCreateHeaders, ShareCreateHeaders>;\n\n/** Contains response data for the createSnapshot operation. */\nexport type ShareCreateSnapshotResponse = WithResponse<\n ShareCreateSnapshotHeaders,\n ShareCreateSnapshotHeaders\n>;\n\n/** Contains response data for the delete operation. */\nexport type ShareDeleteResponse = WithResponse<ShareDeleteHeaders, ShareDeleteHeaders>;\n\n/** Contains response data for the getPermission operation. */\nexport type ShareGetPermissionResponse = WithResponse<\n ShareGetPermissionHeaders & SharePermission,\n ShareGetPermissionHeaders,\n SharePermission\n>;\n\n/** Contains response data for the setAccessPolicy operation. */\nexport type ShareSetAccessPolicyResponse = WithResponse<\n ShareSetAccessPolicyHeaders,\n ShareGetAccessPolicyHeaders\n>;\n\n/** Contains response data for the setMetadata operation. */\nexport type ShareSetMetadataResponse = WithResponse<\n ShareSetMetadataHeaders,\n ShareSetMetadataHeaders\n>;\n\n/** Contains response data for the setProperties operation. */\nexport type ShareSetPropertiesResponse = WithResponse<\n ShareSetPropertiesHeaders,\n ShareSetPropertiesHeaders\n>;\n\n/** Contains response data for the rename operation. */\nexport type DirectoryRenameResponse = WithResponse<DirectoryRenameHeaders, DirectoryRenameHeaders>;\n\n/** Defines headers for File_download operation. */\nexport interface FileDownloadHeaders {\n /** Returns the date and time the file was last modified. Any operation that modifies the file or its properties updates the last modified time. */\n lastModified?: Date;\n /** A set of name-value pairs associated with this file as user-defined metadata. */\n metadata?: { [propertyName: string]: string };\n /** The number of bytes present in the response body. */\n contentLength?: number;\n /** The content type specified for the file. The default content type is 'application/octet-stream' */\n contentType?: string;\n /** Indicates the range of bytes returned if the client requested a subset of the file by setting the Range request header. */\n contentRange?: string;\n /** The ETag contains a value that you can use to perform operations conditionally, in quotes. */\n etag?: string;\n /** If the file has an MD5 hash and the request is to read the full file, this response header is returned so that the client can check for message content integrity. If the request is to read a specified range and the 'x-ms-range-get-content-md5' is set to true, then the request returns an MD5 hash for the range, as long as the range size is less than or equal to 4 MB. If neither of these sets of conditions is true, then no value is returned for the 'Content-MD5' header. */\n contentMD5?: Uint8Array;\n /** Returns the value that was specified for the Content-Encoding request header. */\n contentEncoding?: string;\n /** Returned if it was previously specified for the file. */\n cacheControl?: string;\n /** Returns the value that was specified for the 'x-ms-content-disposition' header and specifies how to process the response. */\n contentDisposition?: string;\n /** Returns the value that was specified for the Content-Language request header. */\n contentLanguage?: string;\n /** This header uniquely identifies the request that was made and can be used for troubleshooting the request. */\n requestId?: string;\n /** Indicates the version of the File service used to execute the request. */\n version?: string;\n /** Indicates that the service supports requests for partial file content. */\n acceptRanges?: string;\n /** A UTC date/time value generated by the service that indicates the time at which the response was initiated. */\n date?: Date;\n /** Conclusion time of the last attempted Copy File operation where this file was the destination file. This value can specify the time of a completed, aborted, or failed copy attempt. */\n copyCompletedOn?: Date;\n /** Only appears when x-ms-copy-status is failed or pending. Describes cause of fatal or non-fatal copy operation failure. */\n copyStatusDescription?: string;\n /** String identifier for the last attempted Copy File operation where this file was the destination file. */\n copyId?: string;\n /** Contains the number of bytes copied and the total bytes in the source in the last attempted Copy File operation where this file was the destination file. Can show between 0 and Content-Length bytes copied. */\n copyProgress?: string;\n /** URL up to 2KB in length that specifies the source file used in the last attempted Copy File operation where this file was the destination file. */\n copySource?: string;\n /** State of the copy operation identified by 'x-ms-copy-id'. */\n copyStatus?: CopyStatusType;\n /** If the file has a MD5 hash, and if request contains range header (Range or x-ms-range), this response header is returned with the value of the whole file's MD5 value. This value may or may not be equal to the value returned in Content-MD5 header, with the latter calculated from the requested range. */\n fileContentMD5?: Uint8Array;\n /** The value of this header is set to true if the file data and application metadata are completely encrypted using the specified algorithm. Otherwise, the value is set to false (when the file is unencrypted, or if only parts of the file/application metadata are encrypted). */\n isServerEncrypted?: boolean;\n /** Attributes set for the file. */\n fileAttributes?: string;\n /** Creation time for the file. */\n fileCreatedOn?: Date;\n /** Last write time for the file. */\n fileLastWriteOn?: Date;\n /** Change time for the file. */\n fileChangeOn?: Date;\n /** Key of the permission set for the file. */\n filePermissionKey?: string;\n /** The fileId of the file. */\n fileId?: string;\n /** The parent fileId of the file. */\n fileParentId?: string;\n /** When a file is leased, specifies whether the lease is of infinite or fixed duration. */\n leaseDuration?: LeaseDurationType;\n /** Lease state of the file. */\n leaseState?: LeaseStateType;\n /** The current lease status of the file. */\n leaseStatus?: LeaseStatusType;\n /** NFS only. The mode of the file or directory. */\n fileMode?: NfsFileMode;\n /** NFS only. The owner of the file or directory. */\n owner?: string;\n /** NFS only. The owning group of the file or directory. */\n group?: string;\n /** NFS only. The link count of the file or directory. */\n linkCount?: number;\n /** Error Code */\n errorCode?: string;\n}\n\n/** Contains response data for the download operation. */\nexport type FileDownloadResponseModel = WithResponse<FileDownloadResponse, FileDownloadHeaders>;\n\n/** Contains response data for the uploadRangeFromURL operation. */\nexport type FileUploadRangeFromURLResponse = WithResponse<\n FileUploadRangeFromURLHeaders,\n FileUploadRangeFromURLHeaders\n>;\n\n/** Contains response data for the getProperties operation. */\nexport type ShareGetPropertiesResponseModel = WithResponse<\n ShareGetPropertiesHeaders,\n ShareGetPropertiesHeaders\n>;\n\n/** Contains response data for the getStatistics operation. */\nexport type ShareGetStatisticsResponseModel = WithResponse<\n ShareGetStatisticsHeaders & ShareStats,\n ShareGetStatisticsHeaders,\n ShareStats\n>;\n\n/** Contains response data for the getRangeList operation. */\nexport type FileGetRangeListDiffResponse = WithResponse<\n FileGetRangeListHeaders & ShareFileRangeList,\n FileGetRangeListHeaders,\n ShareFileRangeList\n>;\n\n/** Contains response data for the setHttpHeaders operation. */\nexport type FileSetHTTPHeadersResponse = WithResponse<\n FileSetHttpHeadersHeaders,\n FileSetHttpHeadersHeaders\n>;\n\n/** Contains response data for the rename operation. */\nexport type FileRenameResponse = WithResponse<FileRenameHeaders, FileRenameHeaders>;\n\n// explicitly exporting types that we need.\n\nexport {\n CopyStatusType,\n DeleteSnapshotsOptionType,\n FileDownloadOptionalParams,\n FileGetRangeListHeaders,\n FileLastWrittenMode,\n FileServiceProperties,\n FileUploadRangeFromURLOptionalParams,\n PermissionCopyModeType,\n ListSharesIncludeType,\n FileRange as RangeModel,\n ShareGetAccessPolicyHeaders,\n ShareItemInternal,\n SignedIdentifier as SignedIdentifierModel,\n SourceModifiedAccessConditions,\n FileForceCloseHandlesHeaders,\n DirectoryForceCloseHandlesHeaders,\n DirectoryDeleteHeaders,\n DirectoryListFilesAndDirectoriesSegmentHeaders,\n DirectoryRenameHeaders,\n DirectoryListHandlesHeaders,\n DirectorySetMetadataHeaders,\n FileAbortCopyHeaders,\n FileDeleteHeaders,\n FilePermissionFormat,\n FileProperty,\n FileListHandlesHeaders,\n FileRenameHeaders,\n CorsRule,\n Metrics,\n ModeCopyMode,\n NfsFileType,\n FileSetMetadataHeaders,\n FileStartCopyHeaders,\n FileUploadRangeFromURLHeaders,\n FileUploadRangeHeaders,\n OwnerCopyMode,\n ServiceGetPropertiesHeaders,\n ListSharesResponse as ListSharesResponseModel,\n RetentionPolicy,\n ServiceListSharesSegmentHeaders,\n ServiceSetPropertiesHeaders,\n ShareCreatePermissionHeaders,\n ShareCreateHeaders,\n ShareCreateSnapshotHeaders,\n ShareDeleteHeaders,\n SharePermission,\n ShareGetPermissionHeaders,\n ShareGetPropertiesHeaders,\n ShareStats,\n ShareGetStatisticsHeaders,\n SharePropertiesInternal,\n ShareSetAccessPolicyHeaders,\n ShareSetMetadataHeaders,\n ShareSetPropertiesHeaders,\n ShareTokenIntent,\n AccessPolicy,\n LeaseAccessConditions,\n LeaseDurationType,\n LeaseStateType,\n LeaseStatusType,\n CopyFileSmbInfo,\n ShareProtocolSettings,\n ShareSmbSettings,\n SmbMultichannel,\n ShareFileRangeList,\n ClearRange,\n ShareAccessTier,\n ShareRootSquash,\n} from \"./generated/src/models\";\n\nexport {\n FileDownloadResponse as RawFileDownloadResponse,\n FileSetHttpHeadersHeaders as FileSetHTTPHeadersHeaders,\n} from \"./models\";\n/** Known values of {@link ShareTokenIntent} that the service accepts. */\nexport enum KnownShareTokenIntent {\n Backup = \"backup\",\n}\n\n/**\n * Contains response data for the setQuota operation.\n */\nexport type ShareSetQuotaResponse = WithResponse<ShareSetQuotaHeaders, ShareSetQuotaHeaders>;\n\n/**\n * Defines headers for setQuota operation.\n */\nexport type ShareSetQuotaHeaders = ShareSetPropertiesHeaders;\n\n/** A listed file item. */\nexport interface FileItem {\n name: string;\n fileId?: string;\n /** File properties. */\n properties: FileProperty;\n attributes?: string;\n permissionKey?: string;\n}\n\n/** A listed directory item. */\nexport interface DirectoryItem {\n name: string;\n fileId?: string;\n /** File properties. */\n properties?: FileProperty;\n attributes?: string;\n permissionKey?: string;\n}\n\n/** Abstract for entries that can be listed from Directory. */\nexport interface FilesAndDirectoriesListSegment {\n directoryItems: DirectoryItem[];\n fileItems: FileItem[];\n}\n\n/** An enumeration of directories and files. */\nexport interface ListFilesAndDirectoriesSegmentResponse {\n serviceEndpoint: string;\n shareName: string;\n shareSnapshot?: string;\n directoryPath: string;\n prefix: string;\n marker?: string;\n maxResults?: number;\n /** Abstract for entries that can be listed from Directory. */\n segment: FilesAndDirectoriesListSegment;\n continuationToken: string;\n directoryId?: string;\n}\n\n/** Defines values for AccessRight. */\nexport type ShareFileHandleAccessRights = \"Read\" | \"Write\" | \"Delete\";\n\n/** A listed Azure Storage handle item. */\nexport interface HandleItem {\n /** XSMB service handle ID */\n handleId: string;\n /** File or directory name including full path starting from share root */\n path: string;\n /** FileId uniquely identifies the file or directory. */\n fileId: string;\n /** ParentId uniquely identifies the parent directory of the object. */\n parentId?: string;\n /** SMB session ID in context of which the file handle was opened */\n sessionId: string;\n /** Client IP that opened the handle */\n clientIp: string;\n /** Name of the client machine where the share is being mounted */\n clientName: string;\n /** Time when the session that previously opened the handle has last been reconnected. (UTC) */\n openTime: Date;\n /** Time handle was last connected to (UTC) */\n lastReconnectTime?: Date;\n accessRightList?: ShareFileHandleAccessRights[];\n}\n\n/** An enumeration of handles. */\nexport interface ListHandlesResponse {\n handleList?: HandleItem[];\n continuationToken: string;\n}\n"]}
|
@@ -4,6 +4,7 @@ import { RestError } from "@azure/core-rest-pipeline";
|
|
4
4
|
export * from "./Clients";
|
5
5
|
export * from "../../storage-blob/src/credentials/AnonymousCredential";
|
6
6
|
export * from "../../storage-blob/src/credentials/Credential";
|
7
|
+
export { parseOctalFileMode, toOctalFileMode, parseSymbolicFileMode, toSymbolicFileMode, } from "./utils/utils.common";
|
7
8
|
export * from "./FileSystemAttributes";
|
8
9
|
export { Pipeline, isPipelineLike, newPipeline, } from "./Pipeline";
|
9
10
|
export { BaseRequestPolicy } from "../../storage-blob/src/policies/RequestPolicy";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../../../src/index.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,cAAc,WAAW,CAAC;AAC1B,cAAc,wDAAwD,CAAC;AACvE,cAAc,+CAA+C,CAAC;AAY9D,cAAc,wBAAwB,CAAC;AACvC,OAAO,EACL,QAAQ,EAGR,cAAc,EACd,WAAW,GAGZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,cAAc,2DAA2D,CAAC;AAC1E,cAAc,kDAAkD,CAAC;AACjE,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oDAAoD,CAAC;AACnE,cAAc,sBAAsB,CAAC;AAErC,cAAc,mBAAmB,CAAC;AAQlC,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { RestError } from \"@azure/core-rest-pipeline\";\n\nexport * from \"./Clients\";\nexport * from \"../../storage-blob/src/credentials/AnonymousCredential\";\nexport * from \"../../storage-blob/src/credentials/Credential\";\nexport { SasIPRange } from \"./SasIPRange\";\nexport { Range } from \"./Range\";\nexport {\n FilePermissionInheritType,\n FilePermissionPreserveType,\n TimeNowType,\n TimePreserveType,\n FileAttributesPreserveType,\n CloseHandlesInfo,\n HttpAuthorization,\n} from \"./models\";\nexport * from \"./FileSystemAttributes\";\nexport {\n Pipeline,\n PipelineLike,\n PipelineOptions,\n isPipelineLike,\n newPipeline,\n StoragePipelineOptions,\n ServiceClientOptions,\n} from \"./Pipeline\";\nexport { BaseRequestPolicy } from \"../../storage-blob/src/policies/RequestPolicy\";\nexport * from \"../../storage-blob/src/policies/AnonymousCredentialPolicy\";\nexport * from \"../../storage-blob/src/policies/CredentialPolicy\";\nexport * from \"./StorageRetryPolicyFactory\";\nexport * from \"../../storage-blob/src/StorageBrowserPolicyFactory\";\nexport * from \"./ShareServiceClient\";\nexport { CommonOptions } from \"./StorageClient\";\nexport * from \"./generatedModels\";\nexport {\n WithResponse,\n ResponseLike,\n ResponseWithBody,\n ResponseWithHeaders,\n HttpResponse,\n} from \"./utils/utils.common\";\nexport { RestError };\nexport { logger } from \"./log\";\n"]}
|
1
|
+
{"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../../../src/index.browser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,cAAc,WAAW,CAAC;AAC1B,cAAc,wDAAwD,CAAC;AACvE,cAAc,+CAA+C,CAAC;AAY9D,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,OAAO,EACL,QAAQ,EAGR,cAAc,EACd,WAAW,GAGZ,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;AAClF,cAAc,2DAA2D,CAAC;AAC1E,cAAc,kDAAkD,CAAC;AACjE,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oDAAoD,CAAC;AACnE,cAAc,sBAAsB,CAAC;AAErC,cAAc,mBAAmB,CAAC;AAQlC,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { RestError } from \"@azure/core-rest-pipeline\";\n\nexport * from \"./Clients\";\nexport * from \"../../storage-blob/src/credentials/AnonymousCredential\";\nexport * from \"../../storage-blob/src/credentials/Credential\";\nexport { SasIPRange } from \"./SasIPRange\";\nexport { Range } from \"./Range\";\nexport {\n FilePermissionInheritType,\n FilePermissionPreserveType,\n TimeNowType,\n TimePreserveType,\n FileAttributesPreserveType,\n CloseHandlesInfo,\n HttpAuthorization,\n} from \"./models\";\nexport {\n parseOctalFileMode,\n toOctalFileMode,\n parseSymbolicFileMode,\n toSymbolicFileMode,\n} from \"./utils/utils.common\";\nexport * from \"./FileSystemAttributes\";\nexport {\n Pipeline,\n PipelineLike,\n PipelineOptions,\n isPipelineLike,\n newPipeline,\n StoragePipelineOptions,\n ServiceClientOptions,\n} from \"./Pipeline\";\nexport { BaseRequestPolicy } from \"../../storage-blob/src/policies/RequestPolicy\";\nexport * from \"../../storage-blob/src/policies/AnonymousCredentialPolicy\";\nexport * from \"../../storage-blob/src/policies/CredentialPolicy\";\nexport * from \"./StorageRetryPolicyFactory\";\nexport * from \"../../storage-blob/src/StorageBrowserPolicyFactory\";\nexport * from \"./ShareServiceClient\";\nexport { CommonOptions } from \"./StorageClient\";\nexport * from \"./generatedModels\";\nexport {\n WithResponse,\n ResponseLike,\n ResponseWithBody,\n ResponseWithHeaders,\n HttpResponse,\n} from \"./utils/utils.common\";\nexport { RestError };\nexport { logger } from \"./log\";\n"]}
|
@@ -6,6 +6,7 @@ export * from "./AccountSASResourceTypes";
|
|
6
6
|
export * from "./AccountSASServices";
|
7
7
|
export { generateAccountSASQueryParameters, } from "./AccountSASSignatureValues";
|
8
8
|
export * from "./FileSASPermissions";
|
9
|
+
export { parseOctalFileMode, toOctalFileMode, parseSymbolicFileMode, toSymbolicFileMode, } from "./utils/utils.common";
|
9
10
|
export { generateFileSASQueryParameters } from "./FileSASSignatureValues";
|
10
11
|
export * from "./Clients";
|
11
12
|
export * from "./ShareSASPermissions";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAEL,iCAAiC,GA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AC;AACrC,cAAc,sBAAsB,CAAC;AAErC,cAAc,mBAAmB,CAAC;AAQlC,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { RestError } from \"@azure/core-rest-pipeline\";\n\nexport * from \"./AccountSASPermissions\";\nexport * from \"./AccountSASResourceTypes\";\nexport * from \"./AccountSASServices\";\nexport {\n AccountSASSignatureValues,\n generateAccountSASQueryParameters,\n} from \"./AccountSASSignatureValues\";\nexport * from \"./FileSASPermissions\";\nexport {\n parseOctalFileMode,\n toOctalFileMode,\n parseSymbolicFileMode,\n toSymbolicFileMode,\n} from \"./utils/utils.common\";\nexport { FileSASSignatureValues, generateFileSASQueryParameters } from \"./FileSASSignatureValues\";\nexport * from \"./Clients\";\nexport * from \"./ShareSASPermissions\";\nexport * from \"../../storage-blob/src/credentials/AnonymousCredential\";\nexport * from \"../../storage-blob/src/credentials/Credential\";\nexport * from \"../../storage-blob/src/credentials/StorageSharedKeyCredential\";\nexport { SasIPRange } from \"./SasIPRange\";\nexport { Range } from \"./Range\";\nexport {\n FileAndDirectoryCreateCommonOptions,\n FileAndDirectorySetPropertiesCommonOptions,\n FileHttpHeaders,\n FilePermissionInheritType,\n FilePermissionPreserveType,\n PosixRolePermissions,\n NfsFileMode,\n FilePosixProperties,\n Metadata,\n TimeNowType,\n TimePreserveType,\n FileAttributesPreserveType,\n CloseHandlesInfo,\n ShareProtocols,\n HttpAuthorization,\n StorageFileAudience,\n getFileServiceAccountAudience,\n} from \"./models\";\nexport * from \"./FileSystemAttributes\";\nexport { BaseRequestPolicy } from \"../../storage-blob/src/policies/RequestPolicy\";\nexport {\n Pipeline,\n PipelineLike,\n PipelineOptions,\n isPipelineLike,\n newPipeline,\n StoragePipelineOptions,\n RequestPolicyFactory,\n RequestPolicy,\n RequestPolicyOptions,\n WebResource,\n HttpOperationResponse,\n HttpHeaders,\n HttpRequestBody,\n IHttpClient,\n StorageOAuthScopes,\n ServiceClientOptions,\n} from \"./Pipeline\";\nexport * from \"../../storage-blob/src/policies/AnonymousCredentialPolicy\";\nexport * from \"../../storage-blob/src/policies/CredentialPolicy\";\nexport * from \"./StorageRetryPolicyFactory\";\nexport * from \"../../storage-blob/src/policies/StorageSharedKeyCredentialPolicy\";\nexport * from \"../../storage-blob/src/StorageBrowserPolicyFactory\";\nexport * from \"./ShareServiceClient\";\nexport * from \"./SASQueryParameters\";\nexport { CommonOptions } from \"./StorageClient\";\nexport * from \"./generatedModels\";\nexport {\n WithResponse,\n ResponseLike,\n ResponseWithBody,\n ResponseWithHeaders,\n HttpResponse,\n} from \"./utils/utils.common\";\nexport { RestError };\nexport { logger } from \"./log\";\n"]}
|
@@ -51,15 +51,6 @@ export function validateAndSetDefaultsForFileAndDirectoryCreateCommonOptions(opt
|
|
51
51
|
options = {};
|
52
52
|
}
|
53
53
|
validateFilePermissionOptions(options.filePermission, options.filePermissionKey);
|
54
|
-
if (!options.creationTime) {
|
55
|
-
options.creationTime = "now";
|
56
|
-
}
|
57
|
-
if (!options.lastWriteTime) {
|
58
|
-
options.lastWriteTime = "now";
|
59
|
-
}
|
60
|
-
if (!options.filePermission && !options.filePermissionKey) {
|
61
|
-
options.filePermission = "inherit";
|
62
|
-
}
|
63
54
|
return options;
|
64
55
|
}
|
65
56
|
export function validateAndSetDefaultsForFileAndDirectorySetPropertiesCommonOptions(options) {
|
@@ -68,18 +59,6 @@ export function validateAndSetDefaultsForFileAndDirectorySetPropertiesCommonOpti
|
|
68
59
|
options = {};
|
69
60
|
}
|
70
61
|
validateFilePermissionOptions(options.filePermission, options.filePermissionKey);
|
71
|
-
if (!options.creationTime) {
|
72
|
-
options.creationTime = "preserve";
|
73
|
-
}
|
74
|
-
if (!options.lastWriteTime) {
|
75
|
-
options.lastWriteTime = "preserve";
|
76
|
-
}
|
77
|
-
if (!options.fileAttributes) {
|
78
|
-
options.fileAttributes = "preserve";
|
79
|
-
}
|
80
|
-
if (!options.filePermission && !options.filePermissionKey) {
|
81
|
-
options.filePermission = "preserve";
|
82
|
-
}
|
83
62
|
return options;
|
84
63
|
}
|
85
64
|
export function fileAttributesToString(fileAttributes) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAkO/B;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,eAAwB;IACvD,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,gBAAgB,GAAG,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpD,MAAM,SAAS,GAAmB,EAAE,CAAC;IACrC,KAAK,MAAM,QAAQ,IAAI,gBAAgB,EAAE,CAAC;QACxC,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;YACvB,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC;QAC9B,CAAC;aAAM,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;YAC9B,SAAS,CAAC,UAAU,GAAG,IAAI,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,YAA4B,EAAE;IACnE,IAAI,WAAW,GAAG,SAAS,CAAC;IAE5B,IAAI,SAAS,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;QAClC,WAAW,GAAG,KAAK,CAAC;IACtB,CAAC;IACD,IAAI,SAAS,CAAC,UAAU,KAAK,IAAI,EAAE,CAAC;QAClC,MAAM,CAAC,IAAI,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licensed under the MIT License.\nimport { FileSystemAttributes } from \"./FileSystemAttributes\";\nimport { truncatedISO8061Date } from \"./utils/utils.common\";\nimport { logger } from \"./log\";\nimport { FilePermissionFormat, ShareTokenIntent } from \"./generatedModels\";\nimport { StoragePipelineOptions } from \"./Pipeline\";\n\nexport interface Metadata {\n [propertyName: string]: string;\n}\n\nexport interface FileHttpHeaders {\n /**\n * Optional. Sets the file's cache\n * control. If specified, this property is stored with the file and returned\n * with a read request.\n */\n fileCacheControl?: string;\n /**\n * Optional. Sets the file's content type.\n * If specified, this property is stored with the file and returned with a\n * read request.\n */\n fileContentType?: string;\n /**\n * Optional. An MD5 hash of the file\n * content. Note that this hash is not validated, as the hashes for the\n * individual blocks were validated when each was uploaded.\n */\n fileContentMD5?: Uint8Array;\n /**\n * Optional. Sets the file's content\n * encoding. If specified, this property is stored with the file and returned\n * with a read request.\n */\n fileContentEncoding?: string;\n /**\n * Optional. Set the file's content\n * language. If specified, this property is stored with the file and returned\n * with a read request.\n */\n fileContentLanguage?: string;\n /**\n * Optional. Sets the file's\n * Content-Disposition header.\n */\n fileContentDisposition?: string;\n}\n\n/**\n * Indicates inherit file permission from the parent directory.\n */\nexport type FilePermissionInheritType = \"inherit\";\n\n/**\n * Indicates keep existing file permission value unchanged.\n */\nexport type FilePermissionPreserveType = \"preserve\";\n\n/**\n * Indicates setting as the time of the request.\n */\nexport type TimeNowType = \"now\";\n\n/**\n * Indicates keep existing time value unchanged.\n */\nexport type TimePreserveType = \"preserve\";\n\n/**\n * Indicates keep existing file attributes unchanged.\n */\nexport type FileAttributesPreserveType = \"preserve\";\n\nexport interface FileAndDirectoryCreateCommonOptions {\n /**\n * The permission(security descriptor) to be set for the file or directory in the\n * Security Descriptor Definition Language (SDDL) or binary.\n * If specified, it must have an owner, group, and discretionary access control list (DACL).\n * A value of inherit may be passed to inherit from the parent directory.\n *\n * Note that only one of filePermission or filePermissionKey can be specified.\n * And if both are not specified, inherit will be set to filePermission as default value by client library.\n */\n filePermission?: string | FilePermissionInheritType;\n\n /**\n * Optional. Available for version 2023-06-01 and later.\n * Specifies the format in which the permission is returned. Acceptable values are SDDL or binary.\n * If x-ms-file-permission-format is unspecified or explicitly set to SDDL, the permission is returned in SDDL format.\n * If x-ms-file-permission-format is explicitly set to binary, the permission is returned as a base64 string representing the binary encoding of the permission\n */\n filePermissionFormat?: FilePermissionFormat;\n\n /**\n * The key of the permission to be set for the file or directory. This can be created using the Create-Permission API.\n *\n * Note that only one of filePermission or filePermissionKey can be specified.\n */\n filePermissionKey?: string;\n\n /**\n * The file system attributes to be set on the file or directory.\n */\n fileAttributes?: FileSystemAttributes;\n\n /**\n * The Coordinated Universal Time (UTC) creation time property for the directory.\n * A value of now may be used to indicate the time of the request.\n * By default, the value will be set as now.\n */\n creationTime?: Date | TimeNowType;\n\n /**\n * The Coordinated Universal Time (UTC) last write property for the directory.\n * A value of now may be used to indicate the time of the request.\n * By default, the value will be set as now.\n */\n lastWriteTime?: Date | TimeNowType;\n\n /**\n * The Coordinated Universal Time (UTC) change time property for the directory.\n * A value of now may be used to indicate the time of the request.\n * By default, the value will be set to the time of the request.\n */\n changeTime?: Date | TimeNowType;\n}\n\nexport interface FileAndDirectorySetPropertiesCommonOptions {\n /**\n * The permission(security descriptor) to be set for the file or directory in the\n * Security Descriptor Definition Language (SDDL). If specified, it must have an owner, group, and discretionary access control list (DACL).\n * A value of inherit may be passed to inherit from the parent directory.\n * A value of preserve may be passed to keep the value unchanged.\n *\n * Note that only one of filePermission or filePermissionKey can be specified.\n * And if both are not specified, preserve will be set to filePermission as default value by client library.\n */\n filePermission?: string | FilePermissionInheritType | FilePermissionPreserveType;\n\n /**\n * Optional. Available for version 2023-06-01 and later.\n * Specifies the format in which the permission is returned. Acceptable values are SDDL or binary.\n * If x-ms-file-permission-format is unspecified or explicitly set to SDDL, the permission is returned in SDDL format.\n * If x-ms-file-permission-format is explicitly set to binary, the permission is returned as a base64 string representing the binary encoding of the permission\n */\n filePermissionFormat?: FilePermissionFormat;\n\n /**\n * The key of the permission to be set for the file or directory. This can be created using the Create-Permission API.\n *\n * Note that only one of filePermission or filePermissionKey can be specified.\n */\n filePermissionKey?: string;\n\n /**\n * The file system attributes to be set on the file or directory.\n */\n fileAttributes?: FileSystemAttributes | FileAttributesPreserveType;\n\n /**\n * The Coordinated Universal Time (UTC) creation time property for the directory.\n * A value of now may be used to indicate the time of the request.\n * A value of preserve may be passed to keep an existing value unchanged.\n * By default, the value will be set as preserve.\n */\n creationTime?: Date | TimeNowType | TimePreserveType;\n\n /**\n * The Coordinated Universal Time (UTC) last write property for the directory.\n * A value of now may be used to indicate the time of the request.\n * A value of preserve may be passed to keep an existing value unchanged.\n * By default, the value will be set as preserve.\n */\n lastWriteTime?: Date | TimeNowType | TimePreserveType;\n\n /**\n * The Coordinated Universal Time (UTC) change time property for the directory.\n * A value of now may be used to indicate the time of the request.\n * By default, the value will be set to the time of the request.\n */\n changeTime?: Date | TimeNowType;\n}\n\n/**\n * Close handles result information.\n */\nexport interface CloseHandlesInfo {\n closedHandlesCount: number;\n /**\n * Contains count of number of handles that failed to close.\n */\n closeFailureCount?: number;\n}\n\n/**\n * Protocols to enable on the share. For now, only support SMB or NFS.\n */\nexport interface ShareProtocols {\n /**\n * The share can be accessed by SMBv3.0, SMBv2.1 and REST.\n */\n smbEnabled?: boolean;\n /**\n * The share can be accessed by NFSv4.1.\n */\n nfsEnabled?: boolean;\n}\n\nexport interface ShareClientConfig {\n /**\n * The Files OAuth over REST feature requires special permissions to be included in the role definition to use\n * These special permissions will give privileged access to file share data -\n * It will allow users to bypass file/directory level ACL/NTFS permissions and get read/write access to file share data\n * Since this additional permission can be unintended and to prevent unintended and over privileged access,\n * additional checks has been implemented that requires users to explicitly indicate their intent to use these additional permissions.\n * This is done using the fileRequestIntent option.\n * Currently, the only value that the header supports is 'backup'\n * Any user who wishes to use Files OAuth over REST feature has to call the API with the intent header. If the API is not called with the intent header, any subsequent data operation requests will be denied.\n */\n fileRequestIntent?: ShareTokenIntent;\n /** If true, the trailing dot will not be trimmed from the target URI. */\n allowTrailingDot?: boolean;\n /** If true, the trailing dot will not be trimmed from the source URI. */\n allowSourceTrailingDot?: boolean;\n}\n\nexport type ShareClientOptions = StoragePipelineOptions & ShareClientConfig;\n\n/**\n * Convert protocols from joined string to ShareProtocols.\n *\n * @param protocolsString -\n */\nexport function toShareProtocols(protocolsString?: string): ShareProtocols | undefined {\n if (protocolsString === undefined) {\n return undefined;\n }\n\n const protocolStrArray = protocolsString.split(\";\");\n const protocols: ShareProtocols = {};\n for (const protocol of protocolStrArray) {\n if (protocol === \"SMB\") {\n protocols.smbEnabled = true;\n } else if (protocol === \"NFS\") {\n protocols.nfsEnabled = true;\n }\n }\n return protocols;\n}\n\n/**\n * Convert ShareProtocols to joined string.\n *\n * @param protocols -\n */\nexport function toShareProtocolsString(protocols: ShareProtocols = {}): string | undefined {\n let protocolStr = undefined;\n\n if (protocols.smbEnabled === true) {\n protocolStr = \"SMB\";\n }\n if (protocols.nfsEnabled === true) {\n logger.info(\n `Using \"NFS\" in favor of \"SMB\" for the share protocol as currently they can't be supported at the same time.`,\n );\n protocolStr = \"NFS\";\n }\n return protocolStr;\n}\n\nexport function validateFilePermissionOptions(\n filePermission?: string,\n filePermissionKey?: string,\n): void {\n if (filePermission && filePermissionKey) {\n throw new RangeError(\"Only one of filePermission or filePermissionKey can be specified.\");\n }\n}\n\nexport function validateAndSetDefaultsForFileAndDirectoryCreateCommonOptions(\n options: FileAndDirectoryCreateCommonOptions,\n): FileAndDirectoryCreateCommonOptions {\n // Would better deep copy params set by user.\n\n if (!options) {\n options = {};\n }\n\n validateFilePermissionOptions(options.filePermission, options.filePermissionKey);\n\n if (!options.creationTime) {\n options.creationTime = \"now\";\n }\n\n if (!options.lastWriteTime) {\n options.lastWriteTime = \"now\";\n }\n\n if (!options.filePermission && !options.filePermissionKey) {\n options.filePermission = \"inherit\";\n }\n\n return options;\n}\n\nexport function validateAndSetDefaultsForFileAndDirectorySetPropertiesCommonOptions(\n options: FileAndDirectorySetPropertiesCommonOptions,\n): FileAndDirectorySetPropertiesCommonOptions {\n // Would better deep copy params set by user.\n\n if (!options) {\n options = {};\n }\n\n validateFilePermissionOptions(options.filePermission, options.filePermissionKey);\n\n if (!options.creationTime) {\n options.creationTime = \"preserve\";\n }\n\n if (!options.lastWriteTime) {\n options.lastWriteTime = \"preserve\";\n }\n\n if (!options.fileAttributes) {\n options.fileAttributes = \"preserve\";\n }\n\n if (!options.filePermission && !options.filePermissionKey) {\n options.filePermission = \"preserve\";\n }\n\n return options;\n}\n\nexport function fileAttributesToString(\n fileAttributes: FileSystemAttributes | FileAttributesPreserveType,\n): string {\n return fileAttributes instanceof FileSystemAttributes\n ? fileAttributes.toString()\n : fileAttributes;\n}\n\nexport function fileCreationTimeToString(\n time: Date | TimeNowType | TimePreserveType | undefined,\n): string | undefined {\n return time instanceof Date ? truncatedISO8061Date(time) : time;\n}\n\nexport function fileLastWriteTimeToString(\n time: Date | TimeNowType | TimePreserveType | undefined,\n): string | undefined {\n return time instanceof Date ? truncatedISO8061Date(time) : time;\n}\n\nexport function fileChangeTimeToString(\n time: Date | TimeNowType | TimePreserveType | undefined,\n): string | undefined {\n return time instanceof Date ? truncatedISO8061Date(time) : time;\n}\n\n/**\n * Represents authentication information in Authorization, ProxyAuthorization,\n * WWW-Authenticate, and Proxy-Authenticate header values.\n */\nexport interface HttpAuthorization {\n /**\n * The scheme to use for authorization.\n */\n scheme: string;\n\n /**\n * the credentials containing the authentication information of the user agent for the resource being requested.\n */\n value: string;\n}\n\n/**\n * Defines the known cloud audiences for Storage.\n */\nexport enum StorageFileAudience {\n /**\n * The OAuth scope to use to retrieve an AAD token for Azure Storage.\n */\n StorageOAuthScopes = \"https://storage.azure.com/.default\",\n}\n\n/**\n * To get the OAuth audience for a storage account for file service.\n */\nexport function getFileServiceAccountAudience(storageAccountName: string): string {\n return `https://${storageAccountName}.file.core.windows.net/.default`;\n}\n"]}
|
1
|
+
{"version":3,"file":"models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AY,mBAKX;AALD,WAAY,mBAAmB;IAC7B;;OAEG;IACH,gFAAyD,CAAA;AAC3D,CAAC,EALW,mBAAmB,KAAnB,mBAAmB,QAK9B;AAED;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAAC,kBAA0B;IACtE,OAAO,WAAW,kBAAkB,iCAAiC,CAAC;AACxE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nimport { FileSystemAttributes } from \"./FileSystemAttributes\";\nimport { truncatedISO8061Date } from \"./utils/utils.common\";\nimport { logger } from \"./log\";\nimport type { FilePermissionFormat, NfsFileType, ShareTokenIntent } from \"./generatedModels\";\nimport type { StoragePipelineOptions } from \"./Pipeline\";\nimport { FileDownloadHeaders } from \"./generatedModels\";\n\nexport interface Metadata {\n [propertyName: string]: string;\n}\n\n/**\n * Represents file permissions for a specific role.\n */\nexport interface PosixRolePermissions {\n /**\n * The execute permission.\n */\n execute: boolean;\n /**\n * The write permission.\n */\n write: boolean;\n /**\n * The read permission.\n */\n read: boolean;\n}\n\n/**\n * The mode permissions of the file or directory.\n */\nexport interface NfsFileMode {\n /**\n * Permissions the owner has over the file or directory.\n */\n owner: PosixRolePermissions;\n\n /**\n * Permissions the group has over the file or directory.\n */\n group: PosixRolePermissions;\n\n /**\n * Permissions other have over the file or directory.\n */\n other: PosixRolePermissions;\n\n /**\n * Set effective user ID (setuid) on the file or directory.\n */\n effectiveUserIdentity: boolean;\n\n /**\n * Set effective group ID (setgid) on the file or directory.\n */\n effectiveGroupIdentity: boolean;\n\n /**\n * The sticky bit may be set on directories. The files in that\n * directory may only be renamed or deleted by the file's owner, the directory's owner, or the root user.\n */\n stickyBit: boolean;\n}\n\n/**\n * \n NFS properties.\n Note that these properties only apply to files or directories in\n premium NFS file accounts.\n */\nexport interface FilePosixProperties {\n /** Optional, NFS only. The owner of the file or directory. */\n owner?: string;\n /** Optional, NFS only. The owning group of the file or directory. */\n group?: string;\n /** Optional, NFS only. The file mode of the file or directory */\n fileMode?: NfsFileMode;\n /** Optional, NFS only. Type of the file or directory. */\n fileType?: NfsFileType;\n}\n\n/** Defines headers for File_setHttpHeaders operation. */\nexport interface FileSetHttpHeadersHeaders {\n /** The ETag contains a value which represents the version of the file, in quotes. */\n etag?: string;\n /** Returns the date and time the directory was last modified. Any operation that modifies the directory or its properties updates the last modified time. Operations on files do not affect the last modified time of the directory. */\n lastModified?: Date;\n /** This header uniquely identifies the request that was made and can be used for troubleshooting the request. */\n requestId?: string;\n /** Indicates the version of the File service used to execute the request. */\n version?: string;\n /** A UTC date/time value generated by the service that indicates the time at which the response was initiated. */\n date?: Date;\n /** The value of this header is set to true if the contents of the request are successfully encrypted using the specified algorithm, and false otherwise. */\n isServerEncrypted?: boolean;\n /** Key of the permission set for the file. */\n filePermissionKey?: string;\n /** Attributes set for the file. */\n fileAttributes?: string;\n /** Creation time for the file. */\n fileCreatedOn?: Date;\n /** Last write time for the file. */\n fileLastWriteOn?: Date;\n /** Change time for the file. */\n fileChangeOn?: Date;\n /** The fileId of the directory. */\n fileId?: string;\n /** The parent fileId of the directory. */\n fileParentId?: string;\n /** NFS only. The mode of the file or directory. */\n fileMode?: NfsFileMode;\n /** NFS only. The owner of the file or directory. */\n owner?: string;\n /** NFS only. The owning group of the file or directory. */\n group?: string;\n /** NFS only. The link count of the file or directory. */\n linkCount?: number;\n /** Error Code */\n errorCode?: string;\n}\n\n/** Contains response data for the download operation. */\nexport type FileDownloadResponse = FileDownloadHeaders & {\n /**\n * BROWSER ONLY\n *\n * The response body as a browser Blob.\n * Always `undefined` in node.js.\n */\n blobBody?: Promise<Blob>;\n /**\n * NODEJS ONLY\n *\n * The response body as a node.js Readable stream.\n * Always `undefined` in the browser.\n */\n readableStreamBody?: NodeJS.ReadableStream;\n};\n\nexport interface FileHttpHeaders {\n /**\n * Optional. Sets the file's cache\n * control. If specified, this property is stored with the file and returned\n * with a read request.\n */\n fileCacheControl?: string;\n /**\n * Optional. Sets the file's content type.\n * If specified, this property is stored with the file and returned with a\n * read request.\n */\n fileContentType?: string;\n /**\n * Optional. An MD5 hash of the file\n * content. Note that this hash is not validated, as the hashes for the\n * individual blocks were validated when each was uploaded.\n */\n fileContentMD5?: Uint8Array;\n /**\n * Optional. Sets the file's content\n * encoding. If specified, this property is stored with the file and returned\n * with a read request.\n */\n fileContentEncoding?: string;\n /**\n * Optional. Set the file's content\n * language. If specified, this property is stored with the file and returned\n * with a read request.\n */\n fileContentLanguage?: string;\n /**\n * Optional. Sets the file's\n * Content-Disposition header.\n */\n fileContentDisposition?: string;\n}\n\n/**\n * Indicates inherit file permission from the parent directory.\n */\nexport type FilePermissionInheritType = \"inherit\";\n\n/**\n * Indicates keep existing file permission value unchanged.\n */\nexport type FilePermissionPreserveType = \"preserve\";\n\n/**\n * Indicates setting as the time of the request.\n */\nexport type TimeNowType = \"now\";\n\n/**\n * Indicates keep existing time value unchanged.\n */\nexport type TimePreserveType = \"preserve\";\n\n/**\n * Indicates keep existing file attributes unchanged.\n */\nexport type FileAttributesPreserveType = \"preserve\";\n\nexport interface FileAndDirectoryCreateCommonOptions {\n /**\n * The permission(security descriptor) to be set for the file or directory in the\n * Security Descriptor Definition Language (SDDL) or binary.\n * If specified, it must have an owner, group, and discretionary access control list (DACL).\n * A value of inherit may be passed to inherit from the parent directory.\n *\n * Note that only one of filePermission or filePermissionKey can be specified.\n * And if both are not specified, inherit will be set to filePermission as default value by client library.\n */\n filePermission?: string | FilePermissionInheritType;\n\n /**\n * Optional. Available for version 2023-06-01 and later.\n * Specifies the format in which the permission is returned. Acceptable values are SDDL or binary.\n * If x-ms-file-permission-format is unspecified or explicitly set to SDDL, the permission is returned in SDDL format.\n * If x-ms-file-permission-format is explicitly set to binary, the permission is returned as a base64 string representing the binary encoding of the permission\n */\n filePermissionFormat?: FilePermissionFormat;\n\n /**\n * The key of the permission to be set for the file or directory. This can be created using the Create-Permission API.\n *\n * Note that only one of filePermission or filePermissionKey can be specified.\n */\n filePermissionKey?: string;\n\n /**\n * The file system attributes to be set on the file or directory.\n */\n fileAttributes?: FileSystemAttributes;\n\n /**\n * The Coordinated Universal Time (UTC) creation time property for the directory.\n * A value of now may be used to indicate the time of the request.\n * By default, the value will be set as now.\n */\n creationTime?: Date | TimeNowType;\n\n /**\n * The Coordinated Universal Time (UTC) last write property for the directory.\n * A value of now may be used to indicate the time of the request.\n * By default, the value will be set as now.\n */\n lastWriteTime?: Date | TimeNowType;\n\n /**\n * The Coordinated Universal Time (UTC) change time property for the directory.\n * A value of now may be used to indicate the time of the request.\n * By default, the value will be set to the time of the request.\n */\n changeTime?: Date | TimeNowType;\n /**\n * Optional properties to set on NFS files.\n Note that this property is only applicable to files created in NFS shares.\n */\n posixProperties?: FilePosixProperties;\n}\n\nexport interface FileAndDirectorySetPropertiesCommonOptions {\n /**\n * The permission(security descriptor) to be set for the file or directory in the\n * Security Descriptor Definition Language (SDDL). If specified, it must have an owner, group, and discretionary access control list (DACL).\n * A value of inherit may be passed to inherit from the parent directory.\n * A value of preserve may be passed to keep the value unchanged.\n *\n * Note that only one of filePermission or filePermissionKey can be specified.\n * And if both are not specified, preserve will be set to filePermission as default value by client library.\n */\n filePermission?: string | FilePermissionInheritType | FilePermissionPreserveType;\n\n /**\n * Optional. Available for version 2023-06-01 and later.\n * Specifies the format in which the permission is returned. Acceptable values are SDDL or binary.\n * If x-ms-file-permission-format is unspecified or explicitly set to SDDL, the permission is returned in SDDL format.\n * If x-ms-file-permission-format is explicitly set to binary, the permission is returned as a base64 string representing the binary encoding of the permission\n */\n filePermissionFormat?: FilePermissionFormat;\n\n /**\n * The key of the permission to be set for the file or directory. This can be created using the Create-Permission API.\n *\n * Note that only one of filePermission or filePermissionKey can be specified.\n */\n filePermissionKey?: string;\n\n /**\n * The file system attributes to be set on the file or directory.\n */\n fileAttributes?: FileSystemAttributes | FileAttributesPreserveType;\n\n /**\n * The Coordinated Universal Time (UTC) creation time property for the directory.\n * A value of now may be used to indicate the time of the request.\n * A value of preserve may be passed to keep an existing value unchanged.\n * By default, the value will be set as preserve.\n */\n creationTime?: Date | TimeNowType | TimePreserveType;\n\n /**\n * The Coordinated Universal Time (UTC) last write property for the directory.\n * A value of now may be used to indicate the time of the request.\n * A value of preserve may be passed to keep an existing value unchanged.\n * By default, the value will be set as preserve.\n */\n lastWriteTime?: Date | TimeNowType | TimePreserveType;\n\n /**\n * The Coordinated Universal Time (UTC) change time property for the directory.\n * A value of now may be used to indicate the time of the request.\n * By default, the value will be set to the time of the request.\n */\n changeTime?: Date | TimeNowType;\n\n /**\n * Optional properties to set on NFS files.\n Note that this property is only applicable to files created in NFS shares.\n */\n posixProperties?: FilePosixProperties;\n}\n\n/**\n * Close handles result information.\n */\nexport interface CloseHandlesInfo {\n closedHandlesCount: number;\n /**\n * Contains count of number of handles that failed to close.\n */\n closeFailureCount?: number;\n}\n\n/**\n * Protocols to enable on the share. For now, only support SMB or NFS.\n */\nexport interface ShareProtocols {\n /**\n * The share can be accessed by SMBv3.0, SMBv2.1 and REST.\n */\n smbEnabled?: boolean;\n /**\n * The share can be accessed by NFSv4.1.\n */\n nfsEnabled?: boolean;\n}\n\nexport interface ShareClientConfig {\n /**\n * The Files OAuth over REST feature requires special permissions to be included in the role definition to use\n * These special permissions will give privileged access to file share data -\n * It will allow users to bypass file/directory level ACL/NTFS permissions and get read/write access to file share data\n * Since this additional permission can be unintended and to prevent unintended and over privileged access,\n * additional checks has been implemented that requires users to explicitly indicate their intent to use these additional permissions.\n * This is done using the fileRequestIntent option.\n * Currently, the only value that the header supports is 'backup'\n * Any user who wishes to use Files OAuth over REST feature has to call the API with the intent header. If the API is not called with the intent header, any subsequent data operation requests will be denied.\n */\n fileRequestIntent?: ShareTokenIntent;\n /** If true, the trailing dot will not be trimmed from the target URI. */\n allowTrailingDot?: boolean;\n /** If true, the trailing dot will not be trimmed from the source URI. */\n allowSourceTrailingDot?: boolean;\n}\n\nexport type ShareClientOptions = StoragePipelineOptions & ShareClientConfig;\n\n/**\n * Convert protocols from joined string to ShareProtocols.\n *\n * @param protocolsString -\n */\nexport function toShareProtocols(protocolsString?: string): ShareProtocols | undefined {\n if (protocolsString === undefined) {\n return undefined;\n }\n\n const protocolStrArray = protocolsString.split(\";\");\n const protocols: ShareProtocols = {};\n for (const protocol of protocolStrArray) {\n if (protocol === \"SMB\") {\n protocols.smbEnabled = true;\n } else if (protocol === \"NFS\") {\n protocols.nfsEnabled = true;\n }\n }\n return protocols;\n}\n\n/**\n * Convert ShareProtocols to joined string.\n *\n * @param protocols -\n */\nexport function toShareProtocolsString(protocols: ShareProtocols = {}): string | undefined {\n let protocolStr = undefined;\n\n if (protocols.smbEnabled === true) {\n protocolStr = \"SMB\";\n }\n if (protocols.nfsEnabled === true) {\n logger.info(\n `Using \"NFS\" in favor of \"SMB\" for the share protocol as currently they can't be supported at the same time.`,\n );\n protocolStr = \"NFS\";\n }\n return protocolStr;\n}\n\nexport function validateFilePermissionOptions(\n filePermission?: string,\n filePermissionKey?: string,\n): void {\n if (filePermission && filePermissionKey) {\n throw new RangeError(\"Only one of filePermission or filePermissionKey can be specified.\");\n }\n}\n\nexport function validateAndSetDefaultsForFileAndDirectoryCreateCommonOptions(\n options: FileAndDirectoryCreateCommonOptions,\n): FileAndDirectoryCreateCommonOptions {\n // Would better deep copy params set by user.\n\n if (!options) {\n options = {};\n }\n\n validateFilePermissionOptions(options.filePermission, options.filePermissionKey);\n\n return options;\n}\n\nexport function validateAndSetDefaultsForFileAndDirectorySetPropertiesCommonOptions(\n options: FileAndDirectorySetPropertiesCommonOptions,\n): FileAndDirectorySetPropertiesCommonOptions {\n // Would better deep copy params set by user.\n\n if (!options) {\n options = {};\n }\n\n validateFilePermissionOptions(options.filePermission, options.filePermissionKey);\n\n return options;\n}\n\nexport function fileAttributesToString(\n fileAttributes: FileSystemAttributes | FileAttributesPreserveType,\n): string {\n return fileAttributes instanceof FileSystemAttributes\n ? fileAttributes.toString()\n : fileAttributes;\n}\n\nexport function fileCreationTimeToString(\n time: Date | TimeNowType | TimePreserveType | undefined,\n): string | undefined {\n return time instanceof Date ? truncatedISO8061Date(time) : time;\n}\n\nexport function fileLastWriteTimeToString(\n time: Date | TimeNowType | TimePreserveType | undefined,\n): string | undefined {\n return time instanceof Date ? truncatedISO8061Date(time) : time;\n}\n\nexport function fileChangeTimeToString(\n time: Date | TimeNowType | TimePreserveType | undefined,\n): string | undefined {\n return time instanceof Date ? truncatedISO8061Date(time) : time;\n}\n\n/**\n * Represents authentication information in Authorization, ProxyAuthorization,\n * WWW-Authenticate, and Proxy-Authenticate header values.\n */\nexport interface HttpAuthorization {\n /**\n * The scheme to use for authorization.\n */\n scheme: string;\n\n /**\n * the credentials containing the authentication information of the user agent for the resource being requested.\n */\n value: string;\n}\n\n/**\n * Defines the known cloud audiences for Storage.\n */\nexport enum StorageFileAudience {\n /**\n * The OAuth scope to use to retrieve an AAD token for Azure Storage.\n */\n StorageOAuthScopes = \"https://storage.azure.com/.default\",\n}\n\n/**\n * To get the OAuth audience for a storage account for file service.\n */\nexport function getFileServiceAccountAudience(storageAccountName: string): string {\n return `https://${storageAccountName}.file.core.windows.net/.default`;\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"StorageRetryPolicy.js","sourceRoot":"","sources":["../../../../src/policies/StorageRetryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAmB,MAAM,yBAAyB,CAAC;AAStE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAC;AAIrF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAkC;IACtE,OAAO;QACL,MAAM,EAAE,CAAC,UAAyB,EAAE,OAA6B,EAAsB,EAAE;YACvF,OA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right (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortError, AbortSignalLike } from \"@azure/abort-controller\";\n\nimport {\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 \"../../../storage-blob/src/policies/RequestPolicy\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\n\nimport { StorageRetryOptions } from \"../StorageRetryPolicyFactory\";\nimport { URLConstants } from \"../utils/constants\";\nimport { delay, setURLParameter } from \"../utils/utils.common\";\nimport { logger } from \"../log\";\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/**\n * RetryPolicy types.\n */\nexport enum StorageRetryPolicyType {\n /**\n * Exponential retry. Retry time delay grows exponentially.\n */\n EXPONENTIAL,\n /**\n * Linear retry. Retry time delay grows linearly.\n */\n FIXED,\n}\n\n// Default values of StorageRetryOptions\nconst DEFAULT_RETRY_OPTIONS: StorageRetryOptions = {\n maxRetryDelayInMs: 120 * 1000,\n maxTries: 4,\n retryDelayInMs: 4 * 1000,\n retryPolicyType: StorageRetryPolicyType.EXPONENTIAL,\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 }\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 = true;\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 // [Copy source error code] Feature is pending on service side, skip retry on copy source error for now.\n // if (response) {\n // // Retry select Copy Source Error Codes.\n // if (response?.status >= 400) {\n // const copySourceError = response.headers.get(HeaderConstants.X_MS_CopySourceErrorCode);\n // if (copySourceError !== undefined) {\n // switch (copySourceError)\n // {\n // case \"InternalError\":\n // case \"OperationTimedOut\":\n // case \"ServerBusy\":\n // return true;\n // }\n // }\n // }\n // }\n\n 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(isPrimaryRetry: boolean, attempt: number, abortSignal?: AbortSignalLike) {\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;AASrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kDAAkD,CAAC;AAIrF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;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;;GAEG;AACH,MAAM,CAAN,IAAY,sBASX;AATD,WAAY,sBAAsB;IAChC;;OAEG;IACH,iFAAW,CAAA;IACX;;OAEG;IACH,qEAAK,CAAA;AACP,CAAC,EATW,sBAAsB,KAAtB,sBAAsB,QASjC;AAED,wCAAwC;AACxC,MAAM,qBAAqB,GAAwB;IACjD,iBAAiB,EAAE,GAAG,GAAG,IAAI;IAC7B,QAAQ,EAAE,CAAC;IACX,cAAc,EAAE,CAAC,GAAG,IAAI;IACxB,eAAe,EAAE,sBAAsB,CAAC,WAAW;IACnD,cAAc,EAAE,SAAS,EAAE,2CAA2C;CACvE,CAAC;AAEF,MAAM,iBAAiB,GAAG,IAAI,UAAU,CAAC,4BAA4B,CAAC,CAAC;AAEvE;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,iBAAiB;IAMvD;;;;;;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AAW;oBACrC,aAAa,GAAG,IAAI,CAAC,GAAG,CACtB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,GAAG,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\";\n\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 \"../../../storage-blob/src/policies/RequestPolicy\";\nimport type { RestError } from \"@azure/core-rest-pipeline\";\n\nimport type { StorageRetryOptions } from \"../StorageRetryPolicyFactory\";\nimport { URLConstants } from \"../utils/constants\";\nimport { delay, setURLParameter } from \"../utils/utils.common\";\nimport { logger } from \"../log\";\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/**\n * RetryPolicy types.\n */\nexport enum StorageRetryPolicyType {\n /**\n * Exponential retry. Retry time delay grows exponentially.\n */\n EXPONENTIAL,\n /**\n * Linear retry. Retry time delay grows linearly.\n */\n FIXED,\n}\n\n// Default values of StorageRetryOptions\nconst DEFAULT_RETRY_OPTIONS: StorageRetryOptions = {\n maxRetryDelayInMs: 120 * 1000,\n maxTries: 4,\n retryDelayInMs: 4 * 1000,\n retryPolicyType: StorageRetryPolicyType.EXPONENTIAL,\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 }\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 = true;\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 // [Copy source error code] Feature is pending on service side, skip retry on copy source error for now.\n // if (response) {\n // // Retry select Copy Source Error Codes.\n // if (response?.status >= 400) {\n // const copySourceError = response.headers.get(HeaderConstants.X_MS_CopySourceErrorCode);\n // if (copySourceError !== undefined) {\n // switch (copySourceError)\n // {\n // case \"InternalError\":\n // case \"OperationTimedOut\":\n // case \"ServerBusy\":\n // return true;\n // }\n // }\n // }\n // }\n\n 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(isPrimaryRetry: boolean, attempt: number, abortSignal?: AbortSignalLike) {\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,7 +1,7 @@
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
2
2
|
// Licensed under the MIT License.
|
3
3
|
import { AbortError } from "@azure/abort-controller";
|
4
|
-
import { isRestError, RestError
|
4
|
+
import { isRestError, RestError } from "@azure/core-rest-pipeline";
|
5
5
|
import { getErrorMessage } from "@azure/core-util";
|
6
6
|
import { URLConstants } from "../utils/constants";
|
7
7
|
import { delay, setURLParameter } from "../utils/utils.common";
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"StorageRetryPolicyV2.js","sourceRoot":"","sources":["../../../../src/policies/StorageRetryPolicyV2.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAKL,WAAW,EACX,SAAS,GACV,MAAM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AAW,CAAC,CAAC,CAAC,EAAE,CAAC;wBACnB,MAAM,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC,OAAO,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;wBAClF,KAAK,GAAG,CAAC,CAAC;oBACZ,CAAC;yBAAM,CAAC;wBACN,MAAM,CAAC,KAAK,CAAC,uCAAuC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;wBAC1E,MAAM,CAAC,CAAC;oBACV,CAAC;gBACH,CAAC;gBACD,UAAU,GAAG,WAAW,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;gBACvE,IAAI,UAAU,EAAE,CAAC;oBACf,MAAM,KAAK,CACT,cAAc,CAAC,cAAc,EAAE,OAAO,CAAC,EACvC,OAAO,CAAC,WAAW,EACnB,iBAAiB,CAClB,CAAC;gBACJ,CAAC;gBACD,OAAO,EAAE,CAAC;YACZ,CAAC;YACD,IAAI,QAAQ,EAAE,CAAC;gBACb,OAAO,QAAQ,CAAC;YAClB,CAAC;YACD,MAAM,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,SAAS,CAAC,yCAAyC,CAAC,CAAC;QAC1E,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortError } from \"@azure/abort-controller\";\nimport {\n PipelinePolicy,\n PipelineRequest,\n SendRequest,\n PipelineResponse,\n isRestError,\n RestError,\n} from \"@azure/core-rest-pipeline\";\nimport { getErrorMessage } from \"@azure/core-util\";\nimport { StorageRetryOptions } from \"../StorageRetryPolicyFactory\";\nimport { URLConstants } from \"../utils/constants\";\nimport { delay, setURLParameter } from \"../utils/utils.common\";\nimport { logger } from \"../log\";\n\n/**\n * Name of the {@link storageRetryPolicy}\n */\nexport const storageRetryPolicyName = \"storageRetryPolicy\";\n\n/**\n * RetryPolicy types.\n */\nexport enum StorageRetryPolicyType {\n /**\n * Exponential retry. Retry time delay grows exponentially.\n */\n EXPONENTIAL,\n /**\n * Linear retry. Retry time delay grows linearly.\n */\n FIXED,\n}\n\n// Default values of StorageRetryOptions\nconst DEFAULT_RETRY_OPTIONS = {\n maxRetryDelayInMs: 120 * 1000,\n maxTries: 4,\n retryDelayInMs: 4 * 1000,\n retryPolicyType: StorageRetryPolicyType.EXPONENTIAL,\n secondaryHost: \"\",\n tryTimeoutInMs: undefined, // Use server side default timeout strategy\n} as const;\n\nconst retriableErrors = [\n \"ETIMEDOUT\",\n \"ESOCKETTIMEDOUT\",\n \"ECONNREFUSED\",\n \"ECONNRESET\",\n \"ENOENT\",\n \"ENOTFOUND\",\n \"TIMEOUT\",\n \"EPIPE\",\n \"REQUEST_SEND_ERROR\",\n] as const;\n\nconst RETRY_ABORT_ERROR = new AbortError(\"The operation was aborted.\");\n\n/**\n * Retry policy with exponential retry and linear retry implemented.\n */\nexport function storageRetryPolicy(options: StorageRetryOptions = {}): PipelinePolicy {\n const retryPolicyType = options.retryPolicyType ?? DEFAULT_RETRY_OPTIONS.retryPolicyType;\n const maxTries = options.maxTries ?? DEFAULT_RETRY_OPTIONS.maxTries;\n const retryDelayInMs = options.retryDelayInMs ?? DEFAULT_RETRY_OPTIONS.retryDelayInMs;\n const maxRetryDelayInMs = options.maxRetryDelayInMs ?? DEFAULT_RETRY_OPTIONS.maxRetryDelayInMs;\n const tryTimeoutInMs = options.tryTimeoutInMs ?? DEFAULT_RETRY_OPTIONS.tryTimeoutInMs;\n\n function shouldRetry({\n isPrimaryRetry,\n attempt,\n response,\n error,\n }: {\n isPrimaryRetry: boolean;\n attempt: number;\n response?: PipelineResponse;\n error?: RestError;\n }): boolean {\n if (attempt >= maxTries) {\n logger.info(`RetryPolicy: Attempt(s) ${attempt} >= maxTries ${maxTries}, no further try.`);\n return false;\n }\n if (error) {\n for (const retriableError of retriableErrors) {\n if (\n error.name.toUpperCase().includes(retriableError) ||\n error.message.toUpperCase().includes(retriableError) ||\n (error.code && error.code.toString().toUpperCase() === retriableError)\n ) {\n logger.info(`RetryPolicy: Network error ${retriableError} found, will retry.`);\n return true;\n }\n }\n if (\n error?.code === \"PARSE_ERROR\" &&\n error?.message.startsWith(`Error \"Error: Unclosed root tag`)\n ) {\n logger.info(\n \"RetryPolicy: Incomplete XML response likely due to service timeout, will retry.\",\n );\n return true;\n }\n }\n // If attempt was against the secondary & it returned a StatusNotFound (404), then\n // the resource was not found. This may be due to replication delay. So, in this\n // case, we'll never try the secondary again for this operation.\n if (response || error) {\n const statusCode = response?.status ?? error?.statusCode ?? 0;\n if (!isPrimaryRetry && statusCode === 404) {\n logger.info(`RetryPolicy: Secondary access with 404, will retry.`);\n return true;\n }\n\n // Server internal error or server timeout\n if (statusCode === 503 || statusCode === 500) {\n logger.info(`RetryPolicy: Will retry for status code ${statusCode}.`);\n return true;\n }\n }\n\n // [Copy source error code] Feature is pending on service side, skip retry on copy source error for now.\n // if (response) {\n // // Retry select Copy Source Error Codes.\n // if (response?.status >= 400) {\n // const copySourceError = response.headers.get(HeaderConstants.X_MS_CopySourceErrorCode);\n // if (copySourceError !== undefined) {\n // switch (copySourceError)\n // {\n // case \"InternalError\":\n // case \"OperationTimedOut\":\n // case \"ServerBusy\":\n // return true;\n // }\n // }\n // }\n // }\n\n return false;\n }\n function calculateDelay(isPrimaryRetry: boolean, attempt: number): number {\n let delayTimeInMs = 0;\n\n if (isPrimaryRetry) {\n switch (retryPolicyType) {\n case StorageRetryPolicyType.EXPONENTIAL:\n delayTimeInMs = Math.min(\n (Math.pow(2, attempt - 1) - 1) * retryDelayInMs,\n maxRetryDelayInMs,\n );\n break;\n case StorageRetryPolicyType.FIXED:\n delayTimeInMs = retryDelayInMs;\n break;\n }\n } else {\n delayTimeInMs = Math.random() * 1000;\n }\n\n logger.info(`RetryPolicy: Delay for ${delayTimeInMs}ms`);\n return delayTimeInMs;\n }\n return {\n name: storageRetryPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n // Set the server-side timeout query parameter \"timeout=[seconds]\"\n if (tryTimeoutInMs) {\n request.url = setURLParameter(\n request.url,\n URLConstants.Parameters.TIMEOUT,\n String(Math.floor(tryTimeoutInMs / 1000)),\n );\n }\n const primaryUrl = request.url;\n let secondaryHas404 = false;\n let attempt = 1;\n let retryAgain = true;\n let response: PipelineResponse | undefined;\n let error: RestError | undefined;\n while (retryAgain) {\n const isPrimaryRetry: boolean = true;\n request.url = primaryUrl;\n response = undefined;\n error = undefined;\n try {\n logger.info(\n `RetryPolicy: =====> Try=${attempt} ${isPrimaryRetry ? \"Primary\" : \"Secondary\"}`,\n );\n response = await next(request);\n secondaryHas404 = secondaryHas404 || (!isPrimaryRetry && response.status === 404);\n } catch (e: unknown) {\n if (isRestError(e)) {\n logger.error(`RetryPolicy: Caught error, message: ${e.message}, code: ${e.code}`);\n error = e;\n } else {\n logger.error(`RetryPolicy: Caught error, message: ${getErrorMessage(e)}`);\n throw e;\n }\n }\n retryAgain = shouldRetry({ isPrimaryRetry, attempt, response, error });\n if (retryAgain) {\n await delay(\n calculateDelay(isPrimaryRetry, attempt),\n request.abortSignal,\n RETRY_ABORT_ERROR,\n );\n }\n attempt++;\n }\n if (response) {\n return response;\n }\n throw error ?? new RestError(\"RetryPolicy failed without known error.\");\n },\n };\n}\n"]}
|
1
|
+
{"version":3,"file":"StorageRetryPolicyV2.js","sourceRoot":"","sources":["../../../../src/policies/StorageRetryPolicyV2.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAOrD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,C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AC;yBAAM,CAAC;wBACN,MAAM,CAAC,KAAK,CAAC,uCAAuC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;wBAC1E,MAAM,CAAC,CAAC;oBACV,CAAC;gBACH,CAAC;gBACD,UAAU,GAAG,WAAW,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;gBACvE,IAAI,UAAU,EAAE,CAAC;oBACf,MAAM,KAAK,CACT,cAAc,CAAC,cAAc,EAAE,OAAO,CAAC,EACvC,OAAO,CAAC,WAAW,EACnB,iBAAiB,CAClB,CAAC;gBACJ,CAAC;gBACD,OAAO,EAAE,CAAC;YACZ,CAAC;YACD,IAAI,QAAQ,EAAE,CAAC;gBACb,OAAO,QAAQ,CAAC;YAClB,CAAC;YACD,MAAM,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,SAAS,CAAC,yCAAyC,CAAC,CAAC;QAC1E,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortError } from \"@azure/abort-controller\";\nimport type {\n PipelinePolicy,\n PipelineRequest,\n SendRequest,\n PipelineResponse,\n} from \"@azure/core-rest-pipeline\";\nimport { isRestError, RestError } from \"@azure/core-rest-pipeline\";\nimport { getErrorMessage } from \"@azure/core-util\";\nimport type { StorageRetryOptions } from \"../StorageRetryPolicyFactory\";\nimport { URLConstants } from \"../utils/constants\";\nimport { delay, setURLParameter } from \"../utils/utils.common\";\nimport { logger } from \"../log\";\n\n/**\n * Name of the {@link storageRetryPolicy}\n */\nexport const storageRetryPolicyName = \"storageRetryPolicy\";\n\n/**\n * RetryPolicy types.\n */\nexport enum StorageRetryPolicyType {\n /**\n * Exponential retry. Retry time delay grows exponentially.\n */\n EXPONENTIAL,\n /**\n * Linear retry. Retry time delay grows linearly.\n */\n FIXED,\n}\n\n// Default values of StorageRetryOptions\nconst DEFAULT_RETRY_OPTIONS = {\n maxRetryDelayInMs: 120 * 1000,\n maxTries: 4,\n retryDelayInMs: 4 * 1000,\n retryPolicyType: StorageRetryPolicyType.EXPONENTIAL,\n secondaryHost: \"\",\n tryTimeoutInMs: undefined, // Use server side default timeout strategy\n} as const;\n\nconst retriableErrors = [\n \"ETIMEDOUT\",\n \"ESOCKETTIMEDOUT\",\n \"ECONNREFUSED\",\n \"ECONNRESET\",\n \"ENOENT\",\n \"ENOTFOUND\",\n \"TIMEOUT\",\n \"EPIPE\",\n \"REQUEST_SEND_ERROR\",\n] as const;\n\nconst RETRY_ABORT_ERROR = new AbortError(\"The operation was aborted.\");\n\n/**\n * Retry policy with exponential retry and linear retry implemented.\n */\nexport function storageRetryPolicy(options: StorageRetryOptions = {}): PipelinePolicy {\n const retryPolicyType = options.retryPolicyType ?? DEFAULT_RETRY_OPTIONS.retryPolicyType;\n const maxTries = options.maxTries ?? DEFAULT_RETRY_OPTIONS.maxTries;\n const retryDelayInMs = options.retryDelayInMs ?? DEFAULT_RETRY_OPTIONS.retryDelayInMs;\n const maxRetryDelayInMs = options.maxRetryDelayInMs ?? DEFAULT_RETRY_OPTIONS.maxRetryDelayInMs;\n const tryTimeoutInMs = options.tryTimeoutInMs ?? DEFAULT_RETRY_OPTIONS.tryTimeoutInMs;\n\n function shouldRetry({\n isPrimaryRetry,\n attempt,\n response,\n error,\n }: {\n isPrimaryRetry: boolean;\n attempt: number;\n response?: PipelineResponse;\n error?: RestError;\n }): boolean {\n if (attempt >= maxTries) {\n logger.info(`RetryPolicy: Attempt(s) ${attempt} >= maxTries ${maxTries}, no further try.`);\n return false;\n }\n if (error) {\n for (const retriableError of retriableErrors) {\n if (\n error.name.toUpperCase().includes(retriableError) ||\n error.message.toUpperCase().includes(retriableError) ||\n (error.code && error.code.toString().toUpperCase() === retriableError)\n ) {\n logger.info(`RetryPolicy: Network error ${retriableError} found, will retry.`);\n return true;\n }\n }\n if (\n error?.code === \"PARSE_ERROR\" &&\n error?.message.startsWith(`Error \"Error: Unclosed root tag`)\n ) {\n logger.info(\n \"RetryPolicy: Incomplete XML response likely due to service timeout, will retry.\",\n );\n return true;\n }\n }\n // If attempt was against the secondary & it returned a StatusNotFound (404), then\n // the resource was not found. This may be due to replication delay. So, in this\n // case, we'll never try the secondary again for this operation.\n if (response || error) {\n const statusCode = response?.status ?? error?.statusCode ?? 0;\n if (!isPrimaryRetry && statusCode === 404) {\n logger.info(`RetryPolicy: Secondary access with 404, will retry.`);\n return true;\n }\n\n // Server internal error or server timeout\n if (statusCode === 503 || statusCode === 500) {\n logger.info(`RetryPolicy: Will retry for status code ${statusCode}.`);\n return true;\n }\n }\n\n // [Copy source error code] Feature is pending on service side, skip retry on copy source error for now.\n // if (response) {\n // // Retry select Copy Source Error Codes.\n // if (response?.status >= 400) {\n // const copySourceError = response.headers.get(HeaderConstants.X_MS_CopySourceErrorCode);\n // if (copySourceError !== undefined) {\n // switch (copySourceError)\n // {\n // case \"InternalError\":\n // case \"OperationTimedOut\":\n // case \"ServerBusy\":\n // return true;\n // }\n // }\n // }\n // }\n\n return false;\n }\n function calculateDelay(isPrimaryRetry: boolean, attempt: number): number {\n let delayTimeInMs = 0;\n\n if (isPrimaryRetry) {\n switch (retryPolicyType) {\n case StorageRetryPolicyType.EXPONENTIAL:\n delayTimeInMs = Math.min(\n (Math.pow(2, attempt - 1) - 1) * retryDelayInMs,\n maxRetryDelayInMs,\n );\n break;\n case StorageRetryPolicyType.FIXED:\n delayTimeInMs = retryDelayInMs;\n break;\n }\n } else {\n delayTimeInMs = Math.random() * 1000;\n }\n\n logger.info(`RetryPolicy: Delay for ${delayTimeInMs}ms`);\n return delayTimeInMs;\n }\n return {\n name: storageRetryPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n // Set the server-side timeout query parameter \"timeout=[seconds]\"\n if (tryTimeoutInMs) {\n request.url = setURLParameter(\n request.url,\n URLConstants.Parameters.TIMEOUT,\n String(Math.floor(tryTimeoutInMs / 1000)),\n );\n }\n const primaryUrl = request.url;\n let secondaryHas404 = false;\n let attempt = 1;\n let retryAgain = true;\n let response: PipelineResponse | undefined;\n let error: RestError | undefined;\n while (retryAgain) {\n const isPrimaryRetry: boolean = true;\n request.url = primaryUrl;\n response = undefined;\n error = undefined;\n try {\n logger.info(\n `RetryPolicy: =====> Try=${attempt} ${isPrimaryRetry ? \"Primary\" : \"Secondary\"}`,\n );\n response = await next(request);\n secondaryHas404 = secondaryHas404 || (!isPrimaryRetry && response.status === 404);\n } catch (e: unknown) {\n if (isRestError(e)) {\n logger.error(`RetryPolicy: Caught error, message: ${e.message}, code: ${e.code}`);\n error = e;\n } else {\n logger.error(`RetryPolicy: Caught error, message: ${getErrorMessage(e)}`);\n throw e;\n }\n }\n retryAgain = shouldRetry({ isPrimaryRetry, attempt, response, error });\n if (retryAgain) {\n await delay(\n calculateDelay(isPrimaryRetry, attempt),\n request.abortSignal,\n RETRY_ABORT_ERROR,\n );\n }\n attempt++;\n }\n if (response) {\n return response;\n }\n throw error ?? new RestError(\"RetryPolicy failed without known error.\");\n },\n };\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"BufferScheduler.js","sourceRoot":"","sources":["../../../../src/utils/BufferScheduler.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAQtC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,eAAe;IAuF1B;;;;;;;;;;;OAWG;IACH,YACE,QAAkB,EAClB,UAAkB,EAClB,UAAkB,EAClB,eAAgC,EAChC,WAAmB,EACnB,QAAyB;QAlF3B;;WAEG;QACc,YAAO,GAAiB,IAAI,YAAY,EAAE,CAAC;QAO5D;;WAEG;QACK,WAAM,GAAW,CAAC,CAAC;QAE3B;;WAEG;QACK,gBAAW,GAAY,KAAK,CAAC;QAErC;;WAEG;QACK,YAAO,GAAY,KAAK,CAAC;QAEjC;;W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under the MIT License.\n\nimport { EventEmitter } from \"events\";\nimport { Readable } from \"stream\";\n\n/**\n * OutgoingHandler is an async function triggered by BufferScheduler.\n */\nexport declare type OutgoingHandler = (buffer: Buffer, offset?: number) => Promise<any>;\n\n/**\n * This class accepts a Node.js Readable stream as input, and keeps reading data\n * from the stream into the internal buffer structure, until it reaches maxBuffers.\n * Every available buffer will try to trigger outgoingHandler.\n *\n * The internal buffer structure includes an incoming buffer array, and a outgoing\n * buffer array. The incoming buffer array includes the \"empty\" buffers can be filled\n * with new incoming data. The outgoing array includes the filled buffers to be\n * handled by outgoingHandler. Every above buffer size is defined by parameter bufferSize.\n *\n * NUM_OF_ALL_BUFFERS = BUFFERS_IN_INCOMING + BUFFERS_IN_OUTGOING + BUFFERS_UNDER_HANDLING\n *\n * NUM_OF_ALL_BUFFERS lesser than or equal to maxBuffers\n *\n * PERFORMANCE IMPROVEMENT TIPS:\n * 1. Input stream highWaterMark is better to set a same value with bufferSize\n * parameter, which will avoid Buffer.concat() operations.\n * 2. Concurrency should set a smaller value than maxBuffers, which is helpful to\n * reduce the possibility when a outgoing handler waits for the stream data.\n * in this situation, outgoing handlers are blocked.\n * Outgoing queue shouldn't be empty.\n */\nexport class BufferScheduler {\n /**\n * Size of buffers in incoming and outgoing queues. This class will try to align\n * data read from Readable stream into buffer chunks with bufferSize defined.\n */\n private readonly bufferSize: number;\n\n /**\n * How many buffers can be created or maintained.\n */\n private readonly maxBuffers: number;\n\n /**\n * A Node.js Readable stream.\n */\n private readonly readable: Readable;\n\n /**\n * OutgoingHandler is an async function triggered by BufferScheduler when there\n * are available buffers in outgoing array.\n */\n private readonly outgoingHandler: OutgoingHandler;\n\n /**\n * An internal event emitter.\n */\n private readonly emitter: EventEmitter = new EventEmitter();\n\n /**\n * Concurrency of executing outgoingHandlers. (0 lesser than concurrency lesser than or equal to maxBuffers)\n */\n private readonly concurrency: number;\n\n /**\n * An internal offset marker to track data offset in bytes of next outgoingHandler.\n */\n private offset: number = 0;\n\n /**\n * An internal marker to track whether stream is end.\n */\n private isStreamEnd: boolean = false;\n\n /**\n * An internal marker to track whether stream or outgoingHandler returns error.\n */\n private isError: boolean = false;\n\n /**\n * How many handlers are executing.\n */\n private executingOutgoingHandlers: number = 0;\n\n /**\n * Encoding of the input Readable stream which has string data type instead of Buffer.\n */\n private encoding?: BufferEncoding;\n\n /**\n * How many buffers have been allocated.\n */\n private numBuffers: number = 0;\n\n /**\n * Because this class doesn't know how much data every time stream pops, which\n * is defined by highWaterMarker of the stream. So BufferScheduler will cache\n * data received from the stream, when data in unresolvedDataArray exceeds the\n * blockSize defined, it will try to concat a blockSize of buffer, fill into available\n * buffers from incoming and push to outgoing array.\n */\n private unresolvedDataArray: Buffer[] = [];\n\n /**\n * How much data consisted in unresolvedDataArray.\n */\n private unresolvedLength: number = 0;\n\n /**\n * The array includes all the available buffers can be used to fill data from stream.\n */\n private incoming: Buffer[] = [];\n\n /**\n * The array (queue) includes all the buffers filled from stream data.\n */\n private outgoing: Buffer[] = [];\n\n /**\n * Creates an instance of BufferScheduler.\n *\n * @param readable - A Node.js Readable stream\n * @param bufferSize - Buffer size of every maintained buffer\n * @param maxBuffers - How many buffers can be allocated\n * @param outgoingHandler - An async function scheduled to be\n * triggered when a buffer fully filled\n * with stream data\n * @param concurrency - Concurrency of executing outgoingHandlers (greater than 0)\n * @param encoding - [Optional] Encoding of Readable stream when it's a string stream\n */\n constructor(\n readable: Readable,\n bufferSize: number,\n maxBuffers: number,\n outgoingHandler: OutgoingHandler,\n concurrency: number,\n encoding?: BufferEncoding,\n ) {\n if (bufferSize <= 0) {\n throw new RangeError(`bufferSize must be larger than 0, current is ${bufferSize}`);\n }\n\n if (maxBuffers <= 0) {\n throw new RangeError(`maxBuffers must be larger than 0, current is ${maxBuffers}`);\n }\n\n if (concurrency <= 0) {\n throw new RangeError(`concurrency must be larger than 0, current is ${concurrency}`);\n }\n\n this.bufferSize = bufferSize;\n this.maxBuffers = maxBuffers;\n this.readable = readable;\n this.outgoingHandler = outgoingHandler;\n this.concurrency = concurrency;\n this.encoding = encoding;\n }\n\n /**\n * Start the scheduler, will return error when stream of any of the outgoingHandlers\n * returns error.\n *\n */\n public async do(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n this.readable.on(\"data\", (data) => {\n data = typeof data === \"string\" ? Buffer.from(data, this.encoding) : data;\n this.appendUnresolvedData(data);\n\n if (!this.resolveData()) {\n this.readable.pause();\n }\n });\n\n this.readable.on(\"error\", (err) => {\n this.emitter.emit(\"error\", err);\n });\n\n this.readable.on(\"end\", () => {\n this.isStreamEnd = true;\n this.emitter.emit(\"checkEnd\");\n });\n\n this.emitter.on(\"error\", (err) => {\n this.isError = true;\n this.readable.pause();\n reject(err);\n });\n\n this.emitter.on(\"checkEnd\", () => {\n if (this.outgoing.length > 0) {\n this.triggerOutgoingHandlers();\n return;\n }\n\n if (this.isStreamEnd && this.executingOutgoingHandlers === 0) {\n if (this.unresolvedLength > 0 && this.unresolvedLength < this.bufferSize) {\n this.outgoingHandler(this.shiftBufferFromUnresolvedDataArray(), this.offset)\n .then(resolve)\n .catch(reject);\n } else if (this.unresolvedLength >= this.bufferSize) {\n return;\n } else {\n resolve();\n }\n }\n });\n });\n }\n\n /**\n * Insert a new data into unresolved array.\n *\n * @param data -\n */\n private appendUnresolvedData(data: Buffer) {\n this.unresolvedDataArray.push(data);\n this.unresolvedLength += data.length;\n }\n\n /**\n * Try to shift a buffer with size in blockSize. The buffer returned may be less\n * than blockSize when data in unresolvedDataArray is less than bufferSize.\n *\n */\n private shiftBufferFromUnresolvedDataArray(): Buffer {\n if (this.unresolvedLength >= this.bufferSize) {\n if (this.bufferSize === this.unresolvedDataArray[0].length) {\n this.unresolvedLength -= this.bufferSize;\n return this.unresolvedDataArray.shift()!;\n }\n\n // Lazy concat because Buffer.concat highly drops performance\n let merged = Buffer.concat(this.unresolvedDataArray, this.unresolvedLength);\n const buffer = merged.slice(0, this.bufferSize);\n merged = merged.slice(this.bufferSize);\n this.unresolvedDataArray = [merged];\n this.unresolvedLength -= buffer.length;\n return buffer;\n } else if (this.unresolvedLength > 0) {\n const merged = Buffer.concat(this.unresolvedDataArray, this.unresolvedLength);\n this.unresolvedDataArray = [];\n this.unresolvedLength = 0;\n return merged;\n } else {\n return Buffer.allocUnsafe(0);\n }\n }\n\n /**\n * Resolve data in unresolvedDataArray. For every buffer with size in blockSize\n * shifted, it will try to get (or allocate a buffer) from incoming, and fill it,\n * then push it into outgoing to be handled by outgoing handler.\n *\n * Return false when available buffers in incoming are not enough, else true.\n *\n * @returns Return false when buffers in incoming are not enough, else true.\n */\n private resolveData(): boolean {\n while (this.unresolvedLength >= this.bufferSize) {\n let buffer: Buffer;\n\n if (this.incoming.length > 0) {\n buffer = this.incoming.shift()!;\n } else {\n if (this.numBuffers < this.maxBuffers) {\n buffer = Buffer.allocUnsafe(this.bufferSize);\n this.numBuffers++;\n } else {\n // No available buffer, wait for buffer returned\n return false;\n }\n }\n\n buffer.fill(this.shiftBufferFromUnresolvedDataArray());\n this.outgoing.push(buffer);\n this.triggerOutgoingHandlers();\n }\n return true;\n }\n\n /**\n * Try to trigger a outgoing handler for every buffer in outgoing. Stop when\n * concurrency reaches.\n */\n private async triggerOutgoingHandlers() {\n let buffer: Buffer | undefined;\n do {\n if (this.executingOutgoingHandlers >= this.concurrency) {\n return;\n }\n\n buffer = this.outgoing.shift();\n if (buffer) {\n this.triggerOutgoingHandler(buffer);\n }\n } while (buffer);\n }\n\n /**\n * Trigger a outgoing handler for a buffer shifted from outgoing.\n *\n * @param buffer -\n */\n private async triggerOutgoingHandler(buffer: Buffer): Promise<any> {\n const bufferLength = buffer.length;\n\n this.executingOutgoingHandlers++;\n this.offset += bufferLength;\n\n try {\n await this.outgoingHandler(buffer, this.offset - bufferLength);\n } catch (err: any) {\n this.emitter.emit(\"error\", err);\n return;\n }\n\n this.executingOutgoingHandlers--;\n this.reuseBuffer(buffer);\n this.emitter.emit(\"checkEnd\");\n }\n\n /**\n * Return buffer used by outgoing handler into incoming.\n *\n * @param buffer -\n */\n private reuseBuffer(buffer: Buffer) {\n this.incoming.push(buffer);\n if (!this.isError && this.resolveData() && !this.isStreamEnd) {\n this.readable.resume();\n }\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"BufferScheduler.js","sourceRoot":"","sources":["../../../../src/utils/BufferScheduler.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAQtC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,eAAe;IAuF1B;;;;;;;;;;;OAWG;IACH,YACE,QAAkB,EAClB,UAAkB,EAClB,UAAkB,EAClB,eAAgC,EAChC,WAAmB,EACnB,QAAyB;QAlF3B;;WAEG;QACc,YAAO,GAAiB,IAAI,YAAY,EAAE,CAAC;QAO5D;;WAEG;QACK,WAAM,GAAW,CAAC,CAAC;QAE3B;;WAEG;QACK,gBAAW,GAAY,KAAK,CAAC;QAErC;;WAEG;QACK,YAAO,GAAY,KAAK,CAAC;QAEjC;;WAEG;QACK,8BAAyB,GAAW,CAAC,CAAC;QAO9C;;WAEG;QACK,eAAU,GAAW,CAAC,CAAC;QAE/B;;;;;;WAMG;QACK,wBAAmB,GAAa,EAAE,CAAC;QAE3C;;WAEG;QACK,qBAAgB,GAAW,CAAC,CAAC;QAErC;;WAEG;QACK,aAAQ,GAAa,EAAE,CAAC;QAEhC;;WAEG;QACK,aAAQ,GAAa,EAAE,CAAC;QAsB9B,IAAI,UAAU,IAAI,CAAC,EAAE,CAAC;YACpB,MAAM,IAAI,UAAU,CAAC,gDAAgD,UAAU,EAAE,CAAC,CAAC;QACrF,CAAC;QAED,IAAI,UAAU,IAAI,CAAC,EAAE,CAAC;YACpB,MAAM,IAAI,UAAU,CAAC,gDAAgD,UAAU,EAAE,CAAC,CAAC;QACrF,CAAC;QAED,IAAI,WAAW,IAAI,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,UAAU,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AAE,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,CAAC;QACjE,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;YAChC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,yBAAyB,EAAE,CAAC;QACjC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACK,WAAW,CAAC,MAAc;QAChC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3B,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YAC7D,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { EventEmitter } from \"events\";\nimport type { Readable } from \"stream\";\n\n/**\n * OutgoingHandler is an async function triggered by BufferScheduler.\n */\nexport declare type OutgoingHandler = (buffer: Buffer, offset?: number) => Promise<any>;\n\n/**\n * This class accepts a Node.js Readable stream as input, and keeps reading data\n * from the stream into the internal buffer structure, until it reaches maxBuffers.\n * Every available buffer will try to trigger outgoingHandler.\n *\n * The internal buffer structure includes an incoming buffer array, and a outgoing\n * buffer array. The incoming buffer array includes the \"empty\" buffers can be filled\n * with new incoming data. The outgoing array includes the filled buffers to be\n * handled by outgoingHandler. Every above buffer size is defined by parameter bufferSize.\n *\n * NUM_OF_ALL_BUFFERS = BUFFERS_IN_INCOMING + BUFFERS_IN_OUTGOING + BUFFERS_UNDER_HANDLING\n *\n * NUM_OF_ALL_BUFFERS lesser than or equal to maxBuffers\n *\n * PERFORMANCE IMPROVEMENT TIPS:\n * 1. Input stream highWaterMark is better to set a same value with bufferSize\n * parameter, which will avoid Buffer.concat() operations.\n * 2. Concurrency should set a smaller value than maxBuffers, which is helpful to\n * reduce the possibility when a outgoing handler waits for the stream data.\n * in this situation, outgoing handlers are blocked.\n * Outgoing queue shouldn't be empty.\n */\nexport class BufferScheduler {\n /**\n * Size of buffers in incoming and outgoing queues. This class will try to align\n * data read from Readable stream into buffer chunks with bufferSize defined.\n */\n private readonly bufferSize: number;\n\n /**\n * How many buffers can be created or maintained.\n */\n private readonly maxBuffers: number;\n\n /**\n * A Node.js Readable stream.\n */\n private readonly readable: Readable;\n\n /**\n * OutgoingHandler is an async function triggered by BufferScheduler when there\n * are available buffers in outgoing array.\n */\n private readonly outgoingHandler: OutgoingHandler;\n\n /**\n * An internal event emitter.\n */\n private readonly emitter: EventEmitter = new EventEmitter();\n\n /**\n * Concurrency of executing outgoingHandlers. (0 lesser than concurrency lesser than or equal to maxBuffers)\n */\n private readonly concurrency: number;\n\n /**\n * An internal offset marker to track data offset in bytes of next outgoingHandler.\n */\n private offset: number = 0;\n\n /**\n * An internal marker to track whether stream is end.\n */\n private isStreamEnd: boolean = false;\n\n /**\n * An internal marker to track whether stream or outgoingHandler returns error.\n */\n private isError: boolean = false;\n\n /**\n * How many handlers are executing.\n */\n private executingOutgoingHandlers: number = 0;\n\n /**\n * Encoding of the input Readable stream which has string data type instead of Buffer.\n */\n private encoding?: BufferEncoding;\n\n /**\n * How many buffers have been allocated.\n */\n private numBuffers: number = 0;\n\n /**\n * Because this class doesn't know how much data every time stream pops, which\n * is defined by highWaterMarker of the stream. So BufferScheduler will cache\n * data received from the stream, when data in unresolvedDataArray exceeds the\n * blockSize defined, it will try to concat a blockSize of buffer, fill into available\n * buffers from incoming and push to outgoing array.\n */\n private unresolvedDataArray: Buffer[] = [];\n\n /**\n * How much data consisted in unresolvedDataArray.\n */\n private unresolvedLength: number = 0;\n\n /**\n * The array includes all the available buffers can be used to fill data from stream.\n */\n private incoming: Buffer[] = [];\n\n /**\n * The array (queue) includes all the buffers filled from stream data.\n */\n private outgoing: Buffer[] = [];\n\n /**\n * Creates an instance of BufferScheduler.\n *\n * @param readable - A Node.js Readable stream\n * @param bufferSize - Buffer size of every maintained buffer\n * @param maxBuffers - How many buffers can be allocated\n * @param outgoingHandler - An async function scheduled to be\n * triggered when a buffer fully filled\n * with stream data\n * @param concurrency - Concurrency of executing outgoingHandlers (greater than 0)\n * @param encoding - [Optional] Encoding of Readable stream when it's a string stream\n */\n constructor(\n readable: Readable,\n bufferSize: number,\n maxBuffers: number,\n outgoingHandler: OutgoingHandler,\n concurrency: number,\n encoding?: BufferEncoding,\n ) {\n if (bufferSize <= 0) {\n throw new RangeError(`bufferSize must be larger than 0, current is ${bufferSize}`);\n }\n\n if (maxBuffers <= 0) {\n throw new RangeError(`maxBuffers must be larger than 0, current is ${maxBuffers}`);\n }\n\n if (concurrency <= 0) {\n throw new RangeError(`concurrency must be larger than 0, current is ${concurrency}`);\n }\n\n this.bufferSize = bufferSize;\n this.maxBuffers = maxBuffers;\n this.readable = readable;\n this.outgoingHandler = outgoingHandler;\n this.concurrency = concurrency;\n this.encoding = encoding;\n }\n\n /**\n * Start the scheduler, will return error when stream of any of the outgoingHandlers\n * returns error.\n *\n */\n public async do(): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n this.readable.on(\"data\", (data) => {\n data = typeof data === \"string\" ? Buffer.from(data, this.encoding) : data;\n this.appendUnresolvedData(data);\n\n if (!this.resolveData()) {\n this.readable.pause();\n }\n });\n\n this.readable.on(\"error\", (err) => {\n this.emitter.emit(\"error\", err);\n });\n\n this.readable.on(\"end\", () => {\n this.isStreamEnd = true;\n this.emitter.emit(\"checkEnd\");\n });\n\n this.emitter.on(\"error\", (err) => {\n this.isError = true;\n this.readable.pause();\n reject(err);\n });\n\n this.emitter.on(\"checkEnd\", () => {\n if (this.outgoing.length > 0) {\n this.triggerOutgoingHandlers();\n return;\n }\n\n if (this.isStreamEnd && this.executingOutgoingHandlers === 0) {\n if (this.unresolvedLength > 0 && this.unresolvedLength < this.bufferSize) {\n this.outgoingHandler(this.shiftBufferFromUnresolvedDataArray(), this.offset)\n .then(resolve)\n .catch(reject);\n } else if (this.unresolvedLength >= this.bufferSize) {\n return;\n } else {\n resolve();\n }\n }\n });\n });\n }\n\n /**\n * Insert a new data into unresolved array.\n *\n * @param data -\n */\n private appendUnresolvedData(data: Buffer) {\n this.unresolvedDataArray.push(data);\n this.unresolvedLength += data.length;\n }\n\n /**\n * Try to shift a buffer with size in blockSize. The buffer returned may be less\n * than blockSize when data in unresolvedDataArray is less than bufferSize.\n *\n */\n private shiftBufferFromUnresolvedDataArray(): Buffer {\n if (this.unresolvedLength >= this.bufferSize) {\n if (this.bufferSize === this.unresolvedDataArray[0].length) {\n this.unresolvedLength -= this.bufferSize;\n return this.unresolvedDataArray.shift()!;\n }\n\n // Lazy concat because Buffer.concat highly drops performance\n let merged = Buffer.concat(this.unresolvedDataArray, this.unresolvedLength);\n const buffer = merged.slice(0, this.bufferSize);\n merged = merged.slice(this.bufferSize);\n this.unresolvedDataArray = [merged];\n this.unresolvedLength -= buffer.length;\n return buffer;\n } else if (this.unresolvedLength > 0) {\n const merged = Buffer.concat(this.unresolvedDataArray, this.unresolvedLength);\n this.unresolvedDataArray = [];\n this.unresolvedLength = 0;\n return merged;\n } else {\n return Buffer.allocUnsafe(0);\n }\n }\n\n /**\n * Resolve data in unresolvedDataArray. For every buffer with size in blockSize\n * shifted, it will try to get (or allocate a buffer) from incoming, and fill it,\n * then push it into outgoing to be handled by outgoing handler.\n *\n * Return false when available buffers in incoming are not enough, else true.\n *\n * @returns Return false when buffers in incoming are not enough, else true.\n */\n private resolveData(): boolean {\n while (this.unresolvedLength >= this.bufferSize) {\n let buffer: Buffer;\n\n if (this.incoming.length > 0) {\n buffer = this.incoming.shift()!;\n } else {\n if (this.numBuffers < this.maxBuffers) {\n buffer = Buffer.allocUnsafe(this.bufferSize);\n this.numBuffers++;\n } else {\n // No available buffer, wait for buffer returned\n return false;\n }\n }\n\n buffer.fill(this.shiftBufferFromUnresolvedDataArray());\n this.outgoing.push(buffer);\n this.triggerOutgoingHandlers();\n }\n return true;\n }\n\n /**\n * Try to trigger a outgoing handler for every buffer in outgoing. Stop when\n * concurrency reaches.\n */\n private async triggerOutgoingHandlers() {\n let buffer: Buffer | undefined;\n do {\n if (this.executingOutgoingHandlers >= this.concurrency) {\n return;\n }\n\n buffer = this.outgoing.shift();\n if (buffer) {\n this.triggerOutgoingHandler(buffer);\n }\n } while (buffer);\n }\n\n /**\n * Trigger a outgoing handler for a buffer shifted from outgoing.\n *\n * @param buffer -\n */\n private async triggerOutgoingHandler(buffer: Buffer): Promise<any> {\n const bufferLength = buffer.length;\n\n this.executingOutgoingHandlers++;\n this.offset += bufferLength;\n\n try {\n await this.outgoingHandler(buffer, this.offset - bufferLength);\n } catch (err: any) {\n this.emitter.emit(\"error\", err);\n return;\n }\n\n this.executingOutgoingHandlers--;\n this.reuseBuffer(buffer);\n this.emitter.emit(\"checkEnd\");\n }\n\n /**\n * Return buffer used by outgoing handler into incoming.\n *\n * @param buffer -\n */\n private reuseBuffer(buffer: Buffer) {\n this.incoming.push(buffer);\n if (!this.isError && this.resolveData() && !this.isStreamEnd) {\n this.readable.resume();\n }\n }\n}\n"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"RetriableReadableStream.js","sourceRoot":"","sources":["../../../../src/utils/RetriableReadableStream.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AA2BlC;;;;GAIG;AACH,MAAM,OAAO,uBAAwB,SAAQ,QAAQ;IAWnD;;;;;;;;;OASG;IACH,YACE,MAA6B,EAC7B,MAA4B,EAC5B,MAAc,EACd,KAAa,EACb,UAA0C,EAAE;QAE5C,KAAK,EAAE,CAAC;QAtBF,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AAmB,EAAE,QAAiC;QAC7D,iDAAiD;QACjD,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAChC,IAAI,CAAC,MAAmB,CAAC,OAAO,EAAE,CAAC;QAEpC,QAAQ,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { AbortError } from \"@azure/abort-controller\";\nimport { TransferProgressEvent } from \"@azure/core-rest-pipeline\";\nimport { Readable } from \"stream\";\n\nexport type ReadableStreamGetter = (offset: number) => Promise<NodeJS.ReadableStream>;\n\nexport interface RetriableReadableStreamOptions {\n /**\n * Max retry count (greater than or equal to 0), undefined or invalid value means no retry\n */\n maxRetryRequests?: number;\n\n /**\n * Read progress event handler\n */\n onProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Debug purpose only. Used to inject an unexpected end to existing internal stream,\n * to test stream retry works well or not.\n *\n * When assign it to true, for next incoming \"data\" event of internal stream,\n * RetriableReadableStream will try to emit an \"end\" event to existing internal\n * stream to force it end and start retry from the breaking point.\n * The value will then update to \"undefined\", once the injection works.\n */\n doInjectErrorOnce?: boolean;\n}\n\n/**\n * ONLY AVAILABLE IN NODE.JS RUNTIME.\n *\n * A Node.js ReadableStream will internally retry when internal ReadableStream unexpected ends.\n */\nexport class RetriableReadableStream extends Readable {\n private start: number;\n private offset: number;\n private end: number;\n private getter: ReadableStreamGetter;\n private source: NodeJS.ReadableStream;\n private retries: number = 0;\n private maxRetryRequests: number;\n private onProgress?: (progress: TransferProgressEvent) => void;\n private options: RetriableReadableStreamOptions;\n\n /**\n * Creates an instance of RetriableReadableStream.\n *\n * @param source - The current ReadableStream returned from getter\n * @param getter - A method calling downloading request returning\n * a new ReadableStream from specified offset\n * @param offset - Offset position in original data source to read\n * @param count - How much data in original data source to read\n * @param options -\n */\n public constructor(\n source: NodeJS.ReadableStream,\n getter: ReadableStreamGetter,\n offset: number,\n count: number,\n options: RetriableReadableStreamOptions = {},\n ) {\n super();\n this.getter = getter;\n this.source = source;\n this.start = offset;\n this.offset = offset;\n this.end = offset + count - 1;\n this.maxRetryRequests =\n options.maxRetryRequests && options.maxRetryRequests >= 0 ? options.maxRetryRequests : 0;\n this.onProgress = options.onProgress;\n this.options = options;\n\n this.setSourceEventHandlers();\n }\n\n public _read(): void {\n this.source.resume();\n }\n\n private setSourceEventHandlers() {\n this.source.on(\"data\", this.sourceDataHandler);\n this.source.on(\"end\", this.sourceErrorOrEndHandler);\n this.source.on(\"error\", this.sourceErrorOrEndHandler);\n // needed for Node14\n this.source.on(\"aborted\", this.sourceAbortedHandler);\n }\n\n private removeSourceEventHandlers() {\n this.source.removeListener(\"data\", this.sourceDataHandler);\n this.source.removeListener(\"end\", this.sourceErrorOrEndHandler);\n this.source.removeListener(\"error\", this.sourceErrorOrEndHandler);\n this.source.removeListener(\"aborted\", this.sourceAbortedHandler);\n }\n\n private sourceDataHandler = (data: Buffer) => {\n if (this.options.doInjectErrorOnce) {\n this.options.doInjectErrorOnce = undefined;\n this.source.pause();\n this.sourceErrorOrEndHandler();\n (this.source as Readable).destroy();\n return;\n }\n\n // console.log(\n // `Offset: ${this.offset}, Received ${data.length} from internal stream`\n // );\n this.offset += data.length;\n if (this.onProgress) {\n this.onProgress({ loadedBytes: this.offset - this.start });\n }\n if (!this.push(data)) {\n this.source.pause();\n }\n };\n\n private sourceAbortedHandler = () => {\n const abortError = new AbortError(\"The operation was aborted.\");\n this.destroy(abortError);\n };\n\n private sourceErrorOrEndHandler = (err?: Error) => {\n if (err && err.name === \"AbortError\") {\n this.destroy(err);\n return;\n }\n\n // console.log(\n // `Source stream emits end or error, offset: ${\n // this.offset\n // }, dest end : ${this.end}`\n // );\n this.removeSourceEventHandlers();\n if (this.offset - 1 === this.end) {\n this.push(null);\n } else if (this.offset <= this.end) {\n // console.log(\n // `retries: ${this.retries}, max retries: ${this.maxRetries}`\n // );\n if (this.retries < this.maxRetryRequests) {\n this.retries += 1;\n this.getter(this.offset)\n .then((newSource) => {\n this.source = newSource;\n this.setSourceEventHandlers();\n return;\n })\n .catch((error) => {\n this.destroy(error);\n });\n } else {\n this.destroy(\n new Error(\n `Data corruption failure: received less data than required and reached maxRetires limitation. Received data offset: ${\n this.offset - 1\n }, data needed offset: ${this.end}, retries: ${this.retries}, max retries: ${\n this.maxRetryRequests\n }`,\n ),\n );\n }\n } else {\n this.destroy(\n new Error(\n `Data corruption failure: Received more data than original request, data needed offset is ${\n this.end\n }, received offset: ${this.offset - 1}`,\n ),\n );\n }\n };\n\n _destroy(error: Error | null, callback: (error?: Error) => void): void {\n // remove listener from source and release source\n this.removeSourceEventHandlers();\n (this.source as Readable).destroy();\n\n callback(error === null ? undefined : error);\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"RetriableReadableStream.js","sourceRoot":"","sources":["../../../../src/utils/RetriableReadableStream.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AA2BlC;;;;GAIG;AACH,MAAM,OAAO,uBAAwB,SAAQ,QAAQ;IAWnD;;;;;;;;;OASG;IACH,YACE,MAA6B,EAC7B,MAA4B,EAC5B,MAAc,EACd,KAAa,EACb,UAA0C,EAAE;QAE5C,KAAK,EAAE,CAAC;QAtBF,YAAO,GAAW,CAAC,CAAC;QAuDpB,sBAAiB,GAAG,CAAC,IAAY,EAAE,EAAE;YAC3C,IAAI,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;gBACnC,IAAI,CAAC,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;gBAC3C,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;gBACpB,IAAI,CAAC,uBAAuB,EAAE,CAAC;gBAC9B,IAAI,CAAC,MAAmB,CAAC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/abort-controller\";\nimport type { TransferProgressEvent } from \"@azure/core-rest-pipeline\";\nimport { Readable } from \"stream\";\n\nexport type ReadableStreamGetter = (offset: number) => Promise<NodeJS.ReadableStream>;\n\nexport interface RetriableReadableStreamOptions {\n /**\n * Max retry count (greater than or equal to 0), undefined or invalid value means no retry\n */\n maxRetryRequests?: number;\n\n /**\n * Read progress event handler\n */\n onProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Debug purpose only. Used to inject an unexpected end to existing internal stream,\n * to test stream retry works well or not.\n *\n * When assign it to true, for next incoming \"data\" event of internal stream,\n * RetriableReadableStream will try to emit an \"end\" event to existing internal\n * stream to force it end and start retry from the breaking point.\n * The value will then update to \"undefined\", once the injection works.\n */\n doInjectErrorOnce?: boolean;\n}\n\n/**\n * ONLY AVAILABLE IN NODE.JS RUNTIME.\n *\n * A Node.js ReadableStream will internally retry when internal ReadableStream unexpected ends.\n */\nexport class RetriableReadableStream extends Readable {\n private start: number;\n private offset: number;\n private end: number;\n private getter: ReadableStreamGetter;\n private source: NodeJS.ReadableStream;\n private retries: number = 0;\n private maxRetryRequests: number;\n private onProgress?: (progress: TransferProgressEvent) => void;\n private options: RetriableReadableStreamOptions;\n\n /**\n * Creates an instance of RetriableReadableStream.\n *\n * @param source - The current ReadableStream returned from getter\n * @param getter - A method calling downloading request returning\n * a new ReadableStream from specified offset\n * @param offset - Offset position in original data source to read\n * @param count - How much data in original data source to read\n * @param options -\n */\n public constructor(\n source: NodeJS.ReadableStream,\n getter: ReadableStreamGetter,\n offset: number,\n count: number,\n options: RetriableReadableStreamOptions = {},\n ) {\n super();\n this.getter = getter;\n this.source = source;\n this.start = offset;\n this.offset = offset;\n this.end = offset + count - 1;\n this.maxRetryRequests =\n options.maxRetryRequests && options.maxRetryRequests >= 0 ? options.maxRetryRequests : 0;\n this.onProgress = options.onProgress;\n this.options = options;\n\n this.setSourceEventHandlers();\n }\n\n public _read(): void {\n this.source.resume();\n }\n\n private setSourceEventHandlers() {\n this.source.on(\"data\", this.sourceDataHandler);\n this.source.on(\"end\", this.sourceErrorOrEndHandler);\n this.source.on(\"error\", this.sourceErrorOrEndHandler);\n // needed for Node14\n this.source.on(\"aborted\", this.sourceAbortedHandler);\n }\n\n private removeSourceEventHandlers() {\n this.source.removeListener(\"data\", this.sourceDataHandler);\n this.source.removeListener(\"end\", this.sourceErrorOrEndHandler);\n this.source.removeListener(\"error\", this.sourceErrorOrEndHandler);\n this.source.removeListener(\"aborted\", this.sourceAbortedHandler);\n }\n\n private sourceDataHandler = (data: Buffer) => {\n if (this.options.doInjectErrorOnce) {\n this.options.doInjectErrorOnce = undefined;\n this.source.pause();\n this.sourceErrorOrEndHandler();\n (this.source as Readable).destroy();\n return;\n }\n\n // console.log(\n // `Offset: ${this.offset}, Received ${data.length} from internal stream`\n // );\n this.offset += data.length;\n if (this.onProgress) {\n this.onProgress({ loadedBytes: this.offset - this.start });\n }\n if (!this.push(data)) {\n this.source.pause();\n }\n };\n\n private sourceAbortedHandler = () => {\n const abortError = new AbortError(\"The operation was aborted.\");\n this.destroy(abortError);\n };\n\n private sourceErrorOrEndHandler = (err?: Error) => {\n if (err && err.name === \"AbortError\") {\n this.destroy(err);\n return;\n }\n\n // console.log(\n // `Source stream emits end or error, offset: ${\n // this.offset\n // }, dest end : ${this.end}`\n // );\n this.removeSourceEventHandlers();\n if (this.offset - 1 === this.end) {\n this.push(null);\n } else if (this.offset <= this.end) {\n // console.log(\n // `retries: ${this.retries}, max retries: ${this.maxRetries}`\n // );\n if (this.retries < this.maxRetryRequests) {\n this.retries += 1;\n this.getter(this.offset)\n .then((newSource) => {\n this.source = newSource;\n this.setSourceEventHandlers();\n return;\n })\n .catch((error) => {\n this.destroy(error);\n });\n } else {\n this.destroy(\n new Error(\n `Data corruption failure: received less data than required and reached maxRetires limitation. Received data offset: ${\n this.offset - 1\n }, data needed offset: ${this.end}, retries: ${this.retries}, max retries: ${\n this.maxRetryRequests\n }`,\n ),\n );\n }\n } else {\n this.destroy(\n new Error(\n `Data corruption failure: Received more data than original request, data needed offset is ${\n this.end\n }, received offset: ${this.offset - 1}`,\n ),\n );\n }\n };\n\n _destroy(error: Error | null, callback: (error?: Error) => void): void {\n // remove listener from source and release source\n this.removeSourceEventHandlers();\n (this.source as Readable).destroy();\n\n callback(error === null ? undefined : error);\n }\n}\n"]}
|