@1money/protocol-ts-sdk 1.0.14
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/.claude/settings.local.json +14 -0
- package/CLAUDE.md +77 -0
- package/README.md +600 -0
- package/es/api/accounts/index.d.ts +20 -0
- package/es/api/accounts/types.d.ts +9 -0
- package/es/api/chain/index.d.ts +12 -0
- package/es/api/chain/types.d.ts +3 -0
- package/es/api/checkpoints/index.d.ts +26 -0
- package/es/api/checkpoints/types.d.ts +33 -0
- package/es/api/constants.d.ts +9 -0
- package/es/api/index.d.ts +31 -0
- package/es/api/index.js +593 -0
- package/es/api/state/index.d.ts +12 -0
- package/es/api/state/types.d.ts +7 -0
- package/es/api/tokens/index.d.ts +62 -0
- package/es/api/tokens/types.d.ts +130 -0
- package/es/api/transactions/index.d.ts +35 -0
- package/es/api/transactions/types.d.ts +25 -0
- package/es/api/types.d.ts +18 -0
- package/es/client/core.d.ts +109 -0
- package/es/client/index.d.ts +21 -0
- package/es/client/index.js +373 -0
- package/es/index.d.ts +20 -0
- package/es/index.js +1490 -0
- package/es/utils/address.d.ts +15 -0
- package/es/utils/index.d.ts +6 -0
- package/es/utils/index.js +841 -0
- package/es/utils/interface.d.ts +7 -0
- package/es/utils/safePromise.d.ts +4 -0
- package/es/utils/sign.d.ts +15 -0
- package/es/utils/txHash.d.ts +2 -0
- package/es/utils/typeof.d.ts +2 -0
- package/lib/api/accounts/index.d.ts +20 -0
- package/lib/api/accounts/types.d.ts +9 -0
- package/lib/api/chain/index.d.ts +12 -0
- package/lib/api/chain/types.d.ts +3 -0
- package/lib/api/checkpoints/index.d.ts +26 -0
- package/lib/api/checkpoints/types.d.ts +33 -0
- package/lib/api/constants.d.ts +9 -0
- package/lib/api/index.d.ts +31 -0
- package/lib/api/index.js +692 -0
- package/lib/api/state/index.d.ts +12 -0
- package/lib/api/state/types.d.ts +7 -0
- package/lib/api/tokens/index.d.ts +62 -0
- package/lib/api/tokens/types.d.ts +130 -0
- package/lib/api/transactions/index.d.ts +35 -0
- package/lib/api/transactions/types.d.ts +25 -0
- package/lib/api/types.d.ts +18 -0
- package/lib/client/core.d.ts +109 -0
- package/lib/client/index.d.ts +21 -0
- package/lib/client/index.js +434 -0
- package/lib/index.d.ts +20 -0
- package/lib/index.js +1591 -0
- package/lib/utils/address.d.ts +15 -0
- package/lib/utils/index.d.ts +6 -0
- package/lib/utils/index.js +937 -0
- package/lib/utils/interface.d.ts +7 -0
- package/lib/utils/safePromise.d.ts +4 -0
- package/lib/utils/sign.d.ts +15 -0
- package/lib/utils/txHash.d.ts +2 -0
- package/lib/utils/typeof.d.ts +2 -0
- package/package.json +111 -0
- package/public/favicon.ico +0 -0
- package/public/logo.png +0 -0
- package/umd/1money-protocol-ts-sdk.min.js +2 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { AddressSchema, U256Schema } from '../types';
|
|
2
|
+
import type { Signature } from '../../utils/index.js';
|
|
3
|
+
export interface MetaDataKeyValuePair {
|
|
4
|
+
key: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}
|
|
7
|
+
export interface TokenMetadata {
|
|
8
|
+
name: string;
|
|
9
|
+
uri: string;
|
|
10
|
+
additional_metadata: MetaDataKeyValuePair[];
|
|
11
|
+
}
|
|
12
|
+
export interface MinterAllowance {
|
|
13
|
+
minter: AddressSchema;
|
|
14
|
+
allowance: U256Schema;
|
|
15
|
+
}
|
|
16
|
+
export interface MintInfo {
|
|
17
|
+
symbol: string;
|
|
18
|
+
master_authority: AddressSchema;
|
|
19
|
+
master_mint_burn_authority: AddressSchema;
|
|
20
|
+
mint_burn_authorities: MinterAllowance[];
|
|
21
|
+
pause_authorities: AddressSchema[];
|
|
22
|
+
list_authorities: AddressSchema[];
|
|
23
|
+
black_list: AddressSchema[];
|
|
24
|
+
white_list: AddressSchema[];
|
|
25
|
+
metadata_update_authorities: AddressSchema[];
|
|
26
|
+
supply: U256Schema;
|
|
27
|
+
decimals: number;
|
|
28
|
+
is_paused: boolean;
|
|
29
|
+
is_private: boolean;
|
|
30
|
+
meta: TokenMetadata;
|
|
31
|
+
}
|
|
32
|
+
export interface KeyValuePair {
|
|
33
|
+
key: string;
|
|
34
|
+
value: string;
|
|
35
|
+
}
|
|
36
|
+
export declare enum AuthorityType {
|
|
37
|
+
MasterMint = "MasterMint",
|
|
38
|
+
MintBurnTokens = "MintBurnTokens",
|
|
39
|
+
Pause = "Pause",
|
|
40
|
+
ManageList = "ManageList",
|
|
41
|
+
UpdateMetadata = "UpdateMetadata"
|
|
42
|
+
}
|
|
43
|
+
export declare enum AuthorityAction {
|
|
44
|
+
Grant = "Grant",
|
|
45
|
+
Revoke = "Revoke"
|
|
46
|
+
}
|
|
47
|
+
export declare enum ManageListAction {
|
|
48
|
+
Add = "Add",
|
|
49
|
+
Remove = "Remove"
|
|
50
|
+
}
|
|
51
|
+
export declare enum PauseAction {
|
|
52
|
+
Pause = "Pause",
|
|
53
|
+
Unpause = "Unpause"
|
|
54
|
+
}
|
|
55
|
+
export interface RestSignature extends Signature {
|
|
56
|
+
}
|
|
57
|
+
export interface TokenManageListPayload {
|
|
58
|
+
recent_epoch: number;
|
|
59
|
+
recent_checkpoint: number;
|
|
60
|
+
chain_id: number;
|
|
61
|
+
nonce: number;
|
|
62
|
+
action: ManageListAction;
|
|
63
|
+
address: string;
|
|
64
|
+
token: string;
|
|
65
|
+
signature: RestSignature;
|
|
66
|
+
}
|
|
67
|
+
export interface TokenBurnPayload {
|
|
68
|
+
recent_epoch: number;
|
|
69
|
+
recent_checkpoint: number;
|
|
70
|
+
chain_id: number;
|
|
71
|
+
nonce: number;
|
|
72
|
+
recipient: string;
|
|
73
|
+
value: string;
|
|
74
|
+
token: string;
|
|
75
|
+
signature: RestSignature;
|
|
76
|
+
}
|
|
77
|
+
export interface TokenAuthorityPayload {
|
|
78
|
+
recent_epoch: number;
|
|
79
|
+
recent_checkpoint: number;
|
|
80
|
+
chain_id: number;
|
|
81
|
+
nonce: number;
|
|
82
|
+
action: AuthorityAction;
|
|
83
|
+
authority_type: AuthorityType;
|
|
84
|
+
authority_address: string;
|
|
85
|
+
token: string;
|
|
86
|
+
value?: string;
|
|
87
|
+
signature: RestSignature;
|
|
88
|
+
}
|
|
89
|
+
export interface TokenIssuePayload {
|
|
90
|
+
recent_epoch: number;
|
|
91
|
+
recent_checkpoint: number;
|
|
92
|
+
chain_id: number;
|
|
93
|
+
nonce: number;
|
|
94
|
+
symbol: string;
|
|
95
|
+
name: string;
|
|
96
|
+
decimals: number;
|
|
97
|
+
master_authority: string;
|
|
98
|
+
is_private: boolean;
|
|
99
|
+
signature: RestSignature;
|
|
100
|
+
}
|
|
101
|
+
export interface TokenMintPayload {
|
|
102
|
+
recent_epoch: number;
|
|
103
|
+
recent_checkpoint: number;
|
|
104
|
+
chain_id: number;
|
|
105
|
+
nonce: number;
|
|
106
|
+
recipient: string;
|
|
107
|
+
value: string;
|
|
108
|
+
token: string;
|
|
109
|
+
signature: RestSignature;
|
|
110
|
+
}
|
|
111
|
+
export interface TokenPausePayload {
|
|
112
|
+
recent_epoch: number;
|
|
113
|
+
recent_checkpoint: number;
|
|
114
|
+
chain_id: number;
|
|
115
|
+
nonce: number;
|
|
116
|
+
action: PauseAction;
|
|
117
|
+
token: string;
|
|
118
|
+
signature: RestSignature;
|
|
119
|
+
}
|
|
120
|
+
export interface TokenMetadataPayload {
|
|
121
|
+
recent_epoch: number;
|
|
122
|
+
recent_checkpoint: number;
|
|
123
|
+
chain_id: number;
|
|
124
|
+
nonce: number;
|
|
125
|
+
name: string;
|
|
126
|
+
uri: string;
|
|
127
|
+
token: string;
|
|
128
|
+
additional_metadata: KeyValuePair[];
|
|
129
|
+
signature: RestSignature;
|
|
130
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Hash } from '../../api/types';
|
|
2
|
+
import type { Transaction } from '../../api/checkpoints/types';
|
|
3
|
+
import type { TransactionReceipt, EstimateFee, PaymentPayload } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Transactions API methods
|
|
6
|
+
*/
|
|
7
|
+
export declare const transactionsApi: {
|
|
8
|
+
/**
|
|
9
|
+
* Get transaction by hash
|
|
10
|
+
* @param hash Hash of the transaction to lookup
|
|
11
|
+
* @returns Promise with transaction response
|
|
12
|
+
*/
|
|
13
|
+
getByHash: (hash: string) => import("../../client/index.js").PromiseWrapper<"custom", Transaction, Transaction, Transaction, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | Transaction, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<Transaction>;
|
|
14
|
+
/**
|
|
15
|
+
* Get transaction receipt by hash
|
|
16
|
+
* @param hash Hash of the transaction to lookup receipt for
|
|
17
|
+
* @returns Promise with transaction receipt response
|
|
18
|
+
*/
|
|
19
|
+
getReceiptByHash: (hash: string) => import("../../client/index.js").PromiseWrapper<"custom", TransactionReceipt, TransactionReceipt, TransactionReceipt, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | TransactionReceipt, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<TransactionReceipt>;
|
|
20
|
+
/**
|
|
21
|
+
* Estimate transaction fee
|
|
22
|
+
* @param from Address of the transaction author
|
|
23
|
+
* @param value Value of the transaction
|
|
24
|
+
* @param token Optional token address
|
|
25
|
+
* @returns Promise with fee estimate response
|
|
26
|
+
*/
|
|
27
|
+
estimateFee: (from: string, value: string, token?: string) => import("../../client/index.js").PromiseWrapper<"custom", EstimateFee, EstimateFee, EstimateFee, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | EstimateFee, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<EstimateFee>;
|
|
28
|
+
/**
|
|
29
|
+
* Submit payment transaction
|
|
30
|
+
* @param payload Payment transaction payload
|
|
31
|
+
* @returns Promise with transaction hash response
|
|
32
|
+
*/
|
|
33
|
+
payment: (payload: PaymentPayload) => import("../../client/index.js").PromiseWrapper<"custom", Hash, Hash, Hash, import("../../client/index.js").ParsedError<string>, import("../../client/index.js").ParsedError<string> | Hash, import("../../client/index.js").ParsedError<"timeout">, ""> & Promise<Hash>;
|
|
34
|
+
};
|
|
35
|
+
export default transactionsApi;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AddressSchema, B256Schema } from '../types';
|
|
2
|
+
import { RestSignature } from '../tokens/types';
|
|
3
|
+
export interface TransactionReceipt {
|
|
4
|
+
success: boolean;
|
|
5
|
+
transaction_hash: B256Schema;
|
|
6
|
+
fee_used: number;
|
|
7
|
+
from: AddressSchema;
|
|
8
|
+
checkpoint_hash?: B256Schema;
|
|
9
|
+
checkpoint_number?: number;
|
|
10
|
+
to?: AddressSchema;
|
|
11
|
+
token_address?: AddressSchema;
|
|
12
|
+
}
|
|
13
|
+
export interface EstimateFee {
|
|
14
|
+
fee: string;
|
|
15
|
+
}
|
|
16
|
+
export interface PaymentPayload {
|
|
17
|
+
recent_epoch: number;
|
|
18
|
+
recent_checkpoint: number;
|
|
19
|
+
chain_id: number;
|
|
20
|
+
nonce: number;
|
|
21
|
+
recipient: AddressSchema;
|
|
22
|
+
value: string;
|
|
23
|
+
token: AddressSchema;
|
|
24
|
+
signature: RestSignature;
|
|
25
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface RESTErrorData {
|
|
2
|
+
error_code: string;
|
|
3
|
+
message: string;
|
|
4
|
+
}
|
|
5
|
+
export type AddressSchema = string;
|
|
6
|
+
export type PubKeySchema = string;
|
|
7
|
+
export type TokenAddressSchema = string;
|
|
8
|
+
export type SignatureSchema = string;
|
|
9
|
+
export type B256Schema = string;
|
|
10
|
+
export type U256Schema = string;
|
|
11
|
+
export type BytesSchema = string;
|
|
12
|
+
export interface Hash {
|
|
13
|
+
hash: B256Schema;
|
|
14
|
+
}
|
|
15
|
+
export interface HashWithToken {
|
|
16
|
+
hash: B256Schema;
|
|
17
|
+
token: TokenAddressSchema;
|
|
18
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { AxiosStatic, AxiosRequestConfig, RawAxiosResponseHeaders, AxiosResponseHeaders, RawAxiosRequestHeaders, AxiosRequestHeaders } from 'axios';
|
|
2
|
+
export type ParsedError<T extends string = string> = {
|
|
3
|
+
name: T;
|
|
4
|
+
message: string;
|
|
5
|
+
stack: string;
|
|
6
|
+
status: number;
|
|
7
|
+
data?: any;
|
|
8
|
+
};
|
|
9
|
+
export type ResponseData<T = null> = {
|
|
10
|
+
code: number | `${number}` | string;
|
|
11
|
+
data: T;
|
|
12
|
+
msg: null | string;
|
|
13
|
+
};
|
|
14
|
+
export type CustomResponseData<T, U, Y = T> = T extends 'custom' ? CheckAny<T> extends false ? unknown extends U ? CheckAny<U> extends false ? ResponseData<Y> : U : U : ResponseData<Y> : ResponseData<Y>;
|
|
15
|
+
export type CheckNever<T> = T extends never ? true : false;
|
|
16
|
+
export type CheckAny<T> = CheckNever<T> extends false ? false : true;
|
|
17
|
+
export type WithFailureData<T = undefined> = T extends null ? null | undefined : T | null | undefined;
|
|
18
|
+
export interface ChainName {
|
|
19
|
+
all: ChainName['success'] | ChainName['failure'] | ChainName['error'] | ChainName['login'] | ChainName['timeout'];
|
|
20
|
+
success: 'success';
|
|
21
|
+
failure: 'failure';
|
|
22
|
+
error: 'error';
|
|
23
|
+
login: 'login';
|
|
24
|
+
timeout: 'timeout';
|
|
25
|
+
withoutS: Exclude<ChainName['all'], 'success'>;
|
|
26
|
+
withoutF: Exclude<ChainName['all'], 'failure'>;
|
|
27
|
+
withoutE: Exclude<ChainName['all'], 'error'>;
|
|
28
|
+
withoutL: Exclude<ChainName['all'], 'login'>;
|
|
29
|
+
withoutT: Exclude<ChainName['all'], 'timeout'>;
|
|
30
|
+
withoutSF: Exclude<ChainName['all'], 'success' | 'failure'>;
|
|
31
|
+
withoutSE: Exclude<ChainName['all'], 'success' | 'error'>;
|
|
32
|
+
withoutSL: Exclude<ChainName['all'], 'success' | 'login'>;
|
|
33
|
+
withoutST: Exclude<ChainName['all'], 'success' | 'timeout'>;
|
|
34
|
+
withoutFE: Exclude<ChainName['all'], 'failure' | 'error'>;
|
|
35
|
+
withoutFL: Exclude<ChainName['all'], 'failure' | 'login'>;
|
|
36
|
+
withoutFT: Exclude<ChainName['all'], 'failure' | 'timeout'>;
|
|
37
|
+
withoutEL: Exclude<ChainName['all'], 'error' | 'login'>;
|
|
38
|
+
withoutET: Exclude<ChainName['all'], 'error' | 'timeout'>;
|
|
39
|
+
withoutLT: Exclude<ChainName['all'], 'login' | 'timeout'>;
|
|
40
|
+
withSF: ChainName['success'] | ChainName['failure'];
|
|
41
|
+
withSE: ChainName['success'] | ChainName['error'];
|
|
42
|
+
withSL: ChainName['success'] | ChainName['login'];
|
|
43
|
+
withST: ChainName['success'] | ChainName['timeout'];
|
|
44
|
+
withFE: ChainName['failure'] | ChainName['error'];
|
|
45
|
+
withFL: ChainName['failure'] | ChainName['login'];
|
|
46
|
+
withFT: ChainName['failure'] | ChainName['timeout'];
|
|
47
|
+
withEL: ChainName['error'] | ChainName['login'];
|
|
48
|
+
withET: ChainName['error'] | ChainName['timeout'];
|
|
49
|
+
withLT: ChainName['login'] | ChainName['timeout'];
|
|
50
|
+
}
|
|
51
|
+
export interface ChainReturn<T, U> {
|
|
52
|
+
success: CustomResponseData<T, U>;
|
|
53
|
+
failure: CustomResponseData<T, U, WithFailureData>;
|
|
54
|
+
error: ParsedError;
|
|
55
|
+
login: CustomResponseData<T, U, WithFailureData> | ParsedError;
|
|
56
|
+
timeout: ParsedError<'timeout'>;
|
|
57
|
+
successOrFailure: CustomResponseData<T, U, WithFailureData<T>>;
|
|
58
|
+
all: CustomResponseData<T, U, WithFailureData<T>> | ParsedError | ParsedError<'timeout'>;
|
|
59
|
+
}
|
|
60
|
+
export type AxiosReqHeaders = RawAxiosRequestHeaders | AxiosRequestHeaders;
|
|
61
|
+
export type AxiosResHeaders = RawAxiosResponseHeaders | AxiosResponseHeaders;
|
|
62
|
+
export interface InitConfig<T = any, U = unknown> {
|
|
63
|
+
onSuccess?: (res: ChainReturn<T, U>['success'], headers: AxiosResHeaders) => any;
|
|
64
|
+
onFailure?: (res: ChainReturn<T, U>['failure'], headers: AxiosResHeaders) => any;
|
|
65
|
+
onLogin?: (res: ChainReturn<T, U>['login'], headers: AxiosResHeaders) => any;
|
|
66
|
+
onError?: (res: ChainReturn<T, U>['error'], headers: AxiosReqHeaders | AxiosResHeaders) => any;
|
|
67
|
+
onTimeout?: (e: ChainReturn<T, U>['timeout'], headers: AxiosReqHeaders) => any;
|
|
68
|
+
isSuccess?: (res: ResponseData<WithFailureData<T>>, status: number, headers: AxiosResHeaders) => boolean;
|
|
69
|
+
isLogin?: (res: ResponseData<WithFailureData<T>>, status: number, headers: AxiosResHeaders) => boolean;
|
|
70
|
+
timeout?: number;
|
|
71
|
+
baseURL?: string;
|
|
72
|
+
}
|
|
73
|
+
export interface Options<T, U = unknown> extends InitConfig<T, U>, AxiosRequestConfig {
|
|
74
|
+
}
|
|
75
|
+
export type FactoryType = 'success' | 'failure' | 'error' | 'login';
|
|
76
|
+
export type ErrorParams = {
|
|
77
|
+
status: number;
|
|
78
|
+
netWorkError: boolean;
|
|
79
|
+
data: Record<string, any>;
|
|
80
|
+
};
|
|
81
|
+
export interface ErrorData extends Record<string, any> {
|
|
82
|
+
status: number;
|
|
83
|
+
}
|
|
84
|
+
export type ErrorRes = {
|
|
85
|
+
message: string;
|
|
86
|
+
data: ErrorData;
|
|
87
|
+
};
|
|
88
|
+
export type RestScopeName = ChainName['all'];
|
|
89
|
+
export type RestScope = Readonly<[RestScopeName, RestScopeName?, RestScopeName?, RestScopeName?, RestScopeName?]>;
|
|
90
|
+
type Tuple2Record<T extends readonly any[]> = {
|
|
91
|
+
[Value in T[number]]: Value;
|
|
92
|
+
};
|
|
93
|
+
export interface PromiseWrapper<T, U, TSuc = ChainReturn<T, U>['success'], TFail = ChainReturn<T, U>['failure'], TErr = ChainReturn<T, U>['error'], TLogin = ChainReturn<T, U>['login'], TTime = ChainReturn<T, U>['timeout'], HadCall extends string = ''> {
|
|
94
|
+
success<TRes = TSuc, Delete extends string = HadCall | 'success'>(onSuccess?: (res: ChainReturn<T, U>['success'], headers: AxiosResHeaders) => TRes): Omit<PromiseWrapper<T, U, TRes, TFail, TErr, TLogin, TTime, Delete>, ChainName['withoutS'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TRes | TFail | TErr | TLogin | TTime>;
|
|
95
|
+
failure<TRes = TFail, Delete extends string = HadCall | 'failure'>(onFailure?: (res: ChainReturn<T, U>['failure'], headers: AxiosResHeaders) => TRes): Omit<PromiseWrapper<T, U, TSuc, TRes, TErr, TLogin, TTime, Delete>, ChainName['withoutF'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TSuc | TRes | TErr | TLogin | TTime>;
|
|
96
|
+
error<TRes = TErr, Delete extends string = HadCall | 'error'>(onError?: (err: ChainReturn<T, U>['error'], headers: AxiosReqHeaders | AxiosResHeaders) => TRes): Omit<PromiseWrapper<T, U, TSuc, TFail, TRes, TLogin, TTime, Delete>, ChainName['withoutE'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TSuc | TFail | TRes | TLogin | TTime>;
|
|
97
|
+
login<TRes = TLogin, Delete extends string = HadCall | 'login'>(onLogin?: (res: ChainReturn<T, U>['login'], headers: AxiosResHeaders) => TRes): Omit<PromiseWrapper<T, U, TSuc, TFail, TErr, TRes, TTime, Delete>, ChainName['withoutL'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TSuc | TFail | TErr | TRes | TTime>;
|
|
98
|
+
timeout<TRes = TTime, Delete extends string = HadCall | 'timeout'>(onTimeout?: (err: ChainReturn<T, U>['timeout'], headers: AxiosReqHeaders) => TRes): Omit<PromiseWrapper<T, U, TSuc, TFail, TErr, TLogin, TRes, Delete>, ChainName['withoutT'] extends HadCall ? Delete | 'rest' : Delete> & Promise<TSuc | TFail | TErr | TLogin | TRes>;
|
|
99
|
+
rest<TRes = TSuc | TFail | TErr | TLogin | TTime, TRestScope extends RestScope = ['success', 'failure', 'login', 'error', 'timeout'], TRestScopeName extends RestScopeName = Exclude<keyof Tuple2Record<TRestScope>, undefined>, THadCallWithNotInScope extends string = HadCall | Exclude<RestScopeName, TRestScopeName>, Delete extends string = HadCall | TRestScopeName | 'rest'>(onRest?: (val: ChainName['all'] extends THadCallWithNotInScope ? unknown : ChainName['withoutS'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success'] : ChainName['withoutF'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure'] : ChainName['withoutE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error'] : ChainName['withoutL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['login'] : ChainName['withoutT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['timeout'] : ChainName['withoutSF'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure'] : ChainName['withoutSE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error'] : ChainName['withoutSL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'login'] : ChainName['withoutST'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'timeout'] : ChainName['withoutFE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error'] : ChainName['withoutFL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'login'] : ChainName['withoutFT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'timeout'] : ChainName['withoutEL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error' | 'login'] : ChainName['withoutET'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error' | 'timeout'] : ChainName['withoutLT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['login' | 'timeout'] : ChainName['withSF'] extends THadCallWithNotInScope ? ChainReturn<T, U>['error' | 'login' | 'timeout'] : ChainName['withSE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'login' | 'timeout'] : ChainName['withSL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error' | 'timeout'] : ChainName['withST'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error' | 'login'] : ChainName['withFE'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'login' | 'timeout'] : ChainName['withFL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error' | 'timeout'] : ChainName['withFT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error' | 'login'] : ChainName['withEL'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'timeout'] : ChainName['withET'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'login'] : ChainName['withLT'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'error'] : ChainName['success'] extends THadCallWithNotInScope ? ChainReturn<T, U>['failure' | 'error' | 'login' | 'timeout'] : ChainName['failure'] extends THadCallWithNotInScope ? ChainReturn<T, U>['success' | 'error' | 'login' | 'timeout'] : ChainName['error'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'login' | 'timeout'] : ChainName['login'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'error' | 'timeout'] : ChainName['timeout'] extends THadCallWithNotInScope ? ChainReturn<T, U>['successOrFailure' | 'error' | 'login'] : ChainReturn<T, U>['all'], headers: AxiosReqHeaders | AxiosResHeaders) => TRes, scope?: TRestScope): Omit<PromiseWrapper<T, U, TSuc, TFail, TErr, TLogin, TTime, Delete>, Delete> & Promise<ChainName['all'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TLogin | TTime : ChainName['withoutS'] extends THadCallWithNotInScope ? TRes | TFail | TErr | TLogin | TTime : ChainName['withoutF'] extends THadCallWithNotInScope ? TSuc | TRes | TErr | TLogin | TTime : ChainName['withoutE'] extends THadCallWithNotInScope ? TSuc | TFail | TRes | TLogin | TTime : ChainName['withoutL'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TRes | TTime : ChainName['withoutT'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TLogin | TRes : ChainName['withoutSF'] extends THadCallWithNotInScope ? TRes | TErr | TLogin | TTime : ChainName['withoutSE'] extends THadCallWithNotInScope ? TRes | TFail | TLogin | TTime : ChainName['withoutSL'] extends THadCallWithNotInScope ? TRes | TFail | TErr | TTime : ChainName['withoutST'] extends THadCallWithNotInScope ? TRes | TFail | TErr | TLogin : ChainName['withoutFE'] extends THadCallWithNotInScope ? TSuc | TRes | TLogin | TTime : ChainName['withoutFL'] extends THadCallWithNotInScope ? TSuc | TRes | TErr | TTime : ChainName['withoutFT'] extends THadCallWithNotInScope ? TSuc | TRes | TErr | TLogin : ChainName['withoutEL'] extends THadCallWithNotInScope ? TSuc | TFail | TRes | TTime : ChainName['withoutET'] extends THadCallWithNotInScope ? TSuc | TFail | TRes | TLogin : ChainName['withoutLT'] extends THadCallWithNotInScope ? TSuc | TFail | TErr | TRes : ChainName['withSF'] extends THadCallWithNotInScope ? TSuc | TFail | TRes : ChainName['withSE'] extends THadCallWithNotInScope ? TSuc | TErr | TRes : ChainName['withSL'] extends THadCallWithNotInScope ? TSuc | TLogin | TRes : ChainName['withST'] extends THadCallWithNotInScope ? TSuc | TTime | TRes : ChainName['withFE'] extends THadCallWithNotInScope ? TFail | TErr | TRes : ChainName['withFL'] extends THadCallWithNotInScope ? TFail | TLogin | TRes : ChainName['withFT'] extends THadCallWithNotInScope ? TFail | TTime | TRes : ChainName['withEL'] extends THadCallWithNotInScope ? TErr | TLogin | TRes : ChainName['withET'] extends THadCallWithNotInScope ? TErr | TTime | TRes : ChainName['withLT'] extends THadCallWithNotInScope ? TLogin | TTime | TRes : ChainName['success'] extends THadCallWithNotInScope ? TSuc | TRes : ChainName['failure'] extends THadCallWithNotInScope ? TFail | TRes : ChainName['error'] extends THadCallWithNotInScope ? TErr | TRes : ChainName['login'] extends THadCallWithNotInScope ? TLogin | TRes : ChainName['timeout'] extends THadCallWithNotInScope ? TTime | TRes : TRes>;
|
|
100
|
+
}
|
|
101
|
+
export declare class Request {
|
|
102
|
+
private _config;
|
|
103
|
+
axios: AxiosStatic;
|
|
104
|
+
constructor(config?: InitConfig);
|
|
105
|
+
private parseError;
|
|
106
|
+
setting(config: InitConfig): void;
|
|
107
|
+
request<T, U = unknown>(options: Options<T, U>): PromiseWrapper<T, U> & Promise<CustomResponseData<T, U, WithFailureData<T>>>;
|
|
108
|
+
}
|
|
109
|
+
export default Request;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { InitConfig, Options } from './core';
|
|
2
|
+
export declare function get<T, U = unknown>(url: string, options?: Omit<Options<T, U>, 'method' | 'url'>): import("./core").PromiseWrapper<T, U, import("./core").CustomResponseData<T, U, T>, import("./core").CustomResponseData<T, U, null | undefined>, import("./core").ParsedError<string>, import("./core").ParsedError<string> | import("./core").CustomResponseData<T, U, null | undefined>, import("./core").ParsedError<"timeout">, ""> & Promise<import("./core").CustomResponseData<T, U, import("./core").WithFailureData<T>>>;
|
|
3
|
+
export declare function post<T, U = unknown>(url: string, data: Record<string, any>, options?: Omit<Options<T, U>, 'method' | 'url' | 'data'>): import("./core").PromiseWrapper<T, U, import("./core").CustomResponseData<T, U, T>, import("./core").CustomResponseData<T, U, null | undefined>, import("./core").ParsedError<string>, import("./core").ParsedError<string> | import("./core").CustomResponseData<T, U, null | undefined>, import("./core").ParsedError<"timeout">, ""> & Promise<import("./core").CustomResponseData<T, U, import("./core").WithFailureData<T>>>;
|
|
4
|
+
export declare function postForm<T, U = unknown>(url: string, data: FormData, options?: Omit<Options<T, U>, 'method' | 'url' | 'data'>): import("./core").PromiseWrapper<T, U, import("./core").CustomResponseData<T, U, T>, import("./core").CustomResponseData<T, U, null | undefined>, import("./core").ParsedError<string>, import("./core").ParsedError<string> | import("./core").CustomResponseData<T, U, null | undefined>, import("./core").ParsedError<"timeout">, ""> & Promise<import("./core").CustomResponseData<T, U, import("./core").WithFailureData<T>>>;
|
|
5
|
+
export declare function put<T, U = unknown>(url: string, data: Record<string, any>, options?: Omit<Options<T, U>, 'method' | 'url' | 'data'>): import("./core").PromiseWrapper<T, U, import("./core").CustomResponseData<T, U, T>, import("./core").CustomResponseData<T, U, null | undefined>, import("./core").ParsedError<string>, import("./core").ParsedError<string> | import("./core").CustomResponseData<T, U, null | undefined>, import("./core").ParsedError<"timeout">, ""> & Promise<import("./core").CustomResponseData<T, U, import("./core").WithFailureData<T>>>;
|
|
6
|
+
export declare function patch<T, U = unknown>(url: string, data: Record<string, any>, options?: Omit<Options<T, U>, 'method' | 'url' | 'data'>): import("./core").PromiseWrapper<T, U, import("./core").CustomResponseData<T, U, T>, import("./core").CustomResponseData<T, U, null | undefined>, import("./core").ParsedError<string>, import("./core").ParsedError<string> | import("./core").CustomResponseData<T, U, null | undefined>, import("./core").ParsedError<"timeout">, ""> & Promise<import("./core").CustomResponseData<T, U, import("./core").WithFailureData<T>>>;
|
|
7
|
+
export declare function del<T, U = unknown>(url: string, data: Record<string, any>, options?: Omit<Options<T, U>, 'method' | 'url' | 'data'>): import("./core").PromiseWrapper<T, U, import("./core").CustomResponseData<T, U, T>, import("./core").CustomResponseData<T, U, null | undefined>, import("./core").ParsedError<string>, import("./core").ParsedError<string> | import("./core").CustomResponseData<T, U, null | undefined>, import("./core").ParsedError<"timeout">, ""> & Promise<import("./core").CustomResponseData<T, U, import("./core").WithFailureData<T>>>;
|
|
8
|
+
export declare function setInitConfig(config: InitConfig): void;
|
|
9
|
+
export type { InitConfig, Options, ParsedError, PromiseWrapper } from './core';
|
|
10
|
+
export declare const axiosStatic: import("axios").AxiosStatic;
|
|
11
|
+
declare const _default: {
|
|
12
|
+
get: typeof get;
|
|
13
|
+
post: typeof post;
|
|
14
|
+
postForm: typeof postForm;
|
|
15
|
+
del: typeof del;
|
|
16
|
+
put: typeof put;
|
|
17
|
+
patch: typeof patch;
|
|
18
|
+
setInitConfig: typeof setInitConfig;
|
|
19
|
+
axiosStatic: import("axios").AxiosStatic;
|
|
20
|
+
};
|
|
21
|
+
export default _default;
|