@salla.sa/twilight 2.4.0 → 2.5.2
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/api/index.d.ts +9 -3
- package/types/api/loyalty.d.ts +4 -3
- package/types/api/scope.d.ts +42 -0
- package/types/event/index.d.ts +15 -2
- package/types/event/loyalty.d.ts +4 -1
- package/types/event/scope.d.ts +15 -0
package/package.json
CHANGED
package/types/api/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Axios} from "axios";
|
|
1
|
+
import { Axios } from "axios";
|
|
2
2
|
import CartApi from "./cart";
|
|
3
3
|
import AuthApi from "./auth";
|
|
4
4
|
import GiftApi from "./gift";
|
|
@@ -12,6 +12,7 @@ import CurrencyApi from "./currency";
|
|
|
12
12
|
import DocumentApi from "./document";
|
|
13
13
|
import WishlistApi from "./wishlist";
|
|
14
14
|
import TwilightApi from "./twilight";
|
|
15
|
+
import ScopeApi from "./scope";
|
|
15
16
|
|
|
16
17
|
export {
|
|
17
18
|
CartApi,
|
|
@@ -27,6 +28,7 @@ export {
|
|
|
27
28
|
DocumentApi,
|
|
28
29
|
TwilightApi,
|
|
29
30
|
WishlistApi,
|
|
31
|
+
ScopeApi,
|
|
30
32
|
};
|
|
31
33
|
export type ApiActionName =
|
|
32
34
|
'auth.login'
|
|
@@ -48,6 +50,8 @@ export type ApiActionName =
|
|
|
48
50
|
| 'cart.deleteCoupon'
|
|
49
51
|
| 'gift.buy'
|
|
50
52
|
| 'loyalty.exchange'
|
|
53
|
+
| 'loyalty.getProgram'
|
|
54
|
+
| 'loyalty.reset'
|
|
51
55
|
| 'order.cancel'
|
|
52
56
|
| 'order.reOrder'
|
|
53
57
|
| 'order.send'
|
|
@@ -67,8 +71,9 @@ export type ApiActionName =
|
|
|
67
71
|
| 'rating.order'
|
|
68
72
|
| 'wishlist.add'
|
|
69
73
|
| 'wishlist.remove'
|
|
70
|
-
| 'scope.
|
|
71
|
-
| 'scope.
|
|
74
|
+
| 'scope.get'
|
|
75
|
+
| 'scope.change'
|
|
76
|
+
| 'scope.getProductAvailability';
|
|
72
77
|
|
|
73
78
|
export default interface SallaApi extends Axios {
|
|
74
79
|
cart: CartApi;
|
|
@@ -84,6 +89,7 @@ export default interface SallaApi extends Axios {
|
|
|
84
89
|
document: DocumentApi;
|
|
85
90
|
twilight: TwilightApi;
|
|
86
91
|
wishlist: WishlistApi;
|
|
92
|
+
scope: ScopeApi;
|
|
87
93
|
getHeaders: () => {
|
|
88
94
|
Accept: string | 'application/json, text/plain, */*',
|
|
89
95
|
"X-Requested-With": 'XMLHttpRequest',
|
package/types/api/loyalty.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {SuccessResponse} from '../common'
|
|
1
|
+
import { SuccessResponse } from '../common'
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
export interface Loyalty {
|
|
@@ -54,12 +54,12 @@ export interface Condition {
|
|
|
54
54
|
key: string;
|
|
55
55
|
points: number;
|
|
56
56
|
condition: null | string;
|
|
57
|
-
value?: 'fixed_amount'|'total_order';
|
|
57
|
+
value?: 'fixed_amount' | 'total_order';
|
|
58
58
|
op: string;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export interface Prize {
|
|
62
|
-
type: string|'free_shipping'|'free_product'|'coupon';
|
|
62
|
+
type: string | 'free_shipping' | 'free_product' | 'coupon';
|
|
63
63
|
title: string;
|
|
64
64
|
items: Item[];
|
|
65
65
|
}
|
|
@@ -222,4 +222,5 @@ export namespace LoyaltyApiResponse {
|
|
|
222
222
|
export default interface LoyaltyApi {
|
|
223
223
|
getProgram: () => Promise<LoyaltyApiResponse.program>
|
|
224
224
|
exchange: (prize_id: number, cart_id?: number) => Promise<LoyaltyApiResponse.point>
|
|
225
|
+
reset: () => Promise<SuccessResponse>
|
|
225
226
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SuccessResponse } from "../common";
|
|
2
|
+
|
|
3
|
+
export interface Scope {
|
|
4
|
+
id: number;
|
|
5
|
+
name: string;
|
|
6
|
+
selected: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ProductAvailability {
|
|
10
|
+
name: string;
|
|
11
|
+
selected: boolean;
|
|
12
|
+
availability: Availability;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Availability {
|
|
16
|
+
label: string;
|
|
17
|
+
key: string;
|
|
18
|
+
color: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export namespace ScopeApiResponse {
|
|
23
|
+
|
|
24
|
+
export interface scopeList extends SuccessResponse {
|
|
25
|
+
data: Scope[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface scopeAddition extends SuccessResponse {
|
|
29
|
+
data: Scope
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface availability extends SuccessResponse {
|
|
33
|
+
data: ProductAvailability[];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
export default interface ScopeApi {
|
|
39
|
+
get: () => Promise<ScopeApiResponse.scopeList>
|
|
40
|
+
change: (payload: Object) => Promise<SuccessResponse>
|
|
41
|
+
getProductAvailability: (product_id: number) => Promise<ScopeApiResponse.availability>
|
|
42
|
+
}
|
package/types/event/index.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ import DocumentEvent from "./document";
|
|
|
12
12
|
import TwilightEvent from "./twilight";
|
|
13
13
|
import WishlistEvent from "./wishlist";
|
|
14
14
|
import InfiniteScrollEvent from "./infiniteScroll";
|
|
15
|
-
import
|
|
15
|
+
import ScopeEvents from "./scope";
|
|
16
|
+
import { EventEmitter2 } from "eventemitter2";
|
|
16
17
|
|
|
17
18
|
export type event = (symbol | string);
|
|
18
19
|
export type EventName = string
|
|
@@ -55,6 +56,10 @@ export type EventName = string
|
|
|
55
56
|
| 'gift::buying.failed'
|
|
56
57
|
| 'loyalty::exchange.succeeded'
|
|
57
58
|
| 'loyalty::exchange.failed'
|
|
59
|
+
| 'loyalty::program.fetched'
|
|
60
|
+
| 'loyalty::program.not.fetched'
|
|
61
|
+
| 'loyalty::reset.succeeded'
|
|
62
|
+
| 'loyalty::reset.failed'
|
|
58
63
|
| 'order::canceled'
|
|
59
64
|
| 'order::not.canceled'
|
|
60
65
|
| 'order::re.ordered'
|
|
@@ -106,6 +111,12 @@ export type EventName = string
|
|
|
106
111
|
| 'wishlist::removed'
|
|
107
112
|
| 'wishlist::addition.failed'
|
|
108
113
|
| 'wishlist::removing.failed'
|
|
114
|
+
| 'scope::fetched'
|
|
115
|
+
| 'scope::not.fetched'
|
|
116
|
+
| 'scope::changed'
|
|
117
|
+
| 'scope::not.changed'
|
|
118
|
+
| 'scope::product-availability.fetched'
|
|
119
|
+
| 'scope::product-availability.not.fetched';
|
|
109
120
|
export {
|
|
110
121
|
AuthEvent,
|
|
111
122
|
CartEvent,
|
|
@@ -121,6 +132,7 @@ export {
|
|
|
121
132
|
TwilightEvent,
|
|
122
133
|
WishlistEvent,
|
|
123
134
|
InfiniteScrollEvent,
|
|
135
|
+
ScopeEvents,
|
|
124
136
|
}
|
|
125
137
|
|
|
126
138
|
export default interface SallaEvent extends EventEmitter2 {
|
|
@@ -137,6 +149,7 @@ export default interface SallaEvent extends EventEmitter2 {
|
|
|
137
149
|
document: DocumentEvent;
|
|
138
150
|
twilight: TwilightEvent;
|
|
139
151
|
wishlist: WishlistEvent;
|
|
152
|
+
scope: ScopeEvents,
|
|
140
153
|
infiniteScroll: InfiniteScrollEvent;
|
|
141
154
|
dispatchEvents: (events: { [event_name: string]: any }) => void;
|
|
142
155
|
dispatch: (event_name: EventName, ...data: undefined | any) => void;
|
|
@@ -144,4 +157,4 @@ export default interface SallaEvent extends EventEmitter2 {
|
|
|
144
157
|
on(event: EventName, listener: (...values: any[]) => void, options?: boolean | Object): this;
|
|
145
158
|
|
|
146
159
|
once(event: EventName, listener: (...values: any[]) => void, options?: boolean | Object): this;
|
|
147
|
-
}
|
|
160
|
+
}
|
package/types/event/loyalty.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RequestErrorEvent } from "../common";
|
|
1
|
+
import { RequestErrorEvent, SuccessResponse } from "../common";
|
|
2
2
|
import { LoyaltyApiResponse } from '../api/loyalty'
|
|
3
3
|
|
|
4
4
|
export default interface LoyaltyEvent {
|
|
@@ -8,4 +8,7 @@ export default interface LoyaltyEvent {
|
|
|
8
8
|
// Point
|
|
9
9
|
onExchangeFetched: (callback: (response: LoyaltyApiResponse.point, prod_id: number) => void) => void;
|
|
10
10
|
onExchangeFetchFailed: RequestErrorEvent;
|
|
11
|
+
// Reset Exchange
|
|
12
|
+
onResetSucceeded: (callback: (response: SuccessResponse) => void) => void;
|
|
13
|
+
onResetFailed: RequestErrorEvent
|
|
11
14
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RequestErrorEvent } from "../common";
|
|
2
|
+
import { ScopeApiResponse } from '../api/scope'
|
|
3
|
+
|
|
4
|
+
export default interface ScopeEvents {
|
|
5
|
+
onFetched: (callback: (response: ScopeApiResponse.scopeList) => void) => void;
|
|
6
|
+
onNotFetched: RequestErrorEvent;
|
|
7
|
+
|
|
8
|
+
// POST
|
|
9
|
+
onChanged: (callback: (response: ScopeApiResponse.scopeAddition) => void) => void;
|
|
10
|
+
onChangeFailed: RequestErrorEvent;
|
|
11
|
+
|
|
12
|
+
// Availability
|
|
13
|
+
onProductAvailabilityFetched: (callback: (response: ScopeApiResponse.availability, product_id: number) => void) => void;
|
|
14
|
+
onProductAvailabilityNotFetched: RequestErrorEvent;
|
|
15
|
+
}
|