@atlassian-dc-mcp/bitbucket 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/bin/run.js +2 -0
- package/package.json +7 -4
- package/src/bitbucket-client/core/ApiError.ts +26 -0
- package/src/bitbucket-client/core/ApiRequestOptions.ts +17 -0
- package/src/bitbucket-client/core/ApiResult.ts +11 -0
- package/src/bitbucket-client/core/CancelablePromise.ts +131 -0
- package/src/bitbucket-client/core/OpenAPI.ts +33 -0
- package/src/bitbucket-client/core/request.ts +322 -0
- package/src/bitbucket-client/index.ts +303 -0
- package/src/bitbucket-client/models/AdminPasswordUpdate.ts +10 -0
- package/src/bitbucket-client/models/ApplicationId.ts +5 -0
- package/src/bitbucket-client/models/ApplicationUser.ts +7 -0
- package/src/bitbucket-client/models/AuthenticationEntity.ts +13 -0
- package/src/bitbucket-client/models/AuthenticationResponse.ts +7 -0
- package/src/bitbucket-client/models/BasicAuthConfigEntity.ts +7 -0
- package/src/bitbucket-client/models/CaptchaDataEntity.ts +7 -0
- package/src/bitbucket-client/models/Comment.ts +38 -0
- package/src/bitbucket-client/models/CommentOperations.ts +10 -0
- package/src/bitbucket-client/models/CommentThread.ts +22 -0
- package/src/bitbucket-client/models/CommentThreadDiffAnchor.ts +46 -0
- package/src/bitbucket-client/models/Commentable.ts +5 -0
- package/src/bitbucket-client/models/Context.ts +8 -0
- package/src/bitbucket-client/models/ConversationDTO.ts +8 -0
- package/src/bitbucket-client/models/Credentials.ts +10 -0
- package/src/bitbucket-client/models/CredentialsCheckFailedDTO.ts +7 -0
- package/src/bitbucket-client/models/DiffContentFilter.ts +5 -0
- package/src/bitbucket-client/models/ElevationMethodRestDTO.ts +7 -0
- package/src/bitbucket-client/models/EnrichedRepository.ts +7 -0
- package/src/bitbucket-client/models/ErrorEntity.ts +7 -0
- package/src/bitbucket-client/models/ExampleAvatarMultipartFormData.ts +11 -0
- package/src/bitbucket-client/models/ExampleCertificateMultipartFormData.ts +11 -0
- package/src/bitbucket-client/models/ExampleFiles.ts +7 -0
- package/src/bitbucket-client/models/ExampleJsonLastModifiedCallback.ts +7 -0
- package/src/bitbucket-client/models/ExampleMultipartFormData.ts +27 -0
- package/src/bitbucket-client/models/ExamplePostMultipartFormData.ts +23 -0
- package/src/bitbucket-client/models/ExamplePreviewMigration.ts +7 -0
- package/src/bitbucket-client/models/ExamplePutMultipartFormData.ts +19 -0
- package/src/bitbucket-client/models/ExampleRequirements.ts +7 -0
- package/src/bitbucket-client/models/ExampleSettings.ts +7 -0
- package/src/bitbucket-client/models/ExampleSettingsMap.ts +7 -0
- package/src/bitbucket-client/models/ExampleSocketAddress.ts +7 -0
- package/src/bitbucket-client/models/ExampleStatus.ts +7 -0
- package/src/bitbucket-client/models/FileListResource.ts +7 -0
- package/src/bitbucket-client/models/FilePart.ts +13 -0
- package/src/bitbucket-client/models/Group.ts +7 -0
- package/src/bitbucket-client/models/GroupAndUsers.ts +9 -0
- package/src/bitbucket-client/models/GroupPickerContext.ts +9 -0
- package/src/bitbucket-client/models/IdpConfigEntity.ts +7 -0
- package/src/bitbucket-client/models/JitConfigEntity.ts +7 -0
- package/src/bitbucket-client/models/JitUserEntity.ts +7 -0
- package/src/bitbucket-client/models/LineNumberRange.ts +10 -0
- package/src/bitbucket-client/models/LoginOptionEntity.ts +7 -0
- package/src/bitbucket-client/models/MethodStateDTO.ts +7 -0
- package/src/bitbucket-client/models/NextLoginStepDTO.ts +7 -0
- package/src/bitbucket-client/models/OptionalBodyBeanParam.ts +5 -0
- package/src/bitbucket-client/models/PageRequestImpl.ts +9 -0
- package/src/bitbucket-client/models/PasswordElevationRestDTO.ts +8 -0
- package/src/bitbucket-client/models/Project.ts +19 -0
- package/src/bitbucket-client/models/PropertyMap.ts +7 -0
- package/src/bitbucket-client/models/PullRequest.ts +36 -0
- package/src/bitbucket-client/models/PullRequestParticipant.ts +28 -0
- package/src/bitbucket-client/models/PullRequestRef.ts +15 -0
- package/src/bitbucket-client/models/RefType.ts +7 -0
- package/src/bitbucket-client/models/Repository.ts +36 -0
- package/src/bitbucket-client/models/RepositoryHookDetails.ts +7 -0
- package/src/bitbucket-client/models/RestAccessToken.ts +7 -0
- package/src/bitbucket-client/models/RestAccessTokenRequest.ts +10 -0
- package/src/bitbucket-client/models/RestAggregateRejectCounter.ts +7 -0
- package/src/bitbucket-client/models/RestAnalyticsSettings.ts +7 -0
- package/src/bitbucket-client/models/RestAnnouncementBanner.ts +7 -0
- package/src/bitbucket-client/models/RestApplicationProperties.ts +7 -0
- package/src/bitbucket-client/models/RestApplicationUser.ts +7 -0
- package/src/bitbucket-client/models/RestApplicationUserWithPermissions.ts +7 -0
- package/src/bitbucket-client/models/RestApplySuggestionRequest.ts +11 -0
- package/src/bitbucket-client/models/RestAttachmentMetadata.ts +7 -0
- package/src/bitbucket-client/models/RestAuthenticationRequest.ts +11 -0
- package/src/bitbucket-client/models/RestAutoDeclineSettings.ts +7 -0
- package/src/bitbucket-client/models/RestAutoDeclineSettingsRequest.ts +9 -0
- package/src/bitbucket-client/models/RestAutoMergeProcessingResult.ts +7 -0
- package/src/bitbucket-client/models/RestAutoMergeProjectSettingsRequest.ts +16 -0
- package/src/bitbucket-client/models/RestAutoMergeRequest.ts +7 -0
- package/src/bitbucket-client/models/RestAutoMergeRestrictedSettings.ts +7 -0
- package/src/bitbucket-client/models/RestAutoMergeSettingsRequest.ts +8 -0
- package/src/bitbucket-client/models/RestBearerTokenCredentials.ts +8 -0
- package/src/bitbucket-client/models/RestBitbucketLicense.ts +7 -0
- package/src/bitbucket-client/models/RestBranch.ts +7 -0
- package/src/bitbucket-client/models/RestBranchCreateRequest.ts +15 -0
- package/src/bitbucket-client/models/RestBranchDeleteRequest.ts +19 -0
- package/src/bitbucket-client/models/RestBuildCapabilities.ts +7 -0
- package/src/bitbucket-client/models/RestBuildStats.ts +7 -0
- package/src/bitbucket-client/models/RestBuildStatus.ts +7 -0
- package/src/bitbucket-client/models/RestBuildStatusSetRequest.ts +31 -0
- package/src/bitbucket-client/models/RestBulkAddInsightAnnotationRequest.ts +10 -0
- package/src/bitbucket-client/models/RestBulkUserRateLimitSettingsUpdateRequest.ts +13 -0
- package/src/bitbucket-client/models/RestChange.ts +7 -0
- package/src/bitbucket-client/models/RestChangeset.ts +7 -0
- package/src/bitbucket-client/models/RestClusterInformation.ts +7 -0
- package/src/bitbucket-client/models/RestClusterNode.ts +7 -0
- package/src/bitbucket-client/models/RestComment.ts +7 -0
- package/src/bitbucket-client/models/RestCommentJiraIssue.ts +7 -0
- package/src/bitbucket-client/models/RestCommentThreadDiffAnchor.ts +7 -0
- package/src/bitbucket-client/models/RestCommit.ts +7 -0
- package/src/bitbucket-client/models/RestCommitMessageSuggestion.ts +7 -0
- package/src/bitbucket-client/models/RestConflict.ts +7 -0
- package/src/bitbucket-client/models/RestConflictChange.ts +7 -0
- package/src/bitbucket-client/models/RestConnectivitySummary.ts +7 -0
- package/src/bitbucket-client/models/RestCreateBranchRequest.ts +10 -0
- package/src/bitbucket-client/models/RestCreateTagRequest.ts +10 -0
- package/src/bitbucket-client/models/RestDefaultBranch.ts +8 -0
- package/src/bitbucket-client/models/RestDefaultReviewersRequest.ts +38 -0
- package/src/bitbucket-client/models/RestDefaultTask.ts +7 -0
- package/src/bitbucket-client/models/RestDefaultTaskRequest.ts +33 -0
- package/src/bitbucket-client/models/RestDelayedSyncRepository.ts +10 -0
- package/src/bitbucket-client/models/RestDeployment.ts +7 -0
- package/src/bitbucket-client/models/RestDeploymentEnvironment.ts +7 -0
- package/src/bitbucket-client/models/RestDeploymentSetRequest.ts +28 -0
- package/src/bitbucket-client/models/RestDetailedGroup.ts +7 -0
- package/src/bitbucket-client/models/RestDetailedInvocation.ts +7 -0
- package/src/bitbucket-client/models/RestDetailedUser.ts +7 -0
- package/src/bitbucket-client/models/RestDiff.ts +7 -0
- package/src/bitbucket-client/models/RestDiffHunk.ts +7 -0
- package/src/bitbucket-client/models/RestDiffLine.ts +7 -0
- package/src/bitbucket-client/models/RestDiffSegment.ts +7 -0
- package/src/bitbucket-client/models/RestDiffStatsSummary.ts +7 -0
- package/src/bitbucket-client/models/RestEmoticon.ts +7 -0
- package/src/bitbucket-client/models/RestEnhancedEntityLink.ts +7 -0
- package/src/bitbucket-client/models/RestErasedUser.ts +7 -0
- package/src/bitbucket-client/models/RestErrorMessage.ts +7 -0
- package/src/bitbucket-client/models/RestErrors.ts +7 -0
- package/src/bitbucket-client/models/RestExportRequest.ts +13 -0
- package/src/bitbucket-client/models/RestFarmSynchronizationRequest.ts +17 -0
- package/src/bitbucket-client/models/RestGitTagCreateRequest.ts +18 -0
- package/src/bitbucket-client/models/RestGpgKey.ts +7 -0
- package/src/bitbucket-client/models/RestGpgSubKey.ts +7 -0
- package/src/bitbucket-client/models/RestHookScript.ts +7 -0
- package/src/bitbucket-client/models/RestHookScriptConfig.ts +7 -0
- package/src/bitbucket-client/models/RestHookScriptTriggers.ts +8 -0
- package/src/bitbucket-client/models/RestImportRequest.ts +8 -0
- package/src/bitbucket-client/models/RestInsightAnnotation.ts +7 -0
- package/src/bitbucket-client/models/RestInsightAnnotationsResponse.ts +7 -0
- package/src/bitbucket-client/models/RestInsightReport.ts +7 -0
- package/src/bitbucket-client/models/RestInsightReportData.ts +7 -0
- package/src/bitbucket-client/models/RestInvocationHistory.ts +7 -0
- package/src/bitbucket-client/models/RestInvocationRequest.ts +7 -0
- package/src/bitbucket-client/models/RestInvocationResult.ts +7 -0
- package/src/bitbucket-client/models/RestJiraIssue.ts +9 -0
- package/src/bitbucket-client/models/RestJob.ts +7 -0
- package/src/bitbucket-client/models/RestJobMessage.ts +7 -0
- package/src/bitbucket-client/models/RestLabel.ts +7 -0
- package/src/bitbucket-client/models/RestLabelable.ts +7 -0
- package/src/bitbucket-client/models/RestLogLevel.ts +7 -0
- package/src/bitbucket-client/models/RestLoggingSettings.ts +7 -0
- package/src/bitbucket-client/models/RestMailConfiguration.ts +7 -0
- package/src/bitbucket-client/models/RestMarkup.ts +7 -0
- package/src/bitbucket-client/models/RestMeshConnectivityReport.ts +7 -0
- package/src/bitbucket-client/models/RestMeshMigrationQueueStateCounts.ts +7 -0
- package/src/bitbucket-client/models/RestMeshMigrationRequest.ts +14 -0
- package/src/bitbucket-client/models/RestMeshMigrationSummary.ts +7 -0
- package/src/bitbucket-client/models/RestMeshNode.ts +7 -0
- package/src/bitbucket-client/models/RestMigrationRepository.ts +7 -0
- package/src/bitbucket-client/models/RestMinimalCommit.ts +7 -0
- package/src/bitbucket-client/models/RestMinimalRef.ts +7 -0
- package/src/bitbucket-client/models/RestMirrorHashes.ts +7 -0
- package/src/bitbucket-client/models/RestMirrorRepositorySynchronizationStatus.ts +7 -0
- package/src/bitbucket-client/models/RestMirrorServer.ts +7 -0
- package/src/bitbucket-client/models/RestMirrorUpgradeRequest.ts +9 -0
- package/src/bitbucket-client/models/RestMirroredRepository.ts +7 -0
- package/src/bitbucket-client/models/RestMirroredRepositoryDescriptor.ts +7 -0
- package/src/bitbucket-client/models/RestMirroringRequest.ts +7 -0
- package/src/bitbucket-client/models/RestMultilineCommentMarker.ts +7 -0
- package/src/bitbucket-client/models/RestMultilineCommentSpan.ts +7 -0
- package/src/bitbucket-client/models/RestMultipleBuildStats.ts +7 -0
- package/src/bitbucket-client/models/RestNamedLink.ts +7 -0
- package/src/bitbucket-client/models/RestNode.ts +7 -0
- package/src/bitbucket-client/models/RestNodeConnectivityReport.ts +7 -0
- package/src/bitbucket-client/models/RestNodeConnectivitySummary.ts +7 -0
- package/src/bitbucket-client/models/RestPageIdpConfigEntity.ts +14 -0
- package/src/bitbucket-client/models/RestPageLoginOptionEntity.ts +14 -0
- package/src/bitbucket-client/models/RestPageRestChange.ts +7 -0
- package/src/bitbucket-client/models/RestPath.ts +7 -0
- package/src/bitbucket-client/models/RestPermitted.ts +7 -0
- package/src/bitbucket-client/models/RestPermittedGroup.ts +7 -0
- package/src/bitbucket-client/models/RestPermittedUser.ts +7 -0
- package/src/bitbucket-client/models/RestPerson.ts +7 -0
- package/src/bitbucket-client/models/RestProgress.ts +7 -0
- package/src/bitbucket-client/models/RestProject.ts +7 -0
- package/src/bitbucket-client/models/RestProjectSettingsRestriction.ts +7 -0
- package/src/bitbucket-client/models/RestProjectSettingsRestrictionRequest.ts +10 -0
- package/src/bitbucket-client/models/RestProperties.ts +7 -0
- package/src/bitbucket-client/models/RestPullRequest.ts +7 -0
- package/src/bitbucket-client/models/RestPullRequestActivity.ts +7 -0
- package/src/bitbucket-client/models/RestPullRequestAssignParticipantRoleRequest.ts +30 -0
- package/src/bitbucket-client/models/RestPullRequestAssignStatusRequest.ts +16 -0
- package/src/bitbucket-client/models/RestPullRequestCommitMessageTemplate.ts +7 -0
- package/src/bitbucket-client/models/RestPullRequestCondition.ts +7 -0
- package/src/bitbucket-client/models/RestPullRequestDeclineRequest.ts +9 -0
- package/src/bitbucket-client/models/RestPullRequestDeleteRequest.ts +8 -0
- package/src/bitbucket-client/models/RestPullRequestFinishReviewRequest.ts +10 -0
- package/src/bitbucket-client/models/RestPullRequestMergeConfig.ts +7 -0
- package/src/bitbucket-client/models/RestPullRequestMergeRequest.ts +12 -0
- package/src/bitbucket-client/models/RestPullRequestMergeStrategy.ts +7 -0
- package/src/bitbucket-client/models/RestPullRequestMergeability.ts +7 -0
- package/src/bitbucket-client/models/RestPullRequestParticipant.ts +7 -0
- package/src/bitbucket-client/models/RestPullRequestRebaseRequest.ts +8 -0
- package/src/bitbucket-client/models/RestPullRequestRebaseResult.ts +7 -0
- package/src/bitbucket-client/models/RestPullRequestRebaseability.ts +7 -0
- package/src/bitbucket-client/models/RestPullRequestRef.ts +7 -0
- package/src/bitbucket-client/models/RestPullRequestReopenRequest.ts +8 -0
- package/src/bitbucket-client/models/RestPullRequestSettings.ts +7 -0
- package/src/bitbucket-client/models/RestPullRequestSuggestion.ts +7 -0
- package/src/bitbucket-client/models/RestPushRefChange.ts +7 -0
- package/src/bitbucket-client/models/RestRateLimitSettings.ts +7 -0
- package/src/bitbucket-client/models/RestRawAccessToken.ts +7 -0
- package/src/bitbucket-client/models/RestRefChange.ts +7 -0
- package/src/bitbucket-client/models/RestRefMatcher.ts +7 -0
- package/src/bitbucket-client/models/RestRefMatcherType.ts +7 -0
- package/src/bitbucket-client/models/RestRefRestriction.ts +7 -0
- package/src/bitbucket-client/models/RestRefSyncQueue.ts +10 -0
- package/src/bitbucket-client/models/RestRefSyncRequest.ts +19 -0
- package/src/bitbucket-client/models/RestRefSyncStatus.ts +7 -0
- package/src/bitbucket-client/models/RestRejectedRef.ts +7 -0
- package/src/bitbucket-client/models/RestRelatedLinks.ts +7 -0
- package/src/bitbucket-client/models/RestRepositoriesExportRequest.ts +10 -0
- package/src/bitbucket-client/models/RestRepository.ts +7 -0
- package/src/bitbucket-client/models/RestRepositoryHook.ts +7 -0
- package/src/bitbucket-client/models/RestRepositoryHookVeto.ts +7 -0
- package/src/bitbucket-client/models/RestRepositoryLockOwner.ts +7 -0
- package/src/bitbucket-client/models/RestRepositoryMirrorEvent.ts +16 -0
- package/src/bitbucket-client/models/RestRepositoryPolicy.ts +7 -0
- package/src/bitbucket-client/models/RestRepositoryPullRequestSettings.ts +7 -0
- package/src/bitbucket-client/models/RestRepositoryRefChangeActivity.ts +7 -0
- package/src/bitbucket-client/models/RestRepositorySelector.ts +9 -0
- package/src/bitbucket-client/models/RestRequiredBuildCondition.ts +7 -0
- package/src/bitbucket-client/models/RestRequiredBuildConditionSetRequest.ts +31 -0
- package/src/bitbucket-client/models/RestRestrictionRequest.ts +44 -0
- package/src/bitbucket-client/models/RestReviewerGroup.ts +7 -0
- package/src/bitbucket-client/models/RestRollingUpgradeState.ts +7 -0
- package/src/bitbucket-client/models/RestScope.ts +7 -0
- package/src/bitbucket-client/models/RestScopesExample.ts +7 -0
- package/src/bitbucket-client/models/RestSecretScanningAllowlistRule.ts +7 -0
- package/src/bitbucket-client/models/RestSecretScanningAllowlistRuleSetRequest.ts +19 -0
- package/src/bitbucket-client/models/RestSecretScanningRule.ts +7 -0
- package/src/bitbucket-client/models/RestSecretScanningRuleSetRequest.ts +19 -0
- package/src/bitbucket-client/models/RestSetInsightReportRequest.ts +18 -0
- package/src/bitbucket-client/models/RestSingleAddInsightAnnotationRequest.ts +14 -0
- package/src/bitbucket-client/models/RestSshAccessKey.ts +7 -0
- package/src/bitbucket-client/models/RestSshAccessKeyLocations.ts +12 -0
- package/src/bitbucket-client/models/RestSshCredentials.ts +16 -0
- package/src/bitbucket-client/models/RestSshKey.ts +7 -0
- package/src/bitbucket-client/models/RestSshKeySettings.ts +7 -0
- package/src/bitbucket-client/models/RestSshKeyTypeRestriction.ts +7 -0
- package/src/bitbucket-client/models/RestSshSettings.ts +7 -0
- package/src/bitbucket-client/models/RestSyncProgress.ts +7 -0
- package/src/bitbucket-client/models/RestSystemSigningConfiguration.ts +7 -0
- package/src/bitbucket-client/models/RestTag.ts +7 -0
- package/src/bitbucket-client/models/RestTestResults.ts +7 -0
- package/src/bitbucket-client/models/RestTokenBucketSettings.ts +7 -0
- package/src/bitbucket-client/models/RestUpstreamServer.ts +7 -0
- package/src/bitbucket-client/models/RestUpstreamSettings.ts +7 -0
- package/src/bitbucket-client/models/RestUserDirectory.ts +7 -0
- package/src/bitbucket-client/models/RestUserRateLimitSettings.ts +7 -0
- package/src/bitbucket-client/models/RestUserRateLimitSettingsUpdateRequest.ts +12 -0
- package/src/bitbucket-client/models/RestUserReaction.ts +7 -0
- package/src/bitbucket-client/models/RestUsernamePasswordCredentials.ts +9 -0
- package/src/bitbucket-client/models/RestWebhook.ts +7 -0
- package/src/bitbucket-client/models/RestWebhookCredentials.ts +7 -0
- package/src/bitbucket-client/models/RestWebhookRequestResponse.ts +7 -0
- package/src/bitbucket-client/models/RestWebhookScope.ts +7 -0
- package/src/bitbucket-client/models/RestX509Certificate.ts +7 -0
- package/src/bitbucket-client/models/Scope.ts +16 -0
- package/src/bitbucket-client/models/SimpleSshKeyFingerprint.ts +7 -0
- package/src/bitbucket-client/models/SsoConfigEntity.ts +7 -0
- package/src/bitbucket-client/models/SsoManagementStatusDTO.ts +7 -0
- package/src/bitbucket-client/models/StatusDTO.ts +7 -0
- package/src/bitbucket-client/models/TotpCodeVerificationDTO.ts +9 -0
- package/src/bitbucket-client/models/TotpElevationRestDTO.ts +8 -0
- package/src/bitbucket-client/models/TotpRecoveryCodeAuthenticationDTO.ts +9 -0
- package/src/bitbucket-client/models/TotpRecoveryCodeDTO.ts +7 -0
- package/src/bitbucket-client/models/TotpUserEnrollmentDTO.ts +7 -0
- package/src/bitbucket-client/models/UserAndGroups.ts +9 -0
- package/src/bitbucket-client/models/UserPasswordUpdate.ts +10 -0
- package/src/bitbucket-client/models/UserPickerContext.ts +9 -0
- package/src/bitbucket-client/models/UserRename.ts +9 -0
- package/src/bitbucket-client/models/UserUpdate.ts +10 -0
- package/src/bitbucket-client/models/UserUpdateWithCredentials.ts +14 -0
- package/src/bitbucket-client/services/AuthenticationService.ts +1652 -0
- package/src/bitbucket-client/services/BuildsAndDeploymentsService.ts +849 -0
- package/src/bitbucket-client/services/CapabilitiesService.ts +38 -0
- package/src/bitbucket-client/services/DashboardService.ts +96 -0
- package/src/bitbucket-client/services/DefaultService.ts +46 -0
- package/src/bitbucket-client/services/DeprecatedService.ts +396 -0
- package/src/bitbucket-client/services/JiraIntegrationService.ts +133 -0
- package/src/bitbucket-client/services/MarkupService.ts +48 -0
- package/src/bitbucket-client/services/MirroringMirrorService.ts +421 -0
- package/src/bitbucket-client/services/MirroringUpstreamService.ts +487 -0
- package/src/bitbucket-client/services/PermissionManagementService.ts +1484 -0
- package/src/bitbucket-client/services/ProjectService.ts +2502 -0
- package/src/bitbucket-client/services/PullRequestsService.ts +2997 -0
- package/src/bitbucket-client/services/RepositoryService.ts +3944 -0
- package/src/bitbucket-client/services/SecurityService.ts +1253 -0
- package/src/bitbucket-client/services/SystemMaintenanceService.ts +2279 -0
- package/src/bitbucket-service.ts +180 -0
- package/src/index.ts +78 -0
- package/tsconfig.json +12 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/.env +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 0.1.2 (2025-03-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* binary executable is now non compiled ones. ([18fa866](https://github.com/b1ff/atlassian-dc-mcp/commit/18fa8661d71e3b1246f35869bec0acefe7ac2df5))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## 0.1.1 (2025-03-02)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package @atlassian-dc-mcp/bitbucket
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/bin/run.js
ADDED
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlassian-dc-mcp/bitbucket",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"atlassian-dc-mcp-bitbucket": "./
|
|
7
|
+
"atlassian-dc-mcp-bitbucket": "./bin/run.js"
|
|
8
8
|
},
|
|
9
9
|
"private": false,
|
|
10
10
|
"scripts": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"test": "jest"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@atlassian-dc-mcp/common": "^0.1.
|
|
19
|
+
"@atlassian-dc-mcp/common": "^0.1.2",
|
|
20
20
|
"@modelcontextprotocol/sdk": "^1.5.0",
|
|
21
21
|
"dotenv": "^16.4.7",
|
|
22
22
|
"node-fetch": "^3.3.2",
|
|
@@ -28,5 +28,8 @@
|
|
|
28
28
|
"nodemon": "^3.1.9",
|
|
29
29
|
"ts-node": "^10.9.2"
|
|
30
30
|
},
|
|
31
|
-
"
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"gitHead": "d37153519484c8be2397565e2ef040d5662c8d2b"
|
|
32
35
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import type { ApiRequestOptions } from './ApiRequestOptions.js';
|
|
6
|
+
import type { ApiResult } from './ApiResult.js';
|
|
7
|
+
|
|
8
|
+
export class ApiError extends Error {
|
|
9
|
+
public readonly url: string;
|
|
10
|
+
public readonly status: number;
|
|
11
|
+
public readonly statusText: string;
|
|
12
|
+
public readonly body: any;
|
|
13
|
+
public readonly request: ApiRequestOptions;
|
|
14
|
+
|
|
15
|
+
constructor(request: ApiRequestOptions, response: ApiResult, message: string) {
|
|
16
|
+
super(message);
|
|
17
|
+
|
|
18
|
+
this.name = 'ApiError';
|
|
19
|
+
this.url = response.url;
|
|
20
|
+
this.status = response.status;
|
|
21
|
+
this.statusText = response.statusText;
|
|
22
|
+
this.body = response.body;
|
|
23
|
+
this.request = request;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
export type ApiRequestOptions = {
|
|
6
|
+
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
|
|
7
|
+
readonly url: string;
|
|
8
|
+
readonly path?: Record<string, any>;
|
|
9
|
+
readonly cookies?: Record<string, any>;
|
|
10
|
+
readonly headers?: Record<string, any>;
|
|
11
|
+
readonly query?: Record<string, any>;
|
|
12
|
+
readonly formData?: Record<string, any>;
|
|
13
|
+
readonly body?: any;
|
|
14
|
+
readonly mediaType?: string;
|
|
15
|
+
readonly responseHeader?: string;
|
|
16
|
+
readonly errors?: Record<number, string>;
|
|
17
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
export type ApiResult = {
|
|
6
|
+
readonly url: string;
|
|
7
|
+
readonly ok: boolean;
|
|
8
|
+
readonly status: number;
|
|
9
|
+
readonly statusText: string;
|
|
10
|
+
readonly body: any;
|
|
11
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
export class CancelError extends Error {
|
|
6
|
+
|
|
7
|
+
constructor(message: string) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = 'CancelError';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public get isCancelled(): boolean {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface OnCancel {
|
|
18
|
+
readonly isResolved: boolean;
|
|
19
|
+
readonly isRejected: boolean;
|
|
20
|
+
readonly isCancelled: boolean;
|
|
21
|
+
|
|
22
|
+
(cancelHandler: () => void): void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class CancelablePromise<T> implements Promise<T> {
|
|
26
|
+
#isResolved: boolean;
|
|
27
|
+
#isRejected: boolean;
|
|
28
|
+
#isCancelled: boolean;
|
|
29
|
+
readonly #cancelHandlers: (() => void)[];
|
|
30
|
+
readonly #promise: Promise<T>;
|
|
31
|
+
#resolve?: (value: T | PromiseLike<T>) => void;
|
|
32
|
+
#reject?: (reason?: any) => void;
|
|
33
|
+
|
|
34
|
+
constructor(
|
|
35
|
+
executor: (
|
|
36
|
+
resolve: (value: T | PromiseLike<T>) => void,
|
|
37
|
+
reject: (reason?: any) => void,
|
|
38
|
+
onCancel: OnCancel
|
|
39
|
+
) => void
|
|
40
|
+
) {
|
|
41
|
+
this.#isResolved = false;
|
|
42
|
+
this.#isRejected = false;
|
|
43
|
+
this.#isCancelled = false;
|
|
44
|
+
this.#cancelHandlers = [];
|
|
45
|
+
this.#promise = new Promise<T>((resolve, reject) => {
|
|
46
|
+
this.#resolve = resolve;
|
|
47
|
+
this.#reject = reject;
|
|
48
|
+
|
|
49
|
+
const onResolve = (value: T | PromiseLike<T>): void => {
|
|
50
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this.#isResolved = true;
|
|
54
|
+
if (this.#resolve) this.#resolve(value);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const onReject = (reason?: any): void => {
|
|
58
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
this.#isRejected = true;
|
|
62
|
+
if (this.#reject) this.#reject(reason);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const onCancel = (cancelHandler: () => void): void => {
|
|
66
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
this.#cancelHandlers.push(cancelHandler);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
Object.defineProperty(onCancel, 'isResolved', {
|
|
73
|
+
get: (): boolean => this.#isResolved,
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
Object.defineProperty(onCancel, 'isRejected', {
|
|
77
|
+
get: (): boolean => this.#isRejected,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
Object.defineProperty(onCancel, 'isCancelled', {
|
|
81
|
+
get: (): boolean => this.#isCancelled,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return executor(onResolve, onReject, onCancel as OnCancel);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get [Symbol.toStringTag]() {
|
|
89
|
+
return "Cancellable Promise";
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public then<TResult1 = T, TResult2 = never>(
|
|
93
|
+
onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
|
|
94
|
+
onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null
|
|
95
|
+
): Promise<TResult1 | TResult2> {
|
|
96
|
+
return this.#promise.then(onFulfilled, onRejected);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public catch<TResult = never>(
|
|
100
|
+
onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null
|
|
101
|
+
): Promise<T | TResult> {
|
|
102
|
+
return this.#promise.catch(onRejected);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public finally(onFinally?: (() => void) | null): Promise<T> {
|
|
106
|
+
return this.#promise.finally(onFinally);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public cancel(): void {
|
|
110
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
this.#isCancelled = true;
|
|
114
|
+
if (this.#cancelHandlers.length) {
|
|
115
|
+
try {
|
|
116
|
+
for (const cancelHandler of this.#cancelHandlers) {
|
|
117
|
+
cancelHandler();
|
|
118
|
+
}
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.warn('Cancellation threw an error', error);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
this.#cancelHandlers.length = 0;
|
|
125
|
+
if (this.#reject) this.#reject(new CancelError('Request aborted'));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public get isCancelled(): boolean {
|
|
129
|
+
return this.#isCancelled;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import type { ApiRequestOptions } from './ApiRequestOptions.js';
|
|
6
|
+
|
|
7
|
+
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
|
8
|
+
type Headers = Record<string, string>;
|
|
9
|
+
|
|
10
|
+
export type OpenAPIConfig = {
|
|
11
|
+
BASE: string;
|
|
12
|
+
VERSION: string;
|
|
13
|
+
WITH_CREDENTIALS: boolean;
|
|
14
|
+
CREDENTIALS: 'include' | 'omit' | 'same-origin';
|
|
15
|
+
TOKEN?: string | Resolver<string> | undefined;
|
|
16
|
+
USERNAME?: string | Resolver<string> | undefined;
|
|
17
|
+
PASSWORD?: string | Resolver<string> | undefined;
|
|
18
|
+
HEADERS?: Headers | Resolver<Headers> | undefined;
|
|
19
|
+
ENCODE_PATH?: ((path: string) => string) | undefined;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const OpenAPI: OpenAPIConfig = {
|
|
23
|
+
BASE: 'http://example.com:7990/rest',
|
|
24
|
+
VERSION: '9.5',
|
|
25
|
+
WITH_CREDENTIALS: false,
|
|
26
|
+
CREDENTIALS: 'include',
|
|
27
|
+
TOKEN: undefined,
|
|
28
|
+
USERNAME: undefined,
|
|
29
|
+
PASSWORD: undefined,
|
|
30
|
+
HEADERS: undefined,
|
|
31
|
+
ENCODE_PATH: undefined,
|
|
32
|
+
};
|
|
33
|
+
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import FormData from 'form-data';
|
|
6
|
+
import fetch, { Headers } from 'node-fetch';
|
|
7
|
+
import type { RequestInit, Response } from 'node-fetch';
|
|
8
|
+
|
|
9
|
+
import { ApiError } from './ApiError.js';
|
|
10
|
+
import type { ApiRequestOptions } from './ApiRequestOptions.js';
|
|
11
|
+
import type { ApiResult } from './ApiResult.js';
|
|
12
|
+
import { CancelablePromise } from './CancelablePromise.js';
|
|
13
|
+
import type { OnCancel } from './CancelablePromise.js';
|
|
14
|
+
import type { OpenAPIConfig } from './OpenAPI.js';
|
|
15
|
+
|
|
16
|
+
export const isDefined = <T>(value: T | null | undefined): value is Exclude<T, null | undefined> => {
|
|
17
|
+
return value !== undefined && value !== null;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const isString = (value: any): value is string => {
|
|
21
|
+
return typeof value === 'string';
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const isStringWithValue = (value: any): value is string => {
|
|
25
|
+
return isString(value) && value !== '';
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const isBlob = (value: any): value is Blob => {
|
|
29
|
+
return (
|
|
30
|
+
typeof value === 'object' &&
|
|
31
|
+
typeof value.type === 'string' &&
|
|
32
|
+
typeof value.stream === 'function' &&
|
|
33
|
+
typeof value.arrayBuffer === 'function' &&
|
|
34
|
+
typeof value.constructor === 'function' &&
|
|
35
|
+
typeof value.constructor.name === 'string' &&
|
|
36
|
+
/^(Blob|File)$/.test(value.constructor.name) &&
|
|
37
|
+
/^(Blob|File)$/.test(value[Symbol.toStringTag])
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const isFormData = (value: any): value is FormData => {
|
|
42
|
+
return value instanceof FormData;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const base64 = (str: string): string => {
|
|
46
|
+
try {
|
|
47
|
+
return btoa(str);
|
|
48
|
+
} catch (err) {
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
return Buffer.from(str).toString('base64');
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const getQueryString = (params: Record<string, any>): string => {
|
|
55
|
+
const qs: string[] = [];
|
|
56
|
+
|
|
57
|
+
const append = (key: string, value: any) => {
|
|
58
|
+
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const process = (key: string, value: any) => {
|
|
62
|
+
if (isDefined(value)) {
|
|
63
|
+
if (Array.isArray(value)) {
|
|
64
|
+
value.forEach(v => {
|
|
65
|
+
process(key, v);
|
|
66
|
+
});
|
|
67
|
+
} else if (typeof value === 'object') {
|
|
68
|
+
Object.entries(value).forEach(([k, v]) => {
|
|
69
|
+
process(`${key}[${k}]`, v);
|
|
70
|
+
});
|
|
71
|
+
} else {
|
|
72
|
+
append(key, value);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
78
|
+
process(key, value);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
if (qs.length > 0) {
|
|
82
|
+
return `?${qs.join('&')}`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return '';
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => {
|
|
89
|
+
const encoder = config.ENCODE_PATH || encodeURI;
|
|
90
|
+
|
|
91
|
+
const path = options.url
|
|
92
|
+
.replace('{api-version}', config.VERSION)
|
|
93
|
+
.replace(/{(.*?)}/g, (substring: string, group: string) => {
|
|
94
|
+
if (options.path?.hasOwnProperty(group)) {
|
|
95
|
+
return encoder(String(options.path[group]));
|
|
96
|
+
}
|
|
97
|
+
return substring;
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const url = `${config.BASE}${path}`;
|
|
101
|
+
if (options.query) {
|
|
102
|
+
return `${url}${getQueryString(options.query)}`;
|
|
103
|
+
}
|
|
104
|
+
return url;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const getFormData = (options: ApiRequestOptions): FormData | undefined => {
|
|
108
|
+
if (options.formData) {
|
|
109
|
+
const formData = new FormData();
|
|
110
|
+
|
|
111
|
+
const process = (key: string, value: any) => {
|
|
112
|
+
if (isString(value) || isBlob(value)) {
|
|
113
|
+
formData.append(key, value);
|
|
114
|
+
} else {
|
|
115
|
+
formData.append(key, JSON.stringify(value));
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
Object.entries(options.formData)
|
|
120
|
+
.filter(([_, value]) => isDefined(value))
|
|
121
|
+
.forEach(([key, value]) => {
|
|
122
|
+
if (Array.isArray(value)) {
|
|
123
|
+
value.forEach(v => process(key, v));
|
|
124
|
+
} else {
|
|
125
|
+
process(key, value);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
return formData;
|
|
130
|
+
}
|
|
131
|
+
return undefined;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
|
135
|
+
|
|
136
|
+
export const resolve = async <T>(options: ApiRequestOptions, resolver?: T | Resolver<T>): Promise<T | undefined> => {
|
|
137
|
+
if (typeof resolver === 'function') {
|
|
138
|
+
return (resolver as Resolver<T>)(options);
|
|
139
|
+
}
|
|
140
|
+
return resolver;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise<Headers> => {
|
|
144
|
+
const [token, username, password, additionalHeaders] = await Promise.all([
|
|
145
|
+
resolve(options, config.TOKEN),
|
|
146
|
+
resolve(options, config.USERNAME),
|
|
147
|
+
resolve(options, config.PASSWORD),
|
|
148
|
+
resolve(options, config.HEADERS),
|
|
149
|
+
]);
|
|
150
|
+
|
|
151
|
+
const headers = Object.entries({
|
|
152
|
+
Accept: 'application/json',
|
|
153
|
+
...additionalHeaders,
|
|
154
|
+
...options.headers,
|
|
155
|
+
})
|
|
156
|
+
.filter(([_, value]) => isDefined(value))
|
|
157
|
+
.reduce((headers, [key, value]) => ({
|
|
158
|
+
...headers,
|
|
159
|
+
[key]: String(value),
|
|
160
|
+
}), {} as Record<string, string>);
|
|
161
|
+
|
|
162
|
+
if (isStringWithValue(token)) {
|
|
163
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (isStringWithValue(username) && isStringWithValue(password)) {
|
|
167
|
+
const credentials = base64(`${username}:${password}`);
|
|
168
|
+
headers['Authorization'] = `Basic ${credentials}`;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (options.body !== undefined) {
|
|
172
|
+
if (options.mediaType) {
|
|
173
|
+
headers['Content-Type'] = options.mediaType;
|
|
174
|
+
} else if (isBlob(options.body)) {
|
|
175
|
+
headers['Content-Type'] = 'application/octet-stream';
|
|
176
|
+
} else if (isString(options.body)) {
|
|
177
|
+
headers['Content-Type'] = 'text/plain';
|
|
178
|
+
} else if (!isFormData(options.body)) {
|
|
179
|
+
headers['Content-Type'] = 'application/json';
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return new Headers(headers);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export const getRequestBody = (options: ApiRequestOptions): any => {
|
|
187
|
+
if (options.body !== undefined) {
|
|
188
|
+
if (options.mediaType?.includes('/json')) {
|
|
189
|
+
return JSON.stringify(options.body)
|
|
190
|
+
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
|
191
|
+
return options.body as any;
|
|
192
|
+
} else {
|
|
193
|
+
return JSON.stringify(options.body);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return undefined;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export const sendRequest = async (
|
|
200
|
+
options: ApiRequestOptions,
|
|
201
|
+
url: string,
|
|
202
|
+
body: any,
|
|
203
|
+
formData: FormData | undefined,
|
|
204
|
+
headers: Headers,
|
|
205
|
+
onCancel: OnCancel
|
|
206
|
+
): Promise<Response> => {
|
|
207
|
+
const controller = new AbortController();
|
|
208
|
+
|
|
209
|
+
const request: RequestInit = {
|
|
210
|
+
headers,
|
|
211
|
+
method: options.method,
|
|
212
|
+
body: body ?? formData,
|
|
213
|
+
signal: controller.signal as AbortSignal,
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
onCancel(() => controller.abort());
|
|
217
|
+
|
|
218
|
+
return await fetch(url, request);
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export const getResponseHeader = (response: Response, responseHeader?: string): string | undefined => {
|
|
222
|
+
if (responseHeader) {
|
|
223
|
+
const content = response.headers.get(responseHeader);
|
|
224
|
+
if (isString(content)) {
|
|
225
|
+
return content;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return undefined;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export const getResponseBody = async (response: Response): Promise<any> => {
|
|
232
|
+
if (response.status !== 204) {
|
|
233
|
+
try {
|
|
234
|
+
const contentType = response.headers.get('Content-Type');
|
|
235
|
+
if (contentType) {
|
|
236
|
+
const jsonTypes = ['application/json', 'application/problem+json']
|
|
237
|
+
const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
|
|
238
|
+
if (isJSON) {
|
|
239
|
+
return await response.json();
|
|
240
|
+
} else {
|
|
241
|
+
return await response.text();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
} catch (error) {
|
|
245
|
+
console.error(error);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return undefined;
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => {
|
|
252
|
+
const errors: Record<number, string> = {
|
|
253
|
+
400: 'Bad Request',
|
|
254
|
+
401: 'Unauthorized',
|
|
255
|
+
403: 'Forbidden',
|
|
256
|
+
404: 'Not Found',
|
|
257
|
+
500: 'Internal Server Error',
|
|
258
|
+
502: 'Bad Gateway',
|
|
259
|
+
503: 'Service Unavailable',
|
|
260
|
+
...options.errors,
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const error = errors[result.status];
|
|
264
|
+
if (error) {
|
|
265
|
+
throw new ApiError(options, result, error);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (!result.ok) {
|
|
269
|
+
const errorStatus = result.status ?? 'unknown';
|
|
270
|
+
const errorStatusText = result.statusText ?? 'unknown';
|
|
271
|
+
const errorBody = (() => {
|
|
272
|
+
try {
|
|
273
|
+
return JSON.stringify(result.body, null, 2);
|
|
274
|
+
} catch (e) {
|
|
275
|
+
return undefined;
|
|
276
|
+
}
|
|
277
|
+
})();
|
|
278
|
+
|
|
279
|
+
throw new ApiError(options, result,
|
|
280
|
+
`Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Request method
|
|
287
|
+
* @param config The OpenAPI configuration object
|
|
288
|
+
* @param options The request options from the service
|
|
289
|
+
* @returns CancelablePromise<T>
|
|
290
|
+
* @throws ApiError
|
|
291
|
+
*/
|
|
292
|
+
export const request = <T>(config: OpenAPIConfig, options: ApiRequestOptions): CancelablePromise<T> => {
|
|
293
|
+
return new CancelablePromise(async (resolve, reject, onCancel) => {
|
|
294
|
+
try {
|
|
295
|
+
const url = getUrl(config, options);
|
|
296
|
+
const formData = getFormData(options);
|
|
297
|
+
const body = getRequestBody(options);
|
|
298
|
+
const headers = await getHeaders(config, options);
|
|
299
|
+
|
|
300
|
+
if (!onCancel.isCancelled) {
|
|
301
|
+
const response = await sendRequest(options, url, body, formData, headers, onCancel);
|
|
302
|
+
const responseBody = await getResponseBody(response);
|
|
303
|
+
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
304
|
+
|
|
305
|
+
const result: ApiResult = {
|
|
306
|
+
url,
|
|
307
|
+
ok: response.ok,
|
|
308
|
+
status: response.status,
|
|
309
|
+
statusText: response.statusText,
|
|
310
|
+
body: responseHeader ?? responseBody,
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
catchErrorCodes(options, result);
|
|
314
|
+
|
|
315
|
+
resolve(result.body);
|
|
316
|
+
}
|
|
317
|
+
} catch (error) {
|
|
318
|
+
reject(error);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
};
|
|
322
|
+
|