@ayasofyazilim/saas 0.0.132 → 0.0.134
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/CRMService/sdk.gen.ts +6 -6
- package/CRMService/types.gen.ts +3 -3
- package/SaasService/SaasServiceClient.ts +65 -65
- package/SaasService/core/ApiError.ts +20 -20
- package/SaasService/core/ApiRequestOptions.ts +20 -12
- package/SaasService/core/ApiResult.ts +6 -6
- package/SaasService/core/BaseHttpRequest.ts +9 -9
- package/SaasService/core/CancelablePromise.ts +125 -125
- package/SaasService/core/FetchHttpRequest.ts +21 -21
- package/SaasService/core/OpenAPI.ts +55 -55
- package/SaasService/core/request.ts +349 -340
- package/SaasService/index.ts +10 -9
- package/SaasService/schemas.gen.ts +5445 -5345
- package/SaasService/{services.gen.ts → sdk.gen.ts} +1329 -1329
- package/SaasService/types.gen.ts +1048 -2738
- package/package.json +1 -1
package/CRMService/sdk.gen.ts
CHANGED
|
@@ -2496,7 +2496,7 @@ export class RefundPointService {
|
|
|
2496
2496
|
* @param data The data for the request.
|
|
2497
2497
|
* @param data.ids
|
|
2498
2498
|
* @param data.name
|
|
2499
|
-
* @param data.
|
|
2499
|
+
* @param data.typeCodes
|
|
2500
2500
|
* @param data.sorting
|
|
2501
2501
|
* @param data.skipCount
|
|
2502
2502
|
* @param data.maxResultCount
|
|
@@ -2510,7 +2510,7 @@ export class RefundPointService {
|
|
|
2510
2510
|
query: {
|
|
2511
2511
|
Ids: data.ids,
|
|
2512
2512
|
Name: data.name,
|
|
2513
|
-
|
|
2513
|
+
TypeCodes: data.typeCodes,
|
|
2514
2514
|
Sorting: data.sorting,
|
|
2515
2515
|
SkipCount: data.skipCount,
|
|
2516
2516
|
MaxResultCount: data.maxResultCount
|
|
@@ -2530,7 +2530,7 @@ export class RefundPointService {
|
|
|
2530
2530
|
* @param data The data for the request.
|
|
2531
2531
|
* @param data.ids
|
|
2532
2532
|
* @param data.name
|
|
2533
|
-
* @param data.
|
|
2533
|
+
* @param data.typeCodes
|
|
2534
2534
|
* @param data.sorting
|
|
2535
2535
|
* @param data.skipCount
|
|
2536
2536
|
* @param data.maxResultCount
|
|
@@ -2544,7 +2544,7 @@ export class RefundPointService {
|
|
|
2544
2544
|
query: {
|
|
2545
2545
|
Ids: data.ids,
|
|
2546
2546
|
Name: data.name,
|
|
2547
|
-
|
|
2547
|
+
TypeCodes: data.typeCodes,
|
|
2548
2548
|
Sorting: data.sorting,
|
|
2549
2549
|
SkipCount: data.skipCount,
|
|
2550
2550
|
MaxResultCount: data.maxResultCount
|
|
@@ -3056,7 +3056,7 @@ export class RefundPointIntegrationService {
|
|
|
3056
3056
|
* @param data The data for the request.
|
|
3057
3057
|
* @param data.ids
|
|
3058
3058
|
* @param data.name
|
|
3059
|
-
* @param data.
|
|
3059
|
+
* @param data.typeCodes
|
|
3060
3060
|
* @param data.sorting
|
|
3061
3061
|
* @param data.skipCount
|
|
3062
3062
|
* @param data.maxResultCount
|
|
@@ -3070,7 +3070,7 @@ export class RefundPointIntegrationService {
|
|
|
3070
3070
|
query: {
|
|
3071
3071
|
Ids: data.ids,
|
|
3072
3072
|
Name: data.name,
|
|
3073
|
-
|
|
3073
|
+
TypeCodes: data.typeCodes,
|
|
3074
3074
|
Sorting: data.sorting,
|
|
3075
3075
|
SkipCount: data.skipCount,
|
|
3076
3076
|
MaxResultCount: data.maxResultCount
|
package/CRMService/types.gen.ts
CHANGED
|
@@ -2028,7 +2028,7 @@ export type GetApiCrmServiceRefundPointsData = {
|
|
|
2028
2028
|
name?: string;
|
|
2029
2029
|
skipCount?: number;
|
|
2030
2030
|
sorting?: string;
|
|
2031
|
-
|
|
2031
|
+
typeCodes?: Array<UniRefund_CRMService_RefundPoints_RefundPointTypeCode>;
|
|
2032
2032
|
};
|
|
2033
2033
|
|
|
2034
2034
|
export type GetApiCrmServiceRefundPointsResponse = (PagedResultDto_RefundPointProfileDto);
|
|
@@ -2039,7 +2039,7 @@ export type GetApiCrmServiceRefundPointsAccessibleData = {
|
|
|
2039
2039
|
name?: string;
|
|
2040
2040
|
skipCount?: number;
|
|
2041
2041
|
sorting?: string;
|
|
2042
|
-
|
|
2042
|
+
typeCodes?: Array<UniRefund_CRMService_RefundPoints_RefundPointTypeCode>;
|
|
2043
2043
|
};
|
|
2044
2044
|
|
|
2045
2045
|
export type GetApiCrmServiceRefundPointsAccessibleResponse = (PagedResultDto_RefundPointProfileDto);
|
|
@@ -2181,7 +2181,7 @@ export type GetIntegrationApiRefundPointsData = {
|
|
|
2181
2181
|
name?: string;
|
|
2182
2182
|
skipCount?: number;
|
|
2183
2183
|
sorting?: string;
|
|
2184
|
-
|
|
2184
|
+
typeCodes?: Array<UniRefund_CRMService_RefundPoints_RefundPointTypeCode>;
|
|
2185
2185
|
};
|
|
2186
2186
|
|
|
2187
2187
|
export type GetIntegrationApiRefundPointsResponse = (PagedResultDto_RefundPointProfileDto);
|
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import type { BaseHttpRequest } from './core/BaseHttpRequest';
|
|
2
|
-
import type { OpenAPIConfig } from './core/OpenAPI';
|
|
3
|
-
import { Interceptors } from './core/OpenAPI';
|
|
4
|
-
import { FetchHttpRequest } from './core/FetchHttpRequest';
|
|
5
|
-
|
|
6
|
-
import { AbpApiDefinitionService } from './
|
|
7
|
-
import { AbpApplicationConfigurationService } from './
|
|
8
|
-
import { AbpApplicationLocalizationService } from './
|
|
9
|
-
import { EditionService } from './
|
|
10
|
-
import { FeaturesService } from './
|
|
11
|
-
import { GatewayService } from './
|
|
12
|
-
import { PaymentRequestService } from './
|
|
13
|
-
import { PaymentRequestAdminService } from './
|
|
14
|
-
import { PlanService } from './
|
|
15
|
-
import { PlanAdminService } from './
|
|
16
|
-
import { TenantService } from './
|
|
17
|
-
|
|
18
|
-
type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest;
|
|
19
|
-
|
|
20
|
-
export class SaasServiceClient {
|
|
21
|
-
|
|
22
|
-
public readonly abpApiDefinition: AbpApiDefinitionService;
|
|
23
|
-
public readonly abpApplicationConfiguration: AbpApplicationConfigurationService;
|
|
24
|
-
public readonly abpApplicationLocalization: AbpApplicationLocalizationService;
|
|
25
|
-
public readonly edition: EditionService;
|
|
26
|
-
public readonly features: FeaturesService;
|
|
27
|
-
public readonly gateway: GatewayService;
|
|
28
|
-
public readonly paymentRequest: PaymentRequestService;
|
|
29
|
-
public readonly paymentRequestAdmin: PaymentRequestAdminService;
|
|
30
|
-
public readonly plan: PlanService;
|
|
31
|
-
public readonly planAdmin: PlanAdminService;
|
|
32
|
-
public readonly tenant: TenantService;
|
|
33
|
-
|
|
34
|
-
public readonly request: BaseHttpRequest;
|
|
35
|
-
|
|
36
|
-
constructor(config?: Partial<OpenAPIConfig>, HttpRequest: HttpRequestConstructor = FetchHttpRequest) {
|
|
37
|
-
this.request = new HttpRequest({
|
|
38
|
-
BASE: config?.BASE ?? '',
|
|
39
|
-
VERSION: config?.VERSION ?? '1',
|
|
40
|
-
WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
|
|
41
|
-
CREDENTIALS: config?.CREDENTIALS ?? 'include',
|
|
42
|
-
TOKEN: config?.TOKEN,
|
|
43
|
-
USERNAME: config?.USERNAME,
|
|
44
|
-
PASSWORD: config?.PASSWORD,
|
|
45
|
-
HEADERS: config?.HEADERS,
|
|
46
|
-
ENCODE_PATH: config?.ENCODE_PATH,
|
|
47
|
-
interceptors: {
|
|
48
|
-
request: config?.interceptors?.request ?? new Interceptors(),
|
|
49
|
-
response: config?.interceptors?.response ?? new Interceptors(),
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
this.abpApiDefinition = new AbpApiDefinitionService(this.request);
|
|
54
|
-
this.abpApplicationConfiguration = new AbpApplicationConfigurationService(this.request);
|
|
55
|
-
this.abpApplicationLocalization = new AbpApplicationLocalizationService(this.request);
|
|
56
|
-
this.edition = new EditionService(this.request);
|
|
57
|
-
this.features = new FeaturesService(this.request);
|
|
58
|
-
this.gateway = new GatewayService(this.request);
|
|
59
|
-
this.paymentRequest = new PaymentRequestService(this.request);
|
|
60
|
-
this.paymentRequestAdmin = new PaymentRequestAdminService(this.request);
|
|
61
|
-
this.plan = new PlanService(this.request);
|
|
62
|
-
this.planAdmin = new PlanAdminService(this.request);
|
|
63
|
-
this.tenant = new TenantService(this.request);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
1
|
+
import type { BaseHttpRequest } from './core/BaseHttpRequest';
|
|
2
|
+
import type { OpenAPIConfig } from './core/OpenAPI';
|
|
3
|
+
import { Interceptors } from './core/OpenAPI';
|
|
4
|
+
import { FetchHttpRequest } from './core/FetchHttpRequest';
|
|
5
|
+
|
|
6
|
+
import { AbpApiDefinitionService } from './sdk.gen';
|
|
7
|
+
import { AbpApplicationConfigurationService } from './sdk.gen';
|
|
8
|
+
import { AbpApplicationLocalizationService } from './sdk.gen';
|
|
9
|
+
import { EditionService } from './sdk.gen';
|
|
10
|
+
import { FeaturesService } from './sdk.gen';
|
|
11
|
+
import { GatewayService } from './sdk.gen';
|
|
12
|
+
import { PaymentRequestService } from './sdk.gen';
|
|
13
|
+
import { PaymentRequestAdminService } from './sdk.gen';
|
|
14
|
+
import { PlanService } from './sdk.gen';
|
|
15
|
+
import { PlanAdminService } from './sdk.gen';
|
|
16
|
+
import { TenantService } from './sdk.gen';
|
|
17
|
+
|
|
18
|
+
type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest;
|
|
19
|
+
|
|
20
|
+
export class SaasServiceClient {
|
|
21
|
+
|
|
22
|
+
public readonly abpApiDefinition: AbpApiDefinitionService;
|
|
23
|
+
public readonly abpApplicationConfiguration: AbpApplicationConfigurationService;
|
|
24
|
+
public readonly abpApplicationLocalization: AbpApplicationLocalizationService;
|
|
25
|
+
public readonly edition: EditionService;
|
|
26
|
+
public readonly features: FeaturesService;
|
|
27
|
+
public readonly gateway: GatewayService;
|
|
28
|
+
public readonly paymentRequest: PaymentRequestService;
|
|
29
|
+
public readonly paymentRequestAdmin: PaymentRequestAdminService;
|
|
30
|
+
public readonly plan: PlanService;
|
|
31
|
+
public readonly planAdmin: PlanAdminService;
|
|
32
|
+
public readonly tenant: TenantService;
|
|
33
|
+
|
|
34
|
+
public readonly request: BaseHttpRequest;
|
|
35
|
+
|
|
36
|
+
constructor(config?: Partial<OpenAPIConfig>, HttpRequest: HttpRequestConstructor = FetchHttpRequest) {
|
|
37
|
+
this.request = new HttpRequest({
|
|
38
|
+
BASE: config?.BASE ?? '',
|
|
39
|
+
VERSION: config?.VERSION ?? '1',
|
|
40
|
+
WITH_CREDENTIALS: config?.WITH_CREDENTIALS ?? false,
|
|
41
|
+
CREDENTIALS: config?.CREDENTIALS ?? 'include',
|
|
42
|
+
TOKEN: config?.TOKEN,
|
|
43
|
+
USERNAME: config?.USERNAME,
|
|
44
|
+
PASSWORD: config?.PASSWORD,
|
|
45
|
+
HEADERS: config?.HEADERS,
|
|
46
|
+
ENCODE_PATH: config?.ENCODE_PATH,
|
|
47
|
+
interceptors: {
|
|
48
|
+
request: config?.interceptors?.request ?? new Interceptors(),
|
|
49
|
+
response: config?.interceptors?.response ?? new Interceptors(),
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
this.abpApiDefinition = new AbpApiDefinitionService(this.request);
|
|
54
|
+
this.abpApplicationConfiguration = new AbpApplicationConfigurationService(this.request);
|
|
55
|
+
this.abpApplicationLocalization = new AbpApplicationLocalizationService(this.request);
|
|
56
|
+
this.edition = new EditionService(this.request);
|
|
57
|
+
this.features = new FeaturesService(this.request);
|
|
58
|
+
this.gateway = new GatewayService(this.request);
|
|
59
|
+
this.paymentRequest = new PaymentRequestService(this.request);
|
|
60
|
+
this.paymentRequestAdmin = new PaymentRequestAdminService(this.request);
|
|
61
|
+
this.plan = new PlanService(this.request);
|
|
62
|
+
this.planAdmin = new PlanAdminService(this.request);
|
|
63
|
+
this.tenant = new TenantService(this.request);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
2
|
-
import type { ApiResult } from './ApiResult';
|
|
3
|
-
|
|
4
|
-
export class ApiError extends Error {
|
|
5
|
-
public readonly url: string;
|
|
6
|
-
public readonly status: number;
|
|
7
|
-
public readonly statusText: string;
|
|
8
|
-
public readonly body: unknown;
|
|
9
|
-
public readonly request: ApiRequestOptions;
|
|
10
|
-
|
|
11
|
-
constructor(request: ApiRequestOptions, response: ApiResult, message: string) {
|
|
12
|
-
super(message);
|
|
13
|
-
|
|
14
|
-
this.name = 'ApiError';
|
|
15
|
-
this.url = response.url;
|
|
16
|
-
this.status = response.status;
|
|
17
|
-
this.statusText = response.statusText;
|
|
18
|
-
this.body = response.body;
|
|
19
|
-
this.request = request;
|
|
20
|
-
}
|
|
1
|
+
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
2
|
+
import type { ApiResult } from './ApiResult';
|
|
3
|
+
|
|
4
|
+
export class ApiError extends Error {
|
|
5
|
+
public readonly url: string;
|
|
6
|
+
public readonly status: number;
|
|
7
|
+
public readonly statusText: string;
|
|
8
|
+
public readonly body: unknown;
|
|
9
|
+
public readonly request: ApiRequestOptions;
|
|
10
|
+
|
|
11
|
+
constructor(request: ApiRequestOptions, response: ApiResult, message: string) {
|
|
12
|
+
super(message);
|
|
13
|
+
|
|
14
|
+
this.name = 'ApiError';
|
|
15
|
+
this.url = response.url;
|
|
16
|
+
this.status = response.status;
|
|
17
|
+
this.statusText = response.statusText;
|
|
18
|
+
this.body = response.body;
|
|
19
|
+
this.request = request;
|
|
20
|
+
}
|
|
21
21
|
}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
export type ApiRequestOptions = {
|
|
2
|
-
readonly
|
|
3
|
-
readonly
|
|
4
|
-
readonly
|
|
5
|
-
readonly
|
|
6
|
-
readonly headers?: Record<string, unknown>;
|
|
7
|
-
readonly
|
|
8
|
-
readonly
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
export type ApiRequestOptions<T = unknown> = {
|
|
2
|
+
readonly body?: any;
|
|
3
|
+
readonly cookies?: Record<string, unknown>;
|
|
4
|
+
readonly errors?: Record<number | string, string>;
|
|
5
|
+
readonly formData?: Record<string, unknown> | any[] | Blob | File;
|
|
6
|
+
readonly headers?: Record<string, unknown>;
|
|
7
|
+
readonly mediaType?: string;
|
|
8
|
+
readonly method:
|
|
9
|
+
| 'DELETE'
|
|
10
|
+
| 'GET'
|
|
11
|
+
| 'HEAD'
|
|
12
|
+
| 'OPTIONS'
|
|
13
|
+
| 'PATCH'
|
|
14
|
+
| 'POST'
|
|
15
|
+
| 'PUT';
|
|
16
|
+
readonly path?: Record<string, unknown>;
|
|
17
|
+
readonly query?: Record<string, unknown>;
|
|
18
|
+
readonly responseHeader?: string;
|
|
19
|
+
readonly responseTransformer?: (data: unknown) => Promise<T>;
|
|
20
|
+
readonly url: string;
|
|
13
21
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export type ApiResult<TData = any> = {
|
|
2
|
-
readonly body: TData;
|
|
3
|
-
readonly ok: boolean;
|
|
4
|
-
readonly status: number;
|
|
5
|
-
readonly statusText: string;
|
|
6
|
-
readonly url: string;
|
|
1
|
+
export type ApiResult<TData = any> = {
|
|
2
|
+
readonly body: TData;
|
|
3
|
+
readonly ok: boolean;
|
|
4
|
+
readonly status: number;
|
|
5
|
+
readonly statusText: string;
|
|
6
|
+
readonly url: string;
|
|
7
7
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
2
|
-
import type { CancelablePromise } from './CancelablePromise';
|
|
3
|
-
import type { OpenAPIConfig } from './OpenAPI';
|
|
4
|
-
|
|
5
|
-
export abstract class BaseHttpRequest {
|
|
6
|
-
|
|
7
|
-
constructor(public readonly config: OpenAPIConfig) {}
|
|
8
|
-
|
|
9
|
-
public abstract request<T>(options: ApiRequestOptions): CancelablePromise<T>;
|
|
1
|
+
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
2
|
+
import type { CancelablePromise } from './CancelablePromise';
|
|
3
|
+
import type { OpenAPIConfig } from './OpenAPI';
|
|
4
|
+
|
|
5
|
+
export abstract class BaseHttpRequest {
|
|
6
|
+
|
|
7
|
+
constructor(public readonly config: OpenAPIConfig) {}
|
|
8
|
+
|
|
9
|
+
public abstract request<T>(options: ApiRequestOptions<T>): CancelablePromise<T>;
|
|
10
10
|
}
|
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
export class CancelError extends Error {
|
|
2
|
-
constructor(message: string) {
|
|
3
|
-
super(message);
|
|
4
|
-
this.name = 'CancelError';
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
public get isCancelled(): boolean {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface OnCancel {
|
|
13
|
-
readonly isResolved: boolean;
|
|
14
|
-
readonly isRejected: boolean;
|
|
15
|
-
readonly isCancelled: boolean;
|
|
16
|
-
|
|
17
|
-
(cancelHandler: () => void): void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class CancelablePromise<T> implements Promise<T> {
|
|
21
|
-
private _isResolved: boolean;
|
|
22
|
-
private _isRejected: boolean;
|
|
23
|
-
private _isCancelled: boolean;
|
|
24
|
-
readonly cancelHandlers: (() => void)[];
|
|
25
|
-
readonly promise: Promise<T>;
|
|
26
|
-
private _resolve?: (value: T | PromiseLike<T>) => void;
|
|
27
|
-
private _reject?: (reason?: unknown) => void;
|
|
28
|
-
|
|
29
|
-
constructor(
|
|
30
|
-
executor: (
|
|
31
|
-
resolve: (value: T | PromiseLike<T>) => void,
|
|
32
|
-
reject: (reason?: unknown) => void,
|
|
33
|
-
onCancel: OnCancel
|
|
34
|
-
) => void
|
|
35
|
-
) {
|
|
36
|
-
this._isResolved = false;
|
|
37
|
-
this._isRejected = false;
|
|
38
|
-
this._isCancelled = false;
|
|
39
|
-
this.cancelHandlers = [];
|
|
40
|
-
this.promise = new Promise<T>((resolve, reject) => {
|
|
41
|
-
this._resolve = resolve;
|
|
42
|
-
this._reject = reject;
|
|
43
|
-
|
|
44
|
-
const onResolve = (value: T | PromiseLike<T>): void => {
|
|
45
|
-
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
this._isResolved = true;
|
|
49
|
-
if (this._resolve) this._resolve(value);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const onReject = (reason?: unknown): void => {
|
|
53
|
-
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
this._isRejected = true;
|
|
57
|
-
if (this._reject) this._reject(reason);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const onCancel = (cancelHandler: () => void): void => {
|
|
61
|
-
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
this.cancelHandlers.push(cancelHandler);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
Object.defineProperty(onCancel, 'isResolved', {
|
|
68
|
-
get: (): boolean => this._isResolved,
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
Object.defineProperty(onCancel, 'isRejected', {
|
|
72
|
-
get: (): boolean => this._isRejected,
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
Object.defineProperty(onCancel, 'isCancelled', {
|
|
76
|
-
get: (): boolean => this._isCancelled,
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
return executor(onResolve, onReject, onCancel as OnCancel);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
get [Symbol.toStringTag]() {
|
|
84
|
-
return "Cancellable Promise";
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
public then<TResult1 = T, TResult2 = never>(
|
|
88
|
-
onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
|
|
89
|
-
onRejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null
|
|
90
|
-
): Promise<TResult1 | TResult2> {
|
|
91
|
-
return this.promise.then(onFulfilled, onRejected);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
public catch<TResult = never>(
|
|
95
|
-
onRejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null
|
|
96
|
-
): Promise<T | TResult> {
|
|
97
|
-
return this.promise.catch(onRejected);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
public finally(onFinally?: (() => void) | null): Promise<T> {
|
|
101
|
-
return this.promise.finally(onFinally);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
public cancel(): void {
|
|
105
|
-
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
this._isCancelled = true;
|
|
109
|
-
if (this.cancelHandlers.length) {
|
|
110
|
-
try {
|
|
111
|
-
for (const cancelHandler of this.cancelHandlers) {
|
|
112
|
-
cancelHandler();
|
|
113
|
-
}
|
|
114
|
-
} catch (error) {
|
|
115
|
-
console.warn('Cancellation threw an error', error);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
this.cancelHandlers.length = 0;
|
|
120
|
-
if (this._reject) this._reject(new CancelError('Request aborted'));
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
public get isCancelled(): boolean {
|
|
124
|
-
return this._isCancelled;
|
|
125
|
-
}
|
|
1
|
+
export class CancelError extends Error {
|
|
2
|
+
constructor(message: string) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = 'CancelError';
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
public get isCancelled(): boolean {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface OnCancel {
|
|
13
|
+
readonly isResolved: boolean;
|
|
14
|
+
readonly isRejected: boolean;
|
|
15
|
+
readonly isCancelled: boolean;
|
|
16
|
+
|
|
17
|
+
(cancelHandler: () => void): void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class CancelablePromise<T> implements Promise<T> {
|
|
21
|
+
private _isResolved: boolean;
|
|
22
|
+
private _isRejected: boolean;
|
|
23
|
+
private _isCancelled: boolean;
|
|
24
|
+
readonly cancelHandlers: (() => void)[];
|
|
25
|
+
readonly promise: Promise<T>;
|
|
26
|
+
private _resolve?: (value: T | PromiseLike<T>) => void;
|
|
27
|
+
private _reject?: (reason?: unknown) => void;
|
|
28
|
+
|
|
29
|
+
constructor(
|
|
30
|
+
executor: (
|
|
31
|
+
resolve: (value: T | PromiseLike<T>) => void,
|
|
32
|
+
reject: (reason?: unknown) => void,
|
|
33
|
+
onCancel: OnCancel
|
|
34
|
+
) => void
|
|
35
|
+
) {
|
|
36
|
+
this._isResolved = false;
|
|
37
|
+
this._isRejected = false;
|
|
38
|
+
this._isCancelled = false;
|
|
39
|
+
this.cancelHandlers = [];
|
|
40
|
+
this.promise = new Promise<T>((resolve, reject) => {
|
|
41
|
+
this._resolve = resolve;
|
|
42
|
+
this._reject = reject;
|
|
43
|
+
|
|
44
|
+
const onResolve = (value: T | PromiseLike<T>): void => {
|
|
45
|
+
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this._isResolved = true;
|
|
49
|
+
if (this._resolve) this._resolve(value);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const onReject = (reason?: unknown): void => {
|
|
53
|
+
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this._isRejected = true;
|
|
57
|
+
if (this._reject) this._reject(reason);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const onCancel = (cancelHandler: () => void): void => {
|
|
61
|
+
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this.cancelHandlers.push(cancelHandler);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
Object.defineProperty(onCancel, 'isResolved', {
|
|
68
|
+
get: (): boolean => this._isResolved,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
Object.defineProperty(onCancel, 'isRejected', {
|
|
72
|
+
get: (): boolean => this._isRejected,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
Object.defineProperty(onCancel, 'isCancelled', {
|
|
76
|
+
get: (): boolean => this._isCancelled,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return executor(onResolve, onReject, onCancel as OnCancel);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
get [Symbol.toStringTag]() {
|
|
84
|
+
return "Cancellable Promise";
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public then<TResult1 = T, TResult2 = never>(
|
|
88
|
+
onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null,
|
|
89
|
+
onRejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null
|
|
90
|
+
): Promise<TResult1 | TResult2> {
|
|
91
|
+
return this.promise.then(onFulfilled, onRejected);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
public catch<TResult = never>(
|
|
95
|
+
onRejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null
|
|
96
|
+
): Promise<T | TResult> {
|
|
97
|
+
return this.promise.catch(onRejected);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public finally(onFinally?: (() => void) | null): Promise<T> {
|
|
101
|
+
return this.promise.finally(onFinally);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public cancel(): void {
|
|
105
|
+
if (this._isResolved || this._isRejected || this._isCancelled) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
this._isCancelled = true;
|
|
109
|
+
if (this.cancelHandlers.length) {
|
|
110
|
+
try {
|
|
111
|
+
for (const cancelHandler of this.cancelHandlers) {
|
|
112
|
+
cancelHandler();
|
|
113
|
+
}
|
|
114
|
+
} catch (error) {
|
|
115
|
+
console.warn('Cancellation threw an error', error);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
this.cancelHandlers.length = 0;
|
|
120
|
+
if (this._reject) this._reject(new CancelError('Request aborted'));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public get isCancelled(): boolean {
|
|
124
|
+
return this._isCancelled;
|
|
125
|
+
}
|
|
126
126
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
2
|
-
import { BaseHttpRequest } from './BaseHttpRequest';
|
|
3
|
-
import type { CancelablePromise } from './CancelablePromise';
|
|
4
|
-
import type { OpenAPIConfig } from './OpenAPI';
|
|
5
|
-
import { request as __request } from './request';
|
|
6
|
-
|
|
7
|
-
export class FetchHttpRequest extends BaseHttpRequest {
|
|
8
|
-
|
|
9
|
-
constructor(config: OpenAPIConfig) {
|
|
10
|
-
super(config);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Request method
|
|
15
|
-
* @param options The request options from the service
|
|
16
|
-
* @returns CancelablePromise<T>
|
|
17
|
-
* @throws ApiError
|
|
18
|
-
*/
|
|
19
|
-
public override request<T>(options: ApiRequestOptions): CancelablePromise<T> {
|
|
20
|
-
return __request(this.config, options);
|
|
21
|
-
}
|
|
1
|
+
import type { ApiRequestOptions } from './ApiRequestOptions';
|
|
2
|
+
import { BaseHttpRequest } from './BaseHttpRequest';
|
|
3
|
+
import type { CancelablePromise } from './CancelablePromise';
|
|
4
|
+
import type { OpenAPIConfig } from './OpenAPI';
|
|
5
|
+
import { request as __request } from './request';
|
|
6
|
+
|
|
7
|
+
export class FetchHttpRequest extends BaseHttpRequest {
|
|
8
|
+
|
|
9
|
+
constructor(config: OpenAPIConfig) {
|
|
10
|
+
super(config);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Request method
|
|
15
|
+
* @param options The request options from the service
|
|
16
|
+
* @returns CancelablePromise<T>
|
|
17
|
+
* @throws ApiError
|
|
18
|
+
*/
|
|
19
|
+
public override request<T>(options: ApiRequestOptions<T>): CancelablePromise<T> {
|
|
20
|
+
return __request(this.config, options);
|
|
21
|
+
}
|
|
22
22
|
}
|