@salla.sa/twilight 2.13.39 → 2.13.41
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 +3 -3
- package/dist/@salla.sa/twilight.min.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +5 -5
- package/types/api/component.d.ts +39 -1
- package/types/api/index.d.ts +50 -49
- package/types/api/order.d.ts +72 -0
- package/types/common.d.ts +10 -0
- package/types/event/component.d.ts +6 -2
- package/types/event/order.d.ts +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salla.sa/twilight",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.41",
|
|
4
4
|
"description": "Salla Theme Toolkit, Webcomponents, Events, Requests, Utils",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "npx rollup --config --preserveSymlinks=true",
|
|
10
10
|
"watch": "npx rollup --watch --config --preserveSymlinks=true",
|
|
11
|
-
"test": "jest --detectOpenHandles --
|
|
11
|
+
"test": "jest --detectOpenHandles -- order.test",
|
|
12
12
|
"express": "node tests/server/index.js"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
],
|
|
34
34
|
"homepage": "https://salla.dev",
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@salla.sa/base": "^2.13.
|
|
36
|
+
"@salla.sa/base": "^2.13.41",
|
|
37
37
|
"axios": "^0.27.2",
|
|
38
38
|
"infinite-scroll": "^4.0.1",
|
|
39
39
|
"jwt-decode": "^3.1.2",
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
"rollup-plugin-watch": "^1.0.1",
|
|
63
63
|
"webpack": "^5.74.0",
|
|
64
64
|
"webpack-build-notifier": "^2.3.0",
|
|
65
|
-
"webpack-cli": "^
|
|
65
|
+
"webpack-cli": "^5.1.4"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"webpack": "^4 || ^5"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "383c01510d89d457a0ff13d9a5d7b4cb3c00e5fb"
|
|
71
71
|
}
|
package/types/api/component.d.ts
CHANGED
|
@@ -81,12 +81,50 @@ export interface Footer {
|
|
|
81
81
|
links?: FooterSocialLink[]
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
// Review types
|
|
85
|
+
export interface Review {
|
|
86
|
+
rating?: number;
|
|
87
|
+
content?: string;
|
|
88
|
+
status?: string;
|
|
89
|
+
created_at?: CreatedAt;
|
|
90
|
+
replies?: any[];
|
|
91
|
+
text?: string;
|
|
92
|
+
type?: string;
|
|
93
|
+
avatar?: string;
|
|
94
|
+
name?: string;
|
|
95
|
+
stars?: number;
|
|
96
|
+
is_pending?: boolean;
|
|
97
|
+
has_order?: boolean;
|
|
98
|
+
kind?: string;
|
|
99
|
+
session_id?: string;
|
|
100
|
+
customer_id?: number;
|
|
101
|
+
city?: string;
|
|
102
|
+
date?: string;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface CreatedAt {
|
|
106
|
+
date?: string;
|
|
107
|
+
timezone_type?: number;
|
|
108
|
+
timezone?: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface ReviewQueryParams {
|
|
112
|
+
limit?: number;
|
|
113
|
+
source: 'all' | 'store' | 'categories' | 'products' | 'json';
|
|
114
|
+
source_value: number | string | object | Array<string | number>;
|
|
115
|
+
}
|
|
116
|
+
|
|
84
117
|
export namespace ComponentApiResponse {
|
|
85
118
|
export interface menus extends SuccessResponse {
|
|
86
119
|
data: HeaderMenuItem[] | FooterMenu[] | []
|
|
87
120
|
}
|
|
121
|
+
|
|
122
|
+
export interface reviews extends SuccessResponse {
|
|
123
|
+
data: Array<Review> | []
|
|
124
|
+
}
|
|
88
125
|
}
|
|
89
126
|
|
|
90
127
|
export default interface ComponentApi {
|
|
91
|
-
menus?: (component: string) => Promise<ComponentApiResponse.menus
|
|
128
|
+
menus?: (component: string) => Promise<ComponentApiResponse.menus>,
|
|
129
|
+
getReviews?: (queryParams: ReviewQueryParams) => Promise<ComponentApiResponse.reviews>
|
|
92
130
|
}
|
package/types/api/index.d.ts
CHANGED
|
@@ -11,25 +11,25 @@ import DocumentApi from "./document";
|
|
|
11
11
|
import WishlistApi from "./wishlist";
|
|
12
12
|
import ScopeApi from "./scope";
|
|
13
13
|
import LandingApi from "./landing";
|
|
14
|
-
import BookingApi
|
|
14
|
+
import BookingApi from "./booking";
|
|
15
15
|
import {AxiosInstance} from "axios";
|
|
16
16
|
import {ErrorResponse, SuccessResponse} from "@salla.sa/base/types/common";
|
|
17
17
|
|
|
18
18
|
export {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
CartApi,
|
|
20
|
+
AuthApi,
|
|
21
|
+
OrderApi,
|
|
22
|
+
RatingApi,
|
|
23
|
+
CommentApi,
|
|
24
|
+
LoyaltyApi,
|
|
25
|
+
ProductApi,
|
|
26
|
+
ProfileApi,
|
|
27
|
+
CurrencyApi,
|
|
28
|
+
DocumentApi,
|
|
29
|
+
WishlistApi,
|
|
30
|
+
ScopeApi,
|
|
31
|
+
BookingApi,
|
|
32
|
+
LandingApi,
|
|
33
33
|
};
|
|
34
34
|
export type ApiActionName =
|
|
35
35
|
'auth.login'
|
|
@@ -57,6 +57,7 @@ export type ApiActionName =
|
|
|
57
57
|
| 'order.cancel'
|
|
58
58
|
| 'order.reOrder'
|
|
59
59
|
| 'order.send'
|
|
60
|
+
| 'order.fetch'
|
|
60
61
|
| 'product.getPrice'
|
|
61
62
|
| 'product.availabilitySubscribe'
|
|
62
63
|
| 'product.purchaseNow'
|
|
@@ -90,47 +91,47 @@ export type ApiActionName =
|
|
|
90
91
|
| 'booking.add';
|
|
91
92
|
|
|
92
93
|
export default interface Api {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
94
|
+
cart: CartApi;
|
|
95
|
+
auth: AuthApi;
|
|
96
|
+
order: OrderApi;
|
|
97
|
+
rating: RatingApi;
|
|
98
|
+
comment: CommentApi;
|
|
99
|
+
loyalty: LoyaltyApi;
|
|
100
|
+
product: ProductApi;
|
|
101
|
+
profile: ProfileApi;
|
|
102
|
+
currency: CurrencyApi;
|
|
103
|
+
document: DocumentApi;
|
|
104
|
+
wishlist: WishlistApi;
|
|
105
|
+
scope: ScopeApi;
|
|
106
|
+
booking: BookingApi;
|
|
107
|
+
landing: LandingApi;
|
|
108
|
+
axios: AxiosInstance;
|
|
109
|
+
withoutNotifier: (callback: Function) => Promise<void>;
|
|
110
|
+
getHeaders: () => {
|
|
111
|
+
Accept: string | 'application/json, text/plain, */*',
|
|
112
|
+
"X-Requested-With": 'XMLHttpRequest',
|
|
113
|
+
"S-SOURCE": 'twilight',
|
|
114
|
+
"Store-Identifier"?: number,
|
|
115
|
+
currency?: string | 'SAR',
|
|
116
|
+
"accept-language"?: string | 'ar',
|
|
117
|
+
Authorization?: string
|
|
118
|
+
}
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
request(endPoint: string, formData?: object, method?: string | 'get' | 'post' | 'put', options?: object): Promise<any>
|
|
120
121
|
|
|
121
|
-
|
|
122
|
+
handleAfterResponseActions(response: SuccessResponse | ErrorResponse | any): void;
|
|
122
123
|
|
|
123
|
-
|
|
124
|
+
fireEventsForResponse(response: SuccessResponse | ErrorResponse | any): void;
|
|
124
125
|
|
|
125
|
-
|
|
126
|
+
showAlert(response: SuccessResponse | ErrorResponse | any): void;
|
|
126
127
|
|
|
127
|
-
|
|
128
|
+
handleErrorResponse(error: object): void;
|
|
128
129
|
|
|
129
|
-
|
|
130
|
+
handleInvalidFields(error: object): void;
|
|
130
131
|
|
|
131
|
-
|
|
132
|
+
errorPromise(data: any): Promise<any>;
|
|
132
133
|
|
|
133
|
-
|
|
134
|
+
successPromise(data: any): Promise<any>;
|
|
134
135
|
|
|
135
|
-
|
|
136
|
+
isFastRequestsAllowed(): boolean;
|
|
136
137
|
}
|
package/types/api/order.d.ts
CHANGED
|
@@ -16,9 +16,81 @@ export interface SendInvoicePayload {
|
|
|
16
16
|
id: number
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
export interface OrderRequestParameters {
|
|
20
|
+
branch?: Array<number>;
|
|
21
|
+
city?: string;
|
|
22
|
+
country?: number;
|
|
23
|
+
coupon?: string;
|
|
24
|
+
customer_id?: number;
|
|
25
|
+
expanded?: boolean;
|
|
26
|
+
from_date?: string;
|
|
27
|
+
keyword?: string;
|
|
28
|
+
page?: number;
|
|
29
|
+
payment_method?: Array<string>;
|
|
30
|
+
product?: string;
|
|
31
|
+
reference_id?: number;
|
|
32
|
+
shipping_app_id?: Array<number>;
|
|
33
|
+
source?: Array<'store' | 'landing' | 'forgotten_basket' | 'abandoned-cart' | 'campaign' | 'dashboard' | 'buy_as_gift' | 'mahly-app' | 'buy_now' | 'one-click' | 'complete_order'>;
|
|
34
|
+
status?: Array<number>;
|
|
35
|
+
tags?: Array<number>;
|
|
36
|
+
to_date?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface OrderResponse {
|
|
40
|
+
id?: number;
|
|
41
|
+
reference_id?: number;
|
|
42
|
+
source?: string;
|
|
43
|
+
url?: string;
|
|
44
|
+
created_at?: string;
|
|
45
|
+
total?: Total;
|
|
46
|
+
date?: DateClass;
|
|
47
|
+
status?: Status;
|
|
48
|
+
can_cancel?: boolean;
|
|
49
|
+
can_reorder?: boolean;
|
|
50
|
+
is_pending_payment?: boolean;
|
|
51
|
+
pending_payment_ends_at?: number;
|
|
52
|
+
items?: Item[];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface DateClass {
|
|
56
|
+
date?: Date;
|
|
57
|
+
timezone_type?: number;
|
|
58
|
+
timezone?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface Item {
|
|
62
|
+
name?: string;
|
|
63
|
+
quantity?: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface Status {
|
|
67
|
+
id?: number;
|
|
68
|
+
name?: string;
|
|
69
|
+
slug?: string;
|
|
70
|
+
color?: string;
|
|
71
|
+
customized?: Customized;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface Customized {
|
|
75
|
+
id?: number;
|
|
76
|
+
name?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface Total {
|
|
80
|
+
amount?: number;
|
|
81
|
+
currency?: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
export interface FetchOrdersResponse extends SuccessResponse {
|
|
86
|
+
data: Array<OrderResponse>;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
|
|
19
90
|
export default interface OrderApi {
|
|
20
91
|
createCartFromOrder: (order_id?: number) => Promise<CreateCartFromOrderResponse>;
|
|
21
92
|
cancel: (order_id?: number) => Promise<SuccessResponse>;
|
|
22
93
|
sendInvoice: (payload: SendInvoicePayload) => Promise<SuccessResponse>;
|
|
23
94
|
show: (payload: ShowOrderPayload) => Promise<void>; //should be called from thank you page to trigger native order details page in apps
|
|
95
|
+
fetch: (payload: OrderRequestParameters) => Promise<FetchOrdersResponse>;
|
|
24
96
|
}
|
package/types/common.d.ts
CHANGED
|
@@ -9,6 +9,15 @@ export interface Price {
|
|
|
9
9
|
currency: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export interface Pagination {
|
|
13
|
+
count?: number;
|
|
14
|
+
total?: number;
|
|
15
|
+
perPage?: number;
|
|
16
|
+
currentPage?: number;
|
|
17
|
+
totalPages?: number;
|
|
18
|
+
links?: Array<string>;
|
|
19
|
+
}
|
|
20
|
+
|
|
12
21
|
export interface SuccessResponse {
|
|
13
22
|
status: 200;
|
|
14
23
|
success: true;
|
|
@@ -17,6 +26,7 @@ export interface SuccessResponse {
|
|
|
17
26
|
events?: { [event_name: string]: any };
|
|
18
27
|
[key: string]: any;
|
|
19
28
|
};
|
|
29
|
+
pagination?: Pagination
|
|
20
30
|
}
|
|
21
31
|
|
|
22
32
|
export interface ErrorResponse {
|
|
@@ -3,6 +3,10 @@ import { ComponentApiResponse } from "../api/component";
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export default interface ComponentEvent {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
onMenuFetched: (callback: (response: ComponentApiResponse.menus) => void) => void;
|
|
7
|
+
onMenuFetchFailed: RequestErrorEvent;
|
|
8
|
+
|
|
9
|
+
// Reviews
|
|
10
|
+
onReviewsFetched: (callback: (response: ComponentApiResponse.reviews) => void) => void;
|
|
11
|
+
onReviewsFetchFailed: RequestErrorEvent;
|
|
8
12
|
}
|
package/types/event/order.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {RequestError, SuccessResponse} from "../common";
|
|
2
|
-
import {CreateCartFromOrderResponse} from "../api/order";
|
|
2
|
+
import {CreateCartFromOrderResponse, FetchOrdersResponse} from "../api/order";
|
|
3
3
|
|
|
4
4
|
export default interface OrderEvent {
|
|
5
5
|
onCanceled: (callback: (response: SuccessResponse, order_id?: number) => void) => void;
|
|
@@ -8,4 +8,6 @@ export default interface OrderEvent {
|
|
|
8
8
|
onOrderCreationFailed: (callback: (error: RequestError, order_id?: number) => void) => void;
|
|
9
9
|
onInvoiceSent: (callback: (response: SuccessResponse, order_id?: number) => void) => void;
|
|
10
10
|
onInvoiceNotSent: (callback: (error: RequestError | 'There is no id!', order_id?: number) => void) => void;
|
|
11
|
+
onOrdersFetched: (callback: (response: FetchOrdersResponse) => void) => void;
|
|
12
|
+
onOrdersNotFetched: (callback: (error: RequestError) => void) => void;
|
|
11
13
|
}
|