@salla.sa/twilight 2.0.261 → 2.0.263

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salla.sa/twilight",
3
- "version": "2.0.261",
3
+ "version": "2.0.263",
4
4
  "description": "Salla Theme Toolkit, Webcomponents, Events, Requests, Utils",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  AuthApi, CartApi, CommentApi, CurrencyApi, DocumentApi, RatingApi, GiftApi, OfferApi, OrderApi,
3
- ProductApi, ProfileApi, SearchApi, TwilightApi, WishlistApi, LoyaltyApi
3
+ ProductApi, ProfileApi, TwilightApi, WishlistApi, LoyaltyApi
4
4
  } from "./api";
5
5
  import {
6
6
  AuthEvent, CartEvent, CommentEvent, CurrencyEvent, DocumentEvent, RatingEvent, GiftEvent, OfferEvent,
7
- InfiniteScrollEvent, OrderEvent, ProductEvent, ProfileEvent, SearchEvent, TwilightEvent, WishlistEvent, LoyaltyEvent
7
+ InfiniteScrollEvent, OrderEvent, ProductEvent, ProfileEvent, TwilightEvent, WishlistEvent, LoyaltyEvent
8
8
  } from "./event";
9
9
 
10
10
  export default interface SallaActions {
@@ -13,7 +13,6 @@ export default interface SallaActions {
13
13
  gift: GiftApi & { api: GiftApi, event: GiftEvent };
14
14
  order: OrderApi & { api: OrderApi, event: OrderEvent };
15
15
  offer: OfferApi & { api: OfferApi, event: OfferEvent };
16
- search: SearchApi & { api: SearchApi, event: SearchEvent };
17
16
  rating: RatingApi & { api: RatingApi, event: RatingEvent };
18
17
  comment: CommentApi & { api: CommentApi, event: CommentEvent };
19
18
  loyalty: LoyaltyApi & { api: LoyaltyApi, event: LoyaltyEvent };
@@ -4,7 +4,6 @@ import AuthApi from "./auth";
4
4
  import GiftApi from "./gift";
5
5
  import OrderApi from "./order";
6
6
  import OfferApi from "./offer";
7
- import SearchApi from "./search";
8
7
  import RatingApi from "./rating";
9
8
  import CommentApi from "./comment";
10
9
  import LoyaltyApi from "./loyalty";
@@ -21,7 +20,6 @@ export {
21
20
  GiftApi,
22
21
  OrderApi,
23
22
  OfferApi,
24
- SearchApi,
25
23
  RatingApi,
26
24
  CommentApi,
27
25
  LoyaltyApi,
@@ -57,10 +55,10 @@ export type ApiActionName =
57
55
  | 'order.send'
58
56
  | 'offer.increase'
59
57
  | 'offer.details'
60
- | 'search.search'
61
58
  | 'product.getPrice'
62
59
  | 'product.availabilitySubscribe'
63
60
  | 'product.purchaseNow'
61
+ | 'product.search'
64
62
  | 'profile.update'
65
63
  | 'comment.add'
66
64
  | 'currency.change'
@@ -80,7 +78,6 @@ export default interface SallaApi extends Axios {
80
78
  gift: GiftApi;
81
79
  order: OrderApi;
82
80
  offer: OfferApi;
83
- search: SearchApi;
84
81
  rating: RatingApi;
85
82
  comment: CommentApi;
86
83
  loyalty: LoyaltyApi;
@@ -1,6 +1,6 @@
1
1
  import {SuccessResponse} from "../common";
2
2
 
3
- export interface ReOrderResponse extends SuccessResponse {
3
+ export interface CreateCartFromOrderResponse extends SuccessResponse {
4
4
  data: {
5
5
  cart_id: number;
6
6
  url: string;
@@ -8,7 +8,7 @@ export interface ReOrderResponse extends SuccessResponse {
8
8
  }
9
9
 
10
10
  export default interface OrderApi {
11
- reOrder: (order_id?: number) => Promise<ReOrderResponse>;
11
+ createCartFromOrder: (order_id?: number) => Promise<CreateCartFromOrderResponse>;
12
12
  cancel: (order_id?: number) => Promise<SuccessResponse>;
13
13
  sendInvoice: (order_id?: number) => Promise<SuccessResponse>;
14
14
  }
@@ -1,4 +1,4 @@
1
- import { SuccessResponse} from "../common";
1
+ import { Product, SuccessResponse} from "../common";
2
2
 
3
3
  type ProductOption = { [key: number]: number | string | number[] };
4
4
 
@@ -8,6 +8,16 @@ export interface ProductPayload {
8
8
  options?: ProductOption;
9
9
  }
10
10
 
11
+ export interface SearchPayload {
12
+ query: string;
13
+ type?: 'keyword' | 'tag';//default => 'keyword'
14
+ sort_by?: 'ourSuggest' | 'default' | 'bestSell' | 'topRated' | 'priceFromTopToLow' | 'priceFromLowToTop'; //default => 'ourSuggest'
15
+ per_page?: 32 | number;//max 50
16
+ brands?: number[];
17
+ categories?: number[];// max 5 ids
18
+ branches?: number[];// max 5 ids
19
+ }
20
+
11
21
  export interface AvailabilityPayload {
12
22
  id: number;
13
23
  //💡 Following properties required for guests
@@ -15,6 +25,16 @@ export interface AvailabilityPayload {
15
25
  country_code?: string | 'SA';//required when request without email
16
26
  phone?: string | '555555555';//required when request without email
17
27
  }
28
+ export interface ProductsSearchResponse extends SuccessResponse {
29
+ data: Product[];
30
+ cursor: {
31
+ current: number;
32
+ previous?: string;
33
+ next?: string;
34
+ count: number;
35
+ };
36
+ }
37
+
18
38
 
19
39
  export interface GetPriceResponse extends SuccessResponse {
20
40
  data: {
@@ -27,4 +47,5 @@ export interface GetPriceResponse extends SuccessResponse {
27
47
  export default interface ProductApi {
28
48
  getPrice: (data: /*product_id*/number | ProductPayload) => Promise<GetPriceResponse>;
29
49
  availabilitySubscribe: (product_id: number | AvailabilityPayload) => Promise<SuccessResponse>;
50
+ search: (keyword: string | SearchPayload) => Promise<ProductsSearchResponse>;
30
51
  }
@@ -3,7 +3,6 @@ import CartEvent from "./cart";
3
3
  import GiftEvent from "./gift";
4
4
  import OrderEvent from "./order";
5
5
  import OfferEvent from "./offer";
6
- import SearchEvent from "./search";
7
6
  import RatingEvent from "./rating";
8
7
  import CommentEvent from "./comment";
9
8
  import LoyaltyEvent from "./loyalty";
@@ -76,12 +75,12 @@ export type EventName = string
76
75
  | 'rating::products.failed'
77
76
  | 'rating::shipping.rated'
78
77
  | 'rating::shipping.failed'
79
- | 'search::finished'
80
- | 'search::failed'
81
78
  | 'product::price.updated'
82
79
  | 'product::price.updated.failed'
83
80
  | 'product::availability.subscribed'
84
81
  | 'product::availability.subscribe.failed'
82
+ | 'product::search.failed'
83
+ | 'product::search.results'
85
84
  | 'profile::updated'
86
85
  | 'profile::update.failed'
87
86
  | 'profile::mobile.updated'
@@ -114,7 +113,6 @@ export {
114
113
  GiftEvent,
115
114
  OrderEvent,
116
115
  OfferEvent,
117
- SearchEvent,
118
116
  RatingEvent,
119
117
  CommentEvent,
120
118
  LoyaltyEvent,
@@ -133,7 +131,6 @@ export default interface SallaEvent extends EventEmitter2 {
133
131
  gift: GiftEvent;
134
132
  order: OrderEvent;
135
133
  offer: OfferEvent;
136
- search: SearchEvent;
137
134
  rating: RatingEvent;
138
135
  comment: CommentEvent;
139
136
  loyalty: LoyaltyEvent;
@@ -1,12 +1,11 @@
1
1
  import {RequestError, SuccessResponse} from "../common";
2
- import {ReOrderResponse} from "../api/order";
3
-
2
+ import {CreateCartFromOrderResponse} from "../api/order";
4
3
 
5
4
  export default interface OrderEvent {
6
5
  onCanceled: (callback: (response: SuccessResponse, order_id?: number) => void) => void;
7
6
  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;
7
+ onOrderCreated: (callback: (response: CreateCartFromOrderResponse, order_id?: number) => void) => void;
8
+ onOrderCreationFailed: (callback: (error: RequestError, order_id?: number) => void) => void;
10
9
  onInvoiceSent: (callback: (response: SuccessResponse, order_id?: number) => void) => void;
11
10
  onInvoiceNotSent: (callback: (error: RequestError | 'There is no id!', order_id?: number) => void) => void;
12
11
  }
@@ -1,4 +1,4 @@
1
- import {GetPriceResponse} from "../api/product";
1
+ import {GetPriceResponse, ProductsSearchResponse} from "../api/product";
2
2
  import {RequestErrorEventWithData, SuccessResponse} from "../common";
3
3
 
4
4
  export default interface ProductEvent {
@@ -6,4 +6,6 @@ export default interface ProductEvent {
6
6
  onPriceUpdateFailed: RequestErrorEventWithData</*product_id*/ number>;
7
7
  onAvailabilitySubscribed: (callback: (response: SuccessResponse, product_id: number) => void) => void;
8
8
  onAvailabilitySubscribeFailed: RequestErrorEventWithData</*product_id*/ number>;
9
+ onSearchResults: (callback: (response: ProductsSearchResponse, query?: string) => void) => void;
10
+ onSearchFailed: RequestErrorEventWithData</*query*/string|undefined>;
9
11
  }
@@ -1,15 +0,0 @@
1
- import { Product, SuccessResponse} from "../common";
2
-
3
- export interface SearchProductsResponse extends SuccessResponse {
4
- data: Product[];
5
- cursor: {
6
- current: number;
7
- previous?: string;
8
- next?: string;
9
- count: number;
10
- };
11
- }
12
-
13
- export default interface SearchApi {
14
- products: (query: string) => Promise<SearchProductsResponse>;
15
- }
@@ -1,7 +0,0 @@
1
- import { RequestErrorEventWithData} from "../common";
2
- import {SearchProductsResponse} from "../api/search";
3
-
4
- export default interface SearchEvent {
5
- onFinished: (callback: (response: SearchProductsResponse, query?: string) => void) => void;
6
- onFailed: RequestErrorEventWithData</*query*/string|undefined>;
7
- }