@ayasofyazilim/saas 0.0.4 → 0.0.6
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/AccountService/index.ts +115 -117
- package/AdministrationService/index.ts +111 -116
- package/IdentityService/IdentityServiceClient.ts +70 -0
- package/IdentityService/core/ApiError.ts +25 -0
- package/IdentityService/core/ApiRequestOptions.ts +17 -0
- package/IdentityService/core/ApiResult.ts +11 -0
- package/IdentityService/core/BaseHttpRequest.ts +14 -0
- package/IdentityService/core/CancelablePromise.ts +131 -0
- package/IdentityService/core/FetchHttpRequest.ts +26 -0
- package/IdentityService/core/OpenAPI.ts +32 -0
- package/IdentityService/core/request.ts +322 -0
- package/IdentityService/index.ts +133 -0
- package/IdentityService/models/Volo_Abp_Account_AccountExternalProviderSettingsDto.ts +9 -0
- package/IdentityService/models/Volo_Abp_Account_AccountRecaptchaSettingsDto.ts +14 -0
- package/IdentityService/models/Volo_Abp_Account_AccountSettingsDto.ts +9 -0
- package/IdentityService/models/Volo_Abp_Account_AccountTwoFactorSettingsDto.ts +11 -0
- package/IdentityService/models/Volo_Abp_Account_ExternalProviders_ExternalProviderSettings.ts +12 -0
- package/{ProjectService/models/UpWithCrowdDemo_ProjectService_ProjectSections_ProjectSectionDetailDto.ts → IdentityService/models/Volo_Abp_Account_ExternalProviders_ExternalProviderSettingsProperty.ts} +1 -1
- package/IdentityService/models/Volo_Abp_Account_UpdateExternalProviderDto.ts +12 -0
- package/IdentityService/models/Volo_Abp_Application_Dtos_ListResultDto_1.ts +9 -0
- package/IdentityService/models/Volo_Abp_Application_Dtos_PagedResultDto_1.ts +10 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ApplicationAuthConfigurationDto.ts +8 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ApplicationConfigurationDto.ts +30 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ApplicationFeatureConfigurationDto.ts +8 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ApplicationGlobalFeatureConfigurationDto.ts +8 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ApplicationLocalizationConfigurationDto.ts +18 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ApplicationLocalizationDto.ts +9 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ApplicationLocalizationResourceDto.ts +9 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ApplicationSettingConfigurationDto.ts +8 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ClockDto.ts +8 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_CurrentCultureDto.ts +17 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_CurrentUserDto.ts +22 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_DateTimeFormatDto.ts +14 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_IanaTimeZone.ts +8 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ObjectExtending_EntityExtensionDto.ts +10 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ObjectExtending_ExtensionEnumDto.ts +10 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ObjectExtending_ExtensionEnumFieldDto.ts +9 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ObjectExtending_ExtensionPropertyApiCreateDto.ts +8 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ObjectExtending_ExtensionPropertyApiDto.ts +13 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ObjectExtending_ExtensionPropertyApiGetDto.ts +8 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ObjectExtending_ExtensionPropertyApiUpdateDto.ts +8 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ObjectExtending_ExtensionPropertyAttributeDto.ts +9 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ObjectExtending_ExtensionPropertyDto.ts +19 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ObjectExtending_ExtensionPropertyUiDto.ts +14 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ObjectExtending_ExtensionPropertyUiFormDto.ts +8 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ObjectExtending_ExtensionPropertyUiLookupDto.ts +12 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ObjectExtending_ExtensionPropertyUiTableDto.ts +8 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ObjectExtending_LocalizableStringDto.ts +9 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ObjectExtending_ModuleExtensionDto.ts +10 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_ObjectExtending_ObjectExtensionsDto.ts +11 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_TimeZone.ts +11 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_TimingDto.ts +9 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_ApplicationConfigurations_WindowsTimeZone.ts +8 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_MultiTenancy_CurrentTenantDto.ts +10 -0
- package/IdentityService/models/Volo_Abp_AspNetCore_Mvc_MultiTenancy_MultiTenancyInfoDto.ts +8 -0
- package/IdentityService/models/Volo_Abp_Http_Modeling_ActionApiDescriptionModel.ts +20 -0
- package/IdentityService/models/Volo_Abp_Http_Modeling_ApplicationApiDescriptionModel.ts +11 -0
- package/IdentityService/models/Volo_Abp_Http_Modeling_ControllerApiDescriptionModel.ts +17 -0
- package/IdentityService/models/Volo_Abp_Http_Modeling_ControllerInterfaceApiDescriptionModel.ts +11 -0
- package/IdentityService/models/Volo_Abp_Http_Modeling_InterfaceMethodApiDescriptionModel.ts +12 -0
- package/IdentityService/models/Volo_Abp_Http_Modeling_MethodParameterApiDescriptionModel.ts +13 -0
- package/IdentityService/models/Volo_Abp_Http_Modeling_ModuleApiDescriptionModel.ts +11 -0
- package/IdentityService/models/Volo_Abp_Http_Modeling_ParameterApiDescriptionModel.ts +17 -0
- package/IdentityService/models/Volo_Abp_Http_Modeling_PropertyApiDescriptionModel.ts +17 -0
- package/IdentityService/models/Volo_Abp_Http_Modeling_ReturnValueApiDescriptionModel.ts +9 -0
- package/IdentityService/models/Volo_Abp_Http_Modeling_TypeApiDescriptionModel.ts +14 -0
- package/IdentityService/models/Volo_Abp_Http_RemoteServiceErrorInfo.ts +13 -0
- package/IdentityService/models/Volo_Abp_Http_RemoteServiceErrorResponse.ts +9 -0
- package/IdentityService/models/Volo_Abp_Http_RemoteServiceValidationErrorInfo.ts +9 -0
- package/IdentityService/models/Volo_Abp_Identity_ClaimTypeDto.ts +19 -0
- package/IdentityService/models/Volo_Abp_Identity_CreateClaimTypeDto.ts +15 -0
- package/IdentityService/models/Volo_Abp_Identity_DownloadTokenResultDto.ts +8 -0
- package/IdentityService/models/Volo_Abp_Identity_ExternalLoginProviderDto.ts +9 -0
- package/IdentityService/models/Volo_Abp_Identity_Features_IdentityProTwoFactorBehaviour.ts +9 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityClaimValueType.ts +10 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityLdapSettingsDto.ts +15 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityLockoutSettingsDto.ts +10 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityOAuthSettingsDto.ts +15 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityPasswordSettingsDto.ts +15 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityRoleClaimDto.ts +10 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityRoleCreateDto.ts +11 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityRoleDto.ts +15 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityRoleLookupDto.ts +9 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityRoleUpdateDto.ts +12 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentitySecurityLogDto.ts +21 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentitySettingsDto.ts +15 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentitySignInSettingsDto.ts +10 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityUserClaimDto.ts +10 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityUserCreateDto.ts +20 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityUserDto.ts +35 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityUserSettingsDto.ts +9 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityUserUpdateDto.ts +19 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityUserUpdatePasswordInput.ts +8 -0
- package/IdentityService/models/Volo_Abp_Identity_IdentityUserUpdateRolesDto.ts +8 -0
- package/IdentityService/models/Volo_Abp_Identity_ImportExternalUserInput.ts +10 -0
- package/IdentityService/models/Volo_Abp_Identity_ImportUsersFromFileOutput.ts +12 -0
- package/IdentityService/models/Volo_Abp_Identity_ImportUsersFromFileType.ts +8 -0
- package/IdentityService/models/Volo_Abp_Identity_OrganizationUnitCreateDto.ts +10 -0
- package/IdentityService/models/Volo_Abp_Identity_OrganizationUnitDto.ts +21 -0
- package/IdentityService/models/Volo_Abp_Identity_OrganizationUnitLookupDto.ts +9 -0
- package/IdentityService/models/Volo_Abp_Identity_OrganizationUnitMoveInput.ts +8 -0
- package/IdentityService/models/Volo_Abp_Identity_OrganizationUnitRoleDto.ts +11 -0
- package/IdentityService/models/Volo_Abp_Identity_OrganizationUnitRoleInput.ts +8 -0
- package/IdentityService/models/Volo_Abp_Identity_OrganizationUnitUpdateDto.ts +10 -0
- package/IdentityService/models/Volo_Abp_Identity_OrganizationUnitUserInput.ts +8 -0
- package/IdentityService/models/Volo_Abp_Identity_OrganizationUnitWithDetailsDto.ts +23 -0
- package/IdentityService/models/Volo_Abp_Identity_UpdateClaimTypeDto.ts +16 -0
- package/IdentityService/models/Volo_Abp_Localization_LanguageInfo.ts +12 -0
- package/IdentityService/models/Volo_Abp_NameValue.ts +9 -0
- package/IdentityService/models/Volo_Abp_OpenIddict_Applications_Dtos_ApplicationDto.ts +29 -0
- package/IdentityService/models/Volo_Abp_OpenIddict_Applications_Dtos_ApplicationTokenLifetimeDto.ts +13 -0
- package/IdentityService/models/Volo_Abp_OpenIddict_Applications_Dtos_CreateApplicationInput.ts +28 -0
- package/IdentityService/models/Volo_Abp_OpenIddict_Applications_Dtos_UpdateApplicationInput.ts +28 -0
- package/IdentityService/models/Volo_Abp_OpenIddict_Scopes_Dtos_CreateScopeInput.ts +12 -0
- package/IdentityService/models/Volo_Abp_OpenIddict_Scopes_Dtos_ScopeDto.ts +14 -0
- package/IdentityService/models/Volo_Abp_OpenIddict_Scopes_Dtos_UpdateScopeInput.ts +12 -0
- package/IdentityService/models/Volo_Abp_Users_UserData.ts +18 -0
- package/IdentityService/services/AbpApiDefinitionService.ts +34 -0
- package/IdentityService/services/AbpApplicationConfigurationService.ts +34 -0
- package/IdentityService/services/AbpApplicationLocalizationService.ts +37 -0
- package/IdentityService/services/AccountSettingsService.ts +178 -0
- package/IdentityService/services/ApplicationsService.ts +199 -0
- package/IdentityService/services/ClaimTypeService.ts +149 -0
- package/IdentityService/services/ExternalLoginService.ts +27 -0
- package/IdentityService/services/OrganizationUnitService.ts +539 -0
- package/IdentityService/services/RoleService.ts +269 -0
- package/IdentityService/services/ScopesService.ts +164 -0
- package/IdentityService/services/SecurityLogService.ts +174 -0
- package/IdentityService/services/SettingsService.ts +135 -0
- package/IdentityService/services/UserIntegrationService.ts +144 -0
- package/IdentityService/services/UserLookupService.ts +120 -0
- package/IdentityService/services/UserService.ts +937 -0
- package/ProjectService/ProjectServiceClient.ts +9 -9
- package/ProjectService/index.ts +14 -14
- package/ProjectService/models/{UpWithCrowdDemo_ProjectService_ProjectSectionRelations_CreateProjectSectionRelationDto.ts → AbpForDeploy_ProjectService_ProjectSectionRelations_CreateProjectSectionRelationDto.ts} +2 -1
- package/ProjectService/models/{UpWithCrowdDemo_ProjectService_ProjectSectionRelations_ProjectSectionRelationDto.ts → AbpForDeploy_ProjectService_ProjectSectionRelations_ProjectSectionRelationDto.ts} +1 -1
- package/ProjectService/models/{UpWithCrowdDemo_ProjectService_ProjectSectionRelations_UpdateProjectSectionRelationDto.ts → AbpForDeploy_ProjectService_ProjectSectionRelations_UpdateProjectSectionRelationDto.ts} +2 -1
- package/ProjectService/models/{UpWithCrowdDemo_ProjectService_ProjectSections_CreateProjectSectionDto.ts → AbpForDeploy_ProjectService_ProjectSections_CreateProjectSectionDto.ts} +2 -1
- package/ProjectService/models/AbpForDeploy_ProjectService_ProjectSections_ProjectSectionDetailDto.ts +9 -0
- package/ProjectService/models/{UpWithCrowdDemo_ProjectService_ProjectSections_ProjectSectionDto.ts → AbpForDeploy_ProjectService_ProjectSections_ProjectSectionDto.ts} +1 -1
- package/ProjectService/models/{UpWithCrowdDemo_ProjectService_ProjectSections_UpdateProjectSectionDto.ts → AbpForDeploy_ProjectService_ProjectSections_UpdateProjectSectionDto.ts} +1 -1
- package/ProjectService/models/{UpWithCrowdDemo_ProjectService_ProjectsDto_SaveProjectDto.ts → AbpForDeploy_ProjectService_ProjectsDto_CreateProjectDto.ts} +3 -1
- package/ProjectService/models/{UpWithCrowdDemo_ProjectService_ProjectsDto_UpdateProjectDto.ts → AbpForDeploy_ProjectService_ProjectsDto_UpdateProjectDto.ts} +3 -1
- package/ProjectService/models/{UpWithCrowdDemo_ProjectService_Projects_ProjectDto.ts → AbpForDeploy_ProjectService_Projects_ProjectDto.ts} +4 -3
- package/ProjectService/models/{UpWithCrowdDemo_ProjectService_Samples_SampleDto.ts → AbpForDeploy_ProjectService_Samples_SampleDto.ts} +1 -1
- package/ProjectService/models/Volo_Abp_Application_Dtos_PagedResultDto_1.ts +2 -2
- package/ProjectService/services/{ProjectSectionRelationServiceService.ts → ProjectSectionRelationService.ts} +14 -14
- package/ProjectService/services/{ProjectSectionServiceService.ts → ProjectSectionService.ts} +14 -14
- package/ProjectService/services/ProjectService.ts +29 -23
- package/ProjectService/services/{SampleServiceService.ts → ProjectServiceService.ts} +8 -8
- package/package.json +6 -4
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do no edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import type { BaseHttpRequest } from './core/BaseHttpRequest';
|
|
6
|
+
import type { OpenAPIConfig } from './core/OpenAPI';
|
|
7
|
+
import { FetchHttpRequest } from './core/FetchHttpRequest';
|
|
8
|
+
import { AbpApiDefinitionService } from './services/AbpApiDefinitionService';
|
|
9
|
+
import { AbpApplicationConfigurationService } from './services/AbpApplicationConfigurationService';
|
|
10
|
+
import { AbpApplicationLocalizationService } from './services/AbpApplicationLocalizationService';
|
|
11
|
+
import { AccountSettingsService } from './services/AccountSettingsService';
|
|
12
|
+
import { ApplicationsService } from './services/ApplicationsService';
|
|
13
|
+
import { ClaimTypeService } from './services/ClaimTypeService';
|
|
14
|
+
import { ExternalLoginService } from './services/ExternalLoginService';
|
|
15
|
+
import { OrganizationUnitService } from './services/OrganizationUnitService';
|
|
16
|
+
import { RoleService } from './services/RoleService';
|
|
17
|
+
import { ScopesService } from './services/ScopesService';
|
|
18
|
+
import { SecurityLogService } from './services/SecurityLogService';
|
|
19
|
+
import { SettingsService } from './services/SettingsService';
|
|
20
|
+
import { UserService } from './services/UserService';
|
|
21
|
+
import { UserIntegrationService } from './services/UserIntegrationService';
|
|
22
|
+
import { UserLookupService } from './services/UserLookupService';
|
|
23
|
+
type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest;
|
|
24
|
+
export class IdentityServiceClient {
|
|
25
|
+
public readonly abpApiDefinition: AbpApiDefinitionService;
|
|
26
|
+
public readonly abpApplicationConfiguration: AbpApplicationConfigurationService;
|
|
27
|
+
public readonly abpApplicationLocalization: AbpApplicationLocalizationService;
|
|
28
|
+
public readonly accountSettings: AccountSettingsService;
|
|
29
|
+
public readonly applications: ApplicationsService;
|
|
30
|
+
public readonly claimType: ClaimTypeService;
|
|
31
|
+
public readonly externalLogin: ExternalLoginService;
|
|
32
|
+
public readonly organizationUnit: OrganizationUnitService;
|
|
33
|
+
public readonly role: RoleService;
|
|
34
|
+
public readonly scopes: ScopesService;
|
|
35
|
+
public readonly securityLog: SecurityLogService;
|
|
36
|
+
public readonly settings: SettingsService;
|
|
37
|
+
public readonly user: UserService;
|
|
38
|
+
public readonly userIntegration: UserIntegrationService;
|
|
39
|
+
public readonly userLookup: UserLookupService;
|
|
40
|
+
public readonly request: BaseHttpRequest;
|
|
41
|
+
constructor(config?: Partial<OpenAPIConfig>, HttpRequest: HttpRequestConstructor = FetchHttpRequest) {
|
|
42
|
+
this.request = new HttpRequest({
|
|
43
|
+
BASE: config?.BASE ?? '',
|
|
44
|
+
VERSION: config?.VERSION ?? '1',
|
|
45
|
+
WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
|
|
46
|
+
CREDENTIALS: config?.CREDENTIALS ?? 'include',
|
|
47
|
+
TOKEN: config?.TOKEN,
|
|
48
|
+
USERNAME: config?.USERNAME,
|
|
49
|
+
PASSWORD: config?.PASSWORD,
|
|
50
|
+
HEADERS: config?.HEADERS,
|
|
51
|
+
ENCODE_PATH: config?.ENCODE_PATH,
|
|
52
|
+
});
|
|
53
|
+
this.abpApiDefinition = new AbpApiDefinitionService(this.request);
|
|
54
|
+
this.abpApplicationConfiguration = new AbpApplicationConfigurationService(this.request);
|
|
55
|
+
this.abpApplicationLocalization = new AbpApplicationLocalizationService(this.request);
|
|
56
|
+
this.accountSettings = new AccountSettingsService(this.request);
|
|
57
|
+
this.applications = new ApplicationsService(this.request);
|
|
58
|
+
this.claimType = new ClaimTypeService(this.request);
|
|
59
|
+
this.externalLogin = new ExternalLoginService(this.request);
|
|
60
|
+
this.organizationUnit = new OrganizationUnitService(this.request);
|
|
61
|
+
this.role = new RoleService(this.request);
|
|
62
|
+
this.scopes = new ScopesService(this.request);
|
|
63
|
+
this.securityLog = new SecurityLogService(this.request);
|
|
64
|
+
this.settings = new SettingsService(this.request);
|
|
65
|
+
this.user = new UserService(this.request);
|
|
66
|
+
this.userIntegration = new UserIntegrationService(this.request);
|
|
67
|
+
this.userLookup = new UserLookupService(this.request);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do no edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
6
|
+
import type { ApiResult } from './ApiResult';
|
|
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
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do no 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 no 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,14 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do no edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
6
|
+
import type { CancelablePromise } from './CancelablePromise';
|
|
7
|
+
import type { OpenAPIConfig } from './OpenAPI';
|
|
8
|
+
|
|
9
|
+
export abstract class BaseHttpRequest {
|
|
10
|
+
|
|
11
|
+
constructor(public readonly config: OpenAPIConfig) {}
|
|
12
|
+
|
|
13
|
+
public abstract request<T>(options: ApiRequestOptions): CancelablePromise<T>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do no 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,26 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do no edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
6
|
+
import { BaseHttpRequest } from './BaseHttpRequest';
|
|
7
|
+
import type { CancelablePromise } from './CancelablePromise';
|
|
8
|
+
import type { OpenAPIConfig } from './OpenAPI';
|
|
9
|
+
import { request as __request } from './request';
|
|
10
|
+
|
|
11
|
+
export class FetchHttpRequest extends BaseHttpRequest {
|
|
12
|
+
|
|
13
|
+
constructor(config: OpenAPIConfig) {
|
|
14
|
+
super(config);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Request method
|
|
19
|
+
* @param options The request options from the service
|
|
20
|
+
* @returns CancelablePromise<T>
|
|
21
|
+
* @throws ApiError
|
|
22
|
+
*/
|
|
23
|
+
public override request<T>(options: ApiRequestOptions): CancelablePromise<T> {
|
|
24
|
+
return __request(this.config, options);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do no edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
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: '',
|
|
24
|
+
VERSION: '1',
|
|
25
|
+
WITH_CREDENTIALS: false,
|
|
26
|
+
CREDENTIALS: 'include',
|
|
27
|
+
TOKEN: undefined,
|
|
28
|
+
USERNAME: undefined,
|
|
29
|
+
PASSWORD: undefined,
|
|
30
|
+
HEADERS: undefined,
|
|
31
|
+
ENCODE_PATH: undefined,
|
|
32
|
+
};
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do no edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
import { ApiError } from './ApiError';
|
|
6
|
+
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
7
|
+
import type { ApiResult } from './ApiResult';
|
|
8
|
+
import { CancelablePromise } from './CancelablePromise';
|
|
9
|
+
import type { OnCancel } from './CancelablePromise';
|
|
10
|
+
import type { OpenAPIConfig } from './OpenAPI';
|
|
11
|
+
|
|
12
|
+
export const isDefined = <T>(value: T | null | undefined): value is Exclude<T, null | undefined> => {
|
|
13
|
+
return value !== undefined && value !== null;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const isString = (value: any): value is string => {
|
|
17
|
+
return typeof value === 'string';
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const isStringWithValue = (value: any): value is string => {
|
|
21
|
+
return isString(value) && value !== '';
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const isBlob = (value: any): value is Blob => {
|
|
25
|
+
return (
|
|
26
|
+
typeof value === 'object' &&
|
|
27
|
+
typeof value.type === 'string' &&
|
|
28
|
+
typeof value.stream === 'function' &&
|
|
29
|
+
typeof value.arrayBuffer === 'function' &&
|
|
30
|
+
typeof value.constructor === 'function' &&
|
|
31
|
+
typeof value.constructor.name === 'string' &&
|
|
32
|
+
/^(Blob|File)$/.test(value.constructor.name) &&
|
|
33
|
+
/^(Blob|File)$/.test(value[Symbol.toStringTag])
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const isFormData = (value: any): value is FormData => {
|
|
38
|
+
return value instanceof FormData;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const base64 = (str: string): string => {
|
|
42
|
+
try {
|
|
43
|
+
return btoa(str);
|
|
44
|
+
} catch (err) {
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
return Buffer.from(str).toString('base64');
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const getQueryString = (params: Record<string, any>): string => {
|
|
51
|
+
const qs: string[] = [];
|
|
52
|
+
|
|
53
|
+
const append = (key: string, value: any) => {
|
|
54
|
+
qs.push(`${encodeURIComponent(key)}=${encodeURIComponent(String(value))}`);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const process = (key: string, value: any) => {
|
|
58
|
+
if (isDefined(value)) {
|
|
59
|
+
if (Array.isArray(value)) {
|
|
60
|
+
value.forEach(v => {
|
|
61
|
+
process(key, v);
|
|
62
|
+
});
|
|
63
|
+
} else if (typeof value === 'object') {
|
|
64
|
+
Object.entries(value).forEach(([k, v]) => {
|
|
65
|
+
process(`${key}[${k}]`, v);
|
|
66
|
+
});
|
|
67
|
+
} else {
|
|
68
|
+
append(key, value);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
74
|
+
process(key, value);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
if (qs.length > 0) {
|
|
78
|
+
return `?${qs.join('&')}`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return '';
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const getUrl = (config: OpenAPIConfig, options: ApiRequestOptions): string => {
|
|
85
|
+
const encoder = config.ENCODE_PATH || encodeURI;
|
|
86
|
+
|
|
87
|
+
const path = options.url
|
|
88
|
+
.replace('{api-version}', config.VERSION)
|
|
89
|
+
.replace(/{(.*?)}/g, (substring: string, group: string) => {
|
|
90
|
+
if (options.path?.hasOwnProperty(group)) {
|
|
91
|
+
return encoder(String(options.path[group]));
|
|
92
|
+
}
|
|
93
|
+
return substring;
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const url = `${config.BASE}${path}`;
|
|
97
|
+
if (options.query) {
|
|
98
|
+
return `${url}${getQueryString(options.query)}`;
|
|
99
|
+
}
|
|
100
|
+
return url;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const getFormData = (options: ApiRequestOptions): FormData | undefined => {
|
|
104
|
+
if (options.formData) {
|
|
105
|
+
const formData = new FormData();
|
|
106
|
+
|
|
107
|
+
const process = (key: string, value: any) => {
|
|
108
|
+
if (isString(value) || isBlob(value)) {
|
|
109
|
+
formData.append(key, value);
|
|
110
|
+
} else {
|
|
111
|
+
formData.append(key, JSON.stringify(value));
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
Object.entries(options.formData)
|
|
116
|
+
.filter(([_, value]) => isDefined(value))
|
|
117
|
+
.forEach(([key, value]) => {
|
|
118
|
+
if (Array.isArray(value)) {
|
|
119
|
+
value.forEach(v => process(key, v));
|
|
120
|
+
} else {
|
|
121
|
+
process(key, value);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
return formData;
|
|
126
|
+
}
|
|
127
|
+
return undefined;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
|
|
131
|
+
|
|
132
|
+
export const resolve = async <T>(options: ApiRequestOptions, resolver?: T | Resolver<T>): Promise<T | undefined> => {
|
|
133
|
+
if (typeof resolver === 'function') {
|
|
134
|
+
return (resolver as Resolver<T>)(options);
|
|
135
|
+
}
|
|
136
|
+
return resolver;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export const getHeaders = async (config: OpenAPIConfig, options: ApiRequestOptions): Promise<Headers> => {
|
|
140
|
+
const [token, username, password, additionalHeaders] = await Promise.all([
|
|
141
|
+
resolve(options, config.TOKEN),
|
|
142
|
+
resolve(options, config.USERNAME),
|
|
143
|
+
resolve(options, config.PASSWORD),
|
|
144
|
+
resolve(options, config.HEADERS),
|
|
145
|
+
]);
|
|
146
|
+
|
|
147
|
+
const headers = Object.entries({
|
|
148
|
+
Accept: 'application/json',
|
|
149
|
+
...additionalHeaders,
|
|
150
|
+
...options.headers,
|
|
151
|
+
})
|
|
152
|
+
.filter(([_, value]) => isDefined(value))
|
|
153
|
+
.reduce((headers, [key, value]) => ({
|
|
154
|
+
...headers,
|
|
155
|
+
[key]: String(value),
|
|
156
|
+
}), {} as Record<string, string>);
|
|
157
|
+
|
|
158
|
+
if (isStringWithValue(token)) {
|
|
159
|
+
headers['Authorization'] = `Bearer ${token}`;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (isStringWithValue(username) && isStringWithValue(password)) {
|
|
163
|
+
const credentials = base64(`${username}:${password}`);
|
|
164
|
+
headers['Authorization'] = `Basic ${credentials}`;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (options.body) {
|
|
168
|
+
if (options.mediaType) {
|
|
169
|
+
headers['Content-Type'] = options.mediaType;
|
|
170
|
+
} else if (isBlob(options.body)) {
|
|
171
|
+
headers['Content-Type'] = options.body.type || 'application/octet-stream';
|
|
172
|
+
} else if (isString(options.body)) {
|
|
173
|
+
headers['Content-Type'] = 'text/plain';
|
|
174
|
+
} else if (!isFormData(options.body)) {
|
|
175
|
+
headers['Content-Type'] = 'application/json';
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return new Headers(headers);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export const getRequestBody = (options: ApiRequestOptions): any => {
|
|
183
|
+
if (options.body !== undefined) {
|
|
184
|
+
if (options.mediaType?.includes('/json')) {
|
|
185
|
+
return JSON.stringify(options.body)
|
|
186
|
+
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
|
187
|
+
return options.body;
|
|
188
|
+
} else {
|
|
189
|
+
return JSON.stringify(options.body);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return undefined;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export const sendRequest = async (
|
|
196
|
+
config: OpenAPIConfig,
|
|
197
|
+
options: ApiRequestOptions,
|
|
198
|
+
url: string,
|
|
199
|
+
body: any,
|
|
200
|
+
formData: FormData | undefined,
|
|
201
|
+
headers: Headers,
|
|
202
|
+
onCancel: OnCancel
|
|
203
|
+
): Promise<Response> => {
|
|
204
|
+
const controller = new AbortController();
|
|
205
|
+
|
|
206
|
+
const request: RequestInit = {
|
|
207
|
+
headers,
|
|
208
|
+
body: body ?? formData,
|
|
209
|
+
method: options.method,
|
|
210
|
+
signal: controller.signal,
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
if (config.WITH_CREDENTIALS) {
|
|
214
|
+
request.credentials = config.CREDENTIALS;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
onCancel(() => controller.abort());
|
|
218
|
+
|
|
219
|
+
return await fetch(url, request);
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export const getResponseHeader = (response: Response, responseHeader?: string): string | undefined => {
|
|
223
|
+
if (responseHeader) {
|
|
224
|
+
const content = response.headers.get(responseHeader);
|
|
225
|
+
if (isString(content)) {
|
|
226
|
+
return content;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return undefined;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export const getResponseBody = async (response: Response): Promise<any> => {
|
|
233
|
+
if (response.status !== 204) {
|
|
234
|
+
try {
|
|
235
|
+
const contentType = response.headers.get('Content-Type');
|
|
236
|
+
if (contentType) {
|
|
237
|
+
const jsonTypes = ['application/json', 'application/problem+json']
|
|
238
|
+
const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
|
|
239
|
+
if (isJSON) {
|
|
240
|
+
return await response.json();
|
|
241
|
+
} else {
|
|
242
|
+
return await response.text();
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
} catch (error) {
|
|
246
|
+
console.error(error);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return undefined;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
export const catchErrorCodes = (options: ApiRequestOptions, result: ApiResult): void => {
|
|
253
|
+
const errors: Record<number, string> = {
|
|
254
|
+
400: 'Bad Request',
|
|
255
|
+
401: 'Unauthorized',
|
|
256
|
+
403: 'Forbidden',
|
|
257
|
+
404: 'Not Found',
|
|
258
|
+
500: 'Internal Server Error',
|
|
259
|
+
502: 'Bad Gateway',
|
|
260
|
+
503: 'Service Unavailable',
|
|
261
|
+
...options.errors,
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const error = errors[result.status];
|
|
265
|
+
if (error) {
|
|
266
|
+
throw new ApiError(options, result, error);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (!result.ok) {
|
|
270
|
+
const errorStatus = result.status ?? 'unknown';
|
|
271
|
+
const errorStatusText = result.statusText ?? 'unknown';
|
|
272
|
+
const errorBody = (() => {
|
|
273
|
+
try {
|
|
274
|
+
return JSON.stringify(result.body, null, 2);
|
|
275
|
+
} catch (e) {
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
})();
|
|
279
|
+
|
|
280
|
+
throw new ApiError(options, result,
|
|
281
|
+
`Generic Error: status: ${errorStatus}; status text: ${errorStatusText}; body: ${errorBody}`
|
|
282
|
+
);
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Request method
|
|
288
|
+
* @param config The OpenAPI configuration object
|
|
289
|
+
* @param options The request options from the service
|
|
290
|
+
* @returns CancelablePromise<T>
|
|
291
|
+
* @throws ApiError
|
|
292
|
+
*/
|
|
293
|
+
export const request = <T>(config: OpenAPIConfig, options: ApiRequestOptions): CancelablePromise<T> => {
|
|
294
|
+
return new CancelablePromise(async (resolve, reject, onCancel) => {
|
|
295
|
+
try {
|
|
296
|
+
const url = getUrl(config, options);
|
|
297
|
+
const formData = getFormData(options);
|
|
298
|
+
const body = getRequestBody(options);
|
|
299
|
+
const headers = await getHeaders(config, options);
|
|
300
|
+
|
|
301
|
+
if (!onCancel.isCancelled) {
|
|
302
|
+
const response = await sendRequest(config, options, url, body, formData, headers, onCancel);
|
|
303
|
+
const responseBody = await getResponseBody(response);
|
|
304
|
+
const responseHeader = getResponseHeader(response, options.responseHeader);
|
|
305
|
+
|
|
306
|
+
const result: ApiResult = {
|
|
307
|
+
url,
|
|
308
|
+
ok: response.ok,
|
|
309
|
+
status: response.status,
|
|
310
|
+
statusText: response.statusText,
|
|
311
|
+
body: responseHeader ?? responseBody,
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
catchErrorCodes(options, result);
|
|
315
|
+
|
|
316
|
+
resolve(result.body);
|
|
317
|
+
}
|
|
318
|
+
} catch (error) {
|
|
319
|
+
reject(error);
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
};
|