@salla.sa/twilight 2.12.64 → 2.12.65

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.12.64",
3
+ "version": "2.12.65",
4
4
  "description": "Salla Theme Toolkit, Webcomponents, Events, Requests, Utils",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -8,7 +8,7 @@
8
8
  "scripts": {
9
9
  "build": "npx rollup --config --preserveSymlinks=true",
10
10
  "watch": "npx rollup --watch --config --preserveSymlinks=true",
11
- "test": "jest --detectOpenHandles -- advertisement.test",
11
+ "test": "jest --detectOpenHandles -- component.test",
12
12
  "express": "node tests/server/index.js"
13
13
  },
14
14
  "keywords": [
@@ -67,5 +67,5 @@
67
67
  "peerDependencies": {
68
68
  "webpack": "^4 || ^5"
69
69
  },
70
- "gitHead": "bb9279af324e38f9e4b4f3d1caa34bbf418a7c5a"
70
+ "gitHead": "4114d79a56944bb5a339ca236240538cac4f7f6f"
71
71
  }
@@ -4,6 +4,7 @@ export type VerificationStatus = {
4
4
  type: 'mobile' | 'email';
5
5
  status: 'success' | 'pending' | 'failed';
6
6
  }
7
+
7
8
  export namespace AuthResponse {
8
9
  export interface verify extends SuccessResponse {
9
10
  data: {
@@ -0,0 +1,92 @@
1
+ import {SuccessResponse, Product} from '../common'
2
+
3
+ export interface AdvertisementColor {
4
+ bg: string;
5
+ text: string;
6
+ }
7
+
8
+ export interface HeaderBreadcrumb {
9
+ title: string;
10
+ url: string;
11
+ }
12
+
13
+ export interface HeaderAdvertisement {
14
+ id: number;
15
+ icon: string;
16
+ title: string;
17
+ description: string;
18
+ url?: string;
19
+ close_url: string;
20
+ target: string;
21
+ colors: AdvertisementColor[];
22
+ }
23
+
24
+ export interface HeaderMenuItem {
25
+ has_children?: boolean;
26
+ url?: string;
27
+ title?: string;
28
+ attrs?: string;
29
+ link_attrs?: string;
30
+ products?: Product[];
31
+ children?: Header[];
32
+ }
33
+
34
+ export interface Header {
35
+ menu: HeaderMenuItem[];
36
+ advertisement?: HeaderAdvertisement[];
37
+ breadcrumbs: HeaderBreadcrumb[];
38
+ }
39
+
40
+ // Footer
41
+ export interface FooterMenu {
42
+ id?: number;
43
+ title?: string;
44
+ url?: string;
45
+ target?: string;
46
+ }
47
+
48
+ export interface FooterContact {
49
+ name?: string;
50
+ type?: string;
51
+ icon?: string;
52
+ url?: string;
53
+ value?: string;
54
+ }
55
+
56
+ export interface FooterMobileApp {
57
+ name?: string;
58
+ url?: string;
59
+ // TODO?: ask @jamal to add this field to the DTO,
60
+ // otherwise there is no way to get the image of the mobile app.
61
+ // (i.e. for the sake of simplicity)
62
+ icon?: string;
63
+ }
64
+
65
+ export interface FooterPaymentMethod {
66
+ payment_methods
67
+ }
68
+
69
+ export interface FooterSocialLink {
70
+ name?: string;
71
+ type?: string;
72
+ icon?: string;
73
+ url?: string;
74
+ }
75
+
76
+ export interface Footer {
77
+ contacts?: FooterContact[];
78
+ apps?: FooterMobileApp[];
79
+ items?: FooterMenu[];
80
+ payment_methods?: string[];
81
+ links?: FooterSocialLink[]
82
+ }
83
+
84
+ export namespace ComponentApiResponse {
85
+ export interface menus extends SuccessResponse {
86
+ data: HeaderMenuItem[] | FooterMenu[] | []
87
+ }
88
+ }
89
+
90
+ export default interface ComponentApi {
91
+ menus?: (component: string) => Promise<ComponentApiResponse.menus>
92
+ }
@@ -1,11 +1,11 @@
1
- import {SuccessResponse} from "../common";
1
+ import {SuccessResponse, Genders} from "../common";
2
2
  import {AuthRequest, VerificationStatus} from "./auth";
3
3
 
4
4
  export interface ProfileUpdatePayload {
5
5
  first_name: string;
6
6
  last_name: string;
7
- birthday?: string | '2022-02-22';
8
- gender?: 'male' | 'female';
7
+ birthday?: string;
8
+ gender?: Genders.Male | Genders.Female;
9
9
  avatar?: BinaryType;
10
10
  }
11
11
 
package/types/common.d.ts CHANGED
@@ -41,26 +41,104 @@ export interface Currency {
41
41
  }
42
42
 
43
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';
44
+ id?: number;
45
+ name?: string;
46
+ sku?: null | string;
47
+ subtitle?: null | string;
48
+ url?: string;
49
+ promotion_title?: null | string;
50
+ status?: string;
51
+ type?: string;
52
+ description?: string;
53
+ quantity?: number | any;
54
+ max_quantity?: number;
55
+ sold_quantity?: any;
56
+ price?: any[];
57
+ regular_price?: any[];
58
+ sale_price?: any[];
59
+ starting_price?: any;
60
+ discount_ends?: any;
61
+ discount_percentage?: string;
62
+ image?: MainImage;
63
+ calories?: any;
64
+ weight?: any;
65
+ base_currency_price?: any[];
66
+ currency?: string;
67
+ donation?: any;
68
+ images?: ImageElement[];
69
+ rating?: any;
70
+ options?: any[];
71
+ tags?: any[];
72
+ brand?: Brand | any;
73
+ notify_availability?: any;
74
+ category?: any;
75
+ can_add_note?: boolean;
76
+ can_donate?: boolean;
77
+ can_upload_file?: boolean;
78
+ can_show_sold?: boolean;
79
+ can_show_remained_quantity?: boolean;
80
+ has_3d_image?: boolean;
81
+ has_custom_form?: boolean;
82
+ has_options?: boolean;
83
+ has_read_more?: boolean;
84
+ has_size_guide?: boolean;
85
+ is_available?: boolean;
86
+ is_hidden_quantity?: boolean;
87
+ is_in_wishlist?: boolean;
88
+ is_on_sale?: boolean;
89
+ is_out_of_stock?: boolean;
90
+ is_require_shipping?: boolean;
91
+ is_taxable?: boolean;
92
+ is_giftable?: boolean;
93
+ is_donation?: boolean;
94
+ is_booking?: boolean;
95
+ brand_id?: number | any;
96
+ target_donating_enable?: boolean;
97
+ price_as_float?: number;
98
+ price_as_float_for_payment?: number;
99
+ currency_for_payment?: string;
100
+ sale_end?: any;
101
+ customized_sku_quantity?: any;
102
+ auto_include_tax?: any;
103
+ with_tax?: boolean;
104
+ enabled_image_upload?: any;
105
+ max_quantity_per_order?: any;
106
+ source?: any;
107
+ available?: any;
108
+ notes?: any;
109
+ attachments?: any;
110
+ add_to_cart_label?: string;
111
+ show_availability?: boolean;
112
+ }
113
+
114
+ export interface MainImage {
115
+ url?: string;
116
+ alt?: string;
117
+ }
118
+
119
+ export interface Brand {
120
+ id: string;
59
121
  url: string;
60
- thumbnail: string;
61
- calories?: number;
122
+ name: string;
123
+ logo: string;
124
+ }
125
+
126
+ export interface ImageElement {
127
+ id?: number;
128
+ url?: string;
129
+ main?: boolean;
130
+ three_d_image_url?: string;
131
+ alt?: string;
132
+ video_url?: string;
133
+ type?: Type;
134
+ sort?: number;
62
135
  }
63
136
 
137
+ export enum Type {
138
+ Image = "image",
139
+ }
140
+
141
+
64
142
  export interface Category {
65
143
  id: number;
66
144
  name: string;
@@ -72,4 +150,31 @@ export interface RequestInfo {
72
150
  method: string;
73
151
  payload: any,
74
152
  options: {},
153
+ }
154
+
155
+ export interface UserInstance {
156
+ id?: number;
157
+ currency?: string;
158
+ language?: string;
159
+ first_name?: string;
160
+ last_name?: string;
161
+ phone?: Phone;
162
+ email?: string;
163
+ avatar?: string;
164
+ gender?: string;
165
+ birthday?: string;
166
+ notifications?: number;
167
+ loyalty_program_points?: number;
168
+ pending_orders?: string;
169
+ }
170
+
171
+ export interface Phone {
172
+ code?: string;
173
+ number?: number;
174
+ country?: string;
175
+ }
176
+
177
+ export enum Genders {
178
+ Female = 'female',
179
+ Male = 'male',
75
180
  }
@@ -8,7 +8,7 @@ export default interface AuthEvent {
8
8
  onRegistered: (callback: (response: AuthResponse.verify) => void) => void;
9
9
  onLoggedIn: (callback: (response: AuthResponse.verify) => void) => void;
10
10
  onLoggedOut: (callback: (response: SuccessResponse) => void) => void;
11
-
11
+
12
12
  //Error Responses
13
13
  onCodeNotSent: (callback: (error: RequestError | string, type?: 'mobile' | 'email') => void) => void;
14
14
  onVerificationFailed: (callback: (error: RequestError | string, type?: 'mobile' | 'email') => void) => void;
@@ -0,0 +1,8 @@
1
+ import { RequestErrorEvent } from "../common";
2
+ import { ComponentApiResponse } from "../api/component";
3
+
4
+
5
+ export default interface ComponentEvent {
6
+ onFetched: (callback: (response: ComponentApiResponse.menus) => void) => void;
7
+ onFetchFailed: RequestErrorEvent
8
+ }