@opexa/portal-sdk 0.0.9 → 0.0.11
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 +147 -227
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +590 -698
- package/dist/index.mjs.map +1 -1
- package/dist/sdk/types.d.ts +5 -2
- 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 +28 -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
|
@@ -412,12 +412,14 @@ export interface GamesInput__Next {
|
|
|
412
412
|
}
|
|
413
413
|
export type GamesReturn = OperationResult<never, PaginatedQueryResult<'games', Game>>;
|
|
414
414
|
export interface GamesByNameInput {
|
|
415
|
-
|
|
415
|
+
first?: number;
|
|
416
416
|
filter?: GamesInput['filter'];
|
|
417
|
+
search: string;
|
|
417
418
|
}
|
|
418
419
|
export interface GamesByNameInput__Next {
|
|
420
|
+
first?: number;
|
|
421
|
+
filter?: GamesInput__Next['filter'];
|
|
419
422
|
search: string;
|
|
420
|
-
filter: GamesInput__Next['filter'];
|
|
421
423
|
}
|
|
422
424
|
export type GamesByNameReturn = OperationResult<never, Game[]>;
|
|
423
425
|
export type GameSession = {
|
|
@@ -568,6 +570,7 @@ export type MayaDeposit = DepositCommonProps & {
|
|
|
568
570
|
export interface MayaAppDeposit extends DepositCommonProps {
|
|
569
571
|
type: 'MAYA_APP';
|
|
570
572
|
status: DepositRecordStatus;
|
|
573
|
+
checkoutUrl?: never;
|
|
571
574
|
}
|
|
572
575
|
export type DepositType = Internal.DepositType;
|
|
573
576
|
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';
|
|
@@ -56,9 +55,11 @@ export interface MemberVerificationQuery {
|
|
|
56
55
|
};
|
|
57
56
|
}
|
|
58
57
|
export declare const MEMBER_VERIFICATION_QUERY: string;
|
|
59
|
-
export type RegisterMemberAccountError =
|
|
58
|
+
export type RegisterMemberAccountError = 'AccountNameNotAvailableError' | 'InvalidPlatformError' | 'InvalidReCAPTCHAResponseError' | 'InvalidSMSVerificationCodeError' | 'MinimumAgeRequirementError' | 'MobileNumberNotAvailableError';
|
|
60
59
|
export interface RegisterMemberAccountMutation {
|
|
61
|
-
registerMemberAccount?: null |
|
|
60
|
+
registerMemberAccount?: null | {
|
|
61
|
+
__typename: RegisterMemberAccountError;
|
|
62
|
+
};
|
|
62
63
|
}
|
|
63
64
|
export interface RegisterMemberAccountMutationVariables {
|
|
64
65
|
input: {
|
|
@@ -74,9 +75,11 @@ export interface RegisterMemberAccountMutationVariables {
|
|
|
74
75
|
reCAPTCHAResponse?: string;
|
|
75
76
|
}
|
|
76
77
|
export declare const REGISTER_MEMBER_ACCOUNT_MUTATION: string;
|
|
77
|
-
export type UpdateMemberAccountError =
|
|
78
|
+
export type UpdateMemberAccountError = 'AccountNameNotAvailableError' | 'EmailAddressNotAvailableError' | 'InvalidTransactionPasswordError' | 'MobileNumberNotAvailableError' | 'NickNameNotAvailableError' | 'RealNameAlreadySetError' | 'ValidIdAlreadySetError';
|
|
78
79
|
export interface UpdateMemberAccountMutation {
|
|
79
|
-
updateMemberAccount?: null |
|
|
80
|
+
updateMemberAccount?: null | {
|
|
81
|
+
__typename: UpdateMemberAccountError;
|
|
82
|
+
};
|
|
80
83
|
}
|
|
81
84
|
export interface UpdateMemberAccountMutationVariables {
|
|
82
85
|
input: {
|
|
@@ -97,9 +100,11 @@ export interface UpdateMemberAccountMutationVariables {
|
|
|
97
100
|
};
|
|
98
101
|
}
|
|
99
102
|
export declare const UPDATE_MEMBER_ACCOUNT_MUTATION: string;
|
|
100
|
-
export type ResetPasswordError =
|
|
103
|
+
export type ResetPasswordError = 'AccountNotFoundError' | 'InvalidVerificationCodeError';
|
|
101
104
|
export interface ResetPasswordMutation {
|
|
102
|
-
resetPassword?:
|
|
105
|
+
resetPassword?: null | {
|
|
106
|
+
__typename: ResetPasswordError;
|
|
107
|
+
};
|
|
103
108
|
}
|
|
104
109
|
export interface ResetPasswordMutationVariables {
|
|
105
110
|
input: {
|
|
@@ -118,9 +123,11 @@ export interface DeleteMemberAccountMutationVariables {
|
|
|
118
123
|
};
|
|
119
124
|
}
|
|
120
125
|
export declare const DELETE_MEMBER_ACCOUNT_MUTATION: string;
|
|
121
|
-
export type SendVerificationCodeError =
|
|
126
|
+
export type SendVerificationCodeError = 'InvalidPlatformError' | 'NotReadyToSendVerficationCodeError';
|
|
122
127
|
export interface SendVerificationCodeMutation {
|
|
123
|
-
sendVerificationCode?:
|
|
128
|
+
sendVerificationCode?: null | {
|
|
129
|
+
__typename: SendVerificationCodeError;
|
|
130
|
+
};
|
|
124
131
|
}
|
|
125
132
|
export interface SendVerificationCodeMutationVariables {
|
|
126
133
|
input: {
|
|
@@ -129,9 +136,11 @@ export interface SendVerificationCodeMutationVariables {
|
|
|
129
136
|
};
|
|
130
137
|
}
|
|
131
138
|
export declare const SEND_VERIFICATION_CODE_MUTATION: string;
|
|
132
|
-
export type VerifyMobileNumberError =
|
|
139
|
+
export type VerifyMobileNumberError = 'InvalidSMSVerificationCodeError' | 'MobileNumberAlreadyVerifiedError';
|
|
133
140
|
export interface VerifyMobileNumberMutation {
|
|
134
|
-
verifyMobileNumber?:
|
|
141
|
+
verifyMobileNumber?: null | {
|
|
142
|
+
__typename: VerifyMobileNumberError;
|
|
143
|
+
};
|
|
135
144
|
}
|
|
136
145
|
export interface VerifyMobileNumberMutationVariables {
|
|
137
146
|
input: {
|
|
@@ -139,9 +148,11 @@ export interface VerifyMobileNumberMutationVariables {
|
|
|
139
148
|
};
|
|
140
149
|
}
|
|
141
150
|
export declare const VERIFY_MOBILE_NUMBER_MUTATION: string;
|
|
142
|
-
export type CreateMemberVerificationError =
|
|
151
|
+
export type CreateMemberVerificationError = 'FileDoesNotExistError' | 'FileNotReadyError' | 'MemberVerificationAlreadyExistsError';
|
|
143
152
|
export interface CreateMemberVerificationMutation {
|
|
144
|
-
createMemberVerification?:
|
|
153
|
+
createMemberVerification?: null | {
|
|
154
|
+
__typename: CreateMemberVerificationError;
|
|
155
|
+
};
|
|
145
156
|
}
|
|
146
157
|
export interface CreateMemberVerificationMutationVariables {
|
|
147
158
|
input: {
|
|
@@ -156,9 +167,11 @@ export interface CreateMemberVerificationMutationVariables {
|
|
|
156
167
|
};
|
|
157
168
|
}
|
|
158
169
|
export declare const CREATE_MEMBER_VERIFICATION_MUTATION: string;
|
|
159
|
-
export type UpdateMemberVerificationError =
|
|
170
|
+
export type UpdateMemberVerificationError = 'FileDoesNotExistError' | 'FileNotReadyError' | 'MemberVerificationAlreadyApprovedError' | 'MemberVerificationDoesNotExistError';
|
|
160
171
|
export interface UpdateMemberVerificationMutation {
|
|
161
|
-
updateMemberVerification?:
|
|
172
|
+
updateMemberVerification?: null | {
|
|
173
|
+
__typename: UpdateMemberVerificationError;
|
|
174
|
+
};
|
|
162
175
|
}
|
|
163
176
|
export interface UpdateMemberVerificationMutationVariables {
|
|
164
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 {};
|