@yusr_systems/core 6.0.1 → 6.0.3

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 CHANGED
@@ -131,15 +131,6 @@ 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
-
143
134
  export declare class LoginRequest {
144
135
  companyEmail: string;
145
136
  username: string;
package/dist/yusr-core.js CHANGED
@@ -6,60 +6,44 @@ var n = class {
6
6
  static AuthCheckStorageItemName = "IsLoggedIn";
7
7
  static SettingStorageItemName = "Setting";
8
8
  static UnauthorizedEventName = "ApiUnauthorized";
9
- }, r = {
10
- getItem: (e) => typeof window > "u" ? null : localStorage.getItem(e),
11
- setItem: (e, t) => {
12
- typeof window < "u" && localStorage.setItem(e, t);
13
- },
14
- removeItem: (e) => {
15
- typeof window < "u" && localStorage.removeItem(e);
16
- }
17
- }, i = () => {
18
- let e = r.getItem(n.AuthCheckStorageItemName) === "true", t = r.getItem(n.LoggedInUserStorageItemName), i = r.getItem(n.SettingStorageItemName);
19
- try {
20
- return {
21
- isAuthenticated: e,
22
- loggedInUser: t ? JSON.parse(t) : void 0,
23
- setting: i ? JSON.parse(i) : void 0
24
- };
25
- } catch {
26
- return {
27
- isAuthenticated: !1,
28
- loggedInUser: void 0,
29
- setting: void 0
30
- };
31
- }
32
- }, a = () => e({
9
+ }, r = () => {
10
+ let e = localStorage.getItem(n.AuthCheckStorageItemName) === "true", t = localStorage.getItem(n.LoggedInUserStorageItemName), r = localStorage.getItem(n.SettingStorageItemName);
11
+ return {
12
+ isAuthenticated: e,
13
+ loggedInUser: t ? JSON.parse(t) : void 0,
14
+ setting: r ? JSON.parse(r) : void 0
15
+ };
16
+ }, i = () => e({
33
17
  name: "auth",
34
- initialState: i(),
18
+ initialState: r(),
35
19
  reducers: {
36
20
  login: (e, t) => {
37
- 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)));
21
+ e.isAuthenticated = !0, localStorage.setItem(n.AuthCheckStorageItemName, "true"), t.payload && (e.loggedInUser = t.payload.user, localStorage.setItem(n.LoggedInUserStorageItemName, JSON.stringify(t.payload.user)), e.setting = t.payload.setting, localStorage.setItem(n.SettingStorageItemName, JSON.stringify(t.payload.setting)));
38
22
  },
39
23
  logout: (e) => {
40
- e.isAuthenticated = !1, e.loggedInUser = void 0, e.setting = void 0, r.removeItem(n.AuthCheckStorageItemName), r.removeItem(n.LoggedInUserStorageItemName), r.removeItem(n.SettingStorageItemName);
24
+ e.isAuthenticated = !1, e.loggedInUser = void 0, e.setting = void 0, localStorage.removeItem(n.AuthCheckStorageItemName), localStorage.removeItem(n.LoggedInUserStorageItemName), localStorage.removeItem(n.SettingStorageItemName);
41
25
  },
42
26
  updateLoggedInUser: (e, t) => {
43
27
  e.loggedInUser = {
44
28
  ...e.loggedInUser,
45
29
  ...t.payload
46
- }, r.setItem(n.LoggedInUserStorageItemName, JSON.stringify(e.loggedInUser));
30
+ }, localStorage.setItem(n.LoggedInUserStorageItemName, JSON.stringify(e.loggedInUser));
47
31
  },
48
32
  updateSetting: (e, t) => {
49
33
  e.setting = {
50
34
  ...e.setting,
51
35
  ...t.payload
52
- }, r.setItem(n.SettingStorageItemName, JSON.stringify(e.setting));
36
+ }, localStorage.setItem(n.SettingStorageItemName, JSON.stringify(e.setting));
53
37
  },
54
38
  syncFromStorage: (e) => {
55
- e.isAuthenticated = r.getItem(n.AuthCheckStorageItemName) === "true";
56
- let t = r.getItem(n.LoggedInUserStorageItemName);
39
+ e.isAuthenticated = localStorage.getItem(n.AuthCheckStorageItemName) === "true";
40
+ let t = localStorage.getItem(n.LoggedInUserStorageItemName);
57
41
  e.loggedInUser = t ? JSON.parse(t) : void 0;
58
- let i = r.getItem(n.SettingStorageItemName);
59
- e.setting = i ? JSON.parse(i) : void 0;
42
+ let r = localStorage.getItem(n.SettingStorageItemName);
43
+ e.setting = r ? JSON.parse(r) : void 0;
60
44
  }
