@salla.sa/twilight 2.0.229 → 2.0.231
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/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/types/.DS_Store +0 -0
- package/types/api/.DS_Store +0 -0
- package/types/api/auth/index.d.ts +15 -0
- package/types/api/auth/request.d.ts +41 -0
- package/types/api/auth/response.d.ts +17 -0
- package/types/api/cart/index.d.ts +19 -0
- package/types/api/cart/request.d.ts +8 -0
- package/types/api/cart/response.d.ts +75 -0
- package/types/api/comment.d.ts +4 -4
- package/types/api/coupon.d.ts +3 -9
- package/types/api/currency.d.ts +5 -5
- package/types/api/gift.d.ts +5 -4
- package/types/api/offer.d.ts +3 -3
- package/types/api/order.d.ts +5 -5
- package/types/api/product.d.ts +4 -4
- package/types/api/profile.d.ts +6 -6
- package/types/api/rating.d.ts +10 -17
- package/types/api/search.d.ts +4 -11
- package/types/api/wishlist.d.ts +4 -4
- package/types/common.d.ts +26 -22
- package/types/event/auth.d.ts +13 -14
- package/types/event/cart.d.ts +14 -20
- package/types/event/coupon.d.ts +6 -6
- package/types/event/currency.d.ts +3 -3
- package/types/event/document.d.ts +8 -8
- package/types/event/gift.d.ts +2 -2
- package/types/event/index.d.ts +2 -2
- package/types/event/order.d.ts +7 -7
- package/types/event/product.d.ts +2 -2
- package/types/event/rating.d.ts +5 -10
- package/types/event/search.d.ts +4 -4
- package/types/event/wishlist.d.ts +3 -3
- package/types/helpers/salla-helpers.d.ts +9 -9
- package/types/api/auth.d.ts +0 -69
- package/types/api/cart.d.ts +0 -101
package/package.json
CHANGED
package/types/.DS_Store
ADDED
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {SuccessResponse} from "../../common";
|
|
2
|
+
|
|
3
|
+
export * from "./request";
|
|
4
|
+
export * from "./response";
|
|
5
|
+
import {AuthRequest} from "./request";
|
|
6
|
+
import {AuthResponse} from "./response";
|
|
7
|
+
|
|
8
|
+
export default interface AuthApi {
|
|
9
|
+
login: (data: AuthRequest.loginByMobile | AuthRequest.loginByEmail) => Promise<SuccessResponse>;
|
|
10
|
+
logout: () => Promise<SuccessResponse>;
|
|
11
|
+
verify: (type: 'mobile' | 'email', data: AuthRequest.verifyByMobile | AuthRequest.verifyByEmail, supportWebAuth: boolean) => Promise<AuthResponse.verify>;
|
|
12
|
+
resend: (data: AuthRequest.resend) => Promise<AuthResponse.resend>;
|
|
13
|
+
register: (data: AuthRequest.register) => Promise<AuthResponse.verify>;
|
|
14
|
+
refresh: () => Promise<AuthResponse.verify>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export namespace AuthRequest {
|
|
2
|
+
export interface loginByMobile {
|
|
3
|
+
phone: string;
|
|
4
|
+
type: 'mobile';
|
|
5
|
+
country_code: string | 'SA';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface loginByEmail {
|
|
9
|
+
email: string;
|
|
10
|
+
type: 'email';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface verifyByEmail {
|
|
14
|
+
code: string;
|
|
15
|
+
email: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface verifyByMobile {
|
|
19
|
+
code: string;
|
|
20
|
+
phone: string;
|
|
21
|
+
country_code: string | "SA";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface register {
|
|
25
|
+
first_name: string;
|
|
26
|
+
last_name: string;
|
|
27
|
+
phone: string;
|
|
28
|
+
country_code: string | 'SA';
|
|
29
|
+
country_key: string | '+966';
|
|
30
|
+
verified_by: 'email' | 'phone';
|
|
31
|
+
email?: string;
|
|
32
|
+
code: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface resend {
|
|
36
|
+
resend_by: 'sms' | 'email';
|
|
37
|
+
phone?: string;
|
|
38
|
+
country_code?: string | "SA";
|
|
39
|
+
email?: string;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {SuccessResponse} from "../../common";
|
|
2
|
+
|
|
3
|
+
export namespace AuthResponse {
|
|
4
|
+
export interface verify extends SuccessResponse {
|
|
5
|
+
data: {
|
|
6
|
+
case: 'authenticated' | 'new_customer';
|
|
7
|
+
redirect_url?: string;
|
|
8
|
+
token?: string;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface resend extends SuccessResponse {
|
|
13
|
+
data: {
|
|
14
|
+
resend_counter: 2 | 3 | 4;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from "./request";
|
|
2
|
+
export * from "./response";
|
|
3
|
+
import { SuccessResponse} from "../../common";
|
|
4
|
+
import {CartResponse} from "./response";
|
|
5
|
+
import {CartRequest} from "./request";
|
|
6
|
+
|
|
7
|
+
export default interface CartApi {
|
|
8
|
+
latest: () => Promise<CartResponse.latest>;
|
|
9
|
+
details: () => Promise<CartResponse.update>;
|
|
10
|
+
summary: () => Promise<CartResponse.update>;
|
|
11
|
+
quickAdd: (product_id: number) => Promise<CartResponse.update>;
|
|
12
|
+
addItem: (data: CartRequest.addItem) => Promise<CartResponse.update>;
|
|
13
|
+
deleteItem: (item_id: number) => Promise<CartResponse.update>;
|
|
14
|
+
updateItem: (data: CartRequest.addItem) => Promise<CartResponse.update>;
|
|
15
|
+
deleteImage: (file_id: number) => Promise<SuccessResponse>;
|
|
16
|
+
status: () => Promise<CartResponse.status>;
|
|
17
|
+
reset: () => void;
|
|
18
|
+
submit: () => void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {SuccessResponse} from "../../common";
|
|
2
|
+
export {SuccessResponse} from "../../common";
|
|
3
|
+
export namespace CartResponse {
|
|
4
|
+
export interface latest extends SuccessResponse {
|
|
5
|
+
data: {
|
|
6
|
+
cart: {
|
|
7
|
+
id: number;
|
|
8
|
+
user_id: number | string;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface update extends SuccessResponse {
|
|
14
|
+
data: CartUpdatedData;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface status extends SuccessResponse {
|
|
18
|
+
data: {
|
|
19
|
+
active: boolean;
|
|
20
|
+
next_step: {
|
|
21
|
+
to: 'refresh' | 'login' | 'checkout';
|
|
22
|
+
url?: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
export interface CartUpdatedData extends Object {
|
|
30
|
+
product_id?: number;
|
|
31
|
+
offer?: OfferSummary;
|
|
32
|
+
googleTags: string;//json string
|
|
33
|
+
cart: CartSummary;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface itemOffer {
|
|
37
|
+
discount: number;
|
|
38
|
+
is_free: boolean;
|
|
39
|
+
names: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface CartItem {
|
|
43
|
+
id: number;
|
|
44
|
+
product_id: number;
|
|
45
|
+
product_price: number;
|
|
46
|
+
price: number;
|
|
47
|
+
total: number;
|
|
48
|
+
is_available: true;
|
|
49
|
+
offer?: itemOffer;
|
|
50
|
+
quantity: number;
|
|
51
|
+
total_special_price: number;
|
|
52
|
+
special_price: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface CartSummary {
|
|
56
|
+
id: number;
|
|
57
|
+
user_id: number | string;
|
|
58
|
+
real_shipping_cost: number;
|
|
59
|
+
free_shipping_bar?: {
|
|
60
|
+
minimum_amount: number;
|
|
61
|
+
has_free_shipping: boolean;
|
|
62
|
+
percent: number | 0 | 100;
|
|
63
|
+
remaining: number;
|
|
64
|
+
};
|
|
65
|
+
sub_total: number;
|
|
66
|
+
discount: number;
|
|
67
|
+
total: number;
|
|
68
|
+
count: number;
|
|
69
|
+
items?: CartItem[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface OfferSummary {
|
|
73
|
+
id: number;
|
|
74
|
+
product_id: number;
|
|
75
|
+
}
|
package/types/api/comment.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {SuccessResponse} from "../common";
|
|
2
2
|
|
|
3
|
-
export interface SendCommentResponse extends
|
|
3
|
+
export interface SendCommentResponse extends SuccessResponse {
|
|
4
4
|
data: {
|
|
5
|
-
case: 'success' | 'error'
|
|
6
|
-
message: string
|
|
5
|
+
case: 'success' | 'error';
|
|
6
|
+
message: string;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
package/types/api/coupon.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export interface AddCouponResponse extends CartUpdateResponse {
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export interface RemoveCouponResponse extends CartUpdateResponse {
|
|
7
|
-
}
|
|
1
|
+
import {CartResponse} from "./cart";
|
|
8
2
|
|
|
9
3
|
export default interface CouponApi {
|
|
10
|
-
add: (coupon: string) => Promise<
|
|
11
|
-
remove: () => Promise<
|
|
4
|
+
add: (coupon: string) => Promise<CartResponse.update>;
|
|
5
|
+
remove: () => Promise<CartResponse.update>;
|
|
12
6
|
}
|
package/types/api/currency.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {Currency,
|
|
1
|
+
import {Currency, SuccessResponse} from "../common";
|
|
2
2
|
|
|
3
|
-
export interface ChangeCurrencyResponse extends
|
|
3
|
+
export interface ChangeCurrencyResponse extends SuccessResponse {
|
|
4
4
|
data: {
|
|
5
|
-
code: 'SAR' | string
|
|
6
|
-
symbol: string
|
|
5
|
+
code: 'SAR' | string;
|
|
6
|
+
symbol: string;
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export interface ListCurrenciesResponse extends
|
|
10
|
+
export interface ListCurrenciesResponse extends SuccessResponse {
|
|
11
11
|
data: Array<Currency>
|
|
12
12
|
}
|
|
13
13
|
|
package/types/api/gift.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {SuccessResponse} from "../common";
|
|
2
2
|
|
|
3
3
|
export interface GiftPayload {
|
|
4
4
|
id: number;
|
|
@@ -16,11 +16,12 @@ export interface GiftPayload {
|
|
|
16
16
|
deliver_at: string | '2022-02-22 02:22 pm';
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export interface GiftResponse extends
|
|
20
|
-
|
|
19
|
+
export interface GiftResponse extends SuccessResponse {
|
|
20
|
+
data:{
|
|
21
|
+
redirect: string;
|
|
22
|
+
}
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
export default interface GiftApi {
|
|
24
26
|
buy: (GiftPayload) => Promise<GiftResponse>;
|
|
25
|
-
|
|
26
27
|
}
|
package/types/api/offer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Category, Product,
|
|
1
|
+
import {Category, Product, SuccessResponse} from "../common";
|
|
2
2
|
|
|
3
3
|
type offerType = 'buy_x_get_y' | 'percentage' | 'fixed_amount';
|
|
4
4
|
type paymentMethod = {
|
|
@@ -23,7 +23,7 @@ export interface Offer {
|
|
|
23
23
|
min_amount?: number; //when offer_type != 'buy_x_get_y'
|
|
24
24
|
min_items?: number; //when offer_type != 'buy_x_get_y'
|
|
25
25
|
payment_methods: paymentMethod[];
|
|
26
|
-
}
|
|
26
|
+
};
|
|
27
27
|
get: {
|
|
28
28
|
products?: Product[];
|
|
29
29
|
categories?: Category[];
|
|
@@ -34,7 +34,7 @@ export interface Offer {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export interface OfferDetailsResponse extends
|
|
37
|
+
export interface OfferDetailsResponse extends SuccessResponse {
|
|
38
38
|
data: Offer[] | [];
|
|
39
39
|
}
|
|
40
40
|
|
package/types/api/order.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SuccessResponse} from "../common";
|
|
2
2
|
|
|
3
|
-
export interface ReOrderResponse extends
|
|
3
|
+
export interface ReOrderResponse extends SuccessResponse {
|
|
4
4
|
data: {
|
|
5
5
|
cart_id: number;
|
|
6
6
|
url: string;
|
|
@@ -8,7 +8,7 @@ export interface ReOrderResponse extends TwilightResponse {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export default interface OrderApi {
|
|
11
|
-
reOrder: (order_id?:
|
|
12
|
-
cancel: (order_id?:
|
|
13
|
-
send: (order_id?:
|
|
11
|
+
reOrder: (order_id?: number) => Promise<ReOrderResponse>;
|
|
12
|
+
cancel: (order_id?: number) => Promise<SuccessResponse>;
|
|
13
|
+
send: (order_id?: number) => Promise<SuccessResponse>;
|
|
14
14
|
}
|
package/types/api/product.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SuccessResponse} from "../common";
|
|
2
2
|
|
|
3
3
|
type ProductOption = { [key: number]: number | string | number[] };
|
|
4
4
|
|
|
5
5
|
export interface ProductPayload {
|
|
6
6
|
id: number;
|
|
7
7
|
quantity: 1 | number;
|
|
8
|
-
options?:
|
|
8
|
+
options?: ProductOption;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface AvailabilityPayload {
|
|
@@ -16,7 +16,7 @@ export interface AvailabilityPayload {
|
|
|
16
16
|
mobile?: string | '555555555';//required when request without email
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
export interface GetPriceResponse extends
|
|
19
|
+
export interface GetPriceResponse extends SuccessResponse {
|
|
20
20
|
data: {
|
|
21
21
|
price: number;
|
|
22
22
|
regular_price: number;
|
|
@@ -26,5 +26,5 @@ export interface GetPriceResponse extends TwilightResponse {
|
|
|
26
26
|
|
|
27
27
|
export default interface ProductApi {
|
|
28
28
|
getPrice: (data: /*product_id*/number | ProductPayload) => Promise<GetPriceResponse>;
|
|
29
|
-
availabilitySubscribe: (product_id: number | AvailabilityPayload) => Promise<
|
|
29
|
+
availabilitySubscribe: (product_id: number | AvailabilityPayload) => Promise<SuccessResponse>;
|
|
30
30
|
}
|
package/types/api/profile.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SuccessResponse} from "../common";
|
|
2
2
|
|
|
3
3
|
export interface ProfilePayload {
|
|
4
4
|
first_name: string;
|
|
5
5
|
last_name: string;
|
|
6
|
-
birthday?:
|
|
7
|
-
gender
|
|
6
|
+
birthday?: string | '2022-02-22';
|
|
7
|
+
gender?: 'male' | 'female';
|
|
8
8
|
email: string;
|
|
9
9
|
mobile: string | number;
|
|
10
10
|
country_code: string | 'SA';
|
|
@@ -12,7 +12,7 @@ export interface ProfilePayload {
|
|
|
12
12
|
avatar?: BinaryType;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export interface UpdateProfileResponse extends
|
|
15
|
+
export interface UpdateProfileResponse extends SuccessResponse {
|
|
16
16
|
data: {
|
|
17
17
|
first_name: string;
|
|
18
18
|
last_name: string;
|
|
@@ -20,10 +20,10 @@ export interface UpdateProfileResponse extends TwilightResponse {
|
|
|
20
20
|
code: string | "+966";
|
|
21
21
|
number: string | number;
|
|
22
22
|
country: string | "SA";
|
|
23
|
-
}
|
|
23
|
+
};
|
|
24
24
|
email: string;
|
|
25
25
|
avatar: string;
|
|
26
|
-
gender
|
|
26
|
+
gender?: 'male' | 'female';
|
|
27
27
|
birthday: string | '2022-02-22';
|
|
28
28
|
};
|
|
29
29
|
}
|
package/types/api/rating.d.ts
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Product, Rating, SuccessResponse} from "../common";
|
|
2
2
|
|
|
3
|
-
export interface
|
|
4
|
-
data: {
|
|
5
|
-
case: "success";
|
|
6
|
-
message: string;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface OrderDetailsResponse extends TwilightResponse {
|
|
3
|
+
export interface OrderDetailsResponse extends SuccessResponse {
|
|
11
4
|
data: {
|
|
12
5
|
id: number;
|
|
13
|
-
store
|
|
14
|
-
shipping
|
|
6
|
+
store?: { feedback: RatingContent };
|
|
7
|
+
shipping?: {
|
|
15
8
|
feedback: RatingContent;
|
|
16
9
|
company: {
|
|
17
10
|
id: number;
|
|
18
11
|
name: string;
|
|
19
|
-
logo
|
|
12
|
+
logo?: string;
|
|
20
13
|
}
|
|
21
|
-
}
|
|
14
|
+
};
|
|
22
15
|
products: Array<{ feedback: RatingContent; product: Product; }>;
|
|
23
16
|
testimonials_enabled: boolean;
|
|
24
17
|
shipping_enabled: boolean;
|
|
@@ -28,7 +21,7 @@ export interface OrderDetailsResponse extends TwilightResponse {
|
|
|
28
21
|
}
|
|
29
22
|
|
|
30
23
|
export interface RatingContent {
|
|
31
|
-
content: string
|
|
24
|
+
content: string;
|
|
32
25
|
rating: Rating;
|
|
33
26
|
status?: 'approved' | 'pending';
|
|
34
27
|
}
|
|
@@ -50,7 +43,7 @@ export interface RatingShippingPayload extends RatingStorePayload {
|
|
|
50
43
|
|
|
51
44
|
export default interface RatingApi {
|
|
52
45
|
order: (order_id: number) => Promise<OrderDetailsResponse>;
|
|
53
|
-
store: (data: RatingStorePayload) => Promise<
|
|
54
|
-
products: (data: RatingProductsPayload) => Promise<
|
|
55
|
-
shipping: (data: RatingShippingPayload) => Promise<
|
|
46
|
+
store: (data: RatingStorePayload) => Promise<SuccessResponse>;
|
|
47
|
+
products: (data: RatingProductsPayload) => Promise<SuccessResponse>;
|
|
48
|
+
shipping: (data: RatingShippingPayload) => Promise<SuccessResponse>;
|
|
56
49
|
}
|
package/types/api/search.d.ts
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Product, SuccessResponse} from "../common";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
id: "ourSuggest" | "bestSell" | "topRated" | "priceFromTopToLow" | "priceFromLowToTop";
|
|
5
|
-
name: string
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export interface SearchProductsResponse extends TwilightResponse {
|
|
3
|
+
export interface SearchProductsResponse extends SuccessResponse {
|
|
9
4
|
data: Product[];
|
|
10
5
|
cursor: {
|
|
11
6
|
current: number;
|
|
12
|
-
previous
|
|
13
|
-
next
|
|
7
|
+
previous?: string;
|
|
8
|
+
next?: string;
|
|
14
9
|
count: number;
|
|
15
10
|
};
|
|
16
|
-
features?: { sorting?: true };
|
|
17
|
-
sort_options: SortOption[];
|
|
18
11
|
}
|
|
19
12
|
|
|
20
13
|
export default interface SearchApi {
|
package/types/api/wishlist.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {SuccessResponse} from "../common";
|
|
2
2
|
|
|
3
3
|
export default interface WishlistApi {
|
|
4
|
-
add: (product_id: number) => Promise<
|
|
5
|
-
remove: (product_id: number) => Promise<
|
|
6
|
-
toggle: (product_id: number) => Promise<
|
|
4
|
+
add: (product_id: number) => Promise<SuccessResponse>;
|
|
5
|
+
remove: (product_id: number) => Promise<SuccessResponse>;
|
|
6
|
+
toggle: (product_id: number) => Promise<SuccessResponse>;
|
|
7
7
|
}
|
package/types/common.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
type Nullable<T> = T | undefined | null | '';
|
|
2
1
|
type ProductType = 'product' | 'service' | 'group_products' | 'codes' | 'digital' | 'food' | 'donating';
|
|
3
2
|
type Rating = 1 | 2 | 3 | 4 | 5;
|
|
4
3
|
type RequestError = Error & { response: any }
|
|
@@ -10,25 +9,30 @@ export interface Price {
|
|
|
10
9
|
currency: string;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
export interface
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
export interface SuccessResponse {
|
|
13
|
+
status: 200;
|
|
14
|
+
success: true;
|
|
15
|
+
data: {
|
|
16
|
+
message?: string;
|
|
17
|
+
events?: { [event_name: string]: any };
|
|
18
|
+
[key:string]:any;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ErrorResponse {
|
|
23
|
+
status: 422 | 404;
|
|
24
|
+
success: false;
|
|
25
|
+
error: object | {
|
|
26
|
+
message?: string | 'alert.invalid_fields';
|
|
27
|
+
code?: any;
|
|
28
|
+
case?: string | 'resend_counter' | 'invalid_code';
|
|
29
|
+
events?: { [event_name: string]: any };
|
|
30
|
+
fields?: { [field_name: string]: Array<string> };
|
|
31
|
+
}
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
export interface Currency {
|
|
31
|
-
code: string| 'SAR';
|
|
35
|
+
code: string | 'SAR';
|
|
32
36
|
name: string;
|
|
33
37
|
symbol: string;
|
|
34
38
|
amount?: number;
|
|
@@ -40,20 +44,20 @@ export interface Product {
|
|
|
40
44
|
name: string;
|
|
41
45
|
type: ProductType;
|
|
42
46
|
promotion: {
|
|
43
|
-
title
|
|
44
|
-
sub_title
|
|
47
|
+
title?: string;
|
|
48
|
+
sub_title?: string;
|
|
45
49
|
};
|
|
46
50
|
price: Price;
|
|
47
|
-
sale_price
|
|
51
|
+
sale_price?: Price;
|
|
48
52
|
regular_price: Price;
|
|
49
53
|
has_special_price: boolean;
|
|
50
54
|
status: 'sale' | 'out';
|
|
51
55
|
is_available: boolean;
|
|
52
|
-
sku
|
|
56
|
+
sku?: string;
|
|
53
57
|
currency: string | 'SAR';
|
|
54
58
|
url: string;
|
|
55
59
|
thumbnail: string;
|
|
56
|
-
calories
|
|
60
|
+
calories?: number;
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
export interface Category {
|
package/types/event/auth.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {AuthRequest, AuthResponse} from "../api/auth";
|
|
2
|
+
import {SuccessResponse} from "../common";
|
|
3
3
|
|
|
4
4
|
export default interface AuthEvent {
|
|
5
|
-
onCodeSent: (callback: (response:
|
|
6
|
-
onCodeNotSent: (callback: (error:
|
|
7
|
-
onCodeReSent: (callback: (response:
|
|
8
|
-
onCodeNotReSent: (callback: (error:
|
|
9
|
-
onVerified: (callback: (response:
|
|
10
|
-
onVerificationFailed: (callback: (error:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
onFailedLogout: (callback: (error: TwilightResponse) => void) => void;
|
|
5
|
+
onCodeSent: (callback: (response: SuccessResponse, type?: 'mobile' | 'email') => void) => void;
|
|
6
|
+
onCodeNotSent: (callback: (error: SuccessResponse | string, type?: 'mobile' | 'email') => void) => void;
|
|
7
|
+
onCodeReSent: (callback: (response: AuthResponse.resend, data: AuthRequest.resend) => void) => void;
|
|
8
|
+
onCodeNotReSent: (callback: (error: SuccessResponse | string, data: AuthRequest.resend) => void) => void;
|
|
9
|
+
onVerified: (callback: (response: AuthResponse.verify, type?: 'mobile' | 'email') => void) => void;
|
|
10
|
+
onVerificationFailed: (callback: (error: SuccessResponse | string, type?: 'mobile' | 'email') => void) => void;
|
|
11
|
+
onRegistered: (callback: (response: AuthResponse.verify) => void) => void;
|
|
12
|
+
onRegistrationFailed: (callback: (error: SuccessResponse) => void) => void;
|
|
13
|
+
onLoggedOut: (callback: (response: SuccessResponse) => void) => void;
|
|
14
|
+
onFailedLogout: (callback: (error: SuccessResponse) => void) => void;
|
|
16
15
|
onTokenFetched: (callback: (token: string) => void) => void;
|
|
17
|
-
onRefreshFailed: (callback: (error:
|
|
16
|
+
onRefreshFailed: (callback: (error: SuccessResponse) => void) => void;
|
|
18
17
|
}
|
package/types/event/cart.d.ts
CHANGED
|
@@ -1,31 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
AddToCartResponse,
|
|
4
|
-
UpdateCartItemResponse,
|
|
5
|
-
DeleteCartItemResponse,
|
|
6
|
-
CartLatestResponse, CartStatusResponse
|
|
7
|
-
} from "../api/cart";
|
|
8
|
-
import {Nullable, RequestError, TwilightResponse} from "../common";
|
|
1
|
+
import {CartResponse, CartSummary} from "../api/cart";
|
|
2
|
+
import { RequestError, SuccessResponse} from "../common";
|
|
9
3
|
|
|
10
4
|
export default interface CartEvent {
|
|
11
5
|
onUpdated: (callback: (cart_summary: CartSummary) => void) => void;
|
|
12
|
-
onItemAdded: (callback: (response:
|
|
13
|
-
onItemUpdated: (callback: (response:
|
|
14
|
-
onItemDeleted: (callback: (response:
|
|
15
|
-
onLatestFetched: (callback: (response:
|
|
16
|
-
onSubmitted: (callback: (response:
|
|
17
|
-
onImageDeleted: (callback: (response:
|
|
18
|
-
onSummaryFetched: (callback: (response:
|
|
19
|
-
onDetailsFetched: (callback: (response:
|
|
6
|
+
onItemAdded: (callback: (response: CartResponse.update, product_id: number) => void) => void;
|
|
7
|
+
onItemUpdated: (callback: (response: CartResponse.update, product_id: number) => void) => void;
|
|
8
|
+
onItemDeleted: (callback: (response: CartResponse.update, product_id: number) => void) => void;
|
|
9
|
+
onLatestFetched: (callback: (response: CartResponse.latest) => void) => void;
|
|
10
|
+
onSubmitted: (callback: (response: CartResponse.status) => void) => void;
|
|
11
|
+
onImageDeleted: (callback: (response: SuccessResponse, file_id: number) => void) => void;
|
|
12
|
+
onSummaryFetched: (callback: (response: CartResponse.status) => void) => void;
|
|
13
|
+
onDetailsFetched: (callback: (response: CartResponse.status) => void) => void;
|
|
20
14
|
onSuccessReset: (callback: () => void) => void;
|
|
21
15
|
|
|
22
16
|
//errors
|
|
23
17
|
onLatestFailed: (callback: (error: RequestError) => void) => void;
|
|
24
|
-
onItemUpdatedFailed: (callback: (error: RequestError | 'There is no "id"!', item_id
|
|
25
|
-
onItemAddedFailed: (callback: (error: RequestError | 'There is no product "id"!', product_id
|
|
26
|
-
onItemDeletedFailed: (callback: (error: RequestError | 'There is no "id"!', item_id
|
|
18
|
+
onItemUpdatedFailed: (callback: (error: RequestError | 'There is no "id"!', item_id?: number) => void) => void;
|
|
19
|
+
onItemAddedFailed: (callback: (error: RequestError | 'There is no product "id"!', product_id?: number) => void) => void;
|
|
20
|
+
onItemDeletedFailed: (callback: (error: RequestError | 'There is no "id"!', item_id?: number) => void) => void;
|
|
27
21
|
onSubmitFailed: (callback: (error: RequestError | "Can't find next_step );") => void) => void;
|
|
28
|
-
onImageNotDeleted: (callback: (error: RequestError | 'There is no "id"!', file_id
|
|
22
|
+
onImageNotDeleted: (callback: (error: RequestError | 'There is no "id"!', file_id?: number) => void) => void;
|
|
29
23
|
onSummaryNotFetched: (callback: (error: RequestError) => void) => void;
|
|
30
24
|
onDetailsNotFetched: (callback: (error: RequestError) => void) => void;
|
|
31
25
|
}
|
package/types/event/coupon.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {CartResponse} from "../api/cart";
|
|
2
|
+
import {RequestError} from "../common";
|
|
3
3
|
|
|
4
4
|
export default interface CouponEvent {
|
|
5
|
-
onAdded: (callback: (response:
|
|
6
|
-
onRemoved: (callback: (response:
|
|
7
|
-
onAddedFailed: (callback: (error: RequestError, cart_id
|
|
8
|
-
onRemovedFailed: (callback: (error: RequestError, cart_id
|
|
5
|
+
onAdded: (callback: (response: CartResponse.update, cart_id: number) => void) => void;
|
|
6
|
+
onRemoved: (callback: (response: CartResponse.update, cart_id: number) => void) => void;
|
|
7
|
+
onAddedFailed: (callback: (error: RequestError, cart_id?: number) => void) => void;
|
|
8
|
+
onRemovedFailed: (callback: (error: RequestError, cart_id?: number) => void) => void;
|
|
9
9
|
}
|