@opexa/portal-sdk 0.0.8 → 0.0.10
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/dist/index.js +148 -227
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +592 -698
- package/dist/index.mjs.map +1 -1
- package/dist/sdk/types.d.ts +2 -0
- package/dist/services/auth.service.d.ts +2 -1
- package/dist/services/bonus.d.ts +4 -3
- package/dist/services/deposit.d.ts +10 -5
- package/dist/services/file.d.ts +4 -3
- package/dist/services/game.d.ts +4 -3
- package/dist/services/member.d.ts +29 -15
- package/dist/services/points.d.ts +4 -3
- package/dist/services/session.d.ts +3 -4
- package/dist/services/utils.d.ts +13 -0
- package/dist/services/withdrawal.d.ts +13 -6
- package/dist/utils/graphql-client.d.ts +0 -1
- package/dist/utils/status-code-to-operation-error.d.ts +3 -0
- package/dist/utils/types.d.ts +7 -7
- package/package.json +1 -1
- package/dist/utils/rest-client.d.ts +0 -34
- package/dist/utils/status-code-to-error.d.ts +0 -3
package/dist/sdk/types.d.ts
CHANGED
|
@@ -107,6 +107,7 @@ export interface Account {
|
|
|
107
107
|
mobileNumberVerified: boolean;
|
|
108
108
|
mobileNumberVerificationRequired: boolean;
|
|
109
109
|
transactionPassword: boolean;
|
|
110
|
+
secretAnswerSubmitted: boolean;
|
|
110
111
|
dateTimeLastActive?: Date;
|
|
111
112
|
dateTimeCreated: Date;
|
|
112
113
|
dateTimeLastUpdated: Date;
|
|
@@ -567,6 +568,7 @@ export type MayaDeposit = DepositCommonProps & {
|
|
|
567
568
|
export interface MayaAppDeposit extends DepositCommonProps {
|
|
568
569
|
type: 'MAYA_APP';
|
|
569
570
|
status: DepositRecordStatus;
|
|
571
|
+
checkoutUrl?: never;
|
|
570
572
|
}
|
|
571
573
|
export type DepositType = Internal.DepositType;
|
|
572
574
|
export type Deposit = MayaDeposit | GCashDeposit | MayaAppDeposit;
|
|
@@ -6,7 +6,8 @@ export interface AuthServiceConfig {
|
|
|
6
6
|
platform: string;
|
|
7
7
|
}
|
|
8
8
|
export declare class AuthService {
|
|
9
|
-
private
|
|
9
|
+
private url;
|
|
10
|
+
private platform;
|
|
10
11
|
constructor(config: AuthServiceConfig);
|
|
11
12
|
createSession(input: CreateSessionInput__Maya): Promise<OperationResult<CreateSessionError, CreateSessionMutation__Maya>>;
|
|
12
13
|
createSession(input: CreateSessionInput__MobileNumber): Promise<OperationResult<CreateSessionError, CreateSessionMutation__MobileNumber>>;
|
package/dist/services/bonus.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { DepositRecord } from '..';
|
|
2
|
-
import { OperationError } from '../utils/types';
|
|
3
2
|
import { Cashback } from './cashback';
|
|
4
3
|
import { Promo } from './promo';
|
|
5
4
|
import { DateString, Decimal } from './types';
|
|
@@ -32,9 +31,11 @@ export interface CashbackBonusesQuery {
|
|
|
32
31
|
cashbackBonuses: CashbackBonus[];
|
|
33
32
|
}
|
|
34
33
|
export declare const CASHBACK_BONUSES_QUERY: string;
|
|
35
|
-
export type ClaimCashbackBonusError =
|
|
34
|
+
export type ClaimCashbackBonusError = 'CashbackBonusDoesNotExistError';
|
|
36
35
|
export interface ClaimCashbackBonusMutation {
|
|
37
|
-
claimCashbackBonus?: null |
|
|
36
|
+
claimCashbackBonus?: null | {
|
|
37
|
+
__typename: ClaimCashbackBonusError;
|
|
38
|
+
};
|
|
38
39
|
}
|
|
39
40
|
export interface ClaimCashbackBonusMutationVariables {
|
|
40
41
|
input: {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { OperationError } from '../utils/types';
|
|
2
1
|
import { DateFilterField, DateString, Decimal, EnumFilterField, PaginatedQuery, StringFilterField } from './types';
|
|
3
2
|
|
|
4
3
|
export type DepositRecordType = 'BANK' | 'GCASH' | 'MANUAL' | 'MAYA' | 'MAYA_APP';
|
|
@@ -31,9 +30,11 @@ export interface DepositRecordsQueryVariables {
|
|
|
31
30
|
};
|
|
32
31
|
}
|
|
33
32
|
export declare const DEPOSIT_RECORDS_QUERY: string;
|
|
34
|
-
export type CreateDepositError =
|
|
33
|
+
export type CreateDepositError = 'DepositPromoMaximumAmountExceededError' | 'DepositPromoMinimumAmountNotMetError' | 'HasActiveBonusError' | 'MaximumDepositAmountExceededError' | 'MinimumDepositAmountNotMetError' | 'MinimumFirstDepositAmountNotMetError' | 'PromoNotEnabledError' | 'WalletDoesNotExistError';
|
|
35
34
|
export interface CreateGCashDepositMutation {
|
|
36
|
-
createGCashDeposit?:
|
|
35
|
+
createGCashDeposit?: null | {
|
|
36
|
+
__typename: CreateDepositError;
|
|
37
|
+
};
|
|
37
38
|
}
|
|
38
39
|
export interface CreateGCashDepositMutationVariables {
|
|
39
40
|
input: {
|
|
@@ -44,7 +45,9 @@ export interface CreateGCashDepositMutationVariables {
|
|
|
44
45
|
}
|
|
45
46
|
export declare const CREATE_GCASH_DEPOSIT_MUTATION: string;
|
|
46
47
|
export interface CreateMayaDepositMutation {
|
|
47
|
-
createMayaDeposit?:
|
|
48
|
+
createMayaDeposit?: null | {
|
|
49
|
+
__typename: CreateDepositError;
|
|
50
|
+
};
|
|
48
51
|
}
|
|
49
52
|
export interface CreateMayaDepositMutationVariables {
|
|
50
53
|
input: {
|
|
@@ -55,7 +58,9 @@ export interface CreateMayaDepositMutationVariables {
|
|
|
55
58
|
}
|
|
56
59
|
export declare const CREATE_MAYA_DEPOSIT_MUTATION: string;
|
|
57
60
|
export interface CreateMayaAppDepositMutation {
|
|
58
|
-
createMayaAppDeposit?:
|
|
61
|
+
createMayaAppDeposit?: null | {
|
|
62
|
+
__typename: CreateDepositError;
|
|
63
|
+
};
|
|
59
64
|
}
|
|
60
65
|
export interface CreateMayaAppDepositMutationVariables {
|
|
61
66
|
input: {
|
package/dist/services/file.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { OperationError } from '../utils/types';
|
|
2
1
|
import { DateString } from './types';
|
|
3
2
|
|
|
4
3
|
export type FileStatus = 'UPLOADING' | 'READY' | 'FAILED' | 'DELETED';
|
|
@@ -35,9 +34,11 @@ export interface FileQueryVariables {
|
|
|
35
34
|
}
|
|
36
35
|
export declare const FILE_FRAGMENT: string;
|
|
37
36
|
export declare const FILE_QUERY: string;
|
|
38
|
-
export type UploadPrivateImageFileError =
|
|
37
|
+
export type UploadPrivateImageFileError = 'FileFormatNotSupportedError' | 'FileNameTooLongError' | 'FileSizeTooBigError';
|
|
39
38
|
export interface UploadPrivateImageFileMutation {
|
|
40
|
-
uploadPrivateImageFile?:
|
|
39
|
+
uploadPrivateImageFile?: null | {
|
|
40
|
+
__typename: UploadPrivateImageFileError;
|
|
41
|
+
};
|
|
41
42
|
}
|
|
42
43
|
export interface UploadPrivateImageFileMutationVariables {
|
|
43
44
|
input: {
|
package/dist/services/game.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { OperationError } from '../utils/types';
|
|
2
1
|
import { DateString, EnumFilterField, ObjectIdFilterField, PaginatedQuery, StringFilterField } from './types';
|
|
3
2
|
|
|
4
3
|
export type GameType = 'SLOTS' | 'SPORTS' | 'BINGO' | 'FISHING' | 'LIVE' | 'GAMES';
|
|
@@ -75,9 +74,11 @@ export interface GameSessionQueryVariables {
|
|
|
75
74
|
id: string;
|
|
76
75
|
}
|
|
77
76
|
export declare const GAME_SESSION_QUERY: string;
|
|
78
|
-
export type CreateGameSessionError =
|
|
77
|
+
export type CreateGameSessionError = 'GameDoesNotExistError';
|
|
79
78
|
export interface CreateGameSessionMutation {
|
|
80
|
-
createGameSession?: null |
|
|
79
|
+
createGameSession?: null | {
|
|
80
|
+
__typename: CreateGameSessionError;
|
|
81
|
+
};
|
|
81
82
|
}
|
|
82
83
|
export interface CreateGameSessionMutationVariables {
|
|
83
84
|
input: {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { OperationError } from '../utils/types';
|
|
2
1
|
import { File } from './file';
|
|
3
2
|
import { SecretQuestion } from './session';
|
|
4
3
|
import { DateString, Decimal } from './types';
|
|
@@ -28,6 +27,7 @@ export interface MemberAccount {
|
|
|
28
27
|
mobileNumberVerified?: boolean | null;
|
|
29
28
|
mobileNumberVerificationRequired?: boolean | null;
|
|
30
29
|
transactionPassword: boolean;
|
|
30
|
+
secretAnswerSubmitted?: boolean | null;
|
|
31
31
|
dateTimeCreated: DateString;
|
|
32
32
|
dateTimeLastUpdated: DateString;
|
|
33
33
|
}
|
|
@@ -55,9 +55,11 @@ export interface MemberVerificationQuery {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
export declare const MEMBER_VERIFICATION_QUERY: string;
|
|
58
|
-
export type RegisterMemberAccountError =
|
|
58
|
+
export type RegisterMemberAccountError = 'AccountNameNotAvailableError' | 'InvalidPlatformError' | 'InvalidReCAPTCHAResponseError' | 'InvalidSMSVerificationCodeError' | 'MinimumAgeRequirementError' | 'MobileNumberNotAvailableError';
|
|
59
59
|
export interface RegisterMemberAccountMutation {
|
|
60
|
-
registerMemberAccount?: null |
|
|
60
|
+
registerMemberAccount?: null | {
|
|
61
|
+
__typename: RegisterMemberAccountError;
|
|
62
|
+
};
|
|
61
63
|
}
|
|
62
64
|
export interface RegisterMemberAccountMutationVariables {
|
|
63
65
|
input: {
|
|
@@ -73,9 +75,11 @@ export interface RegisterMemberAccountMutationVariables {
|
|
|
73
75
|
reCAPTCHAResponse?: string;
|
|
74
76
|
}
|
|
75
77
|
export declare const REGISTER_MEMBER_ACCOUNT_MUTATION: string;
|
|
76
|
-
export type UpdateMemberAccountError =
|
|
78
|
+
export type UpdateMemberAccountError = 'AccountNameNotAvailableError' | 'EmailAddressNotAvailableError' | 'InvalidTransactionPasswordError' | 'MobileNumberNotAvailableError' | 'NickNameNotAvailableError' | 'RealNameAlreadySetError' | 'ValidIdAlreadySetError';
|
|
77
79
|
export interface UpdateMemberAccountMutation {
|
|
78
|
-
updateMemberAccount?: null |
|
|
80
|
+
updateMemberAccount?: null | {
|
|
81
|
+
__typename: UpdateMemberAccountError;
|
|
82
|
+
};
|
|
79
83
|
}
|
|
80
84
|
export interface UpdateMemberAccountMutationVariables {
|
|
81
85
|
input: {
|
|
@@ -96,9 +100,11 @@ export interface UpdateMemberAccountMutationVariables {
|
|
|
96
100
|
};
|
|
97
101
|
}
|
|
98
102
|
export declare const UPDATE_MEMBER_ACCOUNT_MUTATION: string;
|
|
99
|
-
export type ResetPasswordError =
|
|
103
|
+
export type ResetPasswordError = 'AccountNotFoundError' | 'InvalidVerificationCodeError';
|
|
100
104
|
export interface ResetPasswordMutation {
|
|
101
|
-
resetPassword?:
|
|
105
|
+
resetPassword?: null | {
|
|
106
|
+
__typename: ResetPasswordError;
|
|
107
|
+
};
|
|
102
108
|
}
|
|
103
109
|
export interface ResetPasswordMutationVariables {
|
|
104
110
|
input: {
|
|
@@ -117,9 +123,11 @@ export interface DeleteMemberAccountMutationVariables {
|
|
|
117
123
|
};
|
|
118
124
|
}
|
|
119
125
|
export declare const DELETE_MEMBER_ACCOUNT_MUTATION: string;
|
|
120
|
-
export type SendVerificationCodeError =
|
|
126
|
+
export type SendVerificationCodeError = 'InvalidPlatformError' | 'NotReadyToSendVerficationCodeError';
|
|
121
127
|
export interface SendVerificationCodeMutation {
|
|
122
|
-
sendVerificationCode?:
|
|
128
|
+
sendVerificationCode?: null | {
|
|
129
|
+
__typename: SendVerificationCodeError;
|
|
130
|
+
};
|
|
123
131
|
}
|
|
124
132
|
export interface SendVerificationCodeMutationVariables {
|
|
125
133
|
input: {
|
|
@@ -128,9 +136,11 @@ export interface SendVerificationCodeMutationVariables {
|
|
|
128
136
|
};
|
|
129
137
|
}
|
|
130
138
|
export declare const SEND_VERIFICATION_CODE_MUTATION: string;
|
|
131
|
-
export type VerifyMobileNumberError =
|
|
139
|
+
export type VerifyMobileNumberError = 'InvalidSMSVerificationCodeError' | 'MobileNumberAlreadyVerifiedError';
|
|
132
140
|
export interface VerifyMobileNumberMutation {
|
|
133
|
-
verifyMobileNumber?:
|
|
141
|
+
verifyMobileNumber?: null | {
|
|
142
|
+
__typename: VerifyMobileNumberError;
|
|
143
|
+
};
|
|
134
144
|
}
|
|
135
145
|
export interface VerifyMobileNumberMutationVariables {
|
|
136
146
|
input: {
|
|
@@ -138,9 +148,11 @@ export interface VerifyMobileNumberMutationVariables {
|
|
|
138
148
|
};
|
|
139
149
|
}
|
|
140
150
|
export declare const VERIFY_MOBILE_NUMBER_MUTATION: string;
|
|
141
|
-
export type CreateMemberVerificationError =
|
|
151
|
+
export type CreateMemberVerificationError = 'FileDoesNotExistError' | 'FileNotReadyError' | 'MemberVerificationAlreadyExistsError';
|
|
142
152
|
export interface CreateMemberVerificationMutation {
|
|
143
|
-
createMemberVerification?:
|
|
153
|
+
createMemberVerification?: null | {
|
|
154
|
+
__typename: CreateMemberVerificationError;
|
|
155
|
+
};
|
|
144
156
|
}
|
|
145
157
|
export interface CreateMemberVerificationMutationVariables {
|
|
146
158
|
input: {
|
|
@@ -155,9 +167,11 @@ export interface CreateMemberVerificationMutationVariables {
|
|
|
155
167
|
};
|
|
156
168
|
}
|
|
157
169
|
export declare const CREATE_MEMBER_VERIFICATION_MUTATION: string;
|
|
158
|
-
export type UpdateMemberVerificationError =
|
|
170
|
+
export type UpdateMemberVerificationError = 'FileDoesNotExistError' | 'FileNotReadyError' | 'MemberVerificationAlreadyApprovedError' | 'MemberVerificationDoesNotExistError';
|
|
159
171
|
export interface UpdateMemberVerificationMutation {
|
|
160
|
-
updateMemberVerification?:
|
|
172
|
+
updateMemberVerification?: null | {
|
|
173
|
+
__typename: UpdateMemberVerificationError;
|
|
174
|
+
};
|
|
161
175
|
}
|
|
162
176
|
export interface UpdateMemberVerificationMutationVariables {
|
|
163
177
|
input: {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { OperationError } from '../utils/types';
|
|
2
1
|
import { DateString, Decimal } from './types';
|
|
3
2
|
|
|
4
3
|
export interface PointsWallet {
|
|
@@ -17,7 +16,9 @@ export interface PointsToCashConversionMutationVariables {
|
|
|
17
16
|
amount: Decimal;
|
|
18
17
|
};
|
|
19
18
|
}
|
|
20
|
-
export type PointsToCashConversionError =
|
|
19
|
+
export type PointsToCashConversionError = 'InsufficientPointsError';
|
|
21
20
|
export interface PointsToCashConversionMutation {
|
|
22
|
-
pointsToCashConversion?:
|
|
21
|
+
pointsToCashConversion?: null | {
|
|
22
|
+
__typename: PointsToCashConversionError;
|
|
23
|
+
};
|
|
23
24
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { OperationError } from '../utils/types';
|
|
2
1
|
import { DateString } from './types';
|
|
3
2
|
|
|
4
3
|
export interface Session {
|
|
@@ -49,8 +48,8 @@ export interface CreateSessionMutation__Maya {
|
|
|
49
48
|
refreshToken: string;
|
|
50
49
|
}
|
|
51
50
|
export type CreateSessionMutation = CreateSessionMutation__NameAndPassword | CreateSessionMutation__MobileNumber | CreateSessionMutation__Maya;
|
|
52
|
-
export type CreateSessionError =
|
|
53
|
-
export type RefreshSessionError =
|
|
51
|
+
export type CreateSessionError = 'AccountNotFound' | 'AccountBlacklisted';
|
|
52
|
+
export type RefreshSessionError = 'InvalidToken' | 'AccountBlacklisted' | 'SessionExpired';
|
|
54
53
|
export interface RefreshSessionMutation {
|
|
55
54
|
accessToken: string;
|
|
56
55
|
refreshToken: string;
|
|
@@ -61,7 +60,7 @@ export interface AuthenticateInput__SecurityQuestion {
|
|
|
61
60
|
secretAnswer: string;
|
|
62
61
|
}
|
|
63
62
|
export type AuthenticateInput = AuthenticateInput__SecurityQuestion;
|
|
64
|
-
export type AuthenticateError =
|
|
63
|
+
export type AuthenticateError = 'InvalidTokenOrSecretAnswer';
|
|
65
64
|
export interface AuthenticateMutation {
|
|
66
65
|
session: Session;
|
|
67
66
|
accessToken: string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OperationError } from '../utils/types';
|
|
2
|
+
import { ClaimCashbackBonusError } from './bonus';
|
|
3
|
+
import { CreateDepositError } from './deposit';
|
|
4
|
+
import { UploadPrivateImageFileError } from './file';
|
|
5
|
+
import { CreateGameSessionError } from './game';
|
|
6
|
+
import { CreateMemberVerificationError, RegisterMemberAccountError, ResetPasswordError, SendVerificationCodeError, UpdateMemberAccountError, UpdateMemberVerificationError, VerifyMobileNumberError } from './member';
|
|
7
|
+
import { PointsToCashConversionError } from './points';
|
|
8
|
+
import { AuthenticateError, CreateSessionError, RefreshSessionError } from './session';
|
|
9
|
+
import { CreateWithdrawalError } from './withdrawal';
|
|
10
|
+
|
|
11
|
+
type E = ClaimCashbackBonusError | CreateDepositError | UploadPrivateImageFileError | CreateGameSessionError | RegisterMemberAccountError | UpdateMemberAccountError | ResetPasswordError | SendVerificationCodeError | VerifyMobileNumberError | CreateMemberVerificationError | UpdateMemberVerificationError | PointsToCashConversionError | CreateWithdrawalError | CreateSessionError | RefreshSessionError | AuthenticateError;
|
|
12
|
+
export declare function createOperationError<T extends E>(code: T): OperationError<T>;
|
|
13
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { OperationError } from '../utils/types';
|
|
2
1
|
import { DateFilterField, DateString, Decimal, EnumFilterField, PaginatedQuery, StringFilterField } from './types';
|
|
3
2
|
|
|
4
3
|
export type Bank = 'AUBKPHMM' | 'MBTCPHMM' | 'BNORPHMM' | 'MKRUPHM1';
|
|
@@ -53,9 +52,11 @@ export interface WithdrawalRecordsQueryVariables {
|
|
|
53
52
|
};
|
|
54
53
|
}
|
|
55
54
|
export declare const WITHDRAWAL_RECORDS_QUERY: string;
|
|
56
|
-
export type CreateWithdrawalError =
|
|
55
|
+
export type CreateWithdrawalError = 'AccountNotVerifiedError' | 'InvalidTransactionPasswordError' | 'InvalidWithdrawalAmountError' | 'MobileNumberNotVerifiedError' | 'NotEnoughBalanceError' | 'WithdrawalDailyLimitExceededError';
|
|
57
56
|
export interface CreateGCashWithdrawalMutation {
|
|
58
|
-
createGCashWithdrawal?:
|
|
57
|
+
createGCashWithdrawal?: null | {
|
|
58
|
+
__typename: CreateWithdrawalError;
|
|
59
|
+
};
|
|
59
60
|
}
|
|
60
61
|
export interface CreateGCashWithdrawalMutationVariables {
|
|
61
62
|
input: {
|
|
@@ -67,7 +68,9 @@ export interface CreateGCashWithdrawalMutationVariables {
|
|
|
67
68
|
}
|
|
68
69
|
export declare const CREATE_GCASH_WITHDRAWAL_MUTATION: string;
|
|
69
70
|
export interface CreateMayaWithdrawalMutation {
|
|
70
|
-
createMayaWithdrawal?:
|
|
71
|
+
createMayaWithdrawal?: null | {
|
|
72
|
+
__typename: CreateWithdrawalError;
|
|
73
|
+
};
|
|
71
74
|
}
|
|
72
75
|
export interface CreateMayaWithdrawalMutationVariables {
|
|
73
76
|
input: {
|
|
@@ -79,7 +82,9 @@ export interface CreateMayaWithdrawalMutationVariables {
|
|
|
79
82
|
}
|
|
80
83
|
export declare const CREATE_MAYA_WITHDRAWAL_MUTATION: string;
|
|
81
84
|
export interface CreateMayaAppWithdrawalMutation {
|
|
82
|
-
createMayaAppWithdrawal?:
|
|
85
|
+
createMayaAppWithdrawal?: null | {
|
|
86
|
+
__typename: CreateWithdrawalError;
|
|
87
|
+
};
|
|
83
88
|
}
|
|
84
89
|
export interface CreateMayaAppWithdrawalMutationVariables {
|
|
85
90
|
input: {
|
|
@@ -90,7 +95,9 @@ export interface CreateMayaAppWithdrawalMutationVariables {
|
|
|
90
95
|
}
|
|
91
96
|
export declare const CREATE_MAYA_APP_WITHDRAWAL_MUTATION: string;
|
|
92
97
|
export interface CreateBankWithdrawalMutation {
|
|
93
|
-
createBankWithdrawal?:
|
|
98
|
+
createBankWithdrawal?: null | {
|
|
99
|
+
__typename: CreateWithdrawalError;
|
|
100
|
+
};
|
|
94
101
|
}
|
|
95
102
|
export interface CreateBankWithdrawalMutationVariables {
|
|
96
103
|
input: {
|
|
@@ -7,7 +7,6 @@ export interface GraphQLClientConfig {
|
|
|
7
7
|
middlewares?: GraphQLClientMiddleware[];
|
|
8
8
|
fetchOptions?: GraphQLClientFetchOptions;
|
|
9
9
|
}
|
|
10
|
-
export type GraphQLClientResponse<Data> = OperationResult<never, Data>;
|
|
11
10
|
export declare class GraphQLClient {
|
|
12
11
|
private url;
|
|
13
12
|
private options;
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -4,10 +4,14 @@ export type Alias<T> = T & {
|
|
|
4
4
|
};
|
|
5
5
|
export type Maybe<T> = T | null | undefined;
|
|
6
6
|
export type HttpError = /* 400 */ 'HttpBadRequest' | /* 401 */ 'HttpUnauthorized' | /* 403 */ 'HttpForbidden' | /* 404 */ 'HttpNotFound' | /* 408 */ 'HttpRequestTimeout' | /* 429 */ 'HttpTooManyRequests' | /* 500 */ 'HttpInternalServerError';
|
|
7
|
-
export type
|
|
7
|
+
export type OperationError<T extends string = string> = {
|
|
8
|
+
name: T;
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
export type OperationResult<Error extends string = string, Data = never> = [Data] extends [never] ? {
|
|
8
12
|
ok: false;
|
|
9
13
|
data?: never;
|
|
10
|
-
error: Error | OperationError<HttpError | 'UnknownError'>;
|
|
14
|
+
error: OperationError<Error> | OperationError<HttpError | 'UnknownError'>;
|
|
11
15
|
} | {
|
|
12
16
|
ok: true;
|
|
13
17
|
data?: never;
|
|
@@ -15,13 +19,9 @@ export type OperationResult<Error = OperationError<string>, Data = never> = [Dat
|
|
|
15
19
|
} : {
|
|
16
20
|
ok: false;
|
|
17
21
|
data?: never;
|
|
18
|
-
error: Error | OperationError<HttpError | 'UnknownError'>;
|
|
22
|
+
error: OperationError<Error> | OperationError<HttpError | 'UnknownError'>;
|
|
19
23
|
} | {
|
|
20
24
|
ok: true;
|
|
21
25
|
data: Data;
|
|
22
26
|
error?: never;
|
|
23
27
|
};
|
|
24
|
-
export type OperationError<T extends string = string> = {
|
|
25
|
-
code: T;
|
|
26
|
-
message: string;
|
|
27
|
-
};
|
package/package.json
CHANGED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { OperationResult } from './types';
|
|
2
|
-
|
|
3
|
-
export type RestClientMiddleware = (req: Request) => Request | Promise<Request>;
|
|
4
|
-
export interface RestClientFetchOptions extends Omit<RequestInit, 'body' | 'method'> {
|
|
5
|
-
}
|
|
6
|
-
export interface RestClientConfig {
|
|
7
|
-
middlewares?: RestClientMiddleware[];
|
|
8
|
-
fetchOptions?: RestClientFetchOptions;
|
|
9
|
-
}
|
|
10
|
-
interface PostOptions {
|
|
11
|
-
body?: Record<string, unknown>;
|
|
12
|
-
headers?: HeadersInit;
|
|
13
|
-
searchParams?: URLSearchParams;
|
|
14
|
-
}
|
|
15
|
-
interface GetOptions {
|
|
16
|
-
headers?: HeadersInit;
|
|
17
|
-
searchParams?: URLSearchParams;
|
|
18
|
-
}
|
|
19
|
-
interface DeleteOptions {
|
|
20
|
-
headers?: HeadersInit;
|
|
21
|
-
searchParams?: URLSearchParams;
|
|
22
|
-
}
|
|
23
|
-
export declare class RestClient {
|
|
24
|
-
private url;
|
|
25
|
-
private options;
|
|
26
|
-
private middlewares;
|
|
27
|
-
constructor(url: string, config?: RestClientConfig);
|
|
28
|
-
post<Data = unknown, Error = never>(path: string, options?: PostOptions): Promise<OperationResult<Error, Data>>;
|
|
29
|
-
get<Data = unknown, Error = never>(path: string, options?: GetOptions): Promise<OperationResult<Error, Data>>;
|
|
30
|
-
delete<Error = never>(path: string, options?: DeleteOptions): Promise<OperationResult<Error>>;
|
|
31
|
-
private runMiddlewares;
|
|
32
|
-
private safeToJson;
|
|
33
|
-
}
|
|
34
|
-
export {};
|