@creopse/utils 0.0.15 → 0.0.16
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/LICENSE +21 -0
- package/dist/enums/index.d.ts +3 -0
- package/dist/enums/index.js +3 -0
- package/dist/enums/notification-type.d.ts +1 -1
- package/dist/enums/notification-type.js +1 -1
- package/dist/enums/permission.d.ts +28 -0
- package/dist/enums/permission.js +38 -0
- package/dist/enums/profile-type.d.ts +1 -0
- package/dist/enums/profile-type.js +1 -0
- package/dist/{utils → helpers}/chronos.d.ts +1 -1
- package/dist/{utils → helpers}/chronos.js +1 -1
- package/dist/helpers/constants/constants.d.ts +2 -0
- package/dist/helpers/constants/constants.js +3 -0
- package/dist/helpers/constants/index.d.ts +1 -0
- package/dist/helpers/constants/index.js +1 -0
- package/dist/helpers/constants.d.ts +2 -0
- package/dist/helpers/constants.js +3 -0
- package/dist/helpers/functions/array.d.ts +22 -0
- package/dist/helpers/functions/array.js +42 -0
- package/dist/helpers/functions/browser.d.ts +40 -0
- package/dist/helpers/functions/browser.js +72 -0
- package/dist/helpers/functions/color.d.ts +14 -0
- package/dist/helpers/functions/color.js +26 -0
- package/dist/helpers/functions/file.d.ts +64 -0
- package/dist/helpers/functions/file.js +210 -0
- package/dist/helpers/functions/geo.d.ts +17 -0
- package/dist/helpers/functions/geo.js +31 -0
- package/dist/helpers/functions/image.d.ts +20 -0
- package/dist/helpers/functions/image.js +44 -0
- package/dist/helpers/functions/index.d.ts +13 -0
- package/dist/helpers/functions/index.js +13 -0
- package/dist/helpers/functions/misc.d.ts +55 -0
- package/dist/helpers/functions/misc.js +125 -0
- package/dist/helpers/functions/number.d.ts +15 -0
- package/dist/helpers/functions/number.js +26 -0
- package/dist/helpers/functions/object.d.ts +79 -0
- package/dist/helpers/functions/object.js +141 -0
- package/dist/helpers/functions/string.d.ts +110 -0
- package/dist/helpers/functions/string.js +211 -0
- package/dist/helpers/functions/svg.d.ts +7 -0
- package/dist/helpers/functions/svg.js +25 -0
- package/dist/helpers/functions/time.d.ts +97 -0
- package/dist/helpers/functions/time.js +97 -0
- package/dist/helpers/functions/url.d.ts +46 -0
- package/dist/helpers/functions/url.js +120 -0
- package/dist/{utils → helpers}/functions.d.ts +14 -0
- package/dist/{utils → helpers}/functions.js +26 -1
- package/dist/{utils → helpers}/index.d.ts +1 -1
- package/dist/{utils → helpers}/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/models/page-section.d.ts +2 -1
- package/dist/models/page-section.js +2 -1
- package/dist/types/core-bridge/api.d.ts +31 -0
- package/dist/types/core-bridge/api.js +1 -0
- package/dist/types/core-bridge/i18n.d.ts +6 -0
- package/dist/types/core-bridge/i18n.js +1 -0
- package/dist/types/core-bridge/index.d.ts +4 -0
- package/dist/types/core-bridge/index.js +4 -0
- package/dist/types/core-bridge/shared-data.d.ts +22 -0
- package/dist/types/core-bridge/shared-data.js +1 -0
- package/dist/types/core-bridge/stores.d.ts +31 -0
- package/dist/types/core-bridge/stores.js +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/plugin.d.ts +30 -0
- package/dist/types/plugin.js +1 -0
- package/package.json +23 -5
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
import 'moment/locale/fr';
|
|
3
|
+
/**
|
|
4
|
+
* Waits for the given amount of milliseconds before resolving the promise.
|
|
5
|
+
* @param {number} ms - The time to wait in milliseconds.
|
|
6
|
+
* @returns {Promise<void>} - A promise that resolves after the specified time.
|
|
7
|
+
*/
|
|
8
|
+
export function sleep(ms) {
|
|
9
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Returns the current timestamp in seconds.
|
|
13
|
+
*
|
|
14
|
+
* @returns {number} The current timestamp in seconds.
|
|
15
|
+
*/
|
|
16
|
+
export function getCurrentTimestamp() {
|
|
17
|
+
return Math.round(Number(new Date()) / 1000);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Converts a timestamp in seconds into a formatted date string.
|
|
21
|
+
*
|
|
22
|
+
* @param {number} date - The timestamp in seconds to convert.
|
|
23
|
+
* @param {{locale?: string, pattern?: string}} options - Optional parameters for the conversion.
|
|
24
|
+
* @param {string} options.locale - The locale to use for the conversion. Defaults to 'en'.
|
|
25
|
+
* @param {string} options.pattern - The pattern to use for the conversion. Defaults to 'MM/DD/YYYY HH:mm'.
|
|
26
|
+
* @returns {string} The formatted date string.
|
|
27
|
+
*/
|
|
28
|
+
export function getDateFromTimestamp(date, { locale = 'en', pattern = 'MM/DD/YYYY HH:mm', } = {}) {
|
|
29
|
+
return moment(new Date(date * 1000))
|
|
30
|
+
.locale(locale)
|
|
31
|
+
.format(pattern);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Converts a date string or Date object from one format to another.
|
|
35
|
+
*
|
|
36
|
+
* @param {string | Date} date - The date string or Date object to convert.
|
|
37
|
+
* @param {{inPattern?: string, outPattern?: string, locale?: string}} options - Optional parameters for the conversion.
|
|
38
|
+
* @param {string} options.inPattern - The pattern of the input date string. Defaults to 'YYYY-MM-DD'.
|
|
39
|
+
* @param {string} options.outPattern - The pattern of the output date string. Defaults to 'DD MMM YYYY'.
|
|
40
|
+
* @param {string} options.locale - The locale to use for the conversion. Defaults to 'fr'.
|
|
41
|
+
* @returns {string} The converted date string.
|
|
42
|
+
*/
|
|
43
|
+
export function reformatDate(date, { inPattern = 'YYYY-MM-DD', outPattern = 'DD MMM YYYY', locale = 'fr', } = {}) {
|
|
44
|
+
return date ? moment(date, inPattern).locale(locale).format(outPattern) : '';
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Converts a date string or Date object into a formatted date string.
|
|
48
|
+
*
|
|
49
|
+
* @param {string | Date} date - The date string or Date object to convert.
|
|
50
|
+
* @param {{outPattern?: string, locale?: string}} options - Optional parameters for the conversion.
|
|
51
|
+
* @param {string} options.outPattern - The pattern of the output date string. Defaults to 'DD MMM YYYY'.
|
|
52
|
+
* @param {string} options.locale - The locale to use for the conversion. Defaults to 'fr'.
|
|
53
|
+
* @returns {string} The formatted date string.
|
|
54
|
+
*/
|
|
55
|
+
export function formatDate(date, { outPattern = 'DD MMM YYYY', locale = 'fr', } = {}) {
|
|
56
|
+
return date ? moment(date).locale(locale).format(outPattern) : '';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Calculates the difference between the given date and today in the given unit.
|
|
60
|
+
*
|
|
61
|
+
* @param {string | Date} date - The date to calculate the difference for.
|
|
62
|
+
* @param {{pattern?: string, unit?: moment.unitOfTime.Diff}} options - Optional parameters for the calculation.
|
|
63
|
+
* @param {string} options.pattern - The pattern of the input date string. Defaults to 'YYYY-MM-DD'.
|
|
64
|
+
* @param {moment.unitOfTime.Diff} options.unit - The unit of time to calculate the difference in. Defaults to 'days'.
|
|
65
|
+
* @returns {number} The difference between the given date and today in the given unit.
|
|
66
|
+
*/
|
|
67
|
+
export function differenceWithToday(date, { pattern = 'YYYY-MM-DD', unit = 'days', } = {}) {
|
|
68
|
+
return moment(date, pattern).diff(moment(), unit);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Calculates the difference between two dates.
|
|
72
|
+
*
|
|
73
|
+
* @param {string | Date} startDate - The start date.
|
|
74
|
+
* @param {string | Date} endDate - The end date.
|
|
75
|
+
* @param {{startDatePattern?: string, endDatePattern?: string, unit?: moment.unitOfTime.Diff}} options - Optional parameters for the calculation.
|
|
76
|
+
* @param {string} options.startDatePattern - The pattern of the start date string. Defaults to 'YYYY-MM-DD'.
|
|
77
|
+
* @param {string} options.endDatePattern - The pattern of the end date string. Defaults to 'YYYY-MM-DD'.
|
|
78
|
+
* @param {moment.unitOfTime.Diff} options.unit - The unit of time to calculate the difference in. Defaults to 'days'.
|
|
79
|
+
* @returns {number} The difference between the start and end dates in the given unit.
|
|
80
|
+
*/
|
|
81
|
+
export function differenceBetweenDates(startDate, endDate, { startDatePattern = 'YYYY-MM-DD', endDatePattern = 'YYYY-MM-DD', unit = 'days', } = {}) {
|
|
82
|
+
const start = moment(startDate, startDatePattern);
|
|
83
|
+
const end = moment(endDate, endDatePattern);
|
|
84
|
+
return start.diff(end, unit);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Calculates the difference between the given date and now.
|
|
88
|
+
*
|
|
89
|
+
* @param {string | Date} date - The date to calculate the difference from.
|
|
90
|
+
* @param {{locale?: string, pattern?: string}} options - Optional parameters for the calculation.
|
|
91
|
+
* @param {string} options.locale - The locale to use for the calculation. Defaults to 'en'.
|
|
92
|
+
* @param {string} options.pattern - The pattern of the date string. Defaults to 'YYYY-MM-DD HH:mm:ss'.
|
|
93
|
+
* @returns {string} The difference between the given date and now, relative to the given locale.
|
|
94
|
+
*/
|
|
95
|
+
export function differenceFromNow(date, { locale = 'en', pattern = 'YYYY-MM-DD HH:mm:ss', } = {}) {
|
|
96
|
+
return moment(date, pattern).locale(locale).fromNow();
|
|
97
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes the trailing slash from a given path.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} path - The path to remove the trailing slash from.
|
|
5
|
+
* @return {string} The path without the trailing slash.
|
|
6
|
+
*/
|
|
7
|
+
export declare function removeTrailingSlash(path: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Removes the leading slash from a given path.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} path - The path to remove the leading slash from.
|
|
12
|
+
* @return {string} The path without the leading slash.
|
|
13
|
+
*/
|
|
14
|
+
export declare function removeLeadingSlash(path: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the base URL of the current window location.
|
|
17
|
+
*
|
|
18
|
+
* @return {string} The base URL of the current window location.
|
|
19
|
+
*/
|
|
20
|
+
export declare function getBaseUrl(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the URL of the current page by appending the base URL with the pathname.
|
|
23
|
+
*
|
|
24
|
+
* @return {string} The URL of the current page.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getPageUrl(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Checks if the given path is an external URL, email address, or phone number.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} path - The path to check.
|
|
31
|
+
* @return {boolean} Returns true if the path is external, false otherwise.
|
|
32
|
+
*/
|
|
33
|
+
export declare function isExternal(path: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Checks if the given string is a valid URL.
|
|
36
|
+
*
|
|
37
|
+
* This function verifies whether a string is formatted as a valid URL. It adds
|
|
38
|
+
* a default 'http' protocol if missing, parses the URL, and checks for valid
|
|
39
|
+
* protocol, hostname, and optional port. It supports 'http', 'https', and 'ftp'
|
|
40
|
+
* protocols, disallows underscores in hostnames, and ensures the presence of a
|
|
41
|
+
* top-level domain (TLD) unless the hostname is 'localhost' or an IP address.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} str - The string to be checked.
|
|
44
|
+
* @return {boolean} Returns true if the string is a valid URL, false otherwise.
|
|
45
|
+
*/
|
|
46
|
+
export declare function isURL(str: string): boolean;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes the trailing slash from a given path.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} path - The path to remove the trailing slash from.
|
|
5
|
+
* @return {string} The path without the trailing slash.
|
|
6
|
+
*/
|
|
7
|
+
export function removeTrailingSlash(path) {
|
|
8
|
+
if (path.length > 1 && path.charAt(path.length - 1) === '/') {
|
|
9
|
+
return path.substring(0, path.length - 1);
|
|
10
|
+
}
|
|
11
|
+
return path;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Removes the leading slash from a given path.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} path - The path to remove the leading slash from.
|
|
17
|
+
* @return {string} The path without the leading slash.
|
|
18
|
+
*/
|
|
19
|
+
export function removeLeadingSlash(path) {
|
|
20
|
+
if (path.length > 1 && path.charAt(0) === '/') {
|
|
21
|
+
return path.substring(1);
|
|
22
|
+
}
|
|
23
|
+
return path;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the base URL of the current window location.
|
|
27
|
+
*
|
|
28
|
+
* @return {string} The base URL of the current window location.
|
|
29
|
+
*/
|
|
30
|
+
export function getBaseUrl() {
|
|
31
|
+
const { protocol, hostname, port } = window.location;
|
|
32
|
+
return protocol + '//' + hostname + (port ? `:${port}` : '');
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns the URL of the current page by appending the base URL with the pathname.
|
|
36
|
+
*
|
|
37
|
+
* @return {string} The URL of the current page.
|
|
38
|
+
*/
|
|
39
|
+
export function getPageUrl() {
|
|
40
|
+
return getBaseUrl() + window.location.pathname;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Checks if the given path is an external URL, email address, or phone number.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} path - The path to check.
|
|
46
|
+
* @return {boolean} Returns true if the path is external, false otherwise.
|
|
47
|
+
*/
|
|
48
|
+
export function isExternal(path) {
|
|
49
|
+
return /^(https?:|mailto:|tel:)/.test(path);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Checks if the given string is a valid URL.
|
|
53
|
+
*
|
|
54
|
+
* This function verifies whether a string is formatted as a valid URL. It adds
|
|
55
|
+
* a default 'http' protocol if missing, parses the URL, and checks for valid
|
|
56
|
+
* protocol, hostname, and optional port. It supports 'http', 'https', and 'ftp'
|
|
57
|
+
* protocols, disallows underscores in hostnames, and ensures the presence of a
|
|
58
|
+
* top-level domain (TLD) unless the hostname is 'localhost' or an IP address.
|
|
59
|
+
*
|
|
60
|
+
* @param {string} str - The string to be checked.
|
|
61
|
+
* @return {boolean} Returns true if the string is a valid URL, false otherwise.
|
|
62
|
+
*/
|
|
63
|
+
export function isURL(str) {
|
|
64
|
+
if (!str || typeof str !== 'string') {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
let url = str.trim();
|
|
68
|
+
// Add default protocol if missing
|
|
69
|
+
if (!url.includes('://')) {
|
|
70
|
+
url = 'http://' + url;
|
|
71
|
+
}
|
|
72
|
+
let urlParts;
|
|
73
|
+
try {
|
|
74
|
+
urlParts = new URL(url);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
// Check protocol (allow http, https, ftp)
|
|
80
|
+
const protocol = urlParts.protocol.replace(':', '');
|
|
81
|
+
if (!['http', 'https', 'ftp'].includes(protocol)) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
// Require hostname
|
|
85
|
+
if (!urlParts.hostname) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
const hostname = urlParts.hostname.toLowerCase();
|
|
89
|
+
// Don't allow underscores in hostname (standard domains)
|
|
90
|
+
if (hostname.includes('_')) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
// Check for valid port (if present)
|
|
94
|
+
if (urlParts.port) {
|
|
95
|
+
const port = parseInt(urlParts.port, 10);
|
|
96
|
+
if (isNaN(port) || port < 1 || port > 65535) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// Check for TLD requirement (except localhost and IP addresses)
|
|
101
|
+
const isLocalhost = hostname === 'localhost';
|
|
102
|
+
const isIPv4 = /^(?:(?:\d{1,3}\.){3}\d{1,3})$/i.test(hostname);
|
|
103
|
+
const isIPv6 = /^\[([0-9a-f:]+)\]$/i.test(hostname) || /^([0-9a-f:]+)$/i.test(hostname);
|
|
104
|
+
if (!isLocalhost && !isIPv4 && !isIPv6) {
|
|
105
|
+
const parts = hostname.split('.');
|
|
106
|
+
if (parts.length < 2 || parts.some((part) => !part)) {
|
|
107
|
+
return false; // No empty parts (e.g., "example..com")
|
|
108
|
+
}
|
|
109
|
+
// Allow single-letter TLDs (e.g., "example.io", "example.a")
|
|
110
|
+
if (parts[parts.length - 1].length < 1) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Hostname validation (allows internationalized domains if needed)
|
|
115
|
+
const hostnameRegex = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i;
|
|
116
|
+
if (!hostnameRegex.test(hostname) && !isLocalhost && !isIPv4 && !isIPv6) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
@@ -317,3 +317,17 @@ export declare function isSVG(input: string): boolean;
|
|
|
317
317
|
* @return {boolean} Returns true if the string is a valid URL, false otherwise.
|
|
318
318
|
*/
|
|
319
319
|
export declare function isURL(str: string): boolean;
|
|
320
|
+
/**
|
|
321
|
+
* Determines if a given string is a valid JSON string representing an object.
|
|
322
|
+
*
|
|
323
|
+
* @param {string} str - The string to be checked.
|
|
324
|
+
* @return {boolean} Returns true if the string is a valid JSON string of an object, false otherwise.
|
|
325
|
+
*/
|
|
326
|
+
export declare function isStringifiedObject(str: string): boolean;
|
|
327
|
+
/**
|
|
328
|
+
* Sanitizes an ID by removing any characters that are not a letter, number, slash, or dash and replacing any slashes with dashes.
|
|
329
|
+
*
|
|
330
|
+
* @param {string} id - The ID to be sanitized.
|
|
331
|
+
* @return {string} The sanitized ID.
|
|
332
|
+
*/
|
|
333
|
+
export declare function sanitizeId(id: string): string;
|
|
@@ -351,7 +351,8 @@ export function parseINIString(iniString) {
|
|
|
351
351
|
* @return {string} The base URL of the current window location.
|
|
352
352
|
*/
|
|
353
353
|
export function getBaseUrl() {
|
|
354
|
-
|
|
354
|
+
const { protocol, hostname, port } = window.location;
|
|
355
|
+
return protocol + '//' + hostname + (port ? `:${port}` : '');
|
|
355
356
|
}
|
|
356
357
|
/**
|
|
357
358
|
* Returns the URL of the current page by appending the base URL with the pathname.
|
|
@@ -652,3 +653,27 @@ export function isURL(str) {
|
|
|
652
653
|
}
|
|
653
654
|
return true;
|
|
654
655
|
}
|
|
656
|
+
/**
|
|
657
|
+
* Determines if a given string is a valid JSON string representing an object.
|
|
658
|
+
*
|
|
659
|
+
* @param {string} str - The string to be checked.
|
|
660
|
+
* @return {boolean} Returns true if the string is a valid JSON string of an object, false otherwise.
|
|
661
|
+
*/
|
|
662
|
+
export function isStringifiedObject(str) {
|
|
663
|
+
try {
|
|
664
|
+
const parsed = JSON.parse(str);
|
|
665
|
+
return (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed));
|
|
666
|
+
}
|
|
667
|
+
catch (e) {
|
|
668
|
+
return false;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
/**
|
|
672
|
+
* Sanitizes an ID by removing any characters that are not a letter, number, slash, or dash and replacing any slashes with dashes.
|
|
673
|
+
*
|
|
674
|
+
* @param {string} id - The ID to be sanitized.
|
|
675
|
+
* @return {string} The sanitized ID.
|
|
676
|
+
*/
|
|
677
|
+
export function sanitizeId(id) {
|
|
678
|
+
return id.replace(/[^a-z0-9\/-]/g, '').replace(/\//g, '-');
|
|
679
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './functions';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './constants';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './functions';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './constants';
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -4,10 +4,11 @@ export declare class PageSectionModel {
|
|
|
4
4
|
dataSourceLinkId?: string | null;
|
|
5
5
|
dataSourcePageId?: number | null;
|
|
6
6
|
dataSourcePageTitle?: string | null;
|
|
7
|
+
linkTitle?: string | null;
|
|
7
8
|
linkId?: string | null;
|
|
8
9
|
data?: any;
|
|
9
10
|
settings?: any;
|
|
10
11
|
createdAt?: string;
|
|
11
12
|
updatedAt?: string;
|
|
12
|
-
constructor(pageId?: number, sectionId?: number, dataSourceLinkId?: string | null, dataSourcePageId?: number | null, dataSourcePageTitle?: string | null, linkId?: string | null, data?: any, settings?: any, createdAt?: string, updatedAt?: string);
|
|
13
|
+
constructor(pageId?: number, sectionId?: number, dataSourceLinkId?: string | null, dataSourcePageId?: number | null, dataSourcePageTitle?: string | null, linkTitle?: string | null, linkId?: string | null, data?: any, settings?: any, createdAt?: string, updatedAt?: string);
|
|
13
14
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export class PageSectionModel {
|
|
2
|
-
constructor(pageId, sectionId, dataSourceLinkId, dataSourcePageId, dataSourcePageTitle, linkId, data, settings, createdAt, updatedAt) {
|
|
2
|
+
constructor(pageId, sectionId, dataSourceLinkId, dataSourcePageId, dataSourcePageTitle, linkTitle, linkId, data, settings, createdAt, updatedAt) {
|
|
3
3
|
this.pageId = pageId;
|
|
4
4
|
this.sectionId = sectionId;
|
|
5
5
|
this.dataSourceLinkId = dataSourceLinkId;
|
|
6
6
|
this.dataSourcePageId = dataSourcePageId;
|
|
7
7
|
this.dataSourcePageTitle = dataSourcePageTitle;
|
|
8
|
+
this.linkTitle = linkTitle;
|
|
8
9
|
this.linkId = linkId;
|
|
9
10
|
this.data = data;
|
|
10
11
|
this.settings = settings;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type ResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream' | 'formdata';
|
|
2
|
+
export type Method = 'get' | 'post' | 'put' | 'delete';
|
|
3
|
+
export interface Payload {
|
|
4
|
+
method?: Method;
|
|
5
|
+
routeBase?: string;
|
|
6
|
+
responseType?: ResponseType;
|
|
7
|
+
params?: Record<string, any>;
|
|
8
|
+
data?: Record<string, any>;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
useApiBaseUrl?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface Response<T> {
|
|
16
|
+
success: boolean;
|
|
17
|
+
failure: boolean;
|
|
18
|
+
result: {
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
data?: T;
|
|
21
|
+
};
|
|
22
|
+
error?: any;
|
|
23
|
+
}
|
|
24
|
+
export interface Api {
|
|
25
|
+
request: <T = any>(payload: Payload) => Promise<Response<T>>;
|
|
26
|
+
postItemRequest: <T = any>(payload: Payload) => Promise<Response<T>>;
|
|
27
|
+
putItemRequest: <T = any>(payload: Payload) => Promise<Response<T>>;
|
|
28
|
+
deleteItemRequest: <T = any>(payload: Payload) => Promise<Response<T>>;
|
|
29
|
+
getItemRequest: <T = any>(payload: Payload) => Promise<Response<T>>;
|
|
30
|
+
getAllItemsRequest: <T = any>(payload: Payload) => Promise<Response<T>>;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface EnvData {
|
|
2
|
+
locale?: string;
|
|
3
|
+
fallbackLocale?: string;
|
|
4
|
+
primaryColor?: string;
|
|
5
|
+
secondaryColor?: string;
|
|
6
|
+
accentColor?: string;
|
|
7
|
+
apiBaseUrl?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface AppConfig {
|
|
10
|
+
apiBaseUrl: string;
|
|
11
|
+
apiUrl: string;
|
|
12
|
+
apiRequestHeaders: {
|
|
13
|
+
'X-API-Key': string;
|
|
14
|
+
Authorization?: string;
|
|
15
|
+
};
|
|
16
|
+
forceDevMode: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface SharedData {
|
|
19
|
+
locale?: Readonly<string>;
|
|
20
|
+
env?: Readonly<EnvData>;
|
|
21
|
+
appConfig?: Readonly<AppConfig>;
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { UserModel } from '../../models';
|
|
2
|
+
export interface UserInterfaceState {
|
|
3
|
+
isLightTheme: boolean;
|
|
4
|
+
isDashboardGuideCollapsed: boolean;
|
|
5
|
+
contentLayoutSize: {
|
|
6
|
+
height: number;
|
|
7
|
+
width: number;
|
|
8
|
+
};
|
|
9
|
+
menuMode: 'overlay' | 'static';
|
|
10
|
+
staticMenuDesktopInactive: boolean;
|
|
11
|
+
staticMenuMobileActive: boolean;
|
|
12
|
+
overlayMenuActive: boolean;
|
|
13
|
+
menuHoverActive: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface BridgeAuthState {
|
|
16
|
+
userData: UserModel | null;
|
|
17
|
+
}
|
|
18
|
+
export interface BridgeServerState {
|
|
19
|
+
isServerAvailable: boolean;
|
|
20
|
+
isDatabaseAvailable: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface BridgeStore<T> {
|
|
23
|
+
getState: () => T;
|
|
24
|
+
setState: (state: Partial<T> | ((state: T) => Partial<T>)) => void;
|
|
25
|
+
subscribe: (listener: (state: T, prevState: T) => void) => () => void;
|
|
26
|
+
}
|
|
27
|
+
export interface BridgeStores {
|
|
28
|
+
auth: BridgeStore<BridgeAuthState>;
|
|
29
|
+
server: BridgeStore<BridgeServerState>;
|
|
30
|
+
ui: BridgeStore<UserInterfaceState>;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface PluginPage {
|
|
2
|
+
name: string;
|
|
3
|
+
path: string;
|
|
4
|
+
title?: string | {
|
|
5
|
+
[key: string]: string;
|
|
6
|
+
};
|
|
7
|
+
module: string;
|
|
8
|
+
icon?: string;
|
|
9
|
+
hidden?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface PluginData {
|
|
12
|
+
id: string;
|
|
13
|
+
entry: string;
|
|
14
|
+
pages?: Array<PluginPage>;
|
|
15
|
+
navIcon?: string;
|
|
16
|
+
indexPageName?: string;
|
|
17
|
+
dashboard?: {
|
|
18
|
+
module: string;
|
|
19
|
+
};
|
|
20
|
+
settings?: {
|
|
21
|
+
module: string;
|
|
22
|
+
};
|
|
23
|
+
mode?: 'development' | 'production';
|
|
24
|
+
development?: {
|
|
25
|
+
host?: string;
|
|
26
|
+
previewPort?: number;
|
|
27
|
+
serverPort?: number;
|
|
28
|
+
ssl?: boolean;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@creopse/utils",
|
|
3
3
|
"description": "Creopse Utils Toolkit",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.16",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Noé Gnanih <noegnanih@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -12,17 +12,30 @@
|
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"import": "./dist/index.js"
|
|
14
14
|
},
|
|
15
|
-
"
|
|
15
|
+
"./enums": {
|
|
16
|
+
"types": "./dist/enums/index.d.ts",
|
|
17
|
+
"import": "./dist/enums/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./models": {
|
|
20
|
+
"types": "./dist/models/index.d.ts",
|
|
21
|
+
"import": "./dist/models/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./types": {
|
|
24
|
+
"types": "./dist/types/index.d.ts",
|
|
25
|
+
"import": "./dist/types/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./helpers": {
|
|
28
|
+
"types": "./dist/helpers/index.d.ts",
|
|
29
|
+
"import": "./dist/helpers/index.js"
|
|
30
|
+
}
|
|
16
31
|
},
|
|
17
32
|
"types": "dist/index.d.ts",
|
|
18
33
|
"files": [
|
|
19
34
|
"dist",
|
|
20
35
|
"README.md"
|
|
21
36
|
],
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "tsc -b && tsc-alias"
|
|
24
|
-
},
|
|
25
37
|
"devDependencies": {
|
|
38
|
+
"@types/lodash": "^4.17.24",
|
|
26
39
|
"tsc-alias": "^1.8.16",
|
|
27
40
|
"typescript": "~5.8.3"
|
|
28
41
|
},
|
|
@@ -40,6 +53,11 @@
|
|
|
40
53
|
},
|
|
41
54
|
"dependencies": {
|
|
42
55
|
"@inertiajs/core": "^2.0.17",
|
|
56
|
+
"browser-image-compression": "^2.0.2",
|
|
57
|
+
"lodash": "^4.18.1",
|
|
43
58
|
"moment": "^2.30.1"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "tsc -b && tsc-alias"
|
|
44
62
|
}
|
|
45
63
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["../src/index.ts","../src/enums/access-guard.ts","../src/enums/account-status.ts","../src/enums/ad-content-type.ts","../src/enums/auth-type.ts","../src/enums/bool.ts","../src/enums/content-type.ts","../src/enums/editor-message-type.ts","../src/enums/index.ts","../src/enums/media-file-type.ts","../src/enums/menu-item-target-type.ts","../src/enums/news-article-status.ts","../src/enums/notification-source.ts","../src/enums/notification-type.ts","../src/enums/permalink-content-type.ts","../src/enums/profile-type.ts","../src/enums/response-error-code.ts","../src/enums/response-status-code.ts","../src/enums/user-role.ts","../src/enums/video-display-type.ts","../src/enums/video-item-source.ts","../src/enums/content-model/access-scope.ts","../src/enums/content-model/intent.ts","../src/enums/content-model/item-creator-type.ts","../src/models/ad-identifier.ts","../src/models/ad.ts","../src/models/admin-profile.ts","../src/models/app-information.ts","../src/models/app-setting.ts","../src/models/content-model-item.ts","../src/models/content-model.ts","../src/models/data-change.ts","../src/models/index.ts","../src/models/media-file.ts","../src/models/menu-item-group.ts","../src/models/menu-item.ts","../src/models/menu-location.ts","../src/models/menu.ts","../src/models/news-article.ts","../src/models/news-category.ts","../src/models/news-comment.ts","../src/models/news-tag.ts","../src/models/newsletter-campaign.ts","../src/models/newsletter-email.ts","../src/models/newsletter-phone.ts","../src/models/notification.ts","../src/models/page-section.ts","../src/models/page.ts","../src/models/permalink.ts","../src/models/permission.ts","../src/models/role.ts","../src/models/section.ts","../src/models/subscriber-profile.ts","../src/models/user-device.ts","../src/models/user-place.ts","../src/models/user-session.ts","../src/models/user.ts","../src/models/video-category.ts","../src/models/video-item.ts","../src/models/video-setting.ts","../src/types/app-information.ts","../src/types/common.ts","../src/types/index.ts","../src/types/pagination.ts","../src/types/props.ts","../src/utils/chronos.ts","../src/utils/functions.ts","../src/utils/index.ts"],"version":"5.8.3"}
|