@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
|
@@ -3,7 +3,7 @@ import {RequestErrorEvent} from "../common";
|
|
|
3
3
|
|
|
4
4
|
export default interface CurrencyEvent {
|
|
5
5
|
changed: (callback: (response: ChangeCurrencyResponse, currency: 'SAR' | string) => void) => void;
|
|
6
|
-
fetched: (callback: (response: ListCurrenciesResponse, currency: 'SAR' | string) => void) => void
|
|
7
|
-
failed: RequestErrorEvent
|
|
8
|
-
failedToFetch: RequestErrorEvent
|
|
6
|
+
fetched: (callback: (response: ListCurrenciesResponse, currency: 'SAR' | string) => void) => void;
|
|
7
|
+
failed: RequestErrorEvent;
|
|
8
|
+
failedToFetch: RequestErrorEvent;
|
|
9
9
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RequestError} from "../common";
|
|
2
2
|
|
|
3
3
|
export interface requestPayload {
|
|
4
|
-
namespace: string | 'cart'
|
|
5
|
-
action: string | 'latest'
|
|
6
|
-
hook: string | 'latest'
|
|
7
|
-
url: string | 'cart/latest'
|
|
8
|
-
payload: {} | { params: {} }
|
|
9
|
-
method: 'get' | 'post' | 'put' | 'delete'
|
|
10
|
-
headers
|
|
4
|
+
namespace: string | 'cart';
|
|
5
|
+
action: string | 'latest';
|
|
6
|
+
hook: string | 'latest';
|
|
7
|
+
url: string | 'cart/latest';
|
|
8
|
+
payload: {} | { params: {} };
|
|
9
|
+
method: 'get' | 'post' | 'put' | 'delete';
|
|
10
|
+
headers?: {};
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export default interface DocumentEvent {
|
package/types/event/gift.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RequestErrorEventWithData} from "../common";
|
|
2
2
|
import {GiftResponse} from "../api/gift";
|
|
3
3
|
|
|
4
4
|
export default interface GiftEvent {
|
|
5
5
|
onBuyingSucceeded: (callback: (response: GiftResponse, product_id: number) => void) => void;
|
|
6
|
-
onBuyingFailed: RequestErrorEventWithData</*product_id*/
|
|
6
|
+
onBuyingFailed: RequestErrorEventWithData</*product_id*/number|undefined>;
|
|
7
7
|
}
|
package/types/event/index.d.ts
CHANGED
package/types/event/order.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {RequestError, SuccessResponse} from "../common";
|
|
2
2
|
import {ReOrderResponse} from "../api/order";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export default interface OrderEvent {
|
|
6
|
-
onCanceled: (callback: (response:
|
|
7
|
-
onNotCanceled: (callback: (error: RequestError, order_id
|
|
8
|
-
onReOrdered: (callback: (response: ReOrderResponse, order_id
|
|
9
|
-
onReOrderFailed: (callback: (error: RequestError, order_id
|
|
10
|
-
onSent: (callback: (response:
|
|
11
|
-
onNotSent: (callback: (error: RequestError | 'There is no id!', order_id
|
|
6
|
+
onCanceled: (callback: (response: SuccessResponse, order_id?: number) => void) => void;
|
|
7
|
+
onNotCanceled: (callback: (error: RequestError, order_id?: number) => void) => void;
|
|
8
|
+
onReOrdered: (callback: (response: ReOrderResponse, order_id?: number) => void) => void;
|
|
9
|
+
onReOrderFailed: (callback: (error: RequestError, order_id?: number) => void) => void;
|
|
10
|
+
onSent: (callback: (response: SuccessResponse, order_id?: number) => void) => void;
|
|
11
|
+
onNotSent: (callback: (error: RequestError | 'There is no id!', order_id?: number) => void) => void;
|
|
12
12
|
}
|
package/types/event/product.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {GetPriceResponse} from "../api/product";
|
|
2
|
-
import {RequestErrorEventWithData,
|
|
2
|
+
import {RequestErrorEventWithData, SuccessResponse} from "../common";
|
|
3
3
|
|
|
4
4
|
export default interface ProductEvent {
|
|
5
5
|
onPriceUpdated: (callback: (response: GetPriceResponse, product_id: number) => void) => void;
|
|
6
6
|
onPriceUpdateFailed: RequestErrorEventWithData</*product_id*/ number>;
|
|
7
|
-
onAvailabilitySubscribed: (callback: (response:
|
|
7
|
+
onAvailabilitySubscribed: (callback: (response: SuccessResponse, product_id: number) => void) => void;
|
|
8
8
|
onAvailabilitySubscribeFailed: RequestErrorEventWithData</*product_id*/ number>;
|
|
9
9
|
}
|
package/types/event/rating.d.ts
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
OrderDetailsResponse,
|
|
4
|
-
RatingStorePayload,
|
|
5
|
-
RatingProductsPayload, RatingShippingPayload
|
|
6
|
-
} from "../api/rating";
|
|
7
|
-
import {RequestErrorEventWithData} from "../common";
|
|
1
|
+
import {OrderDetailsResponse, RatingStorePayload, RatingProductsPayload, RatingShippingPayload} from "../api/rating";
|
|
2
|
+
import {RequestErrorEventWithData, SuccessResponse} from "../common";
|
|
8
3
|
|
|
9
4
|
export default interface RatingEvent {
|
|
10
5
|
onOrderFetched: (callback: (response: OrderDetailsResponse, order_id: number) => void) => void;
|
|
11
6
|
onOrderNotFetched: RequestErrorEventWithData</*order_id*/number>;
|
|
12
|
-
onStoreRated: (callback: (response:
|
|
7
|
+
onStoreRated: (callback: (response: SuccessResponse, data: RatingStorePayload) => void) => void;
|
|
13
8
|
onStoreFailed: RequestErrorEventWithData</*data*/RatingStorePayload>;
|
|
14
|
-
onProductRated: (callback: (response:
|
|
9
|
+
onProductRated: (callback: (response: SuccessResponse, data: RatingProductsPayload) => void) => void;
|
|
15
10
|
onProductFailed: RequestErrorEventWithData</*data*/RatingProductsPayload>;
|
|
16
|
-
onShippingRated: (callback: (response:
|
|
11
|
+
onShippingRated: (callback: (response: SuccessResponse, data: RatingShippingPayload) => void) => void;
|
|
17
12
|
onShippingFailed: RequestErrorEventWithData</*data*/RatingShippingPayload>;
|
|
18
13
|
}
|
package/types/event/search.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { RequestErrorEventWithData} from "../common";
|
|
2
|
+
import {SearchProductsResponse} from "../api/search";
|
|
3
3
|
|
|
4
4
|
export default interface SearchEvent {
|
|
5
|
-
onFinished: (callback: (response:
|
|
6
|
-
onFailed: RequestErrorEventWithData</*query*/
|
|
5
|
+
onFinished: (callback: (response: SearchProductsResponse, query?: string) => void) => void;
|
|
6
|
+
onFailed: RequestErrorEventWithData</*query*/string|undefined>;
|
|
7
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {RequestErrorEventWithData,
|
|
1
|
+
import {RequestErrorEventWithData, SuccessResponse} from "../common";
|
|
2
2
|
|
|
3
3
|
export default interface WishlistEvent {
|
|
4
|
-
onAdded: (callback: (response:
|
|
5
|
-
onRemoved: (callback: (response:
|
|
4
|
+
onAdded: (callback: (response: SuccessResponse, product_id: number) => void) => void;
|
|
5
|
+
onRemoved: (callback: (response: SuccessResponse, product_id: number) => void) => void;
|
|
6
6
|
onAdditionFailed: RequestErrorEventWithData</*product_id*/number>;
|
|
7
7
|
onRemovingFailed: RequestErrorEventWithData</*product_id*/number>;
|
|
8
8
|
}
|
|
@@ -3,14 +3,14 @@ import {Price} from "../common";
|
|
|
3
3
|
export type UrlHelper = (path: string) => string; //add any path to current url, ex: `salla.url('cart?anything=data')` output => `https://store_domain.com/cart?anything=data`
|
|
4
4
|
export default interface SallaHelpers {
|
|
5
5
|
//Numbers helpers
|
|
6
|
-
digitsOnly: (num: string | number) => number
|
|
7
|
-
inputDigitsOnly: (input: string | HTMLInputElement) => number
|
|
8
|
-
number: (num: number) => number | string
|
|
9
|
-
money: (num: number | Price) => string
|
|
6
|
+
digitsOnly: (num: string | number) => number;
|
|
7
|
+
inputDigitsOnly: (input: string | HTMLInputElement) => number;
|
|
8
|
+
number: (num: number) => number | string;
|
|
9
|
+
money: (num: number | Price) => string;
|
|
10
10
|
|
|
11
11
|
//Nested objects helpers
|
|
12
|
-
setNested: (object: Object, key: `${string}.${string}` | string, value: any) => Object
|
|
13
|
-
getNested: (object: Object, key: `${string}.${string}` | string, default_?: any) => any
|
|
12
|
+
setNested: (object: Object, key: `${string}.${string}` | string, value: any) => Object;
|
|
13
|
+
getNested: (object: Object, key: `${string}.${string}` | string, default_?: any) => any;
|
|
14
14
|
/**
|
|
15
15
|
* @example
|
|
16
16
|
* 1- initial data: `let data={items:{total:100,...}};`
|
|
@@ -18,12 +18,12 @@ export default interface SallaHelpers {
|
|
|
18
18
|
* 3- getData as Object: `salla.helpers.inputData('items[total]', 'new-value', data)`
|
|
19
19
|
* 4- output: `{name: items: value:{total:[100, 'new-value'],...}}`
|
|
20
20
|
*/
|
|
21
|
-
inputData: (inputName: `${string}[${null | string | number}]`, inputValue: any, data?: Object) => { name: string, value: string | number | Object | string[] | number[] }
|
|
21
|
+
inputData: (inputName: `${string}[${null | string | number}]`, inputValue: any, data?: Object) => { name: string, value: string | number | Object | string[] | number[] };
|
|
22
22
|
|
|
23
23
|
//Url helpers
|
|
24
|
-
url: UrlHelper
|
|
24
|
+
url: UrlHelper;
|
|
25
25
|
addParamToUrl: (key: string, value: string | number) => string, //`salla.helpers.addParamToUrl('lang','ar')` => `https://store_domain.com/cart?lang=ar`
|
|
26
26
|
|
|
27
27
|
//for advance usage:
|
|
28
|
-
debounce: (callback: Function, delay: number) => (...[]) => Promise<unknown
|
|
28
|
+
debounce: (callback: Function, delay: number) => (...[]) => Promise<unknown>;
|
|
29
29
|
}
|
package/types/api/auth.d.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import {Nullable, TwilightResponse} from "../common";
|
|
2
|
-
|
|
3
|
-
export interface LogoutResponse extends TwilightResponse {
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export interface LoginResponse extends TwilightResponse {
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface VerifyResponse extends TwilightResponse {
|
|
12
|
-
case: 'authenticated' | 'new_customer',
|
|
13
|
-
redirect_url: Nullable<null>,
|
|
14
|
-
token: Nullable<string>,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface ResendResponse extends TwilightResponse {
|
|
18
|
-
data: {
|
|
19
|
-
resend_counter: 2 | 3 | 4,
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface LoginByMobilePayload {
|
|
24
|
-
phone: string;
|
|
25
|
-
type: 'mobile';
|
|
26
|
-
country_code: string | 'SA';
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface LoginByEmailPayload {
|
|
30
|
-
email: string;
|
|
31
|
-
type: 'email';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface VerifyByEmailPayload {
|
|
35
|
-
code: string;
|
|
36
|
-
email: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface VerifyByMobilePayload {
|
|
40
|
-
code: string;
|
|
41
|
-
phone: string,
|
|
42
|
-
country_code: string | "SA",
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface RegisterPayload {
|
|
46
|
-
first_name: string;
|
|
47
|
-
last_name: string;
|
|
48
|
-
phone: string;
|
|
49
|
-
country_code: string | 'SA';
|
|
50
|
-
country_key: string | '+966';
|
|
51
|
-
verified_by: 'email' | 'phone';
|
|
52
|
-
email: Nullable<string>;
|
|
53
|
-
code: number;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface ResendPayload {
|
|
57
|
-
resend_by: 'sms' | 'email',
|
|
58
|
-
phone: string,
|
|
59
|
-
country_code: string | "SA",
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export default interface AuthApi {
|
|
63
|
-
login: (data: LoginByMobilePayload | LoginByEmailPayload) => Promise<LoginResponse>;
|
|
64
|
-
logout: () => Promise<LogoutResponse>;
|
|
65
|
-
verify: (type: 'mobile' | 'email', data: VerifyByMobilePayload | VerifyByEmailPayload, supportWebAuth: boolean) => Promise<VerifyResponse>;
|
|
66
|
-
resend: (data: ResendPayload) => Promise<ResendResponse>,
|
|
67
|
-
register: (data: RegisterPayload) => Promise<VerifyResponse>,
|
|
68
|
-
refresh: () => Promise<VerifyResponse>,
|
|
69
|
-
}
|
package/types/api/cart.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import {Nullable, TwilightResponse} from "../common";
|
|
2
|
-
import {ProductPayload} from "./product";
|
|
3
|
-
|
|
4
|
-
export interface itemOffer {
|
|
5
|
-
discount: number,
|
|
6
|
-
is_free: boolean,
|
|
7
|
-
names: string
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface CartItem {
|
|
11
|
-
id: number,
|
|
12
|
-
product_id: number,
|
|
13
|
-
product_price: number,
|
|
14
|
-
price: number,
|
|
15
|
-
total: number,
|
|
16
|
-
is_available: true,
|
|
17
|
-
offer: Nullable<itemOffer>,
|
|
18
|
-
quantity: number,
|
|
19
|
-
total_special_price: number,
|
|
20
|
-
special_price: number
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface CartSummary {
|
|
24
|
-
id: number,
|
|
25
|
-
user_id: number | string,
|
|
26
|
-
real_shipping_cost: number,
|
|
27
|
-
free_shipping_bar: Nullable<{
|
|
28
|
-
minimum_amount: number,
|
|
29
|
-
has_free_shipping: boolean,
|
|
30
|
-
percent: number | 0 | 100,
|
|
31
|
-
remaining: number
|
|
32
|
-
}>,
|
|
33
|
-
sub_total: number,
|
|
34
|
-
discount: number,
|
|
35
|
-
total: number,
|
|
36
|
-
count: number,
|
|
37
|
-
items: Nullable<CartItem[]>,
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface OfferSummary {
|
|
41
|
-
id: number,
|
|
42
|
-
product_id: number,
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
export interface CartLatestResponse extends TwilightResponse {
|
|
47
|
-
data: {
|
|
48
|
-
cart: {
|
|
49
|
-
id: number;
|
|
50
|
-
user_id: number | string;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface CartUpdateResponse extends TwilightResponse {
|
|
56
|
-
data: {
|
|
57
|
-
product_id: Nullable<number>;
|
|
58
|
-
offer: Nullable<OfferSummary>;
|
|
59
|
-
googleTags: string;//json string
|
|
60
|
-
cart: CartSummary
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
export interface AddToCartResponse extends CartUpdateResponse {
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface UpdateCartItemResponse extends CartUpdateResponse {
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface DeleteCartItemResponse extends CartUpdateResponse {
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export interface CartStatusResponse extends TwilightResponse {
|
|
75
|
-
data: {
|
|
76
|
-
active: boolean;
|
|
77
|
-
next_step: {
|
|
78
|
-
to: 'refresh' | 'login' | 'checkout';
|
|
79
|
-
url: Nullable<string>;
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface AddItemPayload extends ProductPayload {
|
|
85
|
-
notes?: Nullable<string>;
|
|
86
|
-
file?: Nullable<BinaryType | string>;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export default interface CartApi {
|
|
90
|
-
latest: () => Promise<CartLatestResponse>;
|
|
91
|
-
details: () => Promise<CartUpdateResponse>;
|
|
92
|
-
summary: () => Promise<CartUpdateResponse>;
|
|
93
|
-
quickAdd: (product_id: number) => Promise<CartUpdateResponse>;
|
|
94
|
-
addItem: (data: AddItemPayload) => Promise<CartUpdateResponse>;
|
|
95
|
-
deleteItem: (item_id: number) => Promise<CartUpdateResponse>;
|
|
96
|
-
updateItem: (data: AddItemPayload) => Promise<CartUpdateResponse>;
|
|
97
|
-
deleteImage: (file_id: number) => Promise<TwilightResponse>;
|
|
98
|
-
status: () => Promise<CartStatusResponse>;
|
|
99
|
-
reset: () => void;
|
|
100
|
-
submit: () => void;
|
|
101
|
-
}
|