@salla.sa/twilight 2.2.7 → 2.3.0
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 +2 -2
- package/types/api/cart/response.d.ts +1 -1
- package/types/api/product/index.d.ts +5 -3
- package/types/api/product/request.d.ts +18 -0
- package/types/api/product/response.d.ts +31 -1
- package/types/event/product.d.ts +13 -4
- package/types/api/gift.d.ts +0 -27
- package/types/event/gift.d.ts +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salla.sa/twilight",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Salla Theme Toolkit, Webcomponents, Events, Requests, Utils",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
51
51
|
"babel-loader": "^8.2.5",
|
|
52
52
|
"glob": "^8.0.3",
|
|
53
|
-
"rollup": "^2.77.
|
|
53
|
+
"rollup": "^2.77.3",
|
|
54
54
|
"rollup-plugin-cleaner": "^1.0.0",
|
|
55
55
|
"rollup-plugin-node-resolve": "^5.2.0",
|
|
56
56
|
"rollup-plugin-terser": "^7.0.2",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {SuccessResponse} from "../../common";
|
|
2
|
-
import {ProductResponse} from "./response";
|
|
3
|
-
import {ProductRequest} from "./request";
|
|
1
|
+
import { SuccessResponse } from "../../common";
|
|
2
|
+
import { ProductResponse } from "./response";
|
|
3
|
+
import { ProductRequest } from "./request";
|
|
4
4
|
|
|
5
5
|
export * from "./request";
|
|
6
6
|
export * from "./response";
|
|
@@ -11,4 +11,6 @@ export default interface ProductApi {
|
|
|
11
11
|
search: (keyword: string | ProductRequest.search) => Promise<ProductResponse.search>;
|
|
12
12
|
categories: (categoryId?: number) => Promise<ProductResponse.categories>; //get all categories or sub_categories
|
|
13
13
|
offers: (product_id: number) => Promise<ProductResponse.offers>; //get all categories or sub_categories
|
|
14
|
+
getGiftDetails: (product_id: number) => Promise<ProductResponse.giftResponse>;
|
|
15
|
+
addGiftToCart: (product_id: number, payload: Object, withRedirect: boolean);
|
|
14
16
|
}
|
|
@@ -8,6 +8,14 @@ export interface Category {
|
|
|
8
8
|
|
|
9
9
|
export type ProductOption = { [key: number]: number | string | number[] };
|
|
10
10
|
|
|
11
|
+
|
|
12
|
+
export interface Receiver {
|
|
13
|
+
name: string;
|
|
14
|
+
country_code: string;
|
|
15
|
+
mobile: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
11
19
|
export namespace ProductRequest {
|
|
12
20
|
export interface addItem {
|
|
13
21
|
id: number;
|
|
@@ -32,4 +40,14 @@ export namespace ProductRequest {
|
|
|
32
40
|
country_code?: string | 'SA';//required when request without email
|
|
33
41
|
phone?: string | '555555555';//required when request without email
|
|
34
42
|
}
|
|
43
|
+
|
|
44
|
+
export interface giftToCart {
|
|
45
|
+
text: string;
|
|
46
|
+
sender_name: string;
|
|
47
|
+
receiver: Receiver;
|
|
48
|
+
quantity: number;
|
|
49
|
+
deliver_at: string;
|
|
50
|
+
image_url: string;
|
|
51
|
+
time_zone: string;
|
|
52
|
+
}
|
|
35
53
|
}
|
|
@@ -37,6 +37,27 @@ export interface Offer {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Gifting System
|
|
42
|
+
*/
|
|
43
|
+
export interface Gift {
|
|
44
|
+
quantity: number;
|
|
45
|
+
product: Product;
|
|
46
|
+
sender_name: string;
|
|
47
|
+
images: GiftImage[];
|
|
48
|
+
texts: GiftText[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface GiftImage {
|
|
52
|
+
id: number;
|
|
53
|
+
url: string;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface GiftText {
|
|
57
|
+
id: number;
|
|
58
|
+
text: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
40
61
|
export namespace ProductResponse {
|
|
41
62
|
export interface search extends SuccessResponse {
|
|
42
63
|
data: Product[];
|
|
@@ -67,7 +88,16 @@ export namespace ProductResponse {
|
|
|
67
88
|
export interface sizeGuides extends SuccessResponse {
|
|
68
89
|
data: Array<SizeGuide>;
|
|
69
90
|
}
|
|
70
|
-
|
|
71
91
|
|
|
92
|
+
export interface giftResponse extends SuccessResponse {
|
|
93
|
+
data: Gift
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface giftToCart extends SuccessResponse {
|
|
97
|
+
data: Object
|
|
98
|
+
}
|
|
72
99
|
|
|
100
|
+
export interface giftImageUpload extends SuccessResponse {
|
|
101
|
+
data: Object | String
|
|
102
|
+
}
|
|
73
103
|
}
|
package/types/event/product.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {OfferSummary} from "../api/cart";
|
|
2
|
-
import {ProductResponse} from "../api/product";
|
|
3
|
-
import {RequestError, RequestErrorEvent, RequestErrorEventWithData, SuccessResponse} from "../common";
|
|
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;
|
|
@@ -10,7 +10,7 @@ export default interface ProductEvent {
|
|
|
10
10
|
onCategoriesFetched: (callback: (response: ProductResponse.categories) => void) => void;
|
|
11
11
|
onCategoriesFailed: RequestError;
|
|
12
12
|
onSearchResults: (callback: (response: ProductResponse.search, query?: string) => void) => void;
|
|
13
|
-
onSearchFailed: RequestErrorEventWithData</*query*/string|undefined>;
|
|
13
|
+
onSearchFailed: RequestErrorEventWithData</*query*/string | undefined>;
|
|
14
14
|
|
|
15
15
|
onOfferExisted: (callback: (offer: OfferSummary) => void) => void;
|
|
16
16
|
onOffersFetched: (callback: (response: ProductResponse.offers) => void) => void;
|
|
@@ -18,4 +18,13 @@ export default interface ProductEvent {
|
|
|
18
18
|
|
|
19
19
|
onSizeGuideFetched: (callback: (response: ProductResponse.sizeGuides, prod_id: number) => void) => void;
|
|
20
20
|
onSizeGuideFetchFailed: RequestErrorEvent;
|
|
21
|
+
|
|
22
|
+
onGiftFetched: (callback: (response: ProductResponse.giftResponse, product_id: number) => void) => void;
|
|
23
|
+
onGiftFetchFailed: RequestErrorEvent;
|
|
24
|
+
|
|
25
|
+
onAddGiftToCartSucceeded: (callback: (response: ProductResponse.giftToCart, product_id: number) => void) => void;
|
|
26
|
+
onAddGiftToCartFailed: RequestErrorEvent;
|
|
27
|
+
|
|
28
|
+
onGiftImageUploadSucceeded: (callback: (response: ProductResponse.giftImageUpload) => void) => void;
|
|
29
|
+
onGiftImageUploadFailed: RequestErrorEvent;
|
|
21
30
|
}
|
package/types/api/gift.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {SuccessResponse} from "../common";
|
|
2
|
-
|
|
3
|
-
export interface GiftPayload {
|
|
4
|
-
id: number;
|
|
5
|
-
image?: BinaryType;
|
|
6
|
-
image_url_id?: number;
|
|
7
|
-
text_id?: number;//required if text not provided
|
|
8
|
-
text?: string;//required if text_id not provided
|
|
9
|
-
sender_name?: string;
|
|
10
|
-
receiver: {
|
|
11
|
-
name: string;
|
|
12
|
-
mobile: number;
|
|
13
|
-
country_code: string | 'SA';
|
|
14
|
-
email?: string;
|
|
15
|
-
};
|
|
16
|
-
deliver_at: string | '2022-02-22 02:22 pm';
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface GiftResponse extends SuccessResponse {
|
|
20
|
-
data:{
|
|
21
|
-
redirect: string;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export default interface GiftApi {
|
|
26
|
-
buy: (GiftPayload) => Promise<GiftResponse>;
|
|
27
|
-
}
|
package/types/event/gift.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { RequestErrorEventWithData} from "../common";
|
|
2
|
-
import {GiftResponse} from "../api/gift";
|
|
3
|
-
|
|
4
|
-
export default interface GiftEvent {
|
|
5
|
-
onBuyingSucceeded: (callback: (response: GiftResponse, product_id: number) => void) => void;
|
|
6
|
-
onBuyingFailed: RequestErrorEventWithData</*product_id*/number|undefined>;
|
|
7
|
-
}
|