@salla.sa/twilight 2.0.211 → 2.0.212
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/@salla.sa/twilight.min.js +2 -2
- package/dist/@salla.sa/twilight.min.js.map +1 -1
- package/dist/cjs/main.js +2 -2
- package/dist/cjs/main.js.map +1 -1
- package/dist/esm/main.js +2 -2
- package/dist/esm/main.js.map +1 -1
- package/package.json +1 -1
- package/types/api/auth.d.ts +68 -0
- package/types/api/cart.d.ts +2 -5
- package/types/common.d.ts +19 -0
- package/types/event/auth.d.ts +18 -0
- package/types/index.d.ts +4 -2
- package/types/tiwlight-config.d.ts +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {Nullable, TwilightResponse} from "../common";
|
|
2
|
+
|
|
3
|
+
export interface LogoutResponse extends TwilightResponse {
|
|
4
|
+
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface LoginResponse extends TwilightResponse {
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface VerifyResponse extends TwilightResponse {
|
|
12
|
+
case: 'authenticated' | 'new_customer',
|
|
13
|
+
redirect_url: Nullable<null>,
|
|
14
|
+
token: Nullable<string>,
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ResendResponse extends TwilightResponse {
|
|
18
|
+
data: {
|
|
19
|
+
resend_counter: 2 | 3 | 4,
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface LoginByMobilePayload {
|
|
24
|
+
phone: string;
|
|
25
|
+
type: 'mobile';
|
|
26
|
+
country_code: string | 'SA';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface LoginByEmailPayload {
|
|
30
|
+
email: string;
|
|
31
|
+
type: 'email';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface VerifyByEmailPayload {
|
|
35
|
+
code: string;
|
|
36
|
+
email: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface VerifyByMobilePayload {
|
|
40
|
+
code: string;
|
|
41
|
+
email: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface RegisterPayload {
|
|
45
|
+
first_name: string;
|
|
46
|
+
last_name: string;
|
|
47
|
+
phone: string;
|
|
48
|
+
country_code: string | 'SA';
|
|
49
|
+
country_key: string | '+966';
|
|
50
|
+
verified_by: 'email' | 'phone';
|
|
51
|
+
email: Nullable<string>;
|
|
52
|
+
code: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ResendPayload {
|
|
56
|
+
resend_by: 'sms' | 'email',
|
|
57
|
+
phone: string,
|
|
58
|
+
country_code: string | "SA",
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default interface AuthApi {
|
|
62
|
+
login: (data: LoginByMobilePayload | LoginByEmailPayload) => Promise<LoginResponse>;
|
|
63
|
+
logout: () => Promise<LogoutResponse>;
|
|
64
|
+
verify: (type: 'mobile' | 'email', data: VerifyByMobilePayload | VerifyByEmailPayload) => Promise<VerifyResponse>;
|
|
65
|
+
resend: (data: ResendPayload) => Promise<ResendResponse>,
|
|
66
|
+
register: (data: RegisterPayload) => Promise<VerifyResponse>,
|
|
67
|
+
refresh: () => Promise<VerifyResponse>,
|
|
68
|
+
}
|
package/types/api/cart.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// import {CartDetailsResponse} from "./cart/cart-details-response";
|
|
2
|
-
import {Nullable} from "../common";
|
|
2
|
+
import {Nullable, TwilightResponse} from "../common";
|
|
3
3
|
|
|
4
4
|
export interface itemOffer {
|
|
5
5
|
discount: number,
|
|
@@ -48,11 +48,8 @@ export interface CartUpdatedData {
|
|
|
48
48
|
cart: CartSummary
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
export interface CartUpdateResponse {
|
|
51
|
+
export interface CartUpdateResponse extends TwilightResponse {
|
|
52
52
|
data: CartUpdatedData,
|
|
53
|
-
status: 200,
|
|
54
|
-
success: boolean,
|
|
55
|
-
message: string,
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
export interface AddToCartResponse extends CartUpdateResponse {
|
package/types/common.d.ts
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
|
+
import {CartUpdatedData} from "./api/cart";
|
|
2
|
+
|
|
1
3
|
export interface Price {
|
|
2
4
|
amount: string;
|
|
3
5
|
currency: string;
|
|
4
6
|
}
|
|
5
7
|
|
|
8
|
+
export interface TwilightResponse {
|
|
9
|
+
data: Nullable<any>,
|
|
10
|
+
status: 200 | 422 | 404,
|
|
11
|
+
success: boolean,
|
|
12
|
+
message: string,
|
|
13
|
+
events: Nullable<string>
|
|
14
|
+
error: Nullable<{
|
|
15
|
+
message: Nullable<string | 'alert.invalid_fields'>,
|
|
16
|
+
code: Nullable<any>
|
|
17
|
+
case: Nullable<string|'resend_counter'|'invalid_code'>
|
|
18
|
+
events:Nullable<string>
|
|
19
|
+
fields: Nullable<{
|
|
20
|
+
[key: string]: Array<string>
|
|
21
|
+
}>
|
|
22
|
+
}>
|
|
23
|
+
}
|
|
24
|
+
|
|
6
25
|
type Nullable<T> = T | undefined | null;
|
|
7
26
|
|
|
8
27
|
type RequestError = Error & { response: any }
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {LoginResponse, LogoutResponse, ResendPayload, ResendResponse, VerifyResponse} from "../api/auth";
|
|
2
|
+
import {Nullable, TwilightResponse} from "../common";
|
|
3
|
+
|
|
4
|
+
export default interface AuthEvent {
|
|
5
|
+
onCodeSent: (callback: (response: LoginResponse, type: Nullable<'mobile' | 'email'>) => void) => void;
|
|
6
|
+
onCodeNotSent: (callback: (error: TwilightResponse | string, type: Nullable<'mobile' | 'email'>) => void) => void;
|
|
7
|
+
onCodeReSent: (callback: (response: ResendResponse, data: ResendPayload) => void) => void;
|
|
8
|
+
onCodeNotReSent: (callback: (error: TwilightResponse | string, data: ResendPayload) => void) => void;
|
|
9
|
+
onVerified: (callback: (response: VerifyResponse, type: Nullable<'mobile' | 'email'>) => void) => void;
|
|
10
|
+
onVerificationFailed: (callback: (error: TwilightResponse | string, type: Nullable<'mobile' | 'email'>) => void) => void;
|
|
11
|
+
// onLoggedIn: (callback: (response: LoginResponse, data: ResendPayload) => void) => void;
|
|
12
|
+
onRegistered: (callback: (response: VerifyResponse) => void) => void;
|
|
13
|
+
onRegistrationFailed: (callback: (error: TwilightResponse) => void) => void;
|
|
14
|
+
onLoggedOut: (callback: (response: LogoutResponse) => void) => void;
|
|
15
|
+
onFailedLogout: (callback: (error: TwilightResponse) => void) => void;
|
|
16
|
+
onTokenFetched: (callback: (token: string) => void) => void;
|
|
17
|
+
onRefreshFailed: (callback: (error: TwilightResponse) => void) => void;
|
|
18
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import {SallaHelpers} from "./helpers/salla-helpers";
|
|
|
6
6
|
import CartEvent from "./event/cart";
|
|
7
7
|
import CouponEvent from "./event/coupon";
|
|
8
8
|
import CouponApi from "./api/coupon";
|
|
9
|
+
import AuthApi from "./api/auth";
|
|
10
|
+
import AuthEvent from "./event/auth";
|
|
9
11
|
|
|
10
12
|
export * from "./all";
|
|
11
13
|
|
|
@@ -13,7 +15,7 @@ export default interface salla {
|
|
|
13
15
|
notify: string;
|
|
14
16
|
api: Axios | {
|
|
15
17
|
cart: CartApi,
|
|
16
|
-
auth:
|
|
18
|
+
auth: AuthApi;
|
|
17
19
|
gift: any;
|
|
18
20
|
order: any;
|
|
19
21
|
offer: any;
|
|
@@ -36,7 +38,7 @@ export default interface salla {
|
|
|
36
38
|
|
|
37
39
|
//Aliases
|
|
38
40
|
cart: { api: CartApi, event: CartEvent };
|
|
39
|
-
auth: { api:
|
|
41
|
+
auth: { api: AuthApi, event: AuthEvent };
|
|
40
42
|
gift: { api: any, event: any };
|
|
41
43
|
order: { api: any, event: any };
|
|
42
44
|
offer: { api: any, event: any };
|