@yusr_systems/core 2.2.9 → 2.4.0
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/index.d.ts +9 -0
- package/dist/yusr-core.js +66 -174
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -131,6 +131,15 @@ export declare type FilterResult<T> = {
|
|
|
131
131
|
count: number;
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
+
declare class LocalStorageService {
|
|
135
|
+
getItem<T>(key: string): T | null;
|
|
136
|
+
setItem<T>(key: string, value: T): void;
|
|
137
|
+
removeItem(key: string): void;
|
|
138
|
+
exists(key: string): boolean;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export declare const localStorageService: LocalStorageService;
|
|
142
|
+
|
|
134
143
|
export declare class LoginRequest {
|
|
135
144
|
companyEmail: string;
|
|
136
145
|
username: string;
|
package/dist/yusr-core.js
CHANGED
|
@@ -6,44 +6,59 @@ var n = class {
|
|
|
6
6
|
static AuthCheckStorageItemName = "IsLoggedIn";
|
|
7
7
|
static SettingStorageItemName = "Setting";
|
|
8
8
|
static UnauthorizedEventName = "ApiUnauthorized";
|
|
9
|
-
}, r =
|
|
10
|
-
|
|
9
|
+
}, r = new class {
|
|
10
|
+
getItem(e) {
|
|
11
|
+
if (typeof window > "u") return null;
|
|
12
|
+
let t = localStorage.getItem(e);
|
|
13
|
+
return t ? JSON.parse(t) : null;
|
|
14
|
+
}
|
|
15
|
+
setItem(e, t) {
|
|
16
|
+
typeof window > "u" || localStorage.setItem(e, JSON.stringify(t));
|
|
17
|
+
}
|
|
18
|
+
removeItem(e) {
|
|
19
|
+
typeof window > "u" || localStorage.removeItem(e);
|
|
20
|
+
}
|
|
21
|
+
exists(e) {
|
|
22
|
+
return typeof window > "u" ? !1 : localStorage.getItem(e) !== null;
|
|
23
|
+
}
|
|
24
|
+
}(), i = () => {
|
|
25
|
+
let e = r.getItem(n.AuthCheckStorageItemName) === "true", t = r.getItem(n.LoggedInUserStorageItemName), i = r.getItem(n.SettingStorageItemName);
|
|
11
26
|
return {
|
|
12
27
|
isAuthenticated: e,
|
|
13
28
|
loggedInUser: t ? JSON.parse(t) : void 0,
|
|
14
|
-
setting:
|
|
29
|
+
setting: i ? JSON.parse(i) : void 0
|
|
15
30
|
};
|
|
16
|
-
},
|
|
31
|
+
}, a = () => e({
|
|
17
32
|
name: "auth",
|
|
18
|
-
initialState:
|
|
33
|
+
initialState: i(),
|
|
19
34
|
reducers: {
|
|
20
35
|
login: (e, t) => {
|
|
21
|
-
e.isAuthenticated = !0,
|
|
36
|
+
e.isAuthenticated = !0, r.setItem(n.AuthCheckStorageItemName, "true"), t.payload && (e.loggedInUser = t.payload.user, r.setItem(n.LoggedInUserStorageItemName, JSON.stringify(t.payload.user)), e.setting = t.payload.setting, r.setItem(n.SettingStorageItemName, JSON.stringify(t.payload.setting)));
|
|
22
37
|
},
|
|
23
38
|
logout: (e) => {
|
|
24
|
-
e.isAuthenticated = !1, e.loggedInUser = void 0, e.setting = void 0,
|
|
39
|
+
e.isAuthenticated = !1, e.loggedInUser = void 0, e.setting = void 0, r.removeItem(n.AuthCheckStorageItemName), r.removeItem(n.LoggedInUserStorageItemName), r.removeItem(n.SettingStorageItemName);
|
|
25
40
|
},
|
|
26
41
|
updateLoggedInUser: (e, t) => {
|
|
27
42
|
e.loggedInUser = {
|
|
28
43
|
...e.loggedInUser,
|
|
29
44
|
...t.payload
|
|
30
|
-
},
|
|
45
|
+
}, r.setItem(n.LoggedInUserStorageItemName, JSON.stringify(e.loggedInUser));
|
|
31
46
|
},
|
|
32
47
|
updateSetting: (e, t) => {
|
|
33
48
|
e.setting = {
|
|
34
49
|
...e.setting,
|
|
35
50
|
...t.payload
|
|
36
|
-
},
|
|
51
|
+
}, r.setItem(n.SettingStorageItemName, JSON.stringify(e.setting));
|
|
37
52
|
},
|
|
38
53
|
syncFromStorage: (e) => {
|
|
39
|
-
e.isAuthenticated =
|
|
40
|
-
let t =
|
|
54
|
+
e.isAuthenticated = r.getItem(n.AuthCheckStorageItemName) === "true";
|
|
55
|
+
let t = r.getItem(n.LoggedInUserStorageItemName);
|
|
41
56
|
e.loggedInUser = t ? JSON.parse(t) : void 0;
|
|
42
|
-
let
|
|
43
|
-
e.setting =
|
|
57
|
+
let i = r.getItem(n.SettingStorageItemName);
|
|
58
|
+
e.setting = i ? JSON.parse(i) : void 0;
|
|
44
59
|
}
|
|
45
60
|
}
|
|
46
|
-
}),
|
|
61
|
+
}), o = class e {
|
|
47
62
|
static Format(e, t) {
|
|
48
63
|
return `${e}:${t}`;
|
|
49
64
|
}
|
|
@@ -64,32 +79,32 @@ var n = class {
|
|
|
64
79
|
let [t] = e[0].split(":");
|
|
65
80
|
return `/${t.toLowerCase()}`;
|
|
66
81
|
}
|
|
67
|
-
},
|
|
82
|
+
}, s = class {
|
|
68
83
|
id;
|
|
69
|
-
},
|
|
84
|
+
}, c = class extends s {
|
|
70
85
|
name;
|
|
71
86
|
countryId;
|
|
72
87
|
country;
|
|
73
88
|
constructor(e) {
|
|
74
89
|
super(), Object.assign(this, e);
|
|
75
90
|
}
|
|
76
|
-
},
|
|
91
|
+
}, l = class {
|
|
77
92
|
static columnsNames = [{
|
|
78
93
|
label: "اسم المدينة",
|
|
79
94
|
value: "Name"
|
|
80
95
|
}];
|
|
81
|
-
},
|
|
96
|
+
}, u = class extends s {
|
|
82
97
|
name;
|
|
83
98
|
code;
|
|
84
99
|
constructor(e) {
|
|
85
100
|
super(), Object.assign(this, e);
|
|
86
101
|
}
|
|
87
|
-
},
|
|
102
|
+
}, d = class {
|
|
88
103
|
static columnsNames = [{
|
|
89
104
|
label: "اسم الدولة",
|
|
90
105
|
value: "Name"
|
|
91
106
|
}];
|
|
92
|
-
},
|
|
107
|
+
}, f = class extends s {
|
|
93
108
|
name;
|
|
94
109
|
code;
|
|
95
110
|
isFeminine;
|
|
@@ -100,156 +115,33 @@ var n = class {
|
|
|
100
115
|
constructor(e) {
|
|
101
116
|
super(), Object.assign(this, e);
|
|
102
117
|
}
|
|
103
|
-
},
|
|
118
|
+
}, p = class {
|
|
104
119
|
value;
|
|
105
120
|
columnName;
|
|
106
121
|
constructor(e) {
|
|
107
122
|
Object.assign(this, e);
|
|
108
123
|
}
|
|
109
|
-
},
|
|
124
|
+
}, m = class {
|
|
110
125
|
companyEmail;
|
|
111
126
|
username;
|
|
112
127
|
password;
|
|
113
128
|
constructor(e) {
|
|
114
129
|
Object.assign(this, e);
|
|
115
130
|
}
|
|
116
|
-
},
|
|
131
|
+
}, h = class {
|
|
117
132
|
url = null;
|
|
118
133
|
base64File = null;
|
|
119
134
|
extension = null;
|
|
120
135
|
contentType = null;
|
|
121
|
-
status =
|
|
136
|
+
status = g.Unchanged;
|
|
122
137
|
constructor(e) {
|
|
123
138
|
Object.assign(this, e);
|
|
124
139
|
}
|
|
125
|
-
},
|
|
140
|
+
}, g = {
|
|
126
141
|
Unchanged: 0,
|
|
127
142
|
New: 1,
|
|
128
143
|
Delete: 2
|
|
129
|
-
},
|
|
130
|
-
static LoggedInUserStorageItemName = "LoggedInUser";
|
|
131
|
-
static AuthCheckStorageItemName = "IsLoggedIn";
|
|
132
|
-
static SettingStorageItemName = "Setting";
|
|
133
|
-
static UnauthorizedEventName = "ApiUnauthorized";
|
|
134
|
-
}, _ = class {
|
|
135
|
-
id;
|
|
136
|
-
}, v = class {
|
|
137
|
-
static _baseUrl = "";
|
|
138
|
-
static get baseUrl() {
|
|
139
|
-
return this._baseUrl || console.warn("YusrCore: baseUrl has not been initialized. Defaults to empty string."), this._baseUrl;
|
|
140
|
-
}
|
|
141
|
-
static initialize(e) {
|
|
142
|
-
this._baseUrl = e;
|
|
143
|
-
}
|
|
144
|
-
}, y = class e {
|
|
145
|
-
static async Get(t, n) {
|
|
146
|
-
let r = await fetch(t, {
|
|
147
|
-
method: "GET",
|
|
148
|
-
credentials: "include",
|
|
149
|
-
...n
|
|
150
|
-
});
|
|
151
|
-
return e.handleResponse(r);
|
|
152
|
-
}
|
|
153
|
-
static async Post(t, n, r, i) {
|
|
154
|
-
let a = n instanceof FormData, o = {
|
|
155
|
-
...r?.headers || {},
|
|
156
|
-
...!a && n ? { "Content-Type": "application/json" } : {}
|
|
157
|
-
}, s = await fetch(t, {
|
|
158
|
-
method: "POST",
|
|
159
|
-
credentials: "include",
|
|
160
|
-
headers: o,
|
|
161
|
-
body: a ? n : JSON.stringify(n),
|
|
162
|
-
...r
|
|
163
|
-
});
|
|
164
|
-
return e.handleResponse(s, i);
|
|
165
|
-
}
|
|
166
|
-
static async Put(t, n, r, i) {
|
|
167
|
-
let a = n instanceof FormData, o = {
|
|
168
|
-
...r?.headers || {},
|
|
169
|
-
...!a && n ? { "Content-Type": "application/json" } : {}
|
|
170
|
-
}, s = await fetch(t, {
|
|
171
|
-
method: "PUT",
|
|
172
|
-
credentials: "include",
|
|
173
|
-
headers: o,
|
|
174
|
-
body: a ? n : JSON.stringify(n),
|
|
175
|
-
...r
|
|
176
|
-
});
|
|
177
|
-
return e.handleResponse(s, i);
|
|
178
|
-
}
|
|
179
|
-
static async Delete(t, n, r) {
|
|
180
|
-
let i = await fetch(t, {
|
|
181
|
-
method: "DELETE",
|
|
182
|
-
credentials: "include",
|
|
183
|
-
...n
|
|
184
|
-
});
|
|
185
|
-
return e.handleResponse(i, r);
|
|
186
|
-
}
|
|
187
|
-
static async PostBlob(e, n, r) {
|
|
188
|
-
let i = n instanceof FormData, a = {
|
|
189
|
-
...r?.headers || {},
|
|
190
|
-
...!i && n ? { "Content-Type": "application/json" } : {}
|
|
191
|
-
}, o = await fetch(e, {
|
|
192
|
-
method: "POST",
|
|
193
|
-
credentials: "include",
|
|
194
|
-
headers: a,
|
|
195
|
-
body: i ? n : JSON.stringify(n),
|
|
196
|
-
...r
|
|
197
|
-
});
|
|
198
|
-
if (!o.ok) {
|
|
199
|
-
let e = await o.json();
|
|
200
|
-
t.error(e.title || "حدث خطأ أثناء تحميل التقرير", { description: e.detail || "يرجى المحاولة مرة أخرى لاحقاً" });
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
return await o.blob();
|
|
204
|
-
}
|
|
205
|
-
static async handleResponse(e, n) {
|
|
206
|
-
if (e.status === 401) return window.dispatchEvent(new Event(g.UnauthorizedEventName)), t.error("انتهت صلاحية الدخول", { description: "سجل الدخول مجددًا." }), {
|
|
207
|
-
data: void 0,
|
|
208
|
-
status: 401,
|
|
209
|
-
errorTitle: "Unauthorized",
|
|
210
|
-
errorDetails: "Session expired"
|
|
211
|
-
};
|
|
212
|
-
if (e.status === 404) return t.error("لم يتم العثور على طلبك"), {
|
|
213
|
-
data: void 0,
|
|
214
|
-
status: 404,
|
|
215
|
-
errorTitle: "Not Found",
|
|
216
|
-
errorDetails: ""
|
|
217
|
-
};
|
|
218
|
-
if (!e.ok) {
|
|
219
|
-
let n = await e.json();
|
|
220
|
-
return t.error(n.title || "An error occurred", { description: n.detail }), {
|
|
221
|
-
data: void 0,
|
|
222
|
-
status: e.status,
|
|
223
|
-
errorTitle: n.title,
|
|
224
|
-
errorDetails: n.detail
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
let r = await e.json();
|
|
228
|
-
return n && t.success(n), {
|
|
229
|
-
data: r,
|
|
230
|
-
status: e.status,
|
|
231
|
-
errorTitle: "",
|
|
232
|
-
errorDetails: ""
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
}, b = class {
|
|
236
|
-
async Filter(e, t, n) {
|
|
237
|
-
return await y.Post(`${v.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
|
|
238
|
-
}
|
|
239
|
-
}, x = class extends b {
|
|
240
|
-
async Get(e) {
|
|
241
|
-
return await y.Get(`${v.baseUrl}/${this.routeName}/${e}`);
|
|
242
|
-
}
|
|
243
|
-
async Add(e) {
|
|
244
|
-
return await y.Post(`${v.baseUrl}/${this.routeName}/Add`, e, void 0, "تم حفظ البيانات بنجاح");
|
|
245
|
-
}
|
|
246
|
-
async Update(e) {
|
|
247
|
-
return await y.Put(`${v.baseUrl}/${this.routeName}/Update`, e, void 0, "تم تحديث المعلومات بنجاح");
|
|
248
|
-
}
|
|
249
|
-
async Delete(e) {
|
|
250
|
-
return await y.Delete(`${v.baseUrl}/${this.routeName}/${e}`, void 0, "تمت إزالة السجل بنجاح");
|
|
251
|
-
}
|
|
252
|
-
}, S = class extends _ {
|
|
144
|
+
}, _ = class extends s {
|
|
253
145
|
name;
|
|
254
146
|
cityId;
|
|
255
147
|
cityName;
|
|
@@ -260,7 +152,7 @@ var n = class {
|
|
|
260
152
|
constructor(e) {
|
|
261
153
|
super(), Object.assign(this, e);
|
|
262
154
|
}
|
|
263
|
-
},
|
|
155
|
+
}, v = class {
|
|
264
156
|
static columnsNames = [{
|
|
265
157
|
label: "اسم الفرع",
|
|
266
158
|
value: "Name"
|
|
@@ -268,18 +160,18 @@ var n = class {
|
|
|
268
160
|
label: "رقم الفرع",
|
|
269
161
|
value: "Id"
|
|
270
162
|
}];
|
|
271
|
-
},
|
|
163
|
+
}, y = class extends s {
|
|
272
164
|
name;
|
|
273
165
|
permissions;
|
|
274
166
|
constructor(e) {
|
|
275
167
|
super(), Object.assign(this, e);
|
|
276
168
|
}
|
|
277
|
-
},
|
|
169
|
+
}, b = class {
|
|
278
170
|
static columnsNames = [{
|
|
279
171
|
label: "اسم الدور",
|
|
280
172
|
value: "Name"
|
|
281
173
|
}];
|
|
282
|
-
},
|
|
174
|
+
}, x = class extends s {
|
|
283
175
|
username;
|
|
284
176
|
password;
|
|
285
177
|
isActive;
|
|
@@ -290,7 +182,7 @@ var n = class {
|
|
|
290
182
|
constructor(e) {
|
|
291
183
|
super(), Object.assign(this, e);
|
|
292
184
|
}
|
|
293
|
-
},
|
|
185
|
+
}, S = class {
|
|
294
186
|
static columnsNames = [{
|
|
295
187
|
label: "رقم المستخدم",
|
|
296
188
|
value: "Id"
|
|
@@ -298,7 +190,7 @@ var n = class {
|
|
|
298
190
|
label: "اسم المستخدم",
|
|
299
191
|
value: "Username"
|
|
300
192
|
}];
|
|
301
|
-
},
|
|
193
|
+
}, C = class {
|
|
302
194
|
static _baseUrl = "";
|
|
303
195
|
static get baseUrl() {
|
|
304
196
|
return this._baseUrl || console.warn("YusrCore: baseUrl has not been initialized. Defaults to empty string."), this._baseUrl;
|
|
@@ -306,7 +198,7 @@ var n = class {
|
|
|
306
198
|
static initialize(e) {
|
|
307
199
|
this._baseUrl = e;
|
|
308
200
|
}
|
|
309
|
-
},
|
|
201
|
+
}, w = class e {
|
|
310
202
|
static async Get(t, n) {
|
|
311
203
|
let r = await fetch(t, {
|
|
312
204
|
method: "GET",
|
|
@@ -397,45 +289,45 @@ var n = class {
|
|
|
397
289
|
errorDetails: ""
|
|
398
290
|
};
|
|
399
291
|
}
|
|
400
|
-
},
|
|
292
|
+
}, T = class {
|
|
401
293
|
async Filter(e, t, n) {
|
|
402
|
-
return await
|
|
294
|
+
return await w.Post(`${C.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
|
|
403
295
|
}
|
|
404
|
-
},
|
|
296
|
+
}, E = class extends T {
|
|
405
297
|
async Get(e) {
|
|
406
|
-
return await
|
|
298
|
+
return await w.Get(`${C.baseUrl}/${this.routeName}/${e}`);
|
|
407
299
|
}
|
|
408
300
|
async Add(e) {
|
|
409
|
-
return await
|
|
301
|
+
return await w.Post(`${C.baseUrl}/${this.routeName}/Add`, e, void 0, "تم حفظ البيانات بنجاح");
|
|
410
302
|
}
|
|
411
303
|
async Update(e) {
|
|
412
|
-
return await
|
|
304
|
+
return await w.Put(`${C.baseUrl}/${this.routeName}/Update`, e, void 0, "تم تحديث المعلومات بنجاح");
|
|
413
305
|
}
|
|
414
306
|
async Delete(e) {
|
|
415
|
-
return await
|
|
307
|
+
return await w.Delete(`${C.baseUrl}/${this.routeName}/${e}`, void 0, "تمت إزالة السجل بنجاح");
|
|
416
308
|
}
|
|
417
|
-
},
|
|
309
|
+
}, D = class extends E {
|
|
418
310
|
routeName = "Branches";
|
|
419
|
-
},
|
|
311
|
+
}, O = class extends T {
|
|
420
312
|
routeName = "Cities";
|
|
421
313
|
async Filter(e, t, n) {
|
|
422
|
-
return await
|
|
314
|
+
return await w.Post(`${C.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
|
|
423
315
|
}
|
|
424
|
-
},
|
|
316
|
+
}, k = class extends T {
|
|
425
317
|
routeName = "Countries";
|
|
426
318
|
async Filter(e, t, n) {
|
|
427
|
-
return await
|
|
319
|
+
return await w.Post(`${C.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
|
|
428
320
|
}
|
|
429
|
-
},
|
|
321
|
+
}, A = class extends T {
|
|
430
322
|
routeName = "Currencies";
|
|
431
323
|
async Filter(e, t, n) {
|
|
432
|
-
return await
|
|
324
|
+
return await w.Post(`${C.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
|
|
433
325
|
}
|
|
434
|
-
},
|
|
326
|
+
}, j = class extends E {
|
|
435
327
|
routeName = "Roles";
|
|
436
|
-
},
|
|
328
|
+
}, M = class extends E {
|
|
437
329
|
routeName = "Users";
|
|
438
|
-
},
|
|
330
|
+
}, N = class {
|
|
439
331
|
static required(e = "هذا الحقل مطلوب") {
|
|
440
332
|
return (t) => t == null || t === "" || typeof t == "string" && t.trim() === "" ? e : null;
|
|
441
333
|
}
|
|
@@ -453,4 +345,4 @@ var n = class {
|
|
|
453
345
|
}
|
|
454
346
|
};
|
|
455
347
|
//#endregion
|
|
456
|
-
export {
|
|
348
|
+
export { C as ApiConstants, n as AuthConstants, E as BaseApiService, s as BaseEntity, T as BaseFilterableApiService, _ as Branch, v as BranchFilterColumns, D as BranchesApiService, O as CitiesApiService, c as City, l as CityFilterColumns, k as CountriesApiService, u as Country, d as CountryFilterColumns, A as CurrenciesApiService, f as Currency, p as FilterCondition, m as LoginRequest, y as Role, b as RoleFilterColumns, j as RolesApiService, h as StorageFile, g as StorageFileStatus, o as SystemPermissions, x as User, S as UserFilterColumns, M as UsersApiService, N as Validators, w as YusrApiHelper, a as createAuthSlice, r as localStorageService };
|