@yusr_systems/core 2.2.6 → 2.2.8

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
@@ -58,10 +58,19 @@ export declare class Branch extends BaseEntity {
58
58
  constructor(init?: Partial<Branch>);
59
59
  }
60
60
 
61
+ export declare class BranchesApiService extends BaseApiService<Branch> {
62
+ routeName: string;
63
+ }
64
+
61
65
  export declare class BranchFilterColumns {
62
66
  static columnsNames: ColumnName[];
63
67
  }
64
68
 
69
+ export declare class CitiesApiService extends BaseFilterableApiService<City> {
70
+ routeName: string;
71
+ Filter(pageNumber: number, rowsPerPage: number, condition?: FilterCondition): Promise<RequestResult<FilterResult<City>>>;
72
+ }
73
+
65
74
  export declare class City extends BaseEntity {
66
75
  name: string;
67
76
  countryId: number;
@@ -78,6 +87,11 @@ export declare type ColumnName = {
78
87
  value: string;
79
88
  };
80
89
 
90
+ export declare class CountriesApiService extends BaseFilterableApiService<Country> {
91
+ routeName: string;
92
+ Filter(pageNumber: number, rowsPerPage: number, condition?: FilterCondition): Promise<RequestResult<FilterResult<Country>>>;
93
+ }
94
+
81
95
  export declare class Country extends BaseEntity {
82
96
  name: string;
83
97
  code: string;
@@ -90,6 +104,11 @@ export declare class CountryFilterColumns {
90
104
 
91
105
  export declare const createAuthSlice: <TUser extends object, TSetting extends object>() => Slice<AuthState<TUser, TSetting>, AuthReducers<TUser, TSetting>, "auth">;
92
106
 
107
+ export declare class CurrenciesApiService extends BaseFilterableApiService<Currency> {
108
+ routeName: string;
109
+ Filter(pageNumber: number, rowsPerPage: number, condition?: FilterCondition): Promise<RequestResult<FilterResult<Currency>>>;
110
+ }
111
+
93
112
  export declare class Currency extends BaseEntity {
94
113
  name: string;
95
114
  code: string;
@@ -145,6 +164,10 @@ export declare class RoleFilterColumns {
145
164
  static columnsNames: ColumnName[];
146
165
  }
147
166
 
167
+ export declare class RolesApiService extends BaseApiService<Role> {
168
+ routeName: string;
169
+ }
170
+
148
171
  export declare class StorageFile {
149
172
  url: string | null;
150
173
  base64File: string | null;
@@ -187,6 +210,10 @@ export declare class UserFilterColumns {
187
210
  static columnsNames: ColumnName[];
188
211
  }
189
212
 
213
+ export declare class UsersApiService extends BaseApiService<User> {
214
+ routeName: string;
215
+ }
216
+
190
217
  export declare interface ValidationRule<T> {
191
218
  field: keyof T | string;
192
219
  selector: (data: T) => any;
package/dist/yusr-core.js CHANGED
@@ -127,8 +127,129 @@ var n = class {
127
127
  New: 1,
128
128
  Delete: 2
129
129
  }, g = class {
130
+ static LoggedInUserStorageItemName = "LoggedInUser";
131
+ static AuthCheckStorageItemName = "IsLoggedIn";
132
+ static SettingStorageItemName = "Setting";
133
+ static UnauthorizedEventName = "ApiUnauthorized";
134
+ }, _ = class {
130
135
  id;
131
- }, _ = class extends g {
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 _ {
132
253
  name;
133
254
  cityId;
134
255
  cityName;
@@ -139,7 +260,7 @@ var n = class {
139
260
  constructor(e) {
140
261
  super(), Object.assign(this, e);
141
262
  }
142
- }, v = class {
263
+ }, C = class {
143
264
  static columnsNames = [{
144
265
  label: "اسم الفرع",
145
266
  value: "Name"
@@ -147,18 +268,18 @@ var n = class {
147
268
  label: "رقم الفرع",
148
269
  value: "Id"
149
270
  }];
150
- }, y = class extends g {
271
+ }, w = class extends _ {
151
272
  name;
152
273
  permissions;
153
274
  constructor(e) {
154
275
  super(), Object.assign(this, e);
155
276
  }
156
- }, b = class {
277
+ }, T = class {
157
278
  static columnsNames = [{
158
279
  label: "اسم الدور",
159
280
  value: "Name"
160
281
  }];
161
- }, x = class extends g {
282
+ }, E = class extends _ {
162
283
  username;
163
284
  password;
164
285
  isActive;
@@ -169,7 +290,7 @@ var n = class {
169
290
  constructor(e) {
170
291
  super(), Object.assign(this, e);
171
292
  }
172
- }, S = class {
293
+ }, D = class {
173
294
  static columnsNames = [{
174
295
  label: "رقم المستخدم",
175
296
  value: "Id"
@@ -177,7 +298,7 @@ var n = class {
177
298
  label: "اسم المستخدم",
178
299
  value: "Username"
179
300
  }];
180
- }, C = class {
301
+ }, O = class {
181
302
  static _baseUrl = "";
182
303
  static get baseUrl() {
183
304
  return this._baseUrl || console.warn("YusrCore: baseUrl has not been initialized. Defaults to empty string."), this._baseUrl;
@@ -185,7 +306,7 @@ var n = class {
185
306
  static initialize(e) {
186
307
  this._baseUrl = e;
187
308
  }
188
- }, w = class e {
309
+ }, k = class e {
189
310
  static async Get(t, n) {
190
311
  let r = await fetch(t, {
191
312
  method: "GET",
@@ -276,24 +397,45 @@ var n = class {
276
397
  errorDetails: ""
277
398
  };
278
399
  }
279
- }, T = class {
400
+ }, A = class {
280
401
  async Filter(e, t, n) {
281
- return await w.Post(`${C.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
402
+ return await k.Post(`${O.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
282
403
  }
283
- }, E = class extends T {
404
+ }, j = class extends A {
284
405
  async Get(e) {
285
- return await w.Get(`${C.baseUrl}/${this.routeName}/${e}`);
406
+ return await k.Get(`${O.baseUrl}/${this.routeName}/${e}`);
286
407
  }
287
408
  async Add(e) {
288
- return await w.Post(`${C.baseUrl}/${this.routeName}/Add`, e, void 0, "تم حفظ البيانات بنجاح");
409
+ return await k.Post(`${O.baseUrl}/${this.routeName}/Add`, e, void 0, "تم حفظ البيانات بنجاح");
289
410
  }
290
411
  async Update(e) {
291
- return await w.Put(`${C.baseUrl}/${this.routeName}/Update`, e, void 0, "تم تحديث المعلومات بنجاح");
412
+ return await k.Put(`${O.baseUrl}/${this.routeName}/Update`, e, void 0, "تم تحديث المعلومات بنجاح");
292
413
  }
293
414
  async Delete(e) {
294
- return await w.Delete(`${C.baseUrl}/${this.routeName}/${e}`, void 0, "تمت إزالة السجل بنجاح");
415
+ return await k.Delete(`${O.baseUrl}/${this.routeName}/${e}`, void 0, "تمت إزالة السجل بنجاح");
295
416
  }
296
- }, D = class {
417
+ }, M = class extends x {
418
+ routeName = "Branches";
419
+ }, N = class extends b {
420
+ routeName = "Cities";
421
+ async Filter(e, t, n) {
422
+ return await y.Post(`${v.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
423
+ }
424
+ }, P = class extends b {
425
+ routeName = "Countries";
426
+ async Filter(e, t, n) {
427
+ return await y.Post(`${v.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
428
+ }
429
+ }, F = class extends b {
430
+ routeName = "Currencies";
431
+ async Filter(e, t, n) {
432
+ return await y.Post(`${v.baseUrl}/${this.routeName}/Filter?pageNumber=${e}&rowsPerPage=${t}`, n);
433
+ }
434
+ }, I = class extends x {
435
+ routeName = "Roles";
436
+ }, L = class extends x {
437
+ routeName = "Users";
438
+ }, R = class {
297
439
  static required(e = "هذا الحقل مطلوب") {
298
440
  return (t) => t == null || t === "" || typeof t == "string" && t.trim() === "" ? e : null;
299
441
  }
@@ -311,4 +453,4 @@ var n = class {
311
453
  }
312
454
  };
313
455
  //#endregion
314
- export { C as ApiConstants, n as AuthConstants, E as BaseApiService, o as BaseEntity, T as BaseFilterableApiService, _ as Branch, v as BranchFilterColumns, s as City, c as CityFilterColumns, l as Country, u as CountryFilterColumns, d as Currency, f as FilterCondition, p as LoginRequest, y as Role, b as RoleFilterColumns, m as StorageFile, h as StorageFileStatus, a as SystemPermissions, x as User, S as UserFilterColumns, D as Validators, w as YusrApiHelper, i as createAuthSlice };
456
+ export { O as ApiConstants, n as AuthConstants, j as BaseApiService, o as BaseEntity, A as BaseFilterableApiService, S as Branch, C as BranchFilterColumns, M as BranchesApiService, N as CitiesApiService, s as City, c as CityFilterColumns, P as CountriesApiService, l as Country, u as CountryFilterColumns, F as CurrenciesApiService, d as Currency, f as FilterCondition, p as LoginRequest, w as Role, T as RoleFilterColumns, I as RolesApiService, m as StorageFile, h as StorageFileStatus, a as SystemPermissions, E as User, D as UserFilterColumns, L as UsersApiService, R as Validators, k as YusrApiHelper, i as createAuthSlice };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yusr_systems/core",
3
- "version": "2.2.6",
3
+ "version": "2.2.8",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "publishConfig": {