-
Notifications
You must be signed in to change notification settings - Fork 22
/
ts-types.ts
314 lines (282 loc) · 8.06 KB
/
ts-types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
// CUSTOMER PRIVILEGES
export enum INTERNAL_PRIVILEGES {
READ = 'read_privilege',
CREATE = 'create_privilege',
UPDATE = 'update_privilege',
DELETE = 'delete_privilege',
}
// STAFF PRIVILEGES
export enum STAFF_PRIVILEGES {
READ = 'staff_read_privilege',
CREATE = 'staff_create_privilege',
UPDATE = 'staff_update_privilege',
DELETE = 'staff_delete_privilege',
}
// ADMIN PRIVILEGES
export enum ADMIN_PRIVILEGES {
READ = 'admin_read_privilege',
CREATE = 'admin_create_privilege',
UPDATE = 'admin_update_privilege',
DELETE = 'admin_delete_privilege',
SUPER = 'super_admin_privilege',
}
export enum SortOrder {
Asc = 'ASC',
Desc = 'DESC',
}
export enum OrderBy {
CREATED_AT = 'created_at',
UPDATED_AT = 'updated_at',
}
export enum SortOrder {
/** Sort records in ascending order. */
Asc = 'ASC',
/** Sort records in descending order. */
Desc = 'DESC',
}
export enum OrderBy {
CREATED_AT = 'created_at',
UPDATED_AT = 'updated_at',
}
export enum CouponDiscountsType {
Fixed = 'fixed',
Percentage = 'percentage',
FreeShipping = 'free_shipping',
}
// Nullable can be assigned to a value or can be assigned to null.
export declare type Nullable<T> = T | null;
/** Built-in and custom scalars are mapped to their actual values */
export declare type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
SortOrder: SortOrder.Asc | SortOrder.Desc;
/** A datetime string with format `Y-m-d H:i:s`, e.g. `2018-05-23 13:43:32`. */
DateTime: string | number | Date;
Mixed: string | number | Date;
Upload: string | number | Date;
/** A date string with format `Y-m-d`, e.g. `2011-05-23`. */
Date: string | number | Date;
/** A datetime and timezone string in ISO 8601 format `Y-m-dTH:i:sO`, e.g. `2020-04-20T13:53:12+02:00`. */
DateTimeTz: string | number | Date;
};
export type PrivilegesType = (
| typeof INTERNAL_PRIVILEGES.READ
| typeof INTERNAL_PRIVILEGES.CREATE
| typeof INTERNAL_PRIVILEGES.DELETE
| typeof INTERNAL_PRIVILEGES.UPDATE
| typeof STAFF_PRIVILEGES.READ
| typeof STAFF_PRIVILEGES.CREATE
| typeof STAFF_PRIVILEGES.UPDATE
| typeof STAFF_PRIVILEGES.DELETE
| typeof ADMIN_PRIVILEGES.READ
| typeof ADMIN_PRIVILEGES.CREATE
| typeof ADMIN_PRIVILEGES.UPDATE
| typeof ADMIN_PRIVILEGES.DELETE
| typeof ADMIN_PRIVILEGES.SUPER
)[];
export type ActionsType = [
(
| typeof INTERNAL_PRIVILEGES.READ
| typeof INTERNAL_PRIVILEGES.CREATE
| typeof INTERNAL_PRIVILEGES.DELETE
| typeof INTERNAL_PRIVILEGES.UPDATE
| typeof STAFF_PRIVILEGES.READ
| typeof STAFF_PRIVILEGES.CREATE
| typeof STAFF_PRIVILEGES.UPDATE
| typeof STAFF_PRIVILEGES.DELETE
| typeof ADMIN_PRIVILEGES.READ
| typeof ADMIN_PRIVILEGES.CREATE
| typeof ADMIN_PRIVILEGES.UPDATE
| typeof ADMIN_PRIVILEGES.DELETE
),
typeof ADMIN_PRIVILEGES.SUPER?
];
// -----
interface SharedValues {
created_at?: Nullable<Scalars['DateTimeTz']>;
updated_at?: Nullable<Scalars['DateTimeTz']>;
created_by?: Nullable<{
id: Scalars['ID'];
first_name?: Scalars['String'];
last_name?: Scalars['String'];
profile?: IMGType;
}>;
updated_by?: Nullable<{
id: Scalars['ID'];
first_name?: Scalars['String'];
last_name?: Scalars['String'];
profile?: IMGType;
}>;
// extra
page: Nullable<Scalars['Int']>;
limit: Nullable<Scalars['Int']>;
orderBy: OrderBy;
sortedBy: SortOrder;
count: number;
}
export interface CategoryType extends SharedValues {
id: Scalars['ID'];
parent_id?: Nullable<Scalars['ID']>;
category_name: Scalars['String'];
category_description?: Nullable<Scalars['String']>;
active?: Scalars['Boolean'];
icon?: Scalars['String'];
thumbnail?: IMGType;
has_children?: Scalars['Boolean'];
}
export interface AttributesType extends SharedValues {
id?: string;
attribute_name?: string;
attribute_values?: AttributeValuesType[];
}
export interface ShippingType extends SharedValues {
id?: string;
shipper_name?: string;
active?: boolean;
thumbnail?: IMGType;
}
export interface AttributeValuesType {
id?: string;
attribute_id?: string;
attribute_value?: string;
color?: string;
}
export interface TagType extends SharedValues {
id?: string;
tag_name?: string;
icon?: string;
}
export interface OrderStatusType extends SharedValues {
id?: string;
status_name?: string;
color?: string;
privacy?: string;
}
export interface CouponType extends SharedValues {
id?: Nullable<Scalars['ID']>;
code?: Nullable<Scalars['String']>;
discount_value?: Scalars['Int'];
order_amount_limit?: Scalars['Int'];
discount_type?: CouponDiscountsType;
image_path?: Nullable<Scalars['String']>;
times_used?: Nullable<Scalars['Int']>;
max_usage?: Nullable<Scalars['Int']>;
coupon_start_date?: Nullable<Scalars['Date']>;
coupon_end_date?: Nullable<Scalars['Date']>;
}
export interface ProductType extends SharedValues {
id: Scalars['ID'];
slug: Scalars['String'];
product_name: Scalars['String'];
sku?: Nullable<Scalars['String']>;
sale_price?: Scalars['Float'];
compare_price?: Scalars['Float'];
buying_price?: Scalars['Float'];
max_price?: Scalars['Float'];
min_price?: Scalars['Float'];
quantity?: Scalars['Int'];
short_description?: Nullable<Scalars['String']>;
product_description?: Scalars['String'];
published?: Scalars['Boolean'];
status?: 'draft' | 'publish';
disable_out_of_stock?: Scalars['Boolean'];
note?: Nullable<Scalars['String']>;
thumbnail?: IMGType;
gallery?: IMGType[];
categories?: Array<CategoryType>;
suppliers?: Nullable<Array<Nullable<SuppliersType>>>;
tags?: Nullable<Array<Nullable<TagType>>>;
shippings?: Nullable<Array<Nullable<ProductShippings>>>;
product_shipping_info?: ProductShippingInfo;
variation_options: ProductVariationOptions[];
variations?: {
attribute: AttributesType;
attribute_values: Array<Nullable<AttributeValuesType>>;
}[];
// [key: string]: any;
}
export interface ProductVariationOptions {
id: Scalars['ID'];
product_id: Scalars['ID'];
title: Scalars['String'];
is_disable: Scalars['Boolean'];
active: boolean;
image: Scalars['String'];
options: string[];
sale_price: Scalars['Float'];
compare_price: Scalars['Float'];
buying_price: Scalars['Float'];
quantity: Scalars['Int'];
sku: Scalars['String'];
}
export interface IMGType {
id: Scalars['String'];
image: Scalars['String'];
placeholder: Scalars['String'];
is_thumbnail: boolean;
}
export interface ProductShippings {
shipping_zones?: {
zones: { name: string; code: string }[];
shipping_price?: Scalars['Float'];
}[];
shipping_provider?: Shipping;
}
export interface Shipping extends SharedValues {
id?: Nullable<Scalars['ID']>;
shipper_name?: Nullable<Scalars['String']>;
active?: Nullable<Scalars['Boolean']>;
thumbnail?: IMGType;
}
export interface ProductShippingInfo {
id?: Scalars['ID'];
product_id?: Scalars['ID'];
weight?: Scalars['Int'];
weight_unit?: Scalars['String'];
volume?: Scalars['Int'];
volume_unit?: Scalars['String'];
dimension_width?: Scalars['Int'];
dimension_height?: Scalars['Int'];
dimension_depth?: Scalars['Int'];
dimension_unit?: Scalars['String'];
}
export interface StaffAccountType extends SharedValues {
id: string;
first_name: string;
last_name: string;
phone_number: string | null;
email: string;
password_hash: string;
password: string;
active: boolean;
profile: IMGType;
role?: RoleInterfaceType;
role_id?: number;
// privileges: string[];
}
export interface RoleInterfaceType {
id: number;
role_name: string;
privileges: PrivilegesType;
}
export interface LoginType {
email: string;
password: string;
remember_me: boolean;
store_name: string;
}
export interface SuppliersType extends SharedValues {
id?: Scalars['ID'];
supplier_name?: Scalars['String'];
company?: Nullable<Scalars['String']>;
phone_number?: Nullable<Scalars['String']>;
dial_code?: Nullable<Scalars['String']>;
address_line1?: Scalars['String'];
address_line2?: Nullable<Scalars['String']>;
country?: Nullable<Scalars['String']>;
city?: Nullable<Scalars['String']>;
note?: Nullable<Scalars['String']>;
}