nexus-shared 1.1.18 → 1.1.20
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/package.json +1 -1
- package/src/api-services/authentication-service.tsx +23 -0
- package/src/api-services/system-service.tsx +28 -315
- package/src/client.ts +2 -2
- package/src/components/documents/button.tsx +17 -11
- package/src/components/documents/icon-box.tsx +1 -1
- package/src/components/documents/tab-button.tsx +2 -2
- package/src/components/documents/tag.tsx +30 -0
- package/src/components/inputs/input-box.tsx +4 -2
- package/src/components/inputs/input-element.tsx +1 -1
- package/src/components/inputs/input-form.tsx +126 -14
- package/src/components/layouts/global-dialogbox.tsx +5 -9
- package/src/components/layouts/global-layout.tsx +3 -0
- package/src/components/layouts/layout-helpers.tsx +1 -4
- package/src/components/layouts/panels/user-panel.tsx +112 -0
- package/src/components/layouts/utility-menu.tsx +9 -29
- package/src/components/panels/theme-panel.tsx +2 -2
- package/src/helpers/browser-helpers.tsx +88 -3
- package/src/helpers/input-helpers.tsx +34 -4
- package/src/helpers/validation-helpers.tsx +302 -0
- package/src/index.ts +2 -18
- package/src/interface.ts +5 -1
- package/src/interfaces/auth-token-interfaces.tsx +6 -0
- package/src/interfaces/browser-interfaces.tsx +13 -0
- package/src/interfaces/button-interfaces.tsx +2 -2
- package/src/interfaces/http-interfaces.tsx +86 -8
- package/src/interfaces/icon-interfaces.tsx +3 -0
- package/src/interfaces/input-interfaces.tsx +61 -11
- package/src/interfaces/menu-interfaces.tsx +13 -0
- package/src/interfaces/message-interfaces.tsx +32 -0
- package/src/interfaces/storage-interfaces.tsx +2 -0
- package/src/interfaces/theme-interfaces.tsx +43 -129
- package/src/interfaces/type-interfaces.tsx +8 -2
- package/src/interfaces/user-interfaces.tsx +47 -0
- package/src/nexus.environments.tsx +41 -24
- package/src/proxy-api/proxy-backend.tsx +60 -0
- package/src/proxy-api/proxy-constants.tsx +28 -0
- package/src/proxy-api/proxy-helpers.tsx +91 -0
- package/src/proxy-api-client.tsx +1 -0
- package/src/proxy-api-server.tsx +2 -0
- package/src/services/http-client-services.tsx +26 -11
- package/src/services/http-services.tsx +42 -27
- package/src/services/loader-service.tsx +34 -17
- package/src/services/localstorage-service.tsx +81 -5
- package/src/services/message-services.tsx +383 -0
- package/src/services/theme-service.tsx +30 -16
- package/src/services/user-services.tsx +10 -0
- package/src/sso-config/auth-token-validation.ts +16 -0
- package/src/sso-config/callback-route.tsx +35 -0
- package/src/sso-config/cookie-encryption.ts +51 -0
- package/src/sso-config/cookie-helpers.tsx +102 -0
- package/src/sso-config/forgot-password-route.tsx +36 -0
- package/src/sso-config/oauth-callback-state.ts +61 -0
- package/src/sso-config/pkce-helpers.ts +9 -0
- package/src/sso-config/provider-complete-route.tsx +18 -0
- package/src/sso-config/redirect-context-actions.tsx +45 -0
- package/src/sso-config/redirect-context-helpers.tsx +159 -0
- package/src/sso-config/redirect-context-persist.tsx +18 -0
- package/src/sso-config/redirect-context-route.tsx +45 -0
- package/src/sso-config/refresh-route.tsx +23 -0
- package/src/sso-config/sign-in-route.tsx +74 -0
- package/src/sso-config/sign-out-route.tsx +57 -0
- package/src/sso-config/sign-up-route.tsx +57 -0
- package/src/sso-config/sso-backend-flow.ts +38 -0
- package/src/sso-config/sso-complete-route.tsx +50 -0
- package/src/sso-config/sso-config.ts +59 -0
- package/src/sso-config/sso-interfaces.tsx +99 -0
- package/src/sso-config/sso-response-helpers.tsx +20 -0
- package/src/sso-server.tsx +21 -1
- package/src/styles/nexus.dialog.css +3 -0
- package/src/styles/nexus.icon.css +1 -0
- package/src/styles/nexus.logic.css +34 -5
- package/src/interfaces/sso-interfaces.tsx +0 -52
- package/src/load-env.ts +0 -2
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { EInputTypes, ICheckbox, IDate, IInputCreateResults, IInputParameters, IInputRootParameters, INumber, ISelection, ITablularForm, ITextbox, RegexTypes, UN } from "../interface";
|
|
2
|
+
import { BitwiseToList } from "./bitwise-helpers";
|
|
3
|
+
import { GetInputId } from "./input-helpers";
|
|
4
|
+
import { IsNullOrEmpty, MakeFirstLetterUpperCase } from "./string-helpers";
|
|
5
|
+
|
|
6
|
+
export const MAX_INPUT_TYPE = 1900;
|
|
7
|
+
export const MAX_HINT_LENGTH = 5;
|
|
8
|
+
|
|
9
|
+
export const IsValidInputs = (inputObjects: IInputCreateResults[] | UN, inputFormValues: any, isAutoError: boolean, isAutoFocus: boolean): boolean => {
|
|
10
|
+
let isValid = true;
|
|
11
|
+
if (!inputObjects || inputObjects.length === 0) return true;
|
|
12
|
+
const sortedObjects = [...inputObjects].sort((a, b) => b.input.displayOrder - a.input.displayOrder);
|
|
13
|
+
for (const obj of sortedObjects) {
|
|
14
|
+
// Skip unsupported input types
|
|
15
|
+
if (obj.input.inputType >= MAX_INPUT_TYPE) continue;
|
|
16
|
+
|
|
17
|
+
const inputId = GetInputId(obj.input);
|
|
18
|
+
const inputValue = inputFormValues?.[inputId] ?? null;
|
|
19
|
+
const isValidInput = IsValidInput(obj, inputValue, isAutoError, isAutoFocus);
|
|
20
|
+
if (isValid) isValid = isValidInput;
|
|
21
|
+
}
|
|
22
|
+
return isValid;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const IsValidInput = (inputObject: IInputCreateResults, inputValue: any, isAutoError: boolean, isAutoFocus: boolean): boolean => {
|
|
26
|
+
const input = inputObject.inputElement;
|
|
27
|
+
const inputParameters = inputObject.input;
|
|
28
|
+
const value = inputValue;
|
|
29
|
+
|
|
30
|
+
switch (inputParameters.inputType) {
|
|
31
|
+
//---------------------
|
|
32
|
+
case EInputTypes.Textbox:
|
|
33
|
+
case EInputTypes.Textarea:
|
|
34
|
+
case EInputTypes.Texteditor:
|
|
35
|
+
return IsValidTextbox(inputParameters as ITextbox, value, isAutoFocus, isAutoError, input);
|
|
36
|
+
//---------------------
|
|
37
|
+
case EInputTypes.Checkbox:
|
|
38
|
+
return IsValidCheck(inputParameters as ICheckbox, value as boolean, isAutoFocus, isAutoError, input);
|
|
39
|
+
//---------------------
|
|
40
|
+
case EInputTypes.MultiSelection:
|
|
41
|
+
case EInputTypes.SingleSelection:
|
|
42
|
+
return IsValidSelectionbox(inputParameters as ISelection, value, isAutoFocus, isAutoError, input);
|
|
43
|
+
//---------------------
|
|
44
|
+
case EInputTypes.Datepicker:
|
|
45
|
+
return IsValidDate(inputParameters as IDate, value as Date | UN, isAutoFocus, isAutoError, input);
|
|
46
|
+
//---------------------
|
|
47
|
+
case EInputTypes.Number:
|
|
48
|
+
return IsValidNumber(inputParameters as INumber, value as number | UN, isAutoFocus, isAutoError, input);
|
|
49
|
+
//---------------------
|
|
50
|
+
case EInputTypes.TabularForm:
|
|
51
|
+
return IsValidTabularform(inputParameters as ITablularForm, value as any[], isAutoFocus, isAutoError, input);
|
|
52
|
+
//---------------------
|
|
53
|
+
case EInputTypes.Radiobox:
|
|
54
|
+
return true;
|
|
55
|
+
|
|
56
|
+
default:
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// ------------- Start Textbox Validation -------------
|
|
62
|
+
function IsValidTextbox<T>(inputParameters: ITextbox, value: T | UN, isNeedFocus: boolean, isAutoError: boolean, input: HTMLElement | UN): boolean {
|
|
63
|
+
if (!inputParameters) return false;
|
|
64
|
+
return IsValidInputValueWithRegex(inputParameters, input, inputParameters.validatorKey, value as string | UN, inputParameters.minLength ?? 0, inputParameters.maxLength ?? 0, isAutoError, isNeedFocus, inputParameters.regexKey).isValid;
|
|
65
|
+
}
|
|
66
|
+
export function IsValidInputValueWithRegex(inputParameters: ITextbox, input: HTMLElement | UN, key: string | UN, value: string | UN, min: number, max: number, isAutoError: boolean = true, isNeedFocus: boolean, regularExpression: RegexTypes | UN): IValidationMessage {
|
|
67
|
+
const valid = IsValidInputValueWithLength(inputParameters, input, key, value, min, max, false, isNeedFocus);
|
|
68
|
+
if (Array.isArray(regularExpression)) {
|
|
69
|
+
if (IsNullOrEmpty(value)) return { isValid: false, message: InvalidValueMessage(key) };
|
|
70
|
+
|
|
71
|
+
const isMatch = regularExpression.includes(value as string);
|
|
72
|
+
const msg = !isMatch ? `${InvalidValueMessage(key)}\nOnly allowed values are: ${MakeFirstLetterUpperCase(regularExpression.slice(0, MAX_HINT_LENGTH).join(", "))}${regularExpression.length > MAX_HINT_LENGTH ? `...` : "."}` : null;
|
|
73
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, !isMatch, msg, isNeedFocus);
|
|
74
|
+
|
|
75
|
+
return { isValid: isMatch, message: msg };
|
|
76
|
+
} else if (typeof regularExpression === "string") {
|
|
77
|
+
const isMatch = IsMatchRejex(value, regularExpression);
|
|
78
|
+
if (!isMatch) {
|
|
79
|
+
const msg = InvalidValueMessage(key ?? "Input-Value");
|
|
80
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, true, msg, isNeedFocus);
|
|
81
|
+
return { isValid: isMatch, message: msg };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!valid.isValid) {
|
|
86
|
+
AddRemoveErrorFromInput(inputParameters, input, isAutoError, valid.message, isNeedFocus);
|
|
87
|
+
return valid;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (regularExpression && (regularExpression as string) !== "") {
|
|
91
|
+
const isMatch = IsMatchRejex(value, regularExpression);
|
|
92
|
+
if (!isMatch) {
|
|
93
|
+
const msg = InvalidValueMessage(key ?? "Input-Value");
|
|
94
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, true, msg, isNeedFocus);
|
|
95
|
+
return { isValid: isMatch, message: msg };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, false);
|
|
99
|
+
return { isValid: true, message: "Valid" };
|
|
100
|
+
}
|
|
101
|
+
export function IsValidInputValueWithLength(inputParameters: IInputParameters<any>, input: HTMLElement | UN, key: string | UN, value: string | UN, min: number, max: number, isAutoError: boolean = true, isNeedFocus: boolean): IValidationMessage {
|
|
102
|
+
if (IsNullOrEmpty(value) && min > 0) {
|
|
103
|
+
const mes = RequiredMessage(key);
|
|
104
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, true, mes, isNeedFocus);
|
|
105
|
+
return { isValid: false, message: mes };
|
|
106
|
+
}
|
|
107
|
+
value = value ?? "";
|
|
108
|
+
if (min > 0 && value.length < min) {
|
|
109
|
+
const mes = MinLengthNotValidMessage(key ?? "Input-Value", min, false);
|
|
110
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, true, mes, isNeedFocus);
|
|
111
|
+
return { isValid: false, message: mes };
|
|
112
|
+
} else if (max > 0 && value.length > max) {
|
|
113
|
+
const mes = MaxLengthNotValidMessage(key ?? "Input-Value", max, false);
|
|
114
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, true, mes, isNeedFocus);
|
|
115
|
+
return { isValid: false, message: mes };
|
|
116
|
+
}
|
|
117
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, false);
|
|
118
|
+
return { isValid: true, message: "Valid" };
|
|
119
|
+
}
|
|
120
|
+
// ------------- End Textbox Validation -------------
|
|
121
|
+
|
|
122
|
+
// ------------- Start Checkbox Validation -------------
|
|
123
|
+
function IsValidCheck(inputParameters: ICheckbox, value: boolean, isNeedFocus: boolean, isAutoError: boolean, input: HTMLElement | UN): boolean {
|
|
124
|
+
if (!inputParameters) return false;
|
|
125
|
+
if (!value) {
|
|
126
|
+
if (inputParameters.isRequired) {
|
|
127
|
+
const requiredMessage = RequiredMessage(inputParameters.validatorKey);
|
|
128
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, true, requiredMessage, isNeedFocus);
|
|
129
|
+
return false;
|
|
130
|
+
} else {
|
|
131
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, false, undefined, isNeedFocus);
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, false, undefined, isNeedFocus);
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
// ------------- End Checkbox Validation -------------
|
|
140
|
+
|
|
141
|
+
// ------------- Start Selectionbox Validation -------------
|
|
142
|
+
function IsValidSelectionbox(inputParameters: ISelection, value: any | UN, isNeedFocus: boolean, isAutoError: boolean, input: HTMLElement | UN): boolean {
|
|
143
|
+
let isValid = true;
|
|
144
|
+
const isMulti = inputParameters.inputType === EInputTypes.MultiSelection;
|
|
145
|
+
if (!inputParameters) isValid = false;
|
|
146
|
+
else if (!inputParameters.isRequired) isValid = true;
|
|
147
|
+
else isValid = isMulti ? value?.length > 0 : value !== null;
|
|
148
|
+
|
|
149
|
+
if (!isValid && isMulti && inputParameters.bitwiseEnum !== undefined && inputParameters.bitwiseEnum !== null) isValid = BitwiseToList(inputParameters.bitwiseEnum, value).length > 0;
|
|
150
|
+
|
|
151
|
+
if (isValid) {
|
|
152
|
+
AddRemoveErrorFromInput(inputParameters, input, false);
|
|
153
|
+
return isValid;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const msg = RequiredMessage(inputParameters.validatorKey ?? "Input-Value");
|
|
157
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, true, msg, isNeedFocus);
|
|
158
|
+
return isValid;
|
|
159
|
+
}
|
|
160
|
+
// ------------- End Selectionbox Validation -------------
|
|
161
|
+
|
|
162
|
+
// ------------- Start Date Validation -------------
|
|
163
|
+
function IsValidDate(inputParameters: IDate, value: Date | UN, isNeedFocus: boolean, isAutoError: boolean, input: HTMLElement | UN): boolean {
|
|
164
|
+
if (!inputParameters) return false;
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
// ------------- End Date Validation -------------
|
|
168
|
+
|
|
169
|
+
// ------------- Start Number Validation -------------
|
|
170
|
+
function IsValidNumber(inputParameters: INumber, value: number | UN, isNeedFocus: boolean, isAutoError: boolean, input: HTMLElement | UN): boolean {
|
|
171
|
+
if (!inputParameters) return false;
|
|
172
|
+
if (value === null || value === undefined) {
|
|
173
|
+
if (inputParameters.isRequired) {
|
|
174
|
+
const requiredMessage = RequiredMessage(inputParameters.validatorKey);
|
|
175
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, true, requiredMessage, isNeedFocus);
|
|
176
|
+
return false;
|
|
177
|
+
} else {
|
|
178
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, false, undefined, isNeedFocus);
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (inputParameters.minLength !== undefined && inputParameters.minLength !== null && value < inputParameters.minLength) {
|
|
184
|
+
const msg = MinLengthNotValidMessage(inputParameters.validatorKey ?? "Input", inputParameters.minLength, false);
|
|
185
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, true, msg, isNeedFocus);
|
|
186
|
+
return false;
|
|
187
|
+
} else if (inputParameters.maxLength !== undefined && inputParameters.maxLength !== null && value > inputParameters.maxLength) {
|
|
188
|
+
const msg = MaxLengthNotValidMessage(inputParameters.validatorKey ?? "Input", inputParameters.maxLength, false);
|
|
189
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, true, msg, isNeedFocus);
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (isAutoError) AddRemoveErrorFromInput(inputParameters, input, false, undefined, isNeedFocus);
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
// ------------- End Number Validation -------------
|
|
197
|
+
|
|
198
|
+
// ------------- Start Tabularform Validation -------------
|
|
199
|
+
function IsValidTabularform(inputParameters: ITablularForm, value: any[], isNeedFocus: boolean, isAutoError: boolean, input: HTMLElement | UN) {
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
// ------------- End Tabularform Validation -------------
|
|
203
|
+
|
|
204
|
+
// ------------- Starting Input Error Handling -------------
|
|
205
|
+
export const AddRemoveErrorFromInput = (inputParameters: IInputRootParameters<any>, input: HTMLElement | UN, isShowError: boolean, errorMessage?: string | UN, isNeedFocus?: boolean) => {
|
|
206
|
+
if (!input) return;
|
|
207
|
+
const formGroup = input.parentElement;
|
|
208
|
+
if (!formGroup) return;
|
|
209
|
+
|
|
210
|
+
const errorMessageTitle_Class = "input-error-message-popup";
|
|
211
|
+
if ((formGroup as any).cleanup) (formGroup as any).cleanup();
|
|
212
|
+
const formWrapper = formGroup.parentElement;
|
|
213
|
+
if (isShowError) {
|
|
214
|
+
formGroup.classList.add("error");
|
|
215
|
+
const errorMessageTitle = GetValidationMessage(inputParameters);
|
|
216
|
+
//const errorMessageBox = CreateTitle(errorMessageTitle, formGroup);
|
|
217
|
+
//errorMessageBox.titleElement.classList.add(errorMessageTitle_Class);
|
|
218
|
+
if (formWrapper && formWrapper.classList.contains("ipt-wp")) ShowError(input, formWrapper, errorMessage, isNeedFocus);
|
|
219
|
+
else if (formGroup.classList.contains("ipt-wp")) ShowError(input, formGroup, errorMessage, isNeedFocus);
|
|
220
|
+
} else {
|
|
221
|
+
formGroup.classList.remove("error");
|
|
222
|
+
if (formWrapper && formWrapper.classList.contains("ipt-wp")) formWrapper.querySelector(".msg")?.remove();
|
|
223
|
+
else if (formGroup.classList.contains("ipt-wp")) formGroup.querySelector(".msg")?.remove();
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
const ShowError = (input: HTMLElement, formWrapper: HTMLElement, errorMessage?: string | UN, isNeedFocus?: boolean) => {
|
|
227
|
+
formWrapper.querySelector(".msg")?.remove();
|
|
228
|
+
const p = document.createElement("p") as HTMLParagraphElement;
|
|
229
|
+
p.classList.add("msg", "fw500", "fs-08");
|
|
230
|
+
p.style.color = "var(--B13)";
|
|
231
|
+
errorMessage = errorMessage ?? "Input is not valid";
|
|
232
|
+
p.innerHTML = errorMessage;
|
|
233
|
+
p.setAttribute("nlt", errorMessage ?? "");
|
|
234
|
+
formWrapper.querySelector(".smb")?.appendChild(p);
|
|
235
|
+
if (isNeedFocus) input.focus();
|
|
236
|
+
};
|
|
237
|
+
// ------------- End Input Error Handling -------------
|
|
238
|
+
interface IValidationMessage {
|
|
239
|
+
message: string | UN;
|
|
240
|
+
isValid: boolean;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export const IsMatchRejex = (value?: string | UN, reg?: string | UN): boolean => {
|
|
244
|
+
if (!reg) return true;
|
|
245
|
+
const regex = new RegExp(reg);
|
|
246
|
+
return regex.test(value ?? "");
|
|
247
|
+
};
|
|
248
|
+
export function RequiredMessage(key?: string | UN) {
|
|
249
|
+
return IsNullOrEmpty(key) ? "Invalid Request, Required validation error." : `Invalid Request, ${MakeFirstLetterUpperCase(key ?? "")} is Required.`;
|
|
250
|
+
}
|
|
251
|
+
export function GetValidationMessage(inputParams: IInputRootParameters<any>): string {
|
|
252
|
+
const messages: string[] = [];
|
|
253
|
+
const param = inputParams as IInputParameters<any>;
|
|
254
|
+
|
|
255
|
+
if (param.isRequired) {
|
|
256
|
+
messages.push("This field is required.");
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (param.minLength && param.maxLength) messages.push(`Must be between ${param.minLength} and ${param.maxLength} characters.`);
|
|
260
|
+
else if (param.minLength) messages.push(`Minimum length is ${param.minLength} characters.`);
|
|
261
|
+
else if (param.maxLength) messages.push(`Maximum length is ${param.maxLength} characters.`);
|
|
262
|
+
|
|
263
|
+
if ((param as any).regexKey) {
|
|
264
|
+
const pattern = (param as any).regexKey;
|
|
265
|
+
|
|
266
|
+
if (pattern === "^[a-zA-Z0-9_]+$") messages.push("Only letters, numbers, and underscores are allowed.");
|
|
267
|
+
else if (pattern === "^[0-9]+$") messages.push("Only numbers are allowed.");
|
|
268
|
+
else if (pattern === "^[a-zA-Z]+$") messages.push("Only letters are allowed.");
|
|
269
|
+
else if (pattern === "^[a-zA-Z0-9]+$") messages.push("Only letters and numbers are allowed.");
|
|
270
|
+
else messages.push("Please follow the required format.");
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
return messages.join("<br>");
|
|
274
|
+
}
|
|
275
|
+
export function MinLengthNotValidMessage(key: string, min: number, isArrayOrList: boolean = false): string {
|
|
276
|
+
return !isArrayOrList ? `Invalid Request, ${MakeFirstLetterUpperCase(key)} must be at least ${min} characters long.` : `Invalid Request, Please provide at least ${min} ${MakeFirstLetterUpperCase(key)}.`;
|
|
277
|
+
}
|
|
278
|
+
export function MinDateNotValidMessage(key: string, min: Date): string {
|
|
279
|
+
//const formattedDate = EasyDateFormater(min, false);
|
|
280
|
+
const formattedDate = min;
|
|
281
|
+
return `Invalid Request, ${MakeFirstLetterUpperCase(key)} must be on or after ${formattedDate}.`;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export function MaxLengthNotValidMessage(key: string, max: number, isArrayOrList: boolean = false, isSelected?: boolean): string {
|
|
285
|
+
const formattedKey = MakeFirstLetterUpperCase(key);
|
|
286
|
+
|
|
287
|
+
if (isArrayOrList) return `You can provide a maximum of ${max} ${formattedKey}.`;
|
|
288
|
+
if (isSelected) return `You cannot select more than ${max} ${formattedKey}.`;
|
|
289
|
+
return `Invalid request: ${formattedKey} cannot exceed ${max} characters.`;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export function MaxDateNotValidMessage(key: string, max: Date): string {
|
|
293
|
+
//const formattedDate = EasyDateFormater(max, false);
|
|
294
|
+
const formattedDate = max;
|
|
295
|
+
return `Invalid Request, ${MakeFirstLetterUpperCase(key)} cannot be after ${formattedDate}.`;
|
|
296
|
+
}
|
|
297
|
+
export function InvalidValueMessage(key: string | UN): string {
|
|
298
|
+
return IsNullOrEmpty(key) ? "Invalid Request, Given value is not valid." : `Invalid Request, ${MakeFirstLetterUpperCase(key ?? "")} is not valid.`;
|
|
299
|
+
}
|
|
300
|
+
export function UnauthorizedMessage(key?: string) {
|
|
301
|
+
return IsNullOrEmpty(key) ? "Invalid Request, You haven't permission to access this." : `Invalid Request, You haven't permission to access ${MakeFirstLetterUpperCase(key)}.`;
|
|
302
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import "./load-env";
|
|
2
|
-
|
|
3
1
|
// API services
|
|
4
2
|
export * from "./api-services/preference-service";
|
|
5
3
|
export * from "./api-services/system-service";
|
|
@@ -19,24 +17,10 @@ export * from "./helpers/string-helpers";
|
|
|
19
17
|
export * from "./helpers/utility-helpers";
|
|
20
18
|
|
|
21
19
|
// Interfaces
|
|
22
|
-
export * from "./
|
|
23
|
-
export * from "./interfaces/button-interfaces";
|
|
24
|
-
export * from "./interfaces/datasource-interfaces";
|
|
25
|
-
export * from "./interfaces/datatable-interfaces";
|
|
26
|
-
export * from "./interfaces/dialogbox-interfaces";
|
|
27
|
-
export * from "./interfaces/http-interfaces";
|
|
28
|
-
export * from "./interfaces/icon-interfaces";
|
|
29
|
-
export * from "./interfaces/input-interfaces";
|
|
30
|
-
export * from "./interfaces/layout-interfaces";
|
|
31
|
-
export * from "./interfaces/menu-interfaces";
|
|
32
|
-
export * from "./interfaces/permission-interfaces";
|
|
33
|
-
export * from "./interfaces/storage-interfaces";
|
|
34
|
-
export * from "./interfaces/system-interfaces";
|
|
35
|
-
export * from "./interfaces/theme-interfaces";
|
|
36
|
-
export * from "./interfaces/type-interfaces";
|
|
20
|
+
export * from "./interface";
|
|
37
21
|
|
|
38
22
|
// Core
|
|
39
23
|
export * from "./nexus.environments";
|
|
24
|
+
export * from "./proxy-api-server";
|
|
40
25
|
export * from "./services/http-services";
|
|
41
26
|
export * from "./sso-server";
|
|
42
|
-
|
package/src/interface.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
+
export * from "./interfaces/auth-token-interfaces";
|
|
1
2
|
export * from "./interfaces/browser-interfaces";
|
|
2
3
|
export * from "./interfaces/button-interfaces";
|
|
3
|
-
export * from "./interfaces/datatable-interfaces";
|
|
4
4
|
export * from "./interfaces/datasource-interfaces";
|
|
5
|
+
export * from "./interfaces/datatable-interfaces";
|
|
5
6
|
export * from "./interfaces/dialogbox-interfaces";
|
|
7
|
+
export * from "./interfaces/exception-interfaces";
|
|
6
8
|
export * from "./interfaces/http-interfaces";
|
|
7
9
|
export * from "./interfaces/icon-interfaces";
|
|
8
10
|
export * from "./interfaces/input-interfaces";
|
|
9
11
|
export * from "./interfaces/layout-interfaces";
|
|
10
12
|
export * from "./interfaces/menu-interfaces";
|
|
13
|
+
export * from "./interfaces/message-interfaces";
|
|
11
14
|
export * from "./interfaces/permission-interfaces";
|
|
12
15
|
export * from "./interfaces/storage-interfaces";
|
|
13
16
|
export * from "./interfaces/system-interfaces";
|
|
14
17
|
export * from "./interfaces/theme-interfaces";
|
|
15
18
|
export * from "./interfaces/type-interfaces";
|
|
19
|
+
export * from "./interfaces/user-interfaces";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export const DEFAULT_MOBILE_VIEW_WIDTH = 768;
|
|
2
|
+
|
|
1
3
|
export enum EKeys {
|
|
2
4
|
TAB = "Tab",
|
|
3
5
|
DELETE = "Delete",
|
|
@@ -21,3 +23,14 @@ export enum EKeyModifier {
|
|
|
21
23
|
Ctrl = 1 << 1, // 2
|
|
22
24
|
Alt = 1 << 2, // 4
|
|
23
25
|
}
|
|
26
|
+
export enum EFileSizes {
|
|
27
|
+
ORGINAL = 0,
|
|
28
|
+
SIZE_16 = 1,
|
|
29
|
+
SIZE_32 = 2,
|
|
30
|
+
SIZE_64 = 3,
|
|
31
|
+
SIZE_128 = 4,
|
|
32
|
+
SIZE_256 = 5,
|
|
33
|
+
SIZE_512 = 6,
|
|
34
|
+
SIZE_1024 = 7,
|
|
35
|
+
SIZE_2048 = 8,
|
|
36
|
+
}
|
|
@@ -40,10 +40,10 @@ export interface IButton {
|
|
|
40
40
|
iconSize?: ESizes | UN;
|
|
41
41
|
columnSize?: number | UN;
|
|
42
42
|
borderSize?: number | UN;
|
|
43
|
-
target?: ETargets | UN;
|
|
43
|
+
target?: ETargets | EButtonTypes | UN;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export const GetButton = (label?: string | StringCallbackHandler | string | UN, id?: string | UN, url?: string | UN, icon?: EIcons | UN, onClick?: ClickHandler | UN, data?: any | Event | UN, background?: EBackgrounds | UN, defaultClass?: string | UN, displayOrder?: number | UN, iconType?: EIconTypes | UN, iconSize?: ESizes | UN, columnSize?: number | UN, borderSize?: number | UN, target?: ETargets | UN): IButton => {
|
|
46
|
+
export const GetButton = (label?: string | StringCallbackHandler | string | UN, id?: string | UN, url?: string | UN, icon?: EIcons | UN, onClick?: ClickHandler | UN, data?: any | Event | UN, background?: EBackgrounds | UN, defaultClass?: string | UN, displayOrder?: number | UN, iconType?: EIconTypes | UN, iconSize?: ESizes | UN, columnSize?: number | UN, borderSize?: number | UN, target?: ETargets | EButtonTypes | UN): IButton => {
|
|
47
47
|
return {
|
|
48
48
|
label: label,
|
|
49
49
|
id: id,
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import { NEXUS_INFO } from "../nexus.environments";
|
|
2
|
+
import { GetRootApi } from "../services/http-services";
|
|
1
3
|
import { EErrorCodes, EExceptionCategories } from "./exception-interfaces";
|
|
4
|
+
import { EModules } from "./system-interfaces";
|
|
2
5
|
import { IInterface, UN } from "./type-interfaces";
|
|
3
6
|
|
|
7
|
+
export const PROXY_PUBLIC_BASE_PATH = "/api/app";
|
|
8
|
+
|
|
4
9
|
export enum EActions {
|
|
5
10
|
Get = 1,
|
|
6
11
|
Post = 2,
|
|
@@ -8,28 +13,32 @@ export enum EActions {
|
|
|
8
13
|
Delete = 4,
|
|
9
14
|
}
|
|
10
15
|
export interface IApiInformations {
|
|
11
|
-
|
|
16
|
+
module: EModules;
|
|
17
|
+
apiName: string;
|
|
12
18
|
method: EActions;
|
|
13
19
|
}
|
|
20
|
+
|
|
14
21
|
export interface IGetApiInformations extends IApiInformations {
|
|
15
22
|
cacheCode?: string;
|
|
16
23
|
/** In Minutes */
|
|
17
24
|
cacheLifetime?: number;
|
|
25
|
+
bodyType?: EBody;
|
|
26
|
+
parameters?: any;
|
|
18
27
|
}
|
|
19
28
|
|
|
20
29
|
export interface IRootRespose extends IInterface {
|
|
21
|
-
message: string | UN;
|
|
22
|
-
messageCode: string | UN;
|
|
23
30
|
isSuccess: boolean;
|
|
24
31
|
code: number;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
message?: string | UN;
|
|
33
|
+
messageCode?: string | UN;
|
|
34
|
+
exceptionCategory?: EExceptionCategories | UN;
|
|
35
|
+
errorCode?: EErrorCodes | UN;
|
|
36
|
+
inputName?: string | UN;
|
|
37
|
+
result?: any | UN;
|
|
29
38
|
}
|
|
30
39
|
|
|
31
40
|
export interface IErrorRespose extends IRootRespose {
|
|
32
|
-
exception
|
|
41
|
+
exception?: any | UN;
|
|
33
42
|
}
|
|
34
43
|
export interface ISuccessResponse extends IRootRespose {}
|
|
35
44
|
export enum EBody {
|
|
@@ -49,3 +58,72 @@ export const GetMethod = (method?: EActions) => {
|
|
|
49
58
|
return "GET";
|
|
50
59
|
}
|
|
51
60
|
};
|
|
61
|
+
|
|
62
|
+
export const GetResponse = {
|
|
63
|
+
ERROR: (message: string = "An error occurred.", messageCode: string = "GENERIC_ERROR", exceptionCategory: EExceptionCategories = EExceptionCategories.Application, errorCode: EErrorCodes = EErrorCodes.Unknown, inputName: string | undefined = undefined, exception: any | null = null, code: number = 400): IErrorRespose => ({
|
|
64
|
+
isSuccess: false,
|
|
65
|
+
exception: exception,
|
|
66
|
+
code: code,
|
|
67
|
+
message: message,
|
|
68
|
+
messageCode: messageCode,
|
|
69
|
+
exceptionCategory: exceptionCategory,
|
|
70
|
+
errorCode: errorCode,
|
|
71
|
+
inputName: inputName,
|
|
72
|
+
result: null,
|
|
73
|
+
}),
|
|
74
|
+
SUCCESS: (result: any | UN, message: string = "Success", messageCode: string = "SUCCESS", code: number = 200): ISuccessResponse => ({
|
|
75
|
+
isSuccess: true,
|
|
76
|
+
result: result,
|
|
77
|
+
message: message,
|
|
78
|
+
messageCode: messageCode,
|
|
79
|
+
code: code,
|
|
80
|
+
}),
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const GET_API_KEYS = ["cacheCode", "cacheLifetime", "bodyType", "parameters"];
|
|
84
|
+
const _isApi = (apiInformations: any | IApiInformations): boolean => {
|
|
85
|
+
if (!apiInformations || (!apiInformations.module && apiInformations.module !== EModules.None) || !apiInformations.apiName || !apiInformations.method) return false;
|
|
86
|
+
return true;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const GetApiInformations = {
|
|
90
|
+
API: (module: EModules, apiName: string, method?: EActions | UN): IApiInformations => ({
|
|
91
|
+
module: module,
|
|
92
|
+
apiName: apiName,
|
|
93
|
+
method: method ?? EActions.Get,
|
|
94
|
+
}),
|
|
95
|
+
IS_API: _isApi,
|
|
96
|
+
GET_API: (module: EModules, apiName: string, method?: EActions | UN, cacheCode?: string | UN, cacheLifetime?: number | UN, bodyType?: EBody | UN, parameters?: any | UN): IGetApiInformations => {
|
|
97
|
+
return {
|
|
98
|
+
module: module,
|
|
99
|
+
apiName: apiName,
|
|
100
|
+
method: method ?? EActions.Get,
|
|
101
|
+
cacheCode: cacheCode,
|
|
102
|
+
cacheLifetime: cacheLifetime,
|
|
103
|
+
bodyType: bodyType,
|
|
104
|
+
parameters: parameters,
|
|
105
|
+
} as IGetApiInformations;
|
|
106
|
+
},
|
|
107
|
+
IS_GET_API: (apiInformations: any | IApiInformations): boolean => {
|
|
108
|
+
if (!_isApi(apiInformations)) return false;
|
|
109
|
+
const keys = Object.keys(apiInformations);
|
|
110
|
+
return GET_API_KEYS.every((key) => keys.includes(key));
|
|
111
|
+
},
|
|
112
|
+
BUILD_API: (apiInformations: IApiInformations, parameters?: any | UN) => {
|
|
113
|
+
const isProxyServer = NEXUS_INFO.IS_PROXY_SERVER;
|
|
114
|
+
if (isProxyServer) return BuildProxyApiUrl(apiInformations.module, apiInformations.apiName);
|
|
115
|
+
return `${GetRootApi(apiInformations.module)}/${apiInformations.apiName}`;
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
export const BuildProxyApiUrl = (module: EModules, relativePath: string, query?: string): string => {
|
|
119
|
+
const normalizedPath = relativePath.replace(/^\/+/, "");
|
|
120
|
+
if (module === EModules.None) return `/api/${normalizedPath}`;
|
|
121
|
+
const base = `${PROXY_PUBLIC_BASE_PATH}/${module}/${normalizedPath}`;
|
|
122
|
+
|
|
123
|
+
if (!query) {
|
|
124
|
+
return base;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const normalizedQuery = query.replace(/^\?+/, "");
|
|
128
|
+
return normalizedQuery ? `${base}?${normalizedQuery}` : base;
|
|
129
|
+
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { ESizes } from "./layout-interfaces";
|
|
2
|
+
|
|
1
3
|
export const DEFAULT_ICON_ELEMENT_NAME = "ion-icon";
|
|
2
4
|
export const DEFAULT_SMALL_ICON_BOX_SIZE = 1 / 1.25;
|
|
5
|
+
export const DEFAULT_ICON_SIZE = ESizes.VerySmall;
|
|
3
6
|
export enum EIconTypes {
|
|
4
7
|
OUTLINED = "-outline",
|
|
5
8
|
SHARP = "-sharp",
|