@salla.sa/twilight 2.0.213 → 2.0.215
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 +12 -9
- package/dist/@salla.sa/twilight.min.js.map +1 -1
- package/dist/cjs/main.js +12 -9
- package/dist/cjs/main.js.map +1 -1
- package/dist/esm/main.js +12 -9
- package/dist/esm/main.js.map +1 -1
- package/package.json +1 -1
- package/types/api/cart.d.ts +48 -13
- package/types/api/order.d.ts +14 -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/index.d.ts +37 -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,4 +1,3 @@
|
|
|
1
|
-
// import {CartDetailsResponse} from "./cart/cart-details-response";
|
|
2
1
|
import {Nullable, TwilightResponse} from "../common";
|
|
3
2
|
|
|
4
3
|
export interface itemOffer {
|
|
@@ -21,19 +20,20 @@ export interface CartItem {
|
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
export interface CartSummary {
|
|
23
|
+
id: number,
|
|
24
|
+
user_id: number | string,
|
|
24
25
|
real_shipping_cost: number,
|
|
25
|
-
free_shipping_bar: {
|
|
26
|
+
free_shipping_bar: Nullable<{
|
|
26
27
|
minimum_amount: number,
|
|
27
28
|
has_free_shipping: boolean,
|
|
28
29
|
percent: number | 0 | 100,
|
|
29
30
|
remaining: number
|
|
30
|
-
}
|
|
31
|
+
}>,
|
|
31
32
|
sub_total: number,
|
|
32
33
|
discount: number,
|
|
33
34
|
total: number,
|
|
34
35
|
count: number,
|
|
35
36
|
items: Nullable<CartItem[]>,
|
|
36
|
-
user_id: number | string,
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export interface OfferSummary {
|
|
@@ -41,17 +41,26 @@ export interface OfferSummary {
|
|
|
41
41
|
product_id: number,
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
|
|
45
|
+
export interface CartLatestResponse extends TwilightResponse {
|
|
46
|
+
data: {
|
|
47
|
+
cart: {
|
|
48
|
+
id: number;
|
|
49
|
+
user_id: number | string;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
export interface CartUpdateResponse extends TwilightResponse {
|
|
52
|
-
data:
|
|
55
|
+
data: {
|
|
56
|
+
product_id: Nullable<number>;
|
|
57
|
+
offer: Nullable<OfferSummary>;
|
|
58
|
+
googleTags: string;//json string
|
|
59
|
+
cart: CartSummary
|
|
60
|
+
}
|
|
53
61
|
}
|
|
54
62
|
|
|
63
|
+
|
|
55
64
|
export interface AddToCartResponse extends CartUpdateResponse {
|
|
56
65
|
}
|
|
57
66
|
|
|
@@ -61,8 +70,34 @@ export interface UpdateCartItemResponse extends CartUpdateResponse {
|
|
|
61
70
|
export interface DeleteCartItemResponse extends CartUpdateResponse {
|
|
62
71
|
}
|
|
63
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
|
+
|
|
64
91
|
export default interface CartApi {
|
|
65
|
-
latest: () => Promise<
|
|
66
|
-
|
|
67
|
-
|
|
92
|
+
latest: () => Promise<CartLatestResponse>;
|
|
93
|
+
details: () => Promise<CartUpdateResponse>;
|
|
94
|
+
summary: () => Promise<CartUpdateResponse>;
|
|
95
|
+
quickAdd: (product_id: number) => Promise<CartUpdateResponse>;
|
|
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;
|
|
68
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
|
+
}
|
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
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -8,16 +8,18 @@ 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";
|
|
11
13
|
|
|
12
14
|
export * from "./all";
|
|
13
15
|
|
|
14
|
-
export default interface
|
|
16
|
+
export default interface Salla {
|
|
15
17
|
notify: string;
|
|
16
18
|
api: Axios | {
|
|
17
19
|
cart: CartApi,
|
|
18
20
|
auth: AuthApi;
|
|
19
21
|
gift: any;
|
|
20
|
-
order:
|
|
22
|
+
order: OrderApi;
|
|
21
23
|
offer: any;
|
|
22
24
|
search: any;
|
|
23
25
|
coupon: CouponApi;
|
|
@@ -30,20 +32,37 @@ export default interface salla {
|
|
|
30
32
|
twilight: any;
|
|
31
33
|
wishlist: any;
|
|
32
34
|
};
|
|
33
|
-
event:
|
|
34
|
-
|
|
35
|
+
event: {
|
|
36
|
+
auth: AuthEvent,
|
|
37
|
+
cart: CartEvent,
|
|
38
|
+
gift: any;
|
|
39
|
+
order: OrderEvent;
|
|
40
|
+
offer: any;
|
|
41
|
+
search: any;
|
|
42
|
+
coupon: CouponEvent;
|
|
43
|
+
comment: any;
|
|
44
|
+
loyalty: any;
|
|
45
|
+
product: any;
|
|
46
|
+
currency: any;
|
|
47
|
+
document: any;
|
|
48
|
+
feedback: any;
|
|
49
|
+
twilight: any;
|
|
50
|
+
wishlist: any;
|
|
51
|
+
|
|
52
|
+
};
|
|
53
|
+
infiniteScroll: any;
|
|
35
54
|
helpers: SallaHelpers;
|
|
36
55
|
config: SallaConfig;
|
|
37
|
-
localStore:
|
|
56
|
+
localStore: any;
|
|
38
57
|
|
|
39
58
|
//Aliases
|
|
40
|
-
cart: { api: CartApi, event: CartEvent };
|
|
41
|
-
auth: { api: AuthApi, event: AuthEvent };
|
|
59
|
+
cart: CartApi | { api: CartApi, event: CartEvent };
|
|
60
|
+
auth: AuthApi | { api: AuthApi, event: AuthEvent };
|
|
42
61
|
gift: { api: any, event: any };
|
|
43
|
-
order: { api:
|
|
62
|
+
order: OrderApi | { api: OrderApi, event: OrderEvent };
|
|
44
63
|
offer: { api: any, event: any };
|
|
45
64
|
search: { api: any, event: any };
|
|
46
|
-
coupon: { api: CouponApi, event: CouponEvent };
|
|
65
|
+
coupon: CouponApi | { api: CouponApi, event: CouponEvent };
|
|
47
66
|
comment: { api: any, event: any };
|
|
48
67
|
loyalty: { api: any, event: any };
|
|
49
68
|
product: { api: any, event: any };
|
|
@@ -53,10 +72,14 @@ export default interface salla {
|
|
|
53
72
|
twilight: { api: any, event: any };
|
|
54
73
|
wishlist: { api: any, event: any };
|
|
55
74
|
|
|
56
|
-
log:
|
|
57
|
-
success:
|
|
58
|
-
error:
|
|
59
|
-
onReady:
|
|
60
|
-
AppHelpers:
|
|
75
|
+
log: any;
|
|
76
|
+
success: any;
|
|
77
|
+
error: any;
|
|
78
|
+
onReady: any; //don't relay on it because Salla may not existed yet
|
|
79
|
+
AppHelpers: any;
|
|
61
80
|
money: (money: number | Price) => string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare global {
|
|
84
|
+
let salla: Salla;
|
|
62
85
|
}
|
|
@@ -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
|