@salla.sa/twilight 2.0.214 → 2.0.216
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/cart.d.ts +31 -15
- package/types/api/order.d.ts +14 -0
- package/types/api/profile.d.ts +32 -0
- package/types/common.d.ts +0 -2
- package/types/event/cart.d.ts +28 -5
- package/types/event/order.d.ts +12 -0
- package/types/event/profile.d.ts +10 -0
- package/types/index.d.ts +43 -14
- package/types/api/cart/cart-details-response.d.ts +0 -22
- package/types/api/cart/cart-status-response.d.ts +0 -7
- package/types/api/cart/item.d.ts +0 -0
- package/types/api/cart/responses.d.ts +0 -0
- package/types/api/order/re-order-response.d.ts +0 -9
package/package.json
CHANGED
package/types/api/cart.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
// import {CartDetailsResponse} from "./cart/cart-details-response";
|
|
2
1
|
import {Nullable, TwilightResponse} from "../common";
|
|
3
|
-
import {AddCouponResponse} from "./coupon";
|
|
4
2
|
|
|
5
3
|
export interface itemOffer {
|
|
6
4
|
discount: number,
|
|
@@ -43,12 +41,6 @@ export interface OfferSummary {
|
|
|
43
41
|
product_id: number,
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
export interface CartUpdatedData {
|
|
47
|
-
product_id: Nullable<number>;
|
|
48
|
-
offer: Nullable<OfferSummary>;
|
|
49
|
-
googleTags: string;//json string
|
|
50
|
-
cart: CartSummary
|
|
51
|
-
}
|
|
52
44
|
|
|
53
45
|
export interface CartLatestResponse extends TwilightResponse {
|
|
54
46
|
data: {
|
|
@@ -60,7 +52,12 @@ export interface CartLatestResponse extends TwilightResponse {
|
|
|
60
52
|
}
|
|
61
53
|
|
|
62
54
|
export interface CartUpdateResponse extends TwilightResponse {
|
|
63
|
-
data:
|
|
55
|
+
data: {
|
|
56
|
+
product_id: Nullable<number>;
|
|
57
|
+
offer: Nullable<OfferSummary>;
|
|
58
|
+
googleTags: string;//json string
|
|
59
|
+
cart: CartSummary
|
|
60
|
+
}
|
|
64
61
|
}
|
|
65
62
|
|
|
66
63
|
|
|
@@ -73,15 +70,34 @@ export interface UpdateCartItemResponse extends CartUpdateResponse {
|
|
|
73
70
|
export interface DeleteCartItemResponse extends CartUpdateResponse {
|
|
74
71
|
}
|
|
75
72
|
|
|
73
|
+
export interface CartStatusResponse extends TwilightResponse {
|
|
74
|
+
data: {
|
|
75
|
+
active: boolean;
|
|
76
|
+
next_step: {
|
|
77
|
+
to: 'refresh' | 'login' | 'checkout';
|
|
78
|
+
url: Nullable<string>;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface AddItemPayload {
|
|
84
|
+
id: number;
|
|
85
|
+
quantity: 1 | number;
|
|
86
|
+
options: Nullable<{ [key: number]: [value: number | string | Array<{ [key: number]: [value: number] }>] }>;
|
|
87
|
+
notes: Nullable<string>;
|
|
88
|
+
file: Nullable<BinaryType | string>;
|
|
89
|
+
}
|
|
90
|
+
|
|
76
91
|
export default interface CartApi {
|
|
77
92
|
latest: () => Promise<CartLatestResponse>;
|
|
78
93
|
details: () => Promise<CartUpdateResponse>;
|
|
79
94
|
summary: () => Promise<CartUpdateResponse>;
|
|
80
95
|
quickAdd: (product_id: number) => Promise<CartUpdateResponse>;
|
|
81
|
-
addItem:
|
|
82
|
-
deleteItem:
|
|
83
|
-
updateItem:
|
|
84
|
-
deleteImage:
|
|
85
|
-
status:
|
|
86
|
-
|
|
96
|
+
addItem: (data: AddItemPayload) => Promise<CartUpdateResponse>;
|
|
97
|
+
deleteItem: (item_id: number) => Promise<CartUpdateResponse>;
|
|
98
|
+
updateItem: (data: AddItemPayload) => Promise<CartUpdateResponse>;
|
|
99
|
+
deleteImage: (file_id: number) => Promise<TwilightResponse>;
|
|
100
|
+
status: () => Promise<CartStatusResponse>;
|
|
101
|
+
reset: () => void;
|
|
102
|
+
submit: () => void;
|
|
87
103
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {Nullable, TwilightResponse} from "../common";
|
|
2
|
+
|
|
3
|
+
export interface ReOrderResponse extends TwilightResponse {
|
|
4
|
+
data: {
|
|
5
|
+
cart_id: number;
|
|
6
|
+
url: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default interface OrderApi {
|
|
11
|
+
reOrder: (order_id?: Nullable<number>) => Promise<ReOrderResponse>;
|
|
12
|
+
cancel: (order_id?: Nullable<number>) => Promise<TwilightResponse>;
|
|
13
|
+
send: (order_id?: Nullable<number>) => Promise<TwilightResponse>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {Nullable, TwilightResponse} from "../common";
|
|
2
|
+
|
|
3
|
+
export interface ProfilePayload {
|
|
4
|
+
first_name: string;
|
|
5
|
+
last_name: string;
|
|
6
|
+
birthday?: Nullable<string | '2022-02-22'>;
|
|
7
|
+
gender: Nullable<'male' | 'female'>;
|
|
8
|
+
email: string;
|
|
9
|
+
mobile: string | number;
|
|
10
|
+
country_code: string | 'SA';
|
|
11
|
+
country_key: string | '+966';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface UpdateProfileResponse extends TwilightResponse {
|
|
15
|
+
data: {
|
|
16
|
+
first_name: string;
|
|
17
|
+
last_name: string;
|
|
18
|
+
phone: {
|
|
19
|
+
code: string | "+966";
|
|
20
|
+
number: string | number;
|
|
21
|
+
country: string | "SA";
|
|
22
|
+
},
|
|
23
|
+
email: string;
|
|
24
|
+
avatar: string;
|
|
25
|
+
gender: Nullable<'male' | 'female'>;
|
|
26
|
+
birthday: string | '2022-02-22';
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default interface ProfileApi {
|
|
31
|
+
update: (data: ProfilePayload) => Promise<UpdateProfileResponse>;
|
|
32
|
+
}
|
package/types/common.d.ts
CHANGED
package/types/event/cart.d.ts
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CartSummary,
|
|
3
|
+
AddToCartResponse,
|
|
4
|
+
UpdateCartItemResponse,
|
|
5
|
+
DeleteCartItemResponse,
|
|
6
|
+
CartLatestResponse, CartStatusResponse
|
|
7
|
+
} from "../api/cart";
|
|
8
|
+
import {Nullable, RequestError, TwilightResponse} from "../common";
|
|
2
9
|
|
|
3
10
|
export default interface CartEvent {
|
|
4
|
-
onUpdated: (callback: (
|
|
5
|
-
onItemAdded: (callback: (response: AddToCartResponse, product_id: number) => void) => void
|
|
6
|
-
onItemUpdated: (callback: (response: UpdateCartItemResponse, product_id: number) => void) => void
|
|
7
|
-
onItemDeleted: (callback: (response: DeleteCartItemResponse, product_id: number) => void) => void
|
|
11
|
+
onUpdated: (callback: (cart_summary: CartSummary) => void) => void;
|
|
12
|
+
onItemAdded: (callback: (response: AddToCartResponse, product_id: number) => void) => void;
|
|
13
|
+
onItemUpdated: (callback: (response: UpdateCartItemResponse, product_id: number) => void) => void;
|
|
14
|
+
onItemDeleted: (callback: (response: DeleteCartItemResponse, product_id: number) => void) => void;
|
|
15
|
+
onLatestFetched: (callback: (response: CartLatestResponse) => void) => void;
|
|
16
|
+
onSubmitted: (callback: (response: CartStatusResponse) => void) => void;
|
|
17
|
+
onImageDeleted: (callback: (response: TwilightResponse, file_id: number) => void) => void;
|
|
18
|
+
onSummaryFetched: (callback: (response: CartStatusResponse) => void) => void;
|
|
19
|
+
onDetailsFetched: (callback: (response: CartStatusResponse) => void) => void;
|
|
20
|
+
onSuccessReset: (callback: () => void) => void;
|
|
21
|
+
|
|
22
|
+
//errors
|
|
23
|
+
onLatestFailed: (callback: (error: RequestError) => void) => void;
|
|
24
|
+
onItemUpdatedFailed: (callback: (error: RequestError | 'There is no "id"!', item_id: Nullable<number>) => void) => void;
|
|
25
|
+
onItemAddedFailed: (callback: (error: RequestError | 'There is no product "id"!', product_id: Nullable<number>) => void) => void;
|
|
26
|
+
onItemDeletedFailed: (callback: (error: RequestError | 'There is no "id"!', item_id: Nullable<number>) => void) => void;
|
|
27
|
+
onSubmitFailed: (callback: (error: RequestError | "Can't find next_step );") => void) => void;
|
|
28
|
+
onImageNotDeleted: (callback: (error: RequestError | 'There is no "id"!', file_id: Nullable<number>) => void) => void;
|
|
29
|
+
onSummaryNotFetched: (callback: (error: RequestError) => void) => void;
|
|
30
|
+
onDetailsNotFetched: (callback: (error: RequestError) => void) => void;
|
|
8
31
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {Nullable, RequestError, TwilightResponse} from "../common";
|
|
2
|
+
import {ReOrderResponse} from "../api/order";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export default interface OrderEvent {
|
|
6
|
+
onCanceled: (callback: (response: TwilightResponse, order_id: Nullable<number>) => void) => void;
|
|
7
|
+
onNotCanceled: (callback: (error: RequestError, order_id: Nullable<number>) => void) => void;
|
|
8
|
+
onReOrdered: (callback: (response: ReOrderResponse, order_id: Nullable<number>) => void) => void;
|
|
9
|
+
onReOrderFailed: (callback: (error: RequestError, order_id: Nullable<number>) => void) => void;
|
|
10
|
+
onSent: (callback: (response: TwilightResponse, order_id: Nullable<number>) => void) => void;
|
|
11
|
+
onNotSent: (callback: (error: RequestError | 'There is no id!', order_id: Nullable<number>) => void) => void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {UpdateProfileResponse} from "../api/profile";
|
|
2
|
+
import {Nullable, RequestError} from "../common";
|
|
3
|
+
|
|
4
|
+
export default interface ProfileEvent {
|
|
5
|
+
updated: (response: UpdateProfileResponse) => void; //fire the event
|
|
6
|
+
updateFailed: (RequestError) => void;//fire the event
|
|
7
|
+
|
|
8
|
+
onUpdated: (callback: (response: UpdateProfileResponse) => void) => void;
|
|
9
|
+
onUpdateFailed: (callback: (error: RequestError) => void) => void;
|
|
10
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -8,55 +8,84 @@ import CouponEvent from "./event/coupon";
|
|
|
8
8
|
import CouponApi from "./api/coupon";
|
|
9
9
|
import AuthApi from "./api/auth";
|
|
10
10
|
import AuthEvent from "./event/auth";
|
|
11
|
+
import OrderApi from "./api/order";
|
|
12
|
+
import OrderEvent from "./event/order";
|
|
13
|
+
import ProfileApi from "./api/profile";
|
|
14
|
+
import ProfileEvent from "./event/profile";
|
|
11
15
|
|
|
12
16
|
export * from "./all";
|
|
13
17
|
|
|
14
|
-
export default interface
|
|
18
|
+
export default interface Salla {
|
|
15
19
|
notify: string;
|
|
16
20
|
api: Axios | {
|
|
17
21
|
cart: CartApi,
|
|
18
22
|
auth: AuthApi;
|
|
19
23
|
gift: any;
|
|
20
|
-
order:
|
|
24
|
+
order: OrderApi;
|
|
21
25
|
offer: any;
|
|
22
26
|
search: any;
|
|
23
27
|
coupon: CouponApi;
|
|
24
28
|
comment: any;
|
|
25
29
|
loyalty: any;
|
|
26
30
|
product: any;
|
|
31
|
+
profile: ProfileApi;
|
|
27
32
|
currency: any;
|
|
28
33
|
document: any;
|
|
29
34
|
feedback: any;
|
|
30
35
|
twilight: any;
|
|
31
36
|
wishlist: any;
|
|
32
37
|
};
|
|
33
|
-
event:
|
|
34
|
-
|
|
38
|
+
event: {
|
|
39
|
+
auth: AuthEvent,
|
|
40
|
+
cart: CartEvent,
|
|
41
|
+
gift: any;
|
|
42
|
+
order: OrderEvent;
|
|
43
|
+
offer: any;
|
|
44
|
+
search: any;
|
|
45
|
+
coupon: CouponEvent;
|
|
46
|
+
comment: any;
|
|
47
|
+
loyalty: any;
|
|
48
|
+
product: any;
|
|
49
|
+
profile: ProfileEvent;
|
|
50
|
+
currency: any;
|
|
51
|
+
document: any;
|
|
52
|
+
feedback: any;
|
|
53
|
+
twilight: any;
|
|
54
|
+
wishlist: any;
|
|
55
|
+
|
|
56
|
+
};
|
|
57
|
+
infiniteScroll: any;
|
|
35
58
|
helpers: SallaHelpers;
|
|
36
59
|
config: SallaConfig;
|
|
37
|
-
|
|
60
|
+
storage: any;
|
|
61
|
+
form: any;
|
|
38
62
|
|
|
39
63
|
//Aliases
|
|
40
|
-
cart: { api: CartApi, event: CartEvent };
|
|
41
|
-
auth: { api: AuthApi, event: AuthEvent };
|
|
64
|
+
cart: CartApi & { api: CartApi, event: CartEvent };
|
|
65
|
+
auth: AuthApi & { api: AuthApi, event: AuthEvent };
|
|
42
66
|
gift: { api: any, event: any };
|
|
43
|
-
order: { api:
|
|
67
|
+
order: OrderApi & { api: OrderApi, event: OrderEvent };
|
|
44
68
|
offer: { api: any, event: any };
|
|
45
69
|
search: { api: any, event: any };
|
|
46
|
-
coupon: { api: CouponApi, event: CouponEvent };
|
|
70
|
+
coupon: CouponApi & { api: CouponApi, event: CouponEvent };
|
|
47
71
|
comment: { api: any, event: any };
|
|
48
72
|
loyalty: { api: any, event: any };
|
|
49
73
|
product: { api: any, event: any };
|
|
74
|
+
profile: ProfileApi & { api: ProfileApi, event: ProfileEvent };
|
|
50
75
|
currency: { api: any, event: any };
|
|
51
76
|
document: { api: any, event: any };
|
|
52
77
|
feedback: { api: any, event: any };
|
|
53
78
|
twilight: { api: any, event: any };
|
|
54
79
|
wishlist: { api: any, event: any };
|
|
55
80
|
|
|
56
|
-
log:
|
|
57
|
-
success:
|
|
58
|
-
error:
|
|
59
|
-
onReady:
|
|
60
|
-
AppHelpers:
|
|
81
|
+
log: any;
|
|
82
|
+
success: any;
|
|
83
|
+
error: any;
|
|
84
|
+
onReady: any; //don't relay on it because Salla may not existed yet
|
|
85
|
+
AppHelpers: any;
|
|
61
86
|
money: (money: number | Price) => string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
declare global {
|
|
90
|
+
let salla: Salla;
|
|
62
91
|
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import {Price} from "../../common";
|
|
2
|
-
import {CartItem} from "./item";
|
|
3
|
-
|
|
4
|
-
export interface CartDetailsResponse {
|
|
5
|
-
status: number;
|
|
6
|
-
success: boolean;
|
|
7
|
-
data: {
|
|
8
|
-
items: CartItem;
|
|
9
|
-
require_shipping: boolean;
|
|
10
|
-
cart_total: Price;
|
|
11
|
-
total_before_discount: string;
|
|
12
|
-
count: number;
|
|
13
|
-
total: string;
|
|
14
|
-
coupon_discount: number;
|
|
15
|
-
total_discount: string;
|
|
16
|
-
sub_total: string;
|
|
17
|
-
final_total: string;
|
|
18
|
-
shipping_cost: number;
|
|
19
|
-
'free-shipping-bar'?: string;
|
|
20
|
-
};
|
|
21
|
-
message: string;
|
|
22
|
-
}
|
package/types/api/cart/item.d.ts
DELETED
|
File without changes
|
|
File without changes
|