@salla.sa/twilight 2.11.90 → 2.11.92
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 +3 -3
- package/types/api/auth/index.d.ts +6 -2
- package/types/api/auth/response.d.ts +4 -0
- package/types/api/booking.d.ts +2 -2
- package/types/api/cart/index.d.ts +13 -8
- package/types/api/cart/response.d.ts +13 -2
- package/types/api/comment.d.ts +16 -0
- package/types/api/currency.d.ts +6 -1
- package/types/api/index.d.ts +13 -4
- package/types/api/loyalty.d.ts +9 -3
- package/types/api/order.d.ts +11 -2
- package/types/api/product/index.d.ts +3 -1
- package/types/api/product/request.d.ts +7 -0
- package/types/api/product/response.d.ts +9 -2
- package/types/api/profile.d.ts +2 -1
- package/types/api/rating.d.ts +7 -2
- package/types/api/scope.d.ts +1 -1
- package/types/api/wishlist.d.ts +1 -0
- package/types/event/product.d.ts +6 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salla.sa/twilight",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.92",
|
|
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 -- product.test.js",
|
|
12
12
|
"express": "node tests/server/index.js"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"webpack": "^4 || ^5"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "8da3cb22ccdec75291d69699e6be1b21d71a9e7c"
|
|
71
71
|
}
|
|
@@ -4,14 +4,18 @@ export * from "./request";
|
|
|
4
4
|
export * from "./response";
|
|
5
5
|
import {AuthRequest} from "./request";
|
|
6
6
|
import {AuthResponse} from "./response";
|
|
7
|
+
import {ApiActionName} from "../index";
|
|
7
8
|
|
|
8
9
|
export default interface AuthApi {
|
|
9
10
|
canRedirect: () => boolean; //change it to false when you don't want page to reload or redirect automatically after logged in, use `salla.auth.event.onLoggedIn(response=>{...})`
|
|
10
|
-
|
|
11
|
-
login: (data: AuthRequest.loginByMobile | AuthRequest.loginByEmail) => Promise<AuthResponse.loginOrResendCode>;
|
|
11
|
+
login: (data: AuthRequest.loginByMobile | AuthRequest.loginByEmail | object | FormData) => Promise<AuthResponse.loginOrResendCode | AuthResponse.sendVerification>;
|
|
12
12
|
logout: () => Promise<SuccessResponse>;
|
|
13
13
|
verify: (data: AuthRequest.verifyByMobile | AuthRequest.verifyByEmail, supportWebAuth: boolean) => Promise<AuthResponse.verify>;
|
|
14
14
|
resend: (data: AuthRequest.resend) => Promise<AuthResponse.loginOrResendCode>;
|
|
15
15
|
register: (data: AuthRequest.register) => Promise<AuthResponse.verify>;
|
|
16
16
|
refresh: () => Promise<AuthResponse.verify>;
|
|
17
|
+
// Voids
|
|
18
|
+
setAfterLoginEvent: (event: ApiActionName, payload: any) => void;
|
|
19
|
+
setCanRedirect: (canRedirect: boolean) => void;
|
|
20
|
+
afterUserLogin: () => void;
|
|
17
21
|
}
|
|
@@ -14,6 +14,10 @@ export namespace AuthResponse {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
export interface sendVerification extends SuccessResponse {
|
|
18
|
+
data: VerificationStatus
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
export interface loginOrResendCode extends SuccessResponse {
|
|
18
22
|
data: {
|
|
19
23
|
resend_counter?: 2 | 3 | 4;//when resend code
|
package/types/api/booking.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {SuccessResponse} from '../common'
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
export interface RedirectPayload {
|
|
@@ -17,5 +17,5 @@ export namespace BookingApiResponse {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export default interface BookingApi {
|
|
20
|
-
add: (productId: number) => Promise<BookingApiResponse.add>
|
|
20
|
+
add: (productId: number, withRedirect: boolean) => Promise<BookingApiResponse.add>
|
|
21
21
|
}
|
|
@@ -1,27 +1,32 @@
|
|
|
1
1
|
export * from "./request";
|
|
2
2
|
export * from "./response";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import {SuccessResponse} from "../../common";
|
|
4
|
+
import {CartResponse} from "./response";
|
|
5
|
+
import {CartRequest} from "./request";
|
|
6
6
|
|
|
7
7
|
export default interface CartApi {
|
|
8
8
|
latest: () => Promise<CartResponse.update>;
|
|
9
|
-
details: () => Promise<CartResponse.update>;
|
|
10
|
-
quickAdd: (/*product_id*/id: number) => Promise<CartResponse.update>;
|
|
9
|
+
details: (cartId: number | null, withItems: ['options' | 'attachments']) => Promise<CartResponse.update>;
|
|
10
|
+
quickAdd: (/*product_id*/id: number, quantity: number) => Promise<CartResponse.update>;
|
|
11
11
|
addItem: (data: CartRequest.addItem) => Promise<CartResponse.update>;
|
|
12
12
|
deleteItem: (item_id: number) => Promise<CartResponse.update>;
|
|
13
13
|
updateItem: (data: CartRequest.addItem) => Promise<CartResponse.update>;
|
|
14
14
|
deleteImage: (file_id: number) => Promise<SuccessResponse>;
|
|
15
|
-
status: () => Promise<CartResponse.status>;
|
|
15
|
+
status: (cartId: number) => Promise<CartResponse.status>;
|
|
16
16
|
reset: () => void;
|
|
17
17
|
submit: () => void;
|
|
18
18
|
|
|
19
|
+
getCurrentCartId: () => Promise<number>;
|
|
20
|
+
getCartPayload: (productIdOrObject: CartRequest.addItem) => CartResponse.cartPayload;
|
|
21
|
+
normalRequest: (endpoint: string, formData?: Object, method?: string) => Promise<any>;
|
|
22
|
+
priceQuote: (cartId: number) => Promise<CartResponse.PriceQuote>;
|
|
23
|
+
|
|
19
24
|
getUploadImageEndpoint: (cartId?: number) => string;
|
|
20
25
|
|
|
21
26
|
getQuickOrderSettings: () => Promise<CartResponse.quickOrderSettingResponse>;
|
|
22
27
|
createQuickOrder: (payload: CartRequest.quickOrderPayload) => Promise<SuccessResponse>;
|
|
23
28
|
|
|
24
29
|
//coupons
|
|
25
|
-
addCoupon: (coupon: string) => Promise<CartResponse.
|
|
26
|
-
deleteCoupon: () => Promise<CartResponse.
|
|
30
|
+
addCoupon: (coupon: string | Object | FormData) => Promise<CartResponse.latest>;
|
|
31
|
+
deleteCoupon: () => Promise<CartResponse.latest>;
|
|
27
32
|
}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {SuccessResponse} from "../../common";
|
|
2
|
+
import {CartRequest} from "./request";
|
|
3
|
+
|
|
2
4
|
export namespace CartResponse {
|
|
5
|
+
export interface latest extends SuccessResponse {
|
|
6
|
+
data: CartSummary;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface cartPayload {
|
|
10
|
+
id: number,
|
|
11
|
+
payload: CartRequest.addItem
|
|
12
|
+
}
|
|
13
|
+
|
|
3
14
|
export interface update extends SuccessResponse {
|
|
4
15
|
data: CartUpdatedData;
|
|
5
16
|
}
|
|
@@ -81,7 +92,7 @@ export interface QuickOrderSetting {
|
|
|
81
92
|
is_email_required: boolean;
|
|
82
93
|
show_agreement: boolean;
|
|
83
94
|
allowed_countries: string[];
|
|
84
|
-
style: 'default'|'white'|'gray';
|
|
95
|
+
style: 'default' | 'white' | 'gray';
|
|
85
96
|
confirm_button: string;
|
|
86
97
|
agreement: string;
|
|
87
98
|
}
|
package/types/api/comment.d.ts
CHANGED
|
@@ -7,12 +7,28 @@ export interface AddCommentResponse extends SuccessResponse {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export interface FetchCommentsResponse extends SuccessResponse {
|
|
11
|
+
data: any[]
|
|
12
|
+
}
|
|
13
|
+
|
|
10
14
|
export interface AddCommentPayload {
|
|
11
15
|
id: number;
|
|
12
16
|
comment: string;
|
|
13
17
|
type: 'product' | 'page';
|
|
14
18
|
}
|
|
15
19
|
|
|
20
|
+
export interface CommentPayload {
|
|
21
|
+
id: number;
|
|
22
|
+
comment: string;
|
|
23
|
+
type: 'product' | 'page';
|
|
24
|
+
'per_page': number | null,
|
|
25
|
+
'page': number | null
|
|
26
|
+
}
|
|
27
|
+
|
|
16
28
|
export default interface CommentApi {
|
|
17
29
|
add: (data: AddCommentPayload) => Promise<AddCommentResponse>;
|
|
30
|
+
getCommentPayload: (data: AddCommentPayload) => CommentPayload;
|
|
31
|
+
fetch: (data: AddCommentPayload) => Promise<FetchCommentsResponse>;
|
|
32
|
+
getPageComments: (pageId: number, page: number, per_page: number) => Promise<FetchCommentsResponse>;
|
|
33
|
+
getProductComments: (productId: number, page: number, per_page: number) => Promise<FetchCommentsResponse>;
|
|
18
34
|
}
|
package/types/api/currency.d.ts
CHANGED
|
@@ -11,7 +11,12 @@ export interface ListCurrenciesResponse extends SuccessResponse {
|
|
|
11
11
|
data: Array<Currency>
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
export interface CurrencyPayload {
|
|
15
|
+
currency: string | null;
|
|
16
|
+
code: string | null;
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
export default interface CurrencyApi {
|
|
15
|
-
change: (currency_code:
|
|
20
|
+
change: (currency_code: CurrencyPayload | string) => Promise<ChangeCurrencyResponse>;
|
|
16
21
|
list: () => Promise<ListCurrenciesResponse>;
|
|
17
22
|
}
|
package/types/api/index.d.ts
CHANGED
|
@@ -11,9 +11,9 @@ 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, {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
14
|
+
import BookingApi, {Booking} from "./booking";
|
|
15
|
+
import {AxiosInstance} from "axios";
|
|
16
|
+
import {ErrorResponse, SuccessResponse} from "@salla.sa/base/types/common";
|
|
17
17
|
|
|
18
18
|
export {
|
|
19
19
|
CartApi,
|
|
@@ -115,13 +115,22 @@ export default interface Api {
|
|
|
115
115
|
"accept-language"?: string | 'ar',
|
|
116
116
|
Authorization?: string
|
|
117
117
|
}
|
|
118
|
-
|
|
118
|
+
|
|
119
|
+
request(endPoint: string, formData?: object, method?: string | 'get' | 'post' | 'put', options?: object): Promise<any>
|
|
120
|
+
|
|
119
121
|
handleAfterResponseActions(response: SuccessResponse | ErrorResponse | any): void;
|
|
122
|
+
|
|
120
123
|
fireEventsForResponse(response: SuccessResponse | ErrorResponse | any): void;
|
|
124
|
+
|
|
121
125
|
showAlert(response: SuccessResponse | ErrorResponse | any): void;
|
|
126
|
+
|
|
122
127
|
handleErrorResponse(error: object): void;
|
|
128
|
+
|
|
123
129
|
handleInvalidFields(error: object): void;
|
|
130
|
+
|
|
124
131
|
errorPromise(data: any): Promise<any>;
|
|
132
|
+
|
|
125
133
|
successPromise(data: any): Promise<any>;
|
|
134
|
+
|
|
126
135
|
isFastRequestsAllowed(): boolean;
|
|
127
136
|
}
|
package/types/api/loyalty.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {SuccessResponse} from '../common'
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
export interface Loyalty {
|
|
@@ -205,6 +205,12 @@ export interface ExchangePrize {
|
|
|
205
205
|
points: number;
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
+
export interface PrizeObject {
|
|
209
|
+
'id': number | null,
|
|
210
|
+
'loyalty_prize_id': number | null,
|
|
211
|
+
'prize_id': number | null
|
|
212
|
+
}
|
|
213
|
+
|
|
208
214
|
|
|
209
215
|
export namespace LoyaltyApiResponse {
|
|
210
216
|
|
|
@@ -221,6 +227,6 @@ export namespace LoyaltyApiResponse {
|
|
|
221
227
|
|
|
222
228
|
export default interface LoyaltyApi {
|
|
223
229
|
getProgram: () => Promise<LoyaltyApiResponse.program>
|
|
224
|
-
exchange: (prize_id: number, cart_id?: number) => Promise<LoyaltyApiResponse.point>
|
|
225
|
-
reset: () => Promise<SuccessResponse>
|
|
230
|
+
exchange: (prize_id: number | PrizeObject, cart_id?: number) => Promise<LoyaltyApiResponse.point>
|
|
231
|
+
reset: (cart_id?: number) => Promise<SuccessResponse>
|
|
226
232
|
}
|
package/types/api/order.d.ts
CHANGED
|
@@ -7,9 +7,18 @@ export interface CreateCartFromOrderResponse extends SuccessResponse {
|
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export interface ShowOrderPayload {
|
|
11
|
+
order_id: number,
|
|
12
|
+
url: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface SendInvoicePayload {
|
|
16
|
+
id: number
|
|
17
|
+
}
|
|
18
|
+
|
|
10
19
|
export default interface OrderApi {
|
|
11
20
|
createCartFromOrder: (order_id?: number) => Promise<CreateCartFromOrderResponse>;
|
|
12
21
|
cancel: (order_id?: number) => Promise<SuccessResponse>;
|
|
13
|
-
sendInvoice: (
|
|
14
|
-
show: (payload:
|
|
22
|
+
sendInvoice: (payload: SendInvoicePayload) => Promise<SuccessResponse>;
|
|
23
|
+
show: (payload: ShowOrderPayload) => Promise<void>; //should be called from thank you page to trigger native order details page in apps
|
|
15
24
|
}
|
|
@@ -15,5 +15,7 @@ export default interface ProductApi {
|
|
|
15
15
|
getGiftDetails: (product_id: number) => Promise<ProductResponse.giftResponse>;
|
|
16
16
|
addGiftToCart: (product_id: number, payload: Object, withRedirect: boolean) => Promise<ProductResponse.giftToCart>;
|
|
17
17
|
uploadGiftImage: (multiPartData: FormData) => Promise<ProductResponse.giftImageUpload>;
|
|
18
|
-
getDetails: (product_id: number,
|
|
18
|
+
getDetails: (product_id: number, withItems: Array<'images' | 'brand' | 'tags' | 'notify_availability' | 'rating' | 'donation' | 'options' | 'sold_quantity' | 'category'>) => Promise<ProductResponse.detail>;
|
|
19
|
+
getSizeGuides: (product_id: number) => Promise<ProductResponse.sizeGuides>;
|
|
20
|
+
fetch: (queryParam: ProductRequest.FetchProductsQueryParams) => Promise<ProductResponse.lists>
|
|
19
21
|
}
|
|
@@ -50,4 +50,11 @@ export namespace ProductRequest {
|
|
|
50
50
|
image_url: string;
|
|
51
51
|
time_zone: string;
|
|
52
52
|
}
|
|
53
|
+
|
|
54
|
+
export interface FetchProductsQueryParams {
|
|
55
|
+
source: 'categories' | 'latest' | 'related' | 'brands' | 'json' | 'search' | 'tags' | 'selected' | 'offers' | 'landing-page';
|
|
56
|
+
sourceValue: number | string | object | string[];
|
|
57
|
+
filters?: object;
|
|
58
|
+
limit?: number;
|
|
59
|
+
}
|
|
53
60
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {Category as ShortCategory, Product, SuccessResponse} from "../../common";
|
|
2
|
+
import {Category} from "./request";
|
|
3
|
+
|
|
3
4
|
type offerType = 'buy_x_get_y' | 'percentage' | 'fixed_amount';
|
|
4
5
|
type paymentMethod = {
|
|
5
6
|
id: number;
|
|
6
7
|
slug: 'bank';
|
|
7
8
|
name: 'BankTransfer';
|
|
8
9
|
};
|
|
10
|
+
|
|
9
11
|
export interface SizeGuide {
|
|
10
12
|
name: string;
|
|
11
13
|
description: string;
|
|
12
14
|
}
|
|
15
|
+
|
|
13
16
|
export interface Offer {
|
|
14
17
|
id: number;
|
|
15
18
|
name: string;
|
|
@@ -275,4 +278,8 @@ export namespace ProductResponse {
|
|
|
275
278
|
export interface detail extends SuccessResponse {
|
|
276
279
|
data: ProductDetail
|
|
277
280
|
}
|
|
281
|
+
|
|
282
|
+
export interface lists extends SuccessResponse {
|
|
283
|
+
data: Array<ProductDetail>
|
|
284
|
+
}
|
|
278
285
|
}
|
package/types/api/profile.d.ts
CHANGED
|
@@ -58,5 +58,6 @@ export default interface ProfileApi {
|
|
|
58
58
|
verify: (data: AuthRequest.verifyByMobile | AuthRequest.verifyByEmail) => Promise<VerifyContactResponse>;
|
|
59
59
|
updateContacts: (data: ProfileUpdateContactPayload) => Promise<ProfileResponse>;//need to verify after success event
|
|
60
60
|
setNotification: (data: NotificationSettingPayload) => Promise<SuccessResponse>;
|
|
61
|
-
|
|
61
|
+
delete: () => Promise<SuccessResponse>;
|
|
62
|
+
updateSettings: (data: NotificationSettingPayload) => Promise<SuccessResponse>;
|
|
62
63
|
}
|
package/types/api/rating.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Product, Rating, SuccessResponse} from "../common";
|
|
2
2
|
|
|
3
3
|
export interface OrderDetailsResponse extends SuccessResponse {
|
|
4
4
|
data: {
|
|
@@ -20,6 +20,11 @@ export interface OrderDetailsResponse extends SuccessResponse {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export interface OrderDetailPayload {
|
|
24
|
+
id: number,
|
|
25
|
+
order_id: number
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
export interface RatingContent {
|
|
24
29
|
content: string;
|
|
25
30
|
rating: Rating;
|
|
@@ -42,7 +47,7 @@ export interface RatingShippingPayload extends RatingStorePayload {
|
|
|
42
47
|
}
|
|
43
48
|
|
|
44
49
|
export default interface RatingApi {
|
|
45
|
-
order: (order_id: number) => Promise<OrderDetailsResponse>;
|
|
50
|
+
order: (order_id: number | OrderDetailPayload) => Promise<OrderDetailsResponse>;
|
|
46
51
|
store: (data: RatingStorePayload) => Promise<SuccessResponse>;
|
|
47
52
|
products: (data: RatingProductsPayload) => Promise<SuccessResponse>;
|
|
48
53
|
shipping: (data: RatingShippingPayload) => Promise<SuccessResponse>;
|
package/types/api/scope.d.ts
CHANGED
package/types/api/wishlist.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export default interface WishlistApi {
|
|
|
4
4
|
add: (product_id: number) => Promise<SuccessResponse>;
|
|
5
5
|
remove: (product_id: number) => Promise<SuccessResponse>;
|
|
6
6
|
toggle: (product_id: number) => Promise<SuccessResponse>;
|
|
7
|
+
updateWishlistStorage: (id: number, isAdded: boolean) => void;
|
|
7
8
|
}
|
package/types/event/product.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {OfferSummary} from "../api/cart";
|
|
2
|
+
import {ProductResponse} from "../api/product";
|
|
3
|
+
import {RequestError, RequestErrorEvent, RequestErrorEventWithData, SuccessResponse} from "../common";
|
|
4
4
|
|
|
5
5
|
export default interface ProductEvent {
|
|
6
6
|
onPriceUpdated: (callback: (response: ProductResponse.getPrice, product_id: number) => void) => void;
|
|
@@ -30,4 +30,7 @@ export default interface ProductEvent {
|
|
|
30
30
|
|
|
31
31
|
onGiftImageUploadSucceeded: (callback: (response: ProductResponse.giftImageUpload) => void) => void;
|
|
32
32
|
onGiftImageUploadFailed: RequestErrorEvent;
|
|
33
|
+
|
|
34
|
+
onProductListFetchSucceeded: (callback: (response: ProductResponse.lists) => void) => void;
|
|
35
|
+
onProductListFetchFailed: RequestErrorEvent;
|
|
33
36
|
}
|