@salla.sa/twilight 1.0.18 → 1.6.13

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.
Files changed (114) hide show
  1. package/LICENSE.md +674 -0
  2. package/README.md +214 -4
  3. package/dist/@salla.sa/twilight.min.js +20 -0
  4. package/dist/@salla.sa/twilight.min.js.map +1 -0
  5. package/dist/cjs/index.js +2 -0
  6. package/dist/cjs/index.js.map +1 -0
  7. package/dist/esm/index.js +2 -0
  8. package/dist/esm/index.js.map +1 -0
  9. package/package.json +64 -52
  10. package/types/actions.d.ts +47 -0
  11. package/types/api/auth/index.d.ts +17 -0
  12. package/types/api/auth/request.d.ts +42 -0
  13. package/types/api/auth/response.d.ts +22 -0
  14. package/types/api/cart/index.d.ts +24 -0
  15. package/types/api/cart/request.d.ts +8 -0
  16. package/types/api/cart/response.d.ts +66 -0
  17. package/types/api/comment.d.ts +18 -0
  18. package/types/api/currency.d.ts +17 -0
  19. package/types/api/document.d.ts +3 -0
  20. package/types/api/index.d.ts +110 -0
  21. package/types/api/loyalty.d.ts +226 -0
  22. package/types/api/order.d.ts +15 -0
  23. package/types/api/product/index.d.ts +17 -0
  24. package/types/api/product/request.d.ts +53 -0
  25. package/types/api/product/response.d.ts +103 -0
  26. package/types/api/profile.d.ts +50 -0
  27. package/types/api/rating.d.ts +49 -0
  28. package/types/api/scope.d.ts +42 -0
  29. package/types/api/wishlist.d.ts +7 -0
  30. package/types/common.d.ts +75 -0
  31. package/types/event/auth.d.ts +18 -0
  32. package/types/event/cart.d.ts +30 -0
  33. package/types/event/comment.d.ts +7 -0
  34. package/types/event/currency.d.ts +9 -0
  35. package/types/event/document.d.ts +29 -0
  36. package/types/event/index.d.ts +48 -0
  37. package/types/event/infiniteScroll.d.ts +12 -0
  38. package/types/event/loyalty.d.ts +14 -0
  39. package/types/event/order.d.ts +11 -0
  40. package/types/event/product.d.ts +30 -0
  41. package/types/event/profile.d.ts +13 -0
  42. package/types/event/rating.d.ts +13 -0
  43. package/types/event/scope.d.ts +15 -0
  44. package/types/event/wishlist.d.ts +8 -0
  45. package/types/helpers/app-helpers.d.ts +29 -0
  46. package/types/index.d.ts +36 -0
  47. package/types/lib/config.ts +14 -0
  48. package/types/lib/form.d.ts +8 -0
  49. package/types/lib/lang.d.ts +14 -0
  50. package/types/lib/notify.d.ts +14 -0
  51. package/types/tiwlight-config.d.ts +74 -0
  52. package/watcher.js +64 -22
  53. package/components/README.md +0 -55
  54. package/components/dist/cjs/index-9441fd8e.js +0 -1554
  55. package/components/dist/cjs/index.cjs.js +0 -2
  56. package/components/dist/cjs/loader.cjs.js +0 -21
  57. package/components/dist/cjs/salla-login_2.cjs.entry.js +0 -131
  58. package/components/dist/cjs/twilight-components.cjs.js +0 -19
  59. package/components/dist/collection/collection-manifest.json +0 -13
  60. package/components/dist/collection/components/generate-summary.js +0 -35
  61. package/components/dist/collection/components/salla-login/salla-login.css +0 -104
  62. package/components/dist/collection/components/salla-login/salla-login.js +0 -113
  63. package/components/dist/collection/components/search-modal/search-modal.css +0 -9
  64. package/components/dist/collection/components/search-modal/search-modal.js +0 -161
  65. package/components/dist/collection/index.js +0 -1
  66. package/components/dist/collection/interfaces/colors.js +0 -1
  67. package/components/dist/collection/interfaces/index.js +0 -2
  68. package/components/dist/collection/interfaces/ratio.js +0 -1
  69. package/components/dist/collection/plugins/tailwind-theme/index.js +0 -32
  70. package/components/dist/collection/plugins/tailwind-theme/scripts/generator.js +0 -51
  71. package/components/dist/collection/utils/utils.js +0 -16
  72. package/components/dist/esm/index-63e5409f.js +0 -1527
  73. package/components/dist/esm/index.js +0 -1
  74. package/components/dist/esm/loader.js +0 -17
  75. package/components/dist/esm/polyfills/core-js.js +0 -11
  76. package/components/dist/esm/polyfills/css-shim.js +0 -1
  77. package/components/dist/esm/polyfills/dom.js +0 -79
  78. package/components/dist/esm/polyfills/es5-html-element.js +0 -1
  79. package/components/dist/esm/polyfills/index.js +0 -34
  80. package/components/dist/esm/polyfills/system.js +0 -6
  81. package/components/dist/esm/salla-login_2.entry.js +0 -126
  82. package/components/dist/esm/twilight-components.js +0 -17
  83. package/components/dist/index.cjs.js +0 -1
  84. package/components/dist/index.js +0 -1
  85. package/components/dist/twilight-components/index.esm.js +0 -0
  86. package/components/dist/twilight-components/p-3d53781c.js +0 -1
  87. package/components/dist/twilight-components/p-fccb89fa.entry.js +0 -1
  88. package/components/dist/twilight-components/twilight-components.esm.js +0 -1
  89. package/components/dist/types/components/salla-login/salla-login.d.ts +0 -14
  90. package/components/dist/types/components/search-modal/search-modal.d.ts +0 -26
  91. package/components/dist/types/components.d.ts +0 -76
  92. package/components/dist/types/index.d.ts +0 -6
  93. package/components/dist/types/interfaces/colors.d.ts +0 -1
  94. package/components/dist/types/interfaces/index.d.ts +0 -2
  95. package/components/dist/types/interfaces/ratio.d.ts +0 -1
  96. package/components/dist/types/stencil-public-runtime.d.ts +0 -1563
  97. package/components/dist/types/utils/utils.d.ts +0 -6
  98. package/components/loader/cdn.js +0 -3
  99. package/components/loader/index.cjs.js +0 -3
  100. package/components/loader/index.d.ts +0 -13
  101. package/components/loader/index.es2017.js +0 -3
  102. package/components/loader/index.js +0 -4
  103. package/components/loader/package.json +0 -10
  104. package/components/package.json +0 -70
  105. package/components/src/plugins/tailwind-theme/index.js +0 -32
  106. package/components/src/plugins/tailwind-theme/package.json +0 -27
  107. package/components/src/plugins/tailwind-theme/readme.md +0 -47
  108. package/components/src/plugins/tailwind-theme/safe-list-css.txt +0 -19
  109. package/components/src/plugins/tailwind-theme/utilities.json +0 -1
  110. package/components.js +0 -1
  111. package/dist/twilight.js +0 -1239
  112. package/postInstall.js +0 -2
  113. package/tailwind.js +0 -1
  114. package/tailwind_css_list.js +0 -1