61
45
  }
62
- }), o = class e {
46
+ }), a = class e {
63
47
  static Format(e, t) {
64
48
  return `${e}:${t}`;
65
49
  }
@@ -80,32 +64,32 @@ var n = class {
80
64
  let [t] = e[0].split(":");
81
65
  return `/${t.toLowerCase()}`;
82
66
  }
83
- }, s = class {
67
+ }, o = class {
84
68
  id;
85
- }, c = class extends s {
69
+ }, s = class extends o {
86
70
  name;
87
71
  countryId;
88
72
  country;
89
73
  constructor(e) {
90
74
  super(), Object.assign(this, e);
91
75
  }
92
- }, l = class {
76
+ }, c = class {
93
77
  static columnsNames = [{
94
78
  label: "اسم المدينة",
95
79
  value: "Name"
96
80
  }];
97
- }, u = class extends s {
81
+ }, l = class extends o {
98
82
  name;
99
83
  code;
100
84
  constructor(e) {
101
85
  super(), Object.assign(this, e);
102
86
  }
103
- }, d = class {
87
+ }, u = class {
104
88
  static columnsNames = [{
105
89
  label: "اسم الدولة",
106
90
  value: "Name"
107
91
  }];
108
- }, f = class extends s {
92
+ }, d = class extends o {
109
93
  name;
110
94
  code;
111
95
  isFeminine;
@@ -116,33 +100,33 @@ var n = class {
116
100
  constructor(e) {
117
101
  super(), Object.assign(this, e);
118
102
  }
119
- }, p = class {
103
+ }, f = class {
120
104
  value;
121
105
  columnName;
122
106
  constructor(e) {
123
107
  Object.assign(this, e);
124
108
  }
125
- }, m = class {
109
+ }, p = class {
126
110
  companyEmail;
127
111
  username;
128
112
  password;
129
113
  constructor(e) {
130
114
  Object.assign(this, e);
131
115
  }
132
- }, h = class {
116
+ }, m = class {
133
117
  url = null;
134
118
  base64File = null;
135
119
  extension = null;
136
120
  contentType = null;
137
- status = g.Unchanged;
121
+ status = h.Unchanged;
138
122
  constructor(e) {
139
123
  Object.assign(this, e);
140
124
  }
141
- }, g = {
125
+ }, h = {
142
126
  Unchanged: 0,
143
127
  New: 1,
144
128
  Delete: 2
145
- }, _ = class extends s {
129
+ }, g = class extends o {
146
130
  name;
147
131
  cityId;
148
132
  cityName;
@@ -153,7 +137,7 @@ var n = class {
153
137
  constructor(e) {
154
138
  super(), Object.assign(this, e);
155
139
  }
156
- }, v = class {
140
+ }, _ = class {
157
141
  static columnsNames = [{
158
142
  label: "اسم الفرع",
159
143
  value: "Name"
@@ -161,18 +145,18 @@ var n = class {
161
145
  label: "رقم الفرع",
162
146
  value: "Id"
163
147
  }];
164
- }, y = class extends s {
148
+ }, v = class extends o {
165
149
  name;
166
150
  permissions;
167
151
  constructor(e) {
168
152
  super(), Object.assign(this, e);
169
153
  }
170
- }, b = class {
154
+ }, y = class {
171
155
  static columnsNames = [{
172
156
  label: "اسم الدور",
173
157
  value: "Name"
174
158
  }];
175
- }, x = class extends s {
159
+ }, b = class extends o {
176
160
  username;
177
161
  password;
178
162
  isActive;
@@ -183,7 +167,7 @@ var n = class {
183
167
  constructor(e) {
184
168
  super(), Object.assign(this, e);
185
169
  }
186
- }, S = class {
170
+ }, x = class {
187
171
  static columnsNames = [{
188
172
  label: "رقم المستخدم",
189
173
  value: "Id"
@@ -191,7 +175,7 @@ var n = class {
191
175
  label: "اسم المستخدم",
192
176
  value: "Username"
193
177
  }];
194
- }, C = class {
178
+ }, S = class {
195
179
  static _baseUrl = "";
196
180
  static get baseUrl() {
197
181
  return this._baseUrl || console.warn("YusrCore: baseUrl has not been initialized. Defaults to empty string."), this._baseUrl;
@@ -199,7 +183,7 @@ var n = class {
199
183
  static initialize(e) {
200
184
  this._baseUrl = e;
201
185
  }
202
- }, w = class e {
186
+ }, C = class e {
203
187
  static async Get(t, n) {
204
188
  let r = await fetch(t, {
205
189
  method: "GET",
@@ -290,45 +274,45 @@ var n = class {
290
274
  errorDetails: ""
291
275
  };
292
276
  }
293
- }, T = class {
277
+ }, w = class {
294
278
  async Filter(e, t, n) {
295
- return await w.Post(`${C.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
279
+ return await C.Post(`${S.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
296
280
  }
297
- }, E = class extends T {
281
+ }, T = class extends w {
298
282
  async Get(e) {
299
- return await w.Get(`${C.baseUrl}/${this.routeName}/${e}`);
283
+ return await C.Get(`${S.baseUrl}/${this.routeName}/${e}`);
300
284
  }
301
285
  async Add(e) {
302
- return await w.Post(`${C.baseUrl}/${this.routeName}/Add`, e, void 0, "تم حفظ البيانات بنجاح");
286
+ return await C.Post(`${S.baseUrl}/${this.routeName}/Add`, e, void 0, "تم حفظ البيانات بنجاح");
303
287
  }
304
288
  async Update(e) {
305
- return await w.Put(`${C.baseUrl}/${this.routeName}/Update`, e, void 0, "تم تحديث المعلومات بنجاح");
289
+ return await C.Put(`${S.baseUrl}/${this.routeName}/Update`, e, void 0, "تم تحديث المعلومات بنجاح");
306
290
  }
307
291
  async Delete(e) {
308
- return await w.Delete(`${C.baseUrl}/${this.routeName}/${e}`, void 0, "تمت إزالة السجل بنجاح");
292
+ return await C.Delete(`${S.baseUrl}/${this.routeName}/${e}`, void 0, "تمت إزالة السجل بنجاح");
309
293
  }
310
- }, D = class extends E {
294
+ }, E = class extends T {
311
295
  routeName = "Branches";
312
- }, O = class extends T {
296
+ }, D = class extends w {
313
297
  routeName = "Cities";
314
298
  async Filter(e, t, n) {
315
- return await w.Post(`${C.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
299
+ return await C.Post(`${S.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
316
300
  }
317
- }, k = class extends T {
301
+ }, O = class extends w {
318
302
  routeName = "Countries";
319
303
  async Filter(e, t, n) {
320
- return await w.Post(`${C.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
304
+ return await C.Post(`${S.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
321
305
  }
322
- }, A = class extends T {
306
+ }, k = class extends w {
323
307
  routeName = "Currencies";
324
308
  async Filter(e, t, n) {
325
- return await w.Post(`${C.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
309
+ return await C.Post(`${S.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
326
310
  }
327
- }, j = class extends E {
311
+ }, A = class extends T {
328
312
  routeName = "Roles";
329
- }, M = class extends E {
313
+ }, j = class extends T {
330
314
  routeName = "Users";
331
- }, N = class {
315
+ }, M = class {
332
316
  static required(e = "هذا الحقل مطلوب") {
333
317
  return (t) => t == null || t === "" || typeof t == "string" && t.trim() === "" ? e : null;
334
318
  }
@@ -344,21 +328,6 @@ var n = class {
344
328
  static custom(e, t) {
345
329
  return (n, r) => e(n, r) ? null : t;
346
330
  }
347
- }, P = new class {
348
- getItem(e) {
349
- if (typeof window > "u") return null;
350
- let t = localStorage.getItem(e);
351
- return t ? JSON.parse(t) : null;
352
- }
353
- setItem(e, t) {
354
- typeof window > "u" || localStorage.setItem(e, JSON.stringify(t));
355
- }
356
- removeItem(e) {
357
- typeof window > "u" || localStorage.removeItem(e);
358
- }
359
- exists(e) {
360
- return typeof window > "u" ? !1 : localStorage.getItem(e) !== null;
361
- }
362
- }();
331
+ };
363
332
  //#endregion
364
- 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, P as localStorageService };
333
+ export { S as ApiConstants, n as AuthConstants, T as BaseApiService, o as BaseEntity, w as BaseFilterableApiService, g as Branch, _ as BranchFilterColumns, E as BranchesApiService, D as CitiesApiService, s as City, c as CityFilterColumns, O as CountriesApiService, l as Country, u as CountryFilterColumns, k as CurrenciesApiService, d as Currency, f as FilterCondition, p as LoginRequest, v as Role, y as RoleFilterColumns, A as RolesApiService, m as StorageFile, h as StorageFileStatus, a as SystemPermissions, b as User, x as UserFilterColumns, j as UsersApiService, M as Validators, C as YusrApiHelper, i as createAuthSlice };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yusr_systems/core",
3
- "version": "6.0.1",
3
+ "version": "6.0.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "publishConfig": {