@yusr_systems/core 2.2.10 → 6.0.1

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