@yusr_systems/core 2.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/yusr-core.d.ts +202 -0
- package/dist/yusr-core.js +2333 -0
- package/dist/yusr-core.umd.cjs +17 -0
- package/package.json +25 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { InternalDispatch } from '../../../yusr-ui/src/state/factory';
|
|
2
|
+
import { PayloadAction } from '@reduxjs/toolkit';
|
|
3
|
+
import { Slice } from '@reduxjs/toolkit';
|
|
4
|
+
import { SliceSelectors } from '@reduxjs/toolkit';
|
|
5
|
+
|
|
6
|
+
export declare class ApiConstants {
|
|
7
|
+
private static _baseUrl;
|
|
8
|
+
static get baseUrl(): string;
|
|
9
|
+
static initialize(url: string): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare interface AuthActions {
|
|
13
|
+
logout: () => any;
|
|
14
|
+
syncFromStorage: () => any;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export declare class AuthConstants {
|
|
18
|
+
static LoggedInUserStorageItemName: string;
|
|
19
|
+
static AuthCheckStorageItemName: string;
|
|
20
|
+
static SettingStorageItemName: string;
|
|
21
|
+
static UnauthorizedEventName: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export declare interface AuthState<TUser, TSetting> {
|
|
25
|
+
isAuthenticated: boolean;
|
|
26
|
+
loggedInUser: Partial<TUser> | undefined;
|
|
27
|
+
setting: Partial<TSetting> | undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export declare abstract class BaseApiService<T extends BaseEntity> extends BaseFilterableApiService<T> {
|
|
31
|
+
Get(id: number): Promise<RequestResult<T>>;
|
|
32
|
+
Add(entity: T): Promise<RequestResult<unknown>>;
|
|
33
|
+
Update(entity: T): Promise<RequestResult<unknown>>;
|
|
34
|
+
Delete(id: number): Promise<RequestResult<unknown>>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export declare abstract class BaseEntity {
|
|
38
|
+
id: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export declare abstract class BaseFilterableApiService<T extends BaseEntity> {
|
|
42
|
+
abstract routeName: string;
|
|
43
|
+
Filter(pageNumber: number, rowsPerPage: number, condition?: FilterCondition): Promise<RequestResult<FilterResult<T>>>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export declare class City extends BaseEntity {
|
|
47
|
+
name: string;
|
|
48
|
+
countryId: number;
|
|
49
|
+
country: Country;
|
|
50
|
+
constructor(init?: Partial<City>);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export declare class CityFilterColumns {
|
|
54
|
+
static columnsNames: ColumnName[];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export declare type ColumnName = {
|
|
58
|
+
label: string;
|
|
59
|
+
value: string;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export declare class Country extends BaseEntity {
|
|
63
|
+
name: string;
|
|
64
|
+
code: string;
|
|
65
|
+
constructor(init?: Partial<Country>);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export declare class CountryFilterColumns {
|
|
69
|
+
static columnsNames: ColumnName[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export declare const createAuthSlice: <TUser extends object, TSetting extends object>() => Slice<AuthState<object, object>, {
|
|
73
|
+
login: (state: {
|
|
74
|
+
isAuthenticated: boolean;
|
|
75
|
+
loggedInUser: object | undefined;
|
|
76
|
+
setting: object | undefined;
|
|
77
|
+
}, action: PayloadAction<{
|
|
78
|
+
user: TUser;
|
|
79
|
+
setting: TSetting;
|
|
80
|
+
} | undefined>) => void;
|
|
81
|
+
logout: (state: {
|
|
82
|
+
isAuthenticated: boolean;
|
|
83
|
+
loggedInUser: object | undefined;
|
|
84
|
+
setting: object | undefined;
|
|
85
|
+
}) => void;
|
|
86
|
+
updateLoggedInUser: (state: {
|
|
87
|
+
isAuthenticated: boolean;
|
|
88
|
+
loggedInUser: object | undefined;
|
|
89
|
+
setting: object | undefined;
|
|
90
|
+
}, action: PayloadAction<TUser>) => void;
|
|
91
|
+
updateSetting: (state: {
|
|
92
|
+
isAuthenticated: boolean;
|
|
93
|
+
loggedInUser: object | undefined;
|
|
94
|
+
setting: object | undefined;
|
|
95
|
+
}, action: PayloadAction<TSetting>) => void;
|
|
96
|
+
syncFromStorage: (state: {
|
|
97
|
+
isAuthenticated: boolean;
|
|
98
|
+
loggedInUser: object | undefined;
|
|
99
|
+
setting: object | undefined;
|
|
100
|
+
}) => void;
|
|
101
|
+
}, "auth", "auth", SliceSelectors<AuthState<object, object>>>;
|
|
102
|
+
|
|
103
|
+
export declare class Currency extends BaseEntity {
|
|
104
|
+
name: string;
|
|
105
|
+
code: string;
|
|
106
|
+
isFeminine: boolean;
|
|
107
|
+
plural: string;
|
|
108
|
+
subName: string;
|
|
109
|
+
subIsFeminine: boolean;
|
|
110
|
+
subPlural: string;
|
|
111
|
+
constructor(init?: Partial<Currency>);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export declare class FilterCondition {
|
|
115
|
+
value: string;
|
|
116
|
+
columnName: string;
|
|
117
|
+
constructor(init?: Partial<FilterCondition>);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export declare type FilterResult<T> = {
|
|
121
|
+
data: T[] | undefined;
|
|
122
|
+
count: number;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export declare class LoginRequest {
|
|
126
|
+
companyEmail: string;
|
|
127
|
+
username: string;
|
|
128
|
+
password: string;
|
|
129
|
+
constructor(init?: Partial<LoginRequest>);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export declare type PermissionSelector<S> = (state: S, resource: string) => ResourcePermissions;
|
|
133
|
+
|
|
134
|
+
export declare type RequestResult<T> = {
|
|
135
|
+
data?: T;
|
|
136
|
+
status: number;
|
|
137
|
+
errorTitle: string;
|
|
138
|
+
errorDetails: string;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export declare interface ResourcePermissions {
|
|
142
|
+
getPermission: boolean;
|
|
143
|
+
addPermission: boolean;
|
|
144
|
+
updatePermission: boolean;
|
|
145
|
+
deletePermission: boolean;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export declare const setupAuthListeners: (dispatch: InternalDispatch, actions: AuthActions) => void;
|
|
149
|
+
|
|
150
|
+
export declare class StorageFile {
|
|
151
|
+
url: string | null;
|
|
152
|
+
base64File: string | null;
|
|
153
|
+
extension: string | null;
|
|
154
|
+
contentType: string | null;
|
|
155
|
+
status: StorageFileStatus;
|
|
156
|
+
constructor(init?: Partial<StorageFile>);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export declare const StorageFileStatus: {
|
|
160
|
+
readonly Unchanged: 0;
|
|
161
|
+
readonly New: 1;
|
|
162
|
+
readonly Delete: 2;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export declare type StorageFileStatus = typeof StorageFileStatus[keyof typeof StorageFileStatus];
|
|
166
|
+
|
|
167
|
+
export declare class SystemPermissions {
|
|
168
|
+
static Format(resource: string, action: string): string;
|
|
169
|
+
static hasAuth(permissions: string[], resource: string, action: string): boolean;
|
|
170
|
+
private permissions;
|
|
171
|
+
private resource;
|
|
172
|
+
constructor(permissions: string[], resource: string);
|
|
173
|
+
hasAuth(action: string): boolean;
|
|
174
|
+
static getFirstPermissionPath(permissions: string[]): string;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export declare interface ValidationRule<T> {
|
|
178
|
+
field: keyof T | string;
|
|
179
|
+
selector: (data: T) => any;
|
|
180
|
+
validators: ValidatorFn[];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export declare type ValidatorFn<T = any> = (value: T, formData?: any) => string | null;
|
|
184
|
+
|
|
185
|
+
export declare class Validators {
|
|
186
|
+
static required(message?: string): ValidatorFn;
|
|
187
|
+
static min(min: number, message?: string): ValidatorFn;
|
|
188
|
+
static max(threshold: number, message?: string): ValidatorFn;
|
|
189
|
+
static arrayMinLength(min: number, message?: string): ValidatorFn;
|
|
190
|
+
static custom<T>(fn: (value: T, formData: any) => boolean, message: string): ValidatorFn<T>;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export declare class YusrApiHelper {
|
|
194
|
+
static Get<T>(url: string, options?: RequestInit): Promise<RequestResult<T>>;
|
|
195
|
+
static Post<T>(url: string, body?: unknown, options?: RequestInit, successMessage?: string): Promise<RequestResult<T>>;
|
|
196
|
+
static Put<T>(url: string, body?: unknown, options?: RequestInit, successMessage?: string): Promise<RequestResult<T>>;
|
|
197
|
+
static Delete<T>(url: string, options?: RequestInit, successMessage?: string): Promise<RequestResult<T>>;
|
|
198
|
+
static PostBlob(url: string, body?: unknown, options?: RequestInit): Promise<Blob | undefined>;
|
|
199
|
+
private static handleResponse;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export { }
|