dff-util 1.1.2 → 1.1.4
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/README.md +125 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/main/const-messages.d.ts +106 -0
- package/dist/main/const-messages.js +116 -0
- package/dist/main/http.js +34 -23
- package/dist/tests/http.d.ts +1 -0
- package/dist/tests/http.js +26 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -245,6 +245,131 @@ ResponseType = {
|
|
|
245
245
|
|
|
246
246
|
```
|
|
247
247
|
|
|
248
|
+
## ConstMessages
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
export const ConstMessages = {
|
|
252
|
+
// Validation messages
|
|
253
|
+
REQUIRED: 'Required',
|
|
254
|
+
MIN_LENGTH_REQUIRED: 'Minimum length required',
|
|
255
|
+
MAX_LENGTH_EXCEED: 'Maximum length exceeded',
|
|
256
|
+
INVALID_DATA: 'Invalid data',
|
|
257
|
+
FIELD_MUST_BE_NUMERIC: 'This field must be numeric',
|
|
258
|
+
FIELD_MUST_BE_ALPHABETIC: 'This field must contain only letters',
|
|
259
|
+
FIELD_MUST_BE_ALPHANUMERIC: 'This field must contain only letters and numbers',
|
|
260
|
+
INVALID_EMAIL: 'Invalid email format',
|
|
261
|
+
INVALID_PHONE: 'Invalid phone number',
|
|
262
|
+
PASSWORD_TOO_WEAK: 'Password is too weak',
|
|
263
|
+
PASSWORDS_DO_NOT_MATCH: 'Passwords do not match',
|
|
264
|
+
INVALID_DATE_FORMAT: 'Invalid date format',
|
|
265
|
+
DATE_OUT_OF_RANGE: 'Date is out of acceptable range',
|
|
266
|
+
VALUE_TOO_LOW: 'Value is too low',
|
|
267
|
+
VALUE_TOO_HIGH: 'Value is too high',
|
|
268
|
+
EXCEEDS_MAX_CHARACTERS: 'Exceeds maximum character limit',
|
|
269
|
+
INVALID_URL: 'Invalid URL format',
|
|
270
|
+
INVALID_ZIP_CODE: 'Invalid zip/postal code',
|
|
271
|
+
ONLY_POSITIVE_NUMBERS: 'Only positive numbers are allowed',
|
|
272
|
+
INVALID_CREDIT_CARD: 'Invalid credit card number',
|
|
273
|
+
INVALID_FILE_TYPE: 'Unsupported file type',
|
|
274
|
+
FILE_TOO_LARGE: 'File size exceeds the maximum limit',
|
|
275
|
+
|
|
276
|
+
// Success messages
|
|
277
|
+
SUCCESS: 'Operation completed successfully',
|
|
278
|
+
SAVED_SUCCESSFULLY: 'Data saved successfully',
|
|
279
|
+
UPDATED_SUCCESSFULLY: 'Data updated successfully',
|
|
280
|
+
DELETED_SUCCESSFULLY: 'Data deleted successfully',
|
|
281
|
+
SUBMITTED_SUCCESSFULLY: 'Form submitted successfully',
|
|
282
|
+
EMAIL_SENT: 'Email sent successfully',
|
|
283
|
+
PASSWORD_CHANGED: 'Password changed successfully',
|
|
284
|
+
LOGGED_IN: 'Logged in successfully',
|
|
285
|
+
LOGGED_OUT: 'Logged out successfully',
|
|
286
|
+
UPLOAD_SUCCESSFUL: 'File uploaded successfully',
|
|
287
|
+
PAYMENT_SUCCESSFUL: 'Payment processed successfully',
|
|
288
|
+
DATA_FETCHED: 'Data fetched successfully',
|
|
289
|
+
DATA_LOADED: 'Data loaded successfully',
|
|
290
|
+
ACTION_COMPLETED: 'Action completed successfully',
|
|
291
|
+
|
|
292
|
+
// Error messages
|
|
293
|
+
WENT_WRONG: 'Something went wrong, please try again',
|
|
294
|
+
NOT_FOUND: 'Requested resource not found',
|
|
295
|
+
UNAUTHORIZED: 'You are not authorized to perform this action',
|
|
296
|
+
FORBIDDEN: 'Access to this resource is forbidden',
|
|
297
|
+
SERVER_ERROR: 'Internal server error, please contact support',
|
|
298
|
+
CONNECTION_ERROR: 'Unable to connect, please check your internet connection',
|
|
299
|
+
TIMEOUT_ERROR: 'The request timed out, please try again later',
|
|
300
|
+
VALIDATION_FAILED: 'Validation failed, please check the input',
|
|
301
|
+
DUPLICATE_ENTRY: 'Duplicate entry, please provide unique data',
|
|
302
|
+
SESSION_EXPIRED: 'Your session has expired, please log in again',
|
|
303
|
+
INVALID_SESSION: 'Invalid session, please authenticate',
|
|
304
|
+
RATE_LIMIT_EXCEEDED: 'Too many requests, please try again later',
|
|
305
|
+
RESOURCE_LOCKED: 'This resource is currently locked',
|
|
306
|
+
DATA_CORRUPTED: 'Data is corrupted',
|
|
307
|
+
SERVICE_UNAVAILABLE: 'Service is currently unavailable',
|
|
308
|
+
PAYMENT_FAILED: 'Payment failed, please check your details',
|
|
309
|
+
OPERATION_FAILED: 'Operation failed, please try again',
|
|
310
|
+
ACCESS_DENIED: 'Access denied',
|
|
311
|
+
INVALID_CREDENTIALS: 'Invalid credentials, please try again',
|
|
312
|
+
INVALID_TOKEN: 'Invalid token, please try again',
|
|
313
|
+
USER_NOT_FOUND: 'User not found, please try again',
|
|
314
|
+
PASSWORD_RESET_FAILED: 'Password reset failed, please try again',
|
|
315
|
+
|
|
316
|
+
// Informational Messages
|
|
317
|
+
NO_DATA_FOUND: 'No data found',
|
|
318
|
+
NO_RECORD_FOUND: 'No record found',
|
|
319
|
+
NO_RECORDS_FOUND: 'No records found',
|
|
320
|
+
NO_RECORDS_MATCHED: 'No records matched your search criteria',
|
|
321
|
+
NO_RECORDS_MATCHED_FILTER: 'No records matched your filter criteria',
|
|
322
|
+
LOADING: 'Loading, please wait...',
|
|
323
|
+
FETCHING_DATA: 'Fetching data, please wait...',
|
|
324
|
+
PROCESSING: 'Processing your request...',
|
|
325
|
+
PLEASE_WAIT: 'Please wait...',
|
|
326
|
+
NO_RESULTS_FOUND: 'No results found',
|
|
327
|
+
NO_DATA_AVAILABLE: 'No data available',
|
|
328
|
+
SEARCHING: 'Searching...',
|
|
329
|
+
REDIRECTING: 'Redirecting, please wait...',
|
|
330
|
+
CONNECTING: 'Connecting, please wait...',
|
|
331
|
+
LOGGING_OUT: 'Logging out, please wait...',
|
|
332
|
+
LOGGING_IN: 'Logging in, please wait...',
|
|
333
|
+
PREPARING_DOWNLOAD: 'Preparing your download...',
|
|
334
|
+
CHECKING_UPDATES: 'Checking for updates...',
|
|
335
|
+
|
|
336
|
+
// Confirmation Messages
|
|
337
|
+
CONFIRM_DELETE: 'Are you sure you want to delete this?',
|
|
338
|
+
CONFIRM_SAVE: 'Do you want to save changes?',
|
|
339
|
+
CONFIRM_SUBMIT: 'Do you want to submit this form?',
|
|
340
|
+
CONFIRM_LOGOUT: 'Are you sure you want to log out?',
|
|
341
|
+
CONFIRM_ACTION: 'Are you sure you want to proceed?',
|
|
342
|
+
CONFIRM_CLOSE: 'Are you sure you want to close this window?',
|
|
343
|
+
CONFIRM_CANCEL: 'Do you want to cancel this action?',
|
|
344
|
+
CONFIRM_RESTART: 'Do you want to restart the process?',
|
|
345
|
+
|
|
346
|
+
// Warning Messages
|
|
347
|
+
UNSAVED_CHANGES: 'You have unsaved changes. Do you want to discard them?',
|
|
348
|
+
LOW_BATTERY: 'Battery level is low, please connect your charger',
|
|
349
|
+
HIGH_USAGE: 'High system usage detected',
|
|
350
|
+
INCOMPLETE_FORM: 'The form is incomplete',
|
|
351
|
+
LIMIT_REACHED: 'You have reached the maximum limit',
|
|
352
|
+
OUTDATED_VERSION: 'You are using an outdated version of the application',
|
|
353
|
+
|
|
354
|
+
// General Messages
|
|
355
|
+
WELCOME: 'Welcome to the application',
|
|
356
|
+
GOODBYE: 'Goodbye, have a great day!',
|
|
357
|
+
HELLO: 'Hello, how can we help you today?',
|
|
358
|
+
THANK_YOU: 'Thank you for using our service',
|
|
359
|
+
TRY_AGAIN: 'Please try again',
|
|
360
|
+
UNDER_MAINTENANCE: 'The system is under maintenance, please check back later',
|
|
361
|
+
FEATURE_COMING_SOON: 'This feature is coming soon',
|
|
362
|
+
CONTACT_SUPPORT: 'If the issue persists, please contact support',
|
|
363
|
+
UPDATING: 'Updating, please wait...',
|
|
364
|
+
INSTALLING: 'Installing, please wait...',
|
|
365
|
+
RESTART_REQUIRED: 'A restart is required to apply changes',
|
|
366
|
+
RESTARTING: 'Restarting, please wait...',
|
|
367
|
+
LOADING_DATA: 'Loading data, please wait...',
|
|
368
|
+
SAVING: 'Saving, please wait...',
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
```
|
|
372
|
+
|
|
248
373
|
## file upload test
|
|
249
374
|
|
|
250
375
|
```
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -20,3 +20,4 @@ __exportStar(require("./main/http"), exports);
|
|
|
20
20
|
__exportStar(require("./main/regexr"), exports);
|
|
21
21
|
__exportStar(require("./main/const-value"), exports);
|
|
22
22
|
__exportStar(require("./main/const-type"), exports);
|
|
23
|
+
__exportStar(require("./main/const-messages"), exports);
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export declare const ConstMessages: {
|
|
2
|
+
REQUIRED: string;
|
|
3
|
+
MIN_LENGTH_REQUIRED: string;
|
|
4
|
+
MAX_LENGTH_EXCEED: string;
|
|
5
|
+
INVALID_DATA: string;
|
|
6
|
+
FIELD_MUST_BE_NUMERIC: string;
|
|
7
|
+
FIELD_MUST_BE_ALPHABETIC: string;
|
|
8
|
+
FIELD_MUST_BE_ALPHANUMERIC: string;
|
|
9
|
+
INVALID_EMAIL: string;
|
|
10
|
+
INVALID_PHONE: string;
|
|
11
|
+
PASSWORD_TOO_WEAK: string;
|
|
12
|
+
PASSWORDS_DO_NOT_MATCH: string;
|
|
13
|
+
INVALID_DATE_FORMAT: string;
|
|
14
|
+
DATE_OUT_OF_RANGE: string;
|
|
15
|
+
VALUE_TOO_LOW: string;
|
|
16
|
+
VALUE_TOO_HIGH: string;
|
|
17
|
+
EXCEEDS_MAX_CHARACTERS: string;
|
|
18
|
+
INVALID_URL: string;
|
|
19
|
+
INVALID_ZIP_CODE: string;
|
|
20
|
+
ONLY_POSITIVE_NUMBERS: string;
|
|
21
|
+
INVALID_CREDIT_CARD: string;
|
|
22
|
+
INVALID_FILE_TYPE: string;
|
|
23
|
+
FILE_TOO_LARGE: string;
|
|
24
|
+
SUCCESS: string;
|
|
25
|
+
SAVED_SUCCESSFULLY: string;
|
|
26
|
+
UPDATED_SUCCESSFULLY: string;
|
|
27
|
+
DELETED_SUCCESSFULLY: string;
|
|
28
|
+
SUBMITTED_SUCCESSFULLY: string;
|
|
29
|
+
EMAIL_SENT: string;
|
|
30
|
+
PASSWORD_CHANGED: string;
|
|
31
|
+
LOGGED_IN: string;
|
|
32
|
+
LOGGED_OUT: string;
|
|
33
|
+
UPLOAD_SUCCESSFUL: string;
|
|
34
|
+
PAYMENT_SUCCESSFUL: string;
|
|
35
|
+
DATA_FETCHED: string;
|
|
36
|
+
DATA_LOADED: string;
|
|
37
|
+
ACTION_COMPLETED: string;
|
|
38
|
+
WENT_WRONG: string;
|
|
39
|
+
NOT_FOUND: string;
|
|
40
|
+
UNAUTHORIZED: string;
|
|
41
|
+
FORBIDDEN: string;
|
|
42
|
+
SERVER_ERROR: string;
|
|
43
|
+
CONNECTION_ERROR: string;
|
|
44
|
+
TIMEOUT_ERROR: string;
|
|
45
|
+
VALIDATION_FAILED: string;
|
|
46
|
+
DUPLICATE_ENTRY: string;
|
|
47
|
+
SESSION_EXPIRED: string;
|
|
48
|
+
INVALID_SESSION: string;
|
|
49
|
+
RATE_LIMIT_EXCEEDED: string;
|
|
50
|
+
RESOURCE_LOCKED: string;
|
|
51
|
+
DATA_CORRUPTED: string;
|
|
52
|
+
SERVICE_UNAVAILABLE: string;
|
|
53
|
+
PAYMENT_FAILED: string;
|
|
54
|
+
OPERATION_FAILED: string;
|
|
55
|
+
ACCESS_DENIED: string;
|
|
56
|
+
INVALID_CREDENTIALS: string;
|
|
57
|
+
INVALID_TOKEN: string;
|
|
58
|
+
USER_NOT_FOUND: string;
|
|
59
|
+
PASSWORD_RESET_FAILED: string;
|
|
60
|
+
NO_DATA_FOUND: string;
|
|
61
|
+
NO_RECORD_FOUND: string;
|
|
62
|
+
NO_RECORDS_FOUND: string;
|
|
63
|
+
NO_RECORDS_MATCHED: string;
|
|
64
|
+
NO_RECORDS_MATCHED_FILTER: string;
|
|
65
|
+
LOADING: string;
|
|
66
|
+
FETCHING_DATA: string;
|
|
67
|
+
PROCESSING: string;
|
|
68
|
+
PLEASE_WAIT: string;
|
|
69
|
+
NO_RESULTS_FOUND: string;
|
|
70
|
+
NO_DATA_AVAILABLE: string;
|
|
71
|
+
SEARCHING: string;
|
|
72
|
+
REDIRECTING: string;
|
|
73
|
+
CONNECTING: string;
|
|
74
|
+
LOGGING_OUT: string;
|
|
75
|
+
LOGGING_IN: string;
|
|
76
|
+
PREPARING_DOWNLOAD: string;
|
|
77
|
+
CHECKING_UPDATES: string;
|
|
78
|
+
CONFIRM_DELETE: string;
|
|
79
|
+
CONFIRM_SAVE: string;
|
|
80
|
+
CONFIRM_SUBMIT: string;
|
|
81
|
+
CONFIRM_LOGOUT: string;
|
|
82
|
+
CONFIRM_ACTION: string;
|
|
83
|
+
CONFIRM_CLOSE: string;
|
|
84
|
+
CONFIRM_CANCEL: string;
|
|
85
|
+
CONFIRM_RESTART: string;
|
|
86
|
+
UNSAVED_CHANGES: string;
|
|
87
|
+
LOW_BATTERY: string;
|
|
88
|
+
HIGH_USAGE: string;
|
|
89
|
+
INCOMPLETE_FORM: string;
|
|
90
|
+
LIMIT_REACHED: string;
|
|
91
|
+
OUTDATED_VERSION: string;
|
|
92
|
+
WELCOME: string;
|
|
93
|
+
GOODBYE: string;
|
|
94
|
+
HELLO: string;
|
|
95
|
+
THANK_YOU: string;
|
|
96
|
+
TRY_AGAIN: string;
|
|
97
|
+
UNDER_MAINTENANCE: string;
|
|
98
|
+
FEATURE_COMING_SOON: string;
|
|
99
|
+
CONTACT_SUPPORT: string;
|
|
100
|
+
UPDATING: string;
|
|
101
|
+
INSTALLING: string;
|
|
102
|
+
RESTART_REQUIRED: string;
|
|
103
|
+
RESTARTING: string;
|
|
104
|
+
LOADING_DATA: string;
|
|
105
|
+
SAVING: string;
|
|
106
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConstMessages = void 0;
|
|
4
|
+
exports.ConstMessages = {
|
|
5
|
+
// Validation messages
|
|
6
|
+
REQUIRED: 'Required',
|
|
7
|
+
MIN_LENGTH_REQUIRED: 'Minimum length required',
|
|
8
|
+
MAX_LENGTH_EXCEED: 'Maximum length exceeded',
|
|
9
|
+
INVALID_DATA: 'Invalid data',
|
|
10
|
+
FIELD_MUST_BE_NUMERIC: 'This field must be numeric',
|
|
11
|
+
FIELD_MUST_BE_ALPHABETIC: 'This field must contain only letters',
|
|
12
|
+
FIELD_MUST_BE_ALPHANUMERIC: 'This field must contain only letters and numbers',
|
|
13
|
+
INVALID_EMAIL: 'Invalid email format',
|
|
14
|
+
INVALID_PHONE: 'Invalid phone number',
|
|
15
|
+
PASSWORD_TOO_WEAK: 'Password is too weak',
|
|
16
|
+
PASSWORDS_DO_NOT_MATCH: 'Passwords do not match',
|
|
17
|
+
INVALID_DATE_FORMAT: 'Invalid date format',
|
|
18
|
+
DATE_OUT_OF_RANGE: 'Date is out of acceptable range',
|
|
19
|
+
VALUE_TOO_LOW: 'Value is too low',
|
|
20
|
+
VALUE_TOO_HIGH: 'Value is too high',
|
|
21
|
+
EXCEEDS_MAX_CHARACTERS: 'Exceeds maximum character limit',
|
|
22
|
+
INVALID_URL: 'Invalid URL format',
|
|
23
|
+
INVALID_ZIP_CODE: 'Invalid zip/postal code',
|
|
24
|
+
ONLY_POSITIVE_NUMBERS: 'Only positive numbers are allowed',
|
|
25
|
+
INVALID_CREDIT_CARD: 'Invalid credit card number',
|
|
26
|
+
INVALID_FILE_TYPE: 'Unsupported file type',
|
|
27
|
+
FILE_TOO_LARGE: 'File size exceeds the maximum limit',
|
|
28
|
+
// Success messages
|
|
29
|
+
SUCCESS: 'Operation completed successfully',
|
|
30
|
+
SAVED_SUCCESSFULLY: 'Data saved successfully',
|
|
31
|
+
UPDATED_SUCCESSFULLY: 'Data updated successfully',
|
|
32
|
+
DELETED_SUCCESSFULLY: 'Data deleted successfully',
|
|
33
|
+
SUBMITTED_SUCCESSFULLY: 'Form submitted successfully',
|
|
34
|
+
EMAIL_SENT: 'Email sent successfully',
|
|
35
|
+
PASSWORD_CHANGED: 'Password changed successfully',
|
|
36
|
+
LOGGED_IN: 'Logged in successfully',
|
|
37
|
+
LOGGED_OUT: 'Logged out successfully',
|
|
38
|
+
UPLOAD_SUCCESSFUL: 'File uploaded successfully',
|
|
39
|
+
PAYMENT_SUCCESSFUL: 'Payment processed successfully',
|
|
40
|
+
DATA_FETCHED: 'Data fetched successfully',
|
|
41
|
+
DATA_LOADED: 'Data loaded successfully',
|
|
42
|
+
ACTION_COMPLETED: 'Action completed successfully',
|
|
43
|
+
// Error messages
|
|
44
|
+
WENT_WRONG: 'Something went wrong, please try again',
|
|
45
|
+
NOT_FOUND: 'Requested resource not found',
|
|
46
|
+
UNAUTHORIZED: 'You are not authorized to perform this action',
|
|
47
|
+
FORBIDDEN: 'Access to this resource is forbidden',
|
|
48
|
+
SERVER_ERROR: 'Internal server error, please contact support',
|
|
49
|
+
CONNECTION_ERROR: 'Unable to connect, please check your internet connection',
|
|
50
|
+
TIMEOUT_ERROR: 'The request timed out, please try again later',
|
|
51
|
+
VALIDATION_FAILED: 'Validation failed, please check the input',
|
|
52
|
+
DUPLICATE_ENTRY: 'Duplicate entry, please provide unique data',
|
|
53
|
+
SESSION_EXPIRED: 'Your session has expired, please log in again',
|
|
54
|
+
INVALID_SESSION: 'Invalid session, please authenticate',
|
|
55
|
+
RATE_LIMIT_EXCEEDED: 'Too many requests, please try again later',
|
|
56
|
+
RESOURCE_LOCKED: 'This resource is currently locked',
|
|
57
|
+
DATA_CORRUPTED: 'Data is corrupted',
|
|
58
|
+
SERVICE_UNAVAILABLE: 'Service is currently unavailable',
|
|
59
|
+
PAYMENT_FAILED: 'Payment failed, please check your details',
|
|
60
|
+
OPERATION_FAILED: 'Operation failed, please try again',
|
|
61
|
+
ACCESS_DENIED: 'Access denied',
|
|
62
|
+
INVALID_CREDENTIALS: 'Invalid credentials, please try again',
|
|
63
|
+
INVALID_TOKEN: 'Invalid token, please try again',
|
|
64
|
+
USER_NOT_FOUND: 'User not found, please try again',
|
|
65
|
+
PASSWORD_RESET_FAILED: 'Password reset failed, please try again',
|
|
66
|
+
// Informational Messages
|
|
67
|
+
NO_DATA_FOUND: 'No data found',
|
|
68
|
+
NO_RECORD_FOUND: 'No record found',
|
|
69
|
+
NO_RECORDS_FOUND: 'No records found',
|
|
70
|
+
NO_RECORDS_MATCHED: 'No records matched your search criteria',
|
|
71
|
+
NO_RECORDS_MATCHED_FILTER: 'No records matched your filter criteria',
|
|
72
|
+
LOADING: 'Loading, please wait...',
|
|
73
|
+
FETCHING_DATA: 'Fetching data, please wait...',
|
|
74
|
+
PROCESSING: 'Processing your request...',
|
|
75
|
+
PLEASE_WAIT: 'Please wait...',
|
|
76
|
+
NO_RESULTS_FOUND: 'No results found',
|
|
77
|
+
NO_DATA_AVAILABLE: 'No data available',
|
|
78
|
+
SEARCHING: 'Searching...',
|
|
79
|
+
REDIRECTING: 'Redirecting, please wait...',
|
|
80
|
+
CONNECTING: 'Connecting, please wait...',
|
|
81
|
+
LOGGING_OUT: 'Logging out, please wait...',
|
|
82
|
+
LOGGING_IN: 'Logging in, please wait...',
|
|
83
|
+
PREPARING_DOWNLOAD: 'Preparing your download...',
|
|
84
|
+
CHECKING_UPDATES: 'Checking for updates...',
|
|
85
|
+
// Confirmation Messages
|
|
86
|
+
CONFIRM_DELETE: 'Are you sure you want to delete this?',
|
|
87
|
+
CONFIRM_SAVE: 'Do you want to save changes?',
|
|
88
|
+
CONFIRM_SUBMIT: 'Do you want to submit this form?',
|
|
89
|
+
CONFIRM_LOGOUT: 'Are you sure you want to log out?',
|
|
90
|
+
CONFIRM_ACTION: 'Are you sure you want to proceed?',
|
|
91
|
+
CONFIRM_CLOSE: 'Are you sure you want to close this window?',
|
|
92
|
+
CONFIRM_CANCEL: 'Do you want to cancel this action?',
|
|
93
|
+
CONFIRM_RESTART: 'Do you want to restart the process?',
|
|
94
|
+
// Warning Messages
|
|
95
|
+
UNSAVED_CHANGES: 'You have unsaved changes. Do you want to discard them?',
|
|
96
|
+
LOW_BATTERY: 'Battery level is low, please connect your charger',
|
|
97
|
+
HIGH_USAGE: 'High system usage detected',
|
|
98
|
+
INCOMPLETE_FORM: 'The form is incomplete',
|
|
99
|
+
LIMIT_REACHED: 'You have reached the maximum limit',
|
|
100
|
+
OUTDATED_VERSION: 'You are using an outdated version of the application',
|
|
101
|
+
// General Messages
|
|
102
|
+
WELCOME: 'Welcome to the application',
|
|
103
|
+
GOODBYE: 'Goodbye, have a great day!',
|
|
104
|
+
HELLO: 'Hello, how can we help you today?',
|
|
105
|
+
THANK_YOU: 'Thank you for using our service',
|
|
106
|
+
TRY_AGAIN: 'Please try again',
|
|
107
|
+
UNDER_MAINTENANCE: 'The system is under maintenance, please check back later',
|
|
108
|
+
FEATURE_COMING_SOON: 'This feature is coming soon',
|
|
109
|
+
CONTACT_SUPPORT: 'If the issue persists, please contact support',
|
|
110
|
+
UPDATING: 'Updating, please wait...',
|
|
111
|
+
INSTALLING: 'Installing, please wait...',
|
|
112
|
+
RESTART_REQUIRED: 'A restart is required to apply changes',
|
|
113
|
+
RESTARTING: 'Restarting, please wait...',
|
|
114
|
+
LOADING_DATA: 'Loading data, please wait...',
|
|
115
|
+
SAVING: 'Saving, please wait...',
|
|
116
|
+
};
|
package/dist/main/http.js
CHANGED
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Http = exports.BaseHeaders = exports.HttpHeaders = exports.RespType = void 0;
|
|
13
|
+
const util_1 = require("./util");
|
|
13
14
|
var RespType;
|
|
14
15
|
(function (RespType) {
|
|
15
16
|
RespType["JSON"] = "json";
|
|
@@ -31,7 +32,13 @@ class Http {
|
|
|
31
32
|
static RespData(response_1) {
|
|
32
33
|
return __awaiter(this, arguments, void 0, function* (response, type = RespType.JSON) {
|
|
33
34
|
if (!response.ok) {
|
|
34
|
-
|
|
35
|
+
const data = yield response.text();
|
|
36
|
+
if ((data && data.startsWith('{')) || data.startsWith('[')) {
|
|
37
|
+
throw JSON.parse(data);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
throw data;
|
|
41
|
+
}
|
|
35
42
|
}
|
|
36
43
|
switch (type) {
|
|
37
44
|
case RespType.JSON:
|
|
@@ -55,42 +62,45 @@ class Http {
|
|
|
55
62
|
return __awaiter(this, arguments, void 0, function* (url, params, headers, type = RespType.JSON) {
|
|
56
63
|
url = url.startsWith('http') ? url : Http.API_BASE_URL + url;
|
|
57
64
|
const fullUrl = params ? `${url}?${new URLSearchParams(params).toString()}` : url;
|
|
65
|
+
headers = headers || exports.HttpHeaders;
|
|
66
|
+
headers['x-request-id'] = headers['x-request-id'] || (0, util_1.AppUUID4)();
|
|
58
67
|
try {
|
|
59
|
-
const requestOptions = { method: 'GET', headers: headers
|
|
68
|
+
const requestOptions = { method: 'GET', headers: headers };
|
|
60
69
|
const response = yield fetch(fullUrl, requestOptions);
|
|
61
70
|
return yield Http.RespData(response, type);
|
|
62
71
|
}
|
|
63
72
|
catch (error) {
|
|
64
|
-
|
|
65
|
-
throw { url: fullUrl, requestId: exports.HttpHeaders['x-request-id'], error: error };
|
|
73
|
+
throw { url: fullUrl, requestId: headers['x-request-id'], error: error };
|
|
66
74
|
}
|
|
67
75
|
});
|
|
68
76
|
}
|
|
69
77
|
static Post(url_1, data_1, headers_1) {
|
|
70
78
|
return __awaiter(this, arguments, void 0, function* (url, data, headers, type = RespType.JSON) {
|
|
71
79
|
url = url.startsWith('http') ? url : Http.API_BASE_URL + url;
|
|
80
|
+
headers = headers || exports.HttpHeaders;
|
|
81
|
+
headers['x-request-id'] = headers['x-request-id'] || (0, util_1.AppUUID4)();
|
|
72
82
|
try {
|
|
73
|
-
const requestOptions = { method: 'POST', body: JSON.stringify(data
|
|
83
|
+
const requestOptions = { method: 'POST', body: JSON.stringify(data), headers: headers };
|
|
74
84
|
const response = yield fetch(url, requestOptions);
|
|
75
85
|
return yield Http.RespData(response, type);
|
|
76
86
|
}
|
|
77
87
|
catch (error) {
|
|
78
|
-
|
|
79
|
-
throw { url: url, requestId: exports.HttpHeaders['x-request-id'], body: data, error: error };
|
|
88
|
+
throw { url: url, requestId: headers['x-request-id'], body: data, error: error };
|
|
80
89
|
}
|
|
81
90
|
});
|
|
82
91
|
}
|
|
83
92
|
static Put(url_1, data_1, headers_1) {
|
|
84
93
|
return __awaiter(this, arguments, void 0, function* (url, data, headers, type = RespType.JSON) {
|
|
85
94
|
url = url.startsWith('http') ? url : Http.API_BASE_URL + url;
|
|
95
|
+
headers = headers || exports.HttpHeaders;
|
|
96
|
+
headers['x-request-id'] = headers['x-request-id'] || (0, util_1.AppUUID4)();
|
|
86
97
|
try {
|
|
87
|
-
const requestOptions = { method: 'PUT', body: JSON.stringify(data
|
|
98
|
+
const requestOptions = { method: 'PUT', body: JSON.stringify(data), headers: headers };
|
|
88
99
|
const response = yield fetch(url, requestOptions);
|
|
89
100
|
return yield Http.RespData(response, type);
|
|
90
101
|
}
|
|
91
102
|
catch (error) {
|
|
92
|
-
|
|
93
|
-
throw { url: url, requestId: exports.HttpHeaders['x-request-id'], body: data, error: error };
|
|
103
|
+
throw { url: url, requestId: headers['x-request-id'], body: data, error: error };
|
|
94
104
|
}
|
|
95
105
|
});
|
|
96
106
|
}
|
|
@@ -98,14 +108,15 @@ class Http {
|
|
|
98
108
|
return __awaiter(this, arguments, void 0, function* (url, params, headers, type = RespType.JSON) {
|
|
99
109
|
url = url.startsWith('http') ? url : Http.API_BASE_URL + url;
|
|
100
110
|
const fullUrl = params ? `${url}?${new URLSearchParams(params).toString()}` : url;
|
|
111
|
+
headers = headers || exports.HttpHeaders;
|
|
112
|
+
headers['x-request-id'] = headers['x-request-id'] || (0, util_1.AppUUID4)();
|
|
101
113
|
try {
|
|
102
|
-
const requestOptions = { method: 'DELETE', headers: headers
|
|
114
|
+
const requestOptions = { method: 'DELETE', headers: headers };
|
|
103
115
|
const response = yield fetch(fullUrl, requestOptions);
|
|
104
116
|
return yield Http.RespData(response, type);
|
|
105
117
|
}
|
|
106
118
|
catch (error) {
|
|
107
|
-
|
|
108
|
-
throw { url: fullUrl, requestId: exports.HttpHeaders['x-request-id'], error: error };
|
|
119
|
+
throw { url: fullUrl, requestId: headers['x-request-id'], error: error };
|
|
109
120
|
}
|
|
110
121
|
});
|
|
111
122
|
}
|
|
@@ -115,14 +126,14 @@ class Http {
|
|
|
115
126
|
const params = { key: appKey, payload: JSON.stringify(sessionInfo) };
|
|
116
127
|
const fullUrl = `${url}?${new URLSearchParams(params).toString()}`;
|
|
117
128
|
const headers = Object.assign(Object.assign({}, Headers), { 'X-API-KEY': apiKey || '' });
|
|
129
|
+
headers['x-request-id'] = headers['x-request-id'] || (0, util_1.AppUUID4)();
|
|
118
130
|
try {
|
|
119
131
|
const requestOptions = { method: 'GET', headers: headers };
|
|
120
132
|
const response = yield fetch(fullUrl, requestOptions);
|
|
121
133
|
return yield Http.RespData(response, type);
|
|
122
134
|
}
|
|
123
135
|
catch (error) {
|
|
124
|
-
|
|
125
|
-
throw { url: fullUrl, requestId: exports.HttpHeaders['x-request-id'], error: error };
|
|
136
|
+
throw { url: fullUrl, requestId: headers['x-request-id'], error: error };
|
|
126
137
|
}
|
|
127
138
|
});
|
|
128
139
|
}
|
|
@@ -139,19 +150,18 @@ class Http {
|
|
|
139
150
|
if (isHeadersAddMultiForm) {
|
|
140
151
|
headers = Object.assign(Object.assign({}, headers), { 'Content-Type': headers['Content-Type'] || 'multipart/form-data' });
|
|
141
152
|
}
|
|
153
|
+
headers['x-request-id'] = headers['x-request-id'] || (0, util_1.AppUUID4)();
|
|
142
154
|
try {
|
|
143
155
|
const requestOptions = {
|
|
144
156
|
method: method,
|
|
145
157
|
body: formData,
|
|
146
158
|
headers: Object.assign({}, headers),
|
|
147
159
|
};
|
|
148
|
-
console.log(requestOptions);
|
|
149
160
|
const response = yield fetch(url, requestOptions);
|
|
150
161
|
return yield Http.RespData(response, type);
|
|
151
162
|
}
|
|
152
163
|
catch (error) {
|
|
153
|
-
|
|
154
|
-
throw { url: url, requestId: exports.HttpHeaders['x-request-id'], error: error };
|
|
164
|
+
throw { url: url, requestId: headers['x-request-id'], error: error };
|
|
155
165
|
}
|
|
156
166
|
});
|
|
157
167
|
}
|
|
@@ -160,6 +170,7 @@ class Http {
|
|
|
160
170
|
headers = headers || {
|
|
161
171
|
'Content-Type': file.type,
|
|
162
172
|
};
|
|
173
|
+
headers['x-request-id'] = headers['x-request-id'] || (0, util_1.AppUUID4)();
|
|
163
174
|
try {
|
|
164
175
|
const requestOptions = {
|
|
165
176
|
method: method,
|
|
@@ -170,24 +181,24 @@ class Http {
|
|
|
170
181
|
return response;
|
|
171
182
|
}
|
|
172
183
|
catch (error) {
|
|
173
|
-
|
|
174
|
-
throw { url: fullUrl, requestId: exports.HttpHeaders['x-request-id'], error: error };
|
|
184
|
+
throw { url: fullUrl, requestId: headers['x-request-id'], error: error };
|
|
175
185
|
}
|
|
176
186
|
});
|
|
177
187
|
}
|
|
178
188
|
static FileDownload(fullUrl_1, params_1) {
|
|
179
189
|
return __awaiter(this, arguments, void 0, function* (fullUrl, params, headers = exports.HttpHeaders, method = 'GET') {
|
|
180
190
|
fullUrl = params ? `${fullUrl}?${new URLSearchParams(params).toString()}` : fullUrl;
|
|
191
|
+
headers = headers || exports.HttpHeaders;
|
|
192
|
+
headers['x-request-id'] = headers['x-request-id'] || (0, util_1.AppUUID4)();
|
|
181
193
|
try {
|
|
182
|
-
const requestOptions = { method: method, headers: headers
|
|
194
|
+
const requestOptions = { method: method, headers: headers };
|
|
183
195
|
const response = yield fetch(fullUrl, requestOptions);
|
|
184
196
|
const blob = yield response.blob();
|
|
185
197
|
const buffer = Buffer.from(yield blob.arrayBuffer());
|
|
186
198
|
return buffer;
|
|
187
199
|
}
|
|
188
200
|
catch (error) {
|
|
189
|
-
|
|
190
|
-
throw { url: fullUrl, requestId: exports.HttpHeaders['x-request-id'], error: error };
|
|
201
|
+
throw { url: fullUrl, requestId: headers['x-request-id'], error: error };
|
|
191
202
|
}
|
|
192
203
|
});
|
|
193
204
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// bun src/tests/http.ts
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
const index_1 = require("../index");
|
|
14
|
+
const url = '/auth/partner/signin';
|
|
15
|
+
const reqBody = { language: 'en-US', mobile: '111111111', provider: 'mobile', telCode: '+91' };
|
|
16
|
+
const runHttpExample = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
try {
|
|
18
|
+
const res = yield index_1.Http.Post(url, reqBody, null);
|
|
19
|
+
console.log(res);
|
|
20
|
+
return res;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
console.log(error);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
runHttpExample();
|