@@ -0,0 +1,226 @@
1
+ import { SuccessResponse } from '../common'
2
+
3
+
4
+ export interface Loyalty {
5
+ id: number;
6
+ name: string;
7
+ description: string;
8
+ image: string;
9
+ points_validity_by: null;
10
+ points_validity_value: null;
11
+ prize_promotion_title: string;
12
+ prize_promotion_description: string;
13
+ prize_promotion_logo: string;
14
+ customer: Customer;
15
+ points: Point[];
16
+ prizes: Prize[];
17
+ }
18
+
19
+ export interface Customer {
20
+ id: number;
21
+ currency: string;
22
+ language: string;
23
+ first_name: string;
24
+ last_name: string;
25
+ phone: Phone;
26
+ email: string;
27
+ avatar: string;
28
+ gender: string;
29
+ birthday: Date;
30
+ loyalty_program_points: number;
31
+ }
32
+
33
+ export interface Phone {
34
+ code: string;
35
+ number: number;
36
+ country: string;
37
+ }
38
+
39
+ export interface Point {
40
+ id: number;
41
+ key: string;
42
+ name: string;
43
+ description: string;
44
+ points: number;
45
+ icon: number;
46
+ color: number;
47
+ is_completed: boolean;
48
+ target_url: string;
49
+ share_store_url: string;
50
+ conditions: Condition[];
51
+ }
52
+
53
+ export interface Condition {
54
+ key: string;
55
+ points: number;
56
+ condition: null | string;
57
+ value?: 'fixed_amount' | 'total_order';
58
+ op: string;
59
+ }
60
+
61
+ export interface Prize {
62
+ type: string | 'free_shipping' | 'free_product' | 'coupon';
63
+ title: string;
64
+ items: Item[];
65
+ }
66
+
67
+ export interface Item {
68
+ id: number;
69
+ key: string;
70
+ name: string;
71
+ description: string;
72
+ image: string;
73
+ cost_points: number;
74
+ coupon_type: null | string;
75
+ coupon_amount: string;
76
+ coupon_maximum_amount: string;
77
+ included_category_ids: number[];
78
+ order_minimum_amount: string;
79
+ product_id: number | null;
80
+ use_product_image: number;
81
+ free_shipping_maximum_amount: string;
82
+ free_shipping_terms_apply: boolean;
83
+ prize_url: string;
84
+ }
85
+
86
+ /**
87
+ * Loyalty exchange Points
88
+ */
89
+ export interface ExchangePoint {
90
+ message: string;
91
+ cart: Cart;
92
+ }
93
+
94
+ export interface Cart {
95
+ items: ExchangeItem[];
96
+ require_shipping: boolean;
97
+ cart_total: CartTotal;
98
+ total_before_discount: CartTotal;
99
+ coupon: null;
100
+ free_shipping: FreeShipping;
101
+ loyalty_program: LoyaltyProgram;
102
+ }
103
+
104
+ export interface CartTotal {
105
+ amount: number;
106
+ currency: Currency;
107
+ }
108
+
109
+ export enum Currency {
110
+ Sar = "SAR",
111
+ }
112
+
113
+ export interface FreeShipping {
114
+ remaining_to_free_shipping: null;
115
+ has_free_shipping: boolean;
116
+ }
117
+
118
+ export interface ExchangeItem {
119
+ id: number;
120
+ url: string;
121
+ quantity: number;
122
+ product_id: number;
123
+ notes: null | string;
124
+ name: string;
125
+ price: CartTotal;
126
+ sale_price: CartTotal;
127
+ has_special_price: boolean;
128
+ regular_price: CartTotal;
129
+ image: string;
130
+ type: string;
131
+ hide_quantity: boolean;
132
+ features: Features;
133
+ discount_details: DiscountDetails | null;
134
+ max_items_per_user: number;
135
+ active_advance: boolean;
136
+ weight_label: string;
137
+ uploaded_files: any[];
138
+ options: Option[];
139
+ selected_options: SelectedOption[];
140
+ skus: any[];
141
+ }
142
+
143
+ export interface DiscountDetails {
144
+ discount: number;
145
+ item_total_price: CartTotal;
146
+ offer_type: null;
147
+ has_free_items: boolean;
148
+ offer_items_count: number;
149
+ special_price: CartTotal;
150
+ is_free: boolean;
151
+ name: string;
152
+ }
153
+
154
+ export interface Features {
155
+ upload_file: boolean;
156
+ note: boolean;
157
+ }
158
+
159
+ export interface Option {
160
+ id: number;
161
+ name: string;
162
+ description: string;
163
+ type: string;
164
+ required: boolean;
165
+ associated_with_order_time: number;
166
+ availability_range: boolean;
167
+ not_same_day_order: boolean;
168
+ choose_date_time: null;
169
+ from_date_time: null;
170
+ to_date_time: null;
171
+ sort: number;
172
+ advance: boolean;
173
+ display_type: null;
174
+ visibility: string;
175
+ translations: Object;
176
+ values: ValueElement[];
177
+ }
178
+
179
+ export interface ValueElement {
180
+ id: number;
181
+ name: string;
182
+ price: CartTotal;
183
+ display_value: null;
184
+ advance: boolean;
185
+ option_id: number;
186
+ image_url: null;
187
+ hashed_display_value: null;
188
+ translations: Object;
189
+ }
190
+
191
+ export interface SelectedOption {
192
+ id: number;
193
+ value: string[] | number;
194
+ }
195
+
196
+ export interface LoyaltyProgram {
197
+ points: number;
198
+ prize: ExchangePrize;
199
+ }
200
+
201
+ export interface ExchangePrize {
202
+ id: number;
203
+ name: string;
204
+ discount_amount: number;
205
+ points: number;
206
+ }
207
+
208
+
209
+ export namespace LoyaltyApiResponse {
210
+
211
+ export interface program extends SuccessResponse {
212
+ data: Loyalty
213
+ }
214
+
215
+
216
+ export interface point extends SuccessResponse {
217
+ data: ExchangePoint
218
+ }
219
+ }
220
+
221
+
222
+ export default interface LoyaltyApi {
223
+ getProgram: () => Promise<LoyaltyApiResponse.program>
224
+ exchange: (prize_id: number, cart_id?: number) => Promise<LoyaltyApiResponse.point>
225
+ reset: () => Promise<SuccessResponse>
226
+ }
@@ -0,0 +1,15 @@
1
+ import {SuccessResponse} from "../common";
2
+
3
+ export interface CreateCartFromOrderResponse extends SuccessResponse {
4
+ data: {
5
+ cart_id: number;
6
+ url: string;
7
+ };
8
+ }
9
+
10
+ export default interface OrderApi {
11
+ createCartFromOrder: (order_id?: number) => Promise<CreateCartFromOrderResponse>;
12
+ cancel: (order_id?: number) => Promise<SuccessResponse>;
13
+ sendInvoice: (order_id?: number) => Promise<SuccessResponse>;
14
+ show: (payload: { order_id: number, url: string }) => Promise<void>; //should be called from thank you page to trigger native order details page in apps
15
+ }
@@ -0,0 +1,17 @@
1
+ import { SuccessResponse } from "../../common";
2
+ import { ProductResponse } from "./response";
3
+ import { ProductRequest } from "./request";
4
+
5
+ export * from "./request";
6
+ export * from "./response";
7
+
8
+ export default interface ProductApi {
9
+ getPrice: (data: /*product_id*/number | ProductRequest.addItem) => Promise<ProductResponse.getPrice>;
10
+ availabilitySubscribe: (product_id: number | ProductRequest.availability) => Promise<SuccessResponse>;
11
+ search: (keyword: string | ProductRequest.search) => Promise<ProductResponse.search>;
12
+ categories: (categoryId?: number) => Promise<ProductResponse.categories>; //get all categories or sub_categories
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) => Promise<ProductResponse.giftToCart>;
16
+ uploadGiftImage: (multiPartData: FormData) => Promise<ProductResponse.giftImageUpload>;
17
+ }
@@ -0,0 +1,53 @@
1
+ export interface Category {
2
+ id: string;
3
+ id_: number;
4
+ name: string;
5
+ url: string;
6
+ sub_categories: Category[];
7
+ }
8
+
9
+ export type ProductOption = { [key: number]: number | string | number[] };
10
+
11
+
12
+ export interface Receiver {
13
+ name: string;
14
+ country_code: string;
15
+ mobile: string;
16
+ }
17
+
18
+
19
+ export namespace ProductRequest {
20
+ export interface addItem {
21
+ id: number;
22
+ quantity: 1 | number;
23
+ options?: ProductOption;
24
+ }
25
+
26
+ export interface search {
27
+ query: string;
28
+ type?: 'keyword' | 'tag';//default => 'keyword'
29
+ sort_by?: 'ourSuggest' | 'default' | 'bestSell' | 'topRated' | 'priceFromTopToLow' | 'priceFromLowToTop'; //default => 'ourSuggest'
30
+ per_page?: 32 | number;//max 50
31
+ brands?: number[];
32
+ categories?: number[];// max 5 ids
33
+ branches?: number[];// max 5 ids
34
+ }
35
+
36
+ export interface availability {
37
+ id: number;
38
+ //💡 Following properties required for guests
39
+ email?: string;//required when request without mobile
40
+ country_code?: string | 'SA';//required when request without email
41
+ phone?: string | '555555555';//required when request without email
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
+ }
53
+ }
@@ -0,0 +1,103 @@
1
+ import {Category as ShortCategory, Product, SuccessResponse} from "../../common";
2
+ import {Category} from "./request";
3
+ type offerType = 'buy_x_get_y' | 'percentage' | 'fixed_amount';
4
+ type paymentMethod = {
5
+ id: number;
6
+ slug: 'bank';
7
+ name: 'BankTransfer';
8
+ };
9
+ export interface SizeGuide {
10
+ name: string;
11
+ description: string;
12
+ }
13
+ export interface Offer {
14
+ id: number;
15
+ name: string;
16
+ message: string;
17
+ expiry_date: string | '2022-02-22 00:00:00';
18
+ formatted_date: string;
19
+ offer_type: offerType;
20
+ applied_to: 'order' | 'category' | 'product' | 'paymentMethod';
21
+ buy: {
22
+ type: 'product' | 'category';
23
+ quantity: number;
24
+ products?: Product[];
25
+ categories?: ShortCategory[];
26
+ min_amount?: number; //when offer_type != 'buy_x_get_y'
27
+ min_items?: number; //when offer_type != 'buy_x_get_y'
28
+ payment_methods: paymentMethod[];
29
+ };
30
+ get: {
31
+ products?: Product[];
32
+ categories?: ShortCategory[];
33
+ type: 'product' | 'category';
34
+ discount_type: 'free-product' | 'percentage';
35
+ quantity?: number;//when discount_type == 'percentage'
36
+ discount_amount?: number; //when offer_type != 'buy_x_get_y' or get.discount_type !='free-product'
37
+ }
38
+ }
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
+
61
+ export namespace ProductResponse {
62
+ export interface search extends SuccessResponse {
63
+ data: Product[];
64
+ cursor: {
65
+ current: number;
66
+ previous?: string;
67
+ next?: string;
68
+ count: number;
69
+ };
70
+ }
71
+
72
+ export interface getPrice extends SuccessResponse {
73
+ data: {
74
+ price: number;
75
+ regular_price: number;
76
+ has_sale_price: boolean;
77
+ }
78
+ }
79
+
80
+ export interface categories extends SuccessResponse {
81
+ data: Category | Category[]; //single category when getting subCategories by passing categoryId
82
+ }
83
+
84
+ export interface offers extends SuccessResponse {
85
+ data: Offer[] | [];
86
+ }
87
+
88
+ export interface sizeGuides extends SuccessResponse {
89
+ data: Array<SizeGuide>;
90
+ }
91
+
92
+ export interface giftResponse extends SuccessResponse {
93
+ data: Gift
94
+ }
95
+
96
+ export interface giftToCart extends SuccessResponse {
97
+ data: Object
98
+ }
99
+
100
+ export interface giftImageUpload extends SuccessResponse {
101
+ data: Object | String
102
+ }
103
+ }
@@ -0,0 +1,50 @@
1
+ import {SuccessResponse} from "../common";
2
+ import {AuthRequest, VerificationStatus} from "./auth";
3
+
4
+ export interface ProfileUpdatePayload {
5
+ first_name: string;
6
+ last_name: string;
7
+ birthday?: string | '2022-02-22';
8
+ gender?: 'male' | 'female';
9
+ avatar?: BinaryType;
10
+ }
11
+
12
+ export interface ProfileUpdateContactPayload {
13
+ phone?: string | number; //required if there is no email
14
+ country_code?: string | 'SA'; //required if there is phone
15
+ email?: string; //required if there is no phone
16
+ }
17
+
18
+ export interface ProfileResponse extends SuccessResponse {
19
+ data: {
20
+ id: number;
21
+ first_name: string;
22
+ last_name: string;
23
+ currency: string | 'SAR';
24
+ language: string | 'ar';
25
+ phone: {
26
+ code: string | "+966";
27
+ number: string | number;
28
+ country: string | "SA";
29
+ };
30
+ email: string;
31
+ avatar: string;
32
+ gender?: 'male' | 'female';
33
+ birthday: string | '2022-02-22';
34
+ verification?: VerificationStatus; //exists when trying to update email/phone
35
+ };
36
+ }
37
+
38
+ export interface VerifyContactResponse extends SuccessResponse {
39
+ data: {
40
+ message: string;
41
+ verification: VerificationStatus;
42
+ }
43
+ }
44
+
45
+ export default interface ProfileApi {
46
+ info: () => Promise<ProfileResponse>;
47
+ update: (data: ProfileUpdatePayload) => Promise<ProfileResponse>;
48
+ verify: (data: AuthRequest.verifyByMobile | AuthRequest.verifyByEmail) => Promise<VerifyContactResponse>;
49
+ updateContacts: (data: ProfileUpdateContactPayload) => Promise<ProfileResponse>;//need to verify after success event
50
+ }
@@ -0,0 +1,49 @@
1
+ import { Product, Rating, SuccessResponse} from "../common";
2
+
3
+ export interface OrderDetailsResponse extends SuccessResponse {
4
+ data: {
5
+ id: number;
6
+ store?: { feedback: RatingContent };
7
+ shipping?: {
8
+ feedback: RatingContent;
9
+ company: {
10
+ id: number;
11
+ name: string;
12
+ logo?: string;
13
+ }
14
+ };
15
+ products: Array<{ feedback: RatingContent; product: Product; }>;
16
+ testimonials_enabled: boolean;
17
+ shipping_enabled: boolean;
18
+ products_enabled: boolean;
19
+ thanks_message: string;
20
+ }
21
+ }
22
+
23
+ export interface RatingContent {
24
+ content: string;
25
+ rating: Rating;
26
+ status?: 'approved' | 'pending';
27
+ }
28
+
29
+ export interface RatingStorePayload {
30
+ comment: string;
31
+ order_id: number;
32
+ rating: Rating;
33
+ }
34
+
35
+ export interface RatingProductsPayload {
36
+ products: Array<{ product_id: number; comment: string; rating: Rating; }>
37
+ order_id: number;
38
+ }
39
+
40
+ export interface RatingShippingPayload extends RatingStorePayload {
41
+ shipping_company_id: number;
42
+ }
43
+
44
+ export default interface RatingApi {
45
+ order: (order_id: number) => Promise<OrderDetailsResponse>;
46
+ store: (data: RatingStorePayload) => Promise<SuccessResponse>;
47
+ products: (data: RatingProductsPayload) => Promise<SuccessResponse>;
48
+ shipping: (data: RatingShippingPayload) => Promise<SuccessResponse>;
49
+ }
@@ -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
+ }
@@ -0,0 +1,7 @@
1
+ import {SuccessResponse} from "../common";
2
+
3
+ export default interface WishlistApi {
4
+ add: (product_id: number) => Promise<SuccessResponse>;
5
+ remove: (product_id: number) => Promise<SuccessResponse>;
6
+ toggle: (product_id: number) => Promise<SuccessResponse>;
7
+ }
@@ -0,0 +1,75 @@
1
+ type ProductType = 'product' | 'service' | 'group_products' | 'codes' | 'digital' | 'food' | 'donating';
2
+ type Rating = 1 | 2 | 3 | 4 | 5;
3
+ type RequestError = Error & { response: any }
4
+ type RequestErrorEvent = (callback: (error: RequestError | string) => void) => void;
5
+ type RequestErrorEventWithData<data> = (callback: (error: RequestError | string, data) => void) => void;
6
+
7
+ export interface Price {
8
+ amount: string;
9
+ currency: string;
10
+ }
11
+
12
+ export interface SuccessResponse {
13
+ status: 200;
14
+ success: true;
15
+ data: {
16
+ message?: string;
17
+ events?: { [event_name: string]: any };
18
+ [key: string]: any;
19
+ };
20
+ }
21
+
22
+ export interface ErrorResponse {
23
+ status: 422 | 404;
24
+ success: false;
25
+ error: {
26
+ message?: string | 'alert.invalid_fields';
27
+ code?: any;
28
+ case?: string | 'resend_counter' | 'invalid_code';
29
+ events?: { [event_name: string]: any };
30
+ fields?: { [field_name: string]: Array<string> };
31
+ [key: string]: any;
32
+ }
33
+ }
34
+
35
+ export interface Currency {
36
+ code: string | 'SAR';
37
+ name: string;
38
+ symbol: string;
39
+ amount?: number;
40
+ country_code?: string;
41
+ }
42
+
43
+ export interface Product {
44
+ id: number;
45
+ name: string;
46
+ type: ProductType;
47
+ promotion: {
48
+ title?: string;
49
+ sub_title?: string;
50
+ };
51
+ price: Price;
52
+ sale_price?: Price;
53
+ regular_price: Price;
54
+ has_special_price: boolean;
55
+ status: 'sale' | 'out';
56
+ is_available: boolean;
57
+ sku?: string;
58
+ currency: string | 'SAR';
59
+ url: string;
60
+ thumbnail: string;
61
+ calories?: number;
62
+ }
63
+
64
+ export interface Category {
65
+ id: number;
66
+ name: string;
67
+ url: string;
68
+ }
69
+
70
+ export interface RequestInfo {
71
+ endPoint: string;
72
+ method: string;
73
+ payload: any,
74
+ options: {},
75
+ }
@@ -0,0 +1,18 @@
1
+ import {AuthResponse} from "../api/auth";
2
+ import {RequestError, SuccessResponse} from "../common";
3
+
4
+ export default interface AuthEvent {
5
+ //Success Responses
6
+ onCodeSent: (callback: (response: AuthResponse.loginOrResendCode, type?: 'mobile' | 'email') => void) => void;
7
+ onVerified: (callback: (response: AuthResponse.verify, type?: 'mobile' | 'email') => void) => void;
8
+ onRegistered: (callback: (response: AuthResponse.verify) => void) => void;
9
+ onLoggedIn: (callback: (response: AuthResponse.verify) => void) => void;
10
+ onLoggedOut: (callback: (response: SuccessResponse) => void) => void;
11
+
12
+ //Error Responses
13
+ onCodeNotSent: (callback: (error: RequestError | string, type?: 'mobile' | 'email') => void) => void;
14
+ onVerificationFailed: (callback: (error: RequestError | string, type?: 'mobile' | 'email') => void) => void;
15
+ onRegistrationFailed: (callback: (error: RequestError) => void) => void;
16
+ onFailedLogout: (callback: (error: RequestError) => void) => void;
17
+ onRefreshFailed: (callback: (error: RequestError) => void) => void;
18
+ }
@@ -0,0 +1,30 @@
1
+ import {CartResponse, CartSummary} from "../api/cart";
2
+ import { RequestError, SuccessResponse} from "../common";
3
+
4
+ export default interface CartEvent {
5
+ // listeners
6
+ onUpdated: (callback: (cart_summary: CartSummary) => void) => void;
7
+ onItemAdded: (callback: (response: CartResponse.update, product_id: number) => void) => void;
8
+ onItemUpdated: (callback: (response: CartResponse.update, product_id: number) => void) => void;
9
+ onItemDeleted: (callback: (response: CartResponse.update, product_id: number) => void) => void;
10
+ onLatestFetched: (callback: (response: CartResponse.update) => void) => void;
11
+ onSubmitted: (callback: (response: CartResponse.status) => void) => void;
12
+ onImageDeleted: (callback: (response: SuccessResponse, file_id: number) => void) => void;
13
+ onDetailsFetched: (callback: (response: CartResponse.status) => void) => void;
14
+ onSuccessReset: (callback: () => void) => void;
15
+
16
+ //errors
17
+ onLatestFailed: (callback: (error: RequestError) => void) => void;
18
+ onItemUpdatedFailed: (callback: (error: RequestError | 'There is no "id"!', item_id?: number) => void) => void;
19
+ onItemAddedFailed: (callback: (error: RequestError | 'There is no product "id"!', product_id?: number) => void) => void;
20
+ onItemDeletedFailed: (callback: (error: RequestError | 'There is no "id"!', item_id?: number) => void) => void;
21
+ onSubmitFailed: (callback: (error: RequestError | "Can't find next_step );") => void) => void;
22
+ onImageNotDeleted: (callback: (error: RequestError | 'There is no "id"!', file_id?: number) => void) => void;
23
+ onDetailsNotFetched: (callback: (error: RequestError) => void) => void;
24
+
25
+ //coupons
26
+ onCouponAdded: (callback: (response: CartResponse.update, cart_id: number) => void) => void;
27
+ onCouponDeleted: (callback: (response: CartResponse.update, cart_id: number) => void) => void;
28
+ onCouponAdditionFailed: (callback: (error: RequestError, cart_id?: number) => void) => void;
29
+ onCouponDeletionFailed: (callback: (error: RequestError, cart_id?: number) => void) => void;
30
+ }