@finema/core 1.1.4 → 1.2.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/README.md +87 -11
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +15 -0
- package/dist/module.d.ts +15 -0
- package/dist/module.json +8 -0
- package/dist/module.mjs +28 -0
- package/dist/runtime/composables/useLibs.d.ts +24 -0
- package/dist/runtime/composables/useLibs.mjs +4 -0
- package/dist/runtime/composables/useUtils.d.ts +10 -0
- package/dist/runtime/composables/useUtils.mjs +12 -0
- package/dist/{lib → runtime/lib}/Requester.d.ts +1 -1
- package/dist/runtime/lib/Requester.mjs +37 -0
- package/dist/{lib → runtime/lib}/api/apiListHelper.d.ts +2 -2
- package/dist/runtime/lib/api/apiListHelper.mjs +44 -0
- package/dist/{lib → runtime/lib}/api/apiObjectHelper.d.ts +2 -2
- package/dist/runtime/lib/api/apiObjectHelper.mjs +46 -0
- package/dist/{lib → runtime/lib}/api/apiPageHelper.d.ts +2 -2
- package/dist/runtime/lib/api/apiPageHelper.mjs +265 -0
- package/dist/runtime/lib/api/config.mjs +4 -0
- package/dist/{lib → runtime/lib}/api/loaderList.d.ts +1 -1
- package/dist/runtime/lib/api/loaderList.mjs +49 -0
- package/dist/{lib → runtime/lib}/api/loaderObject.d.ts +1 -1
- package/dist/runtime/lib/api/loaderObject.mjs +50 -0
- package/dist/{lib → runtime/lib}/api/loaderPage.d.ts +1 -1
- package/dist/runtime/lib/api/loaderPage.mjs +219 -0
- package/dist/{lib → runtime/lib}/api/loaderTypes.d.ts +3 -3
- package/dist/runtime/lib/api/loaderTypes.mjs +0 -0
- package/dist/{lib → runtime/lib}/index.d.ts +0 -2
- package/dist/runtime/lib/index.mjs +8 -0
- package/dist/runtime/plugin.d.ts +2 -0
- package/dist/runtime/plugin.mjs +4 -0
- package/dist/runtime/types/common.d.ts +13 -0
- package/dist/runtime/types/lib.d.ts +102 -0
- package/dist/runtime/utils/FileHelper.mjs +29 -0
- package/dist/{utils → runtime/utils}/ObjectHelper.d.ts +3 -3
- package/dist/runtime/utils/ObjectHelper.mjs +108 -0
- package/dist/{utils → runtime/utils}/ParamHelper.d.ts +2 -1
- package/dist/runtime/utils/ParamHelper.mjs +39 -0
- package/dist/runtime/utils/StringHelper.mjs +41 -0
- package/dist/runtime/utils/TimeHelper.mjs +83 -0
- package/dist/runtime/utils/lodash.mjs +38 -0
- package/dist/types.d.mts +15 -0
- package/dist/types.d.ts +15 -0
- package/package.json +64 -31
- package/dist/composables/index.d.ts +0 -1
- package/dist/composables/useCookie.d.ts +0 -5
- package/dist/composables/useWatch.d.ts +0 -3
- package/dist/core.js +0 -10031
- package/dist/core.umd.cjs +0 -49
- package/dist/index.d.ts +0 -3
- package/dist/lib/api/types.d.ts +0 -89
- package/dist/lib/api/utils.d.ts +0 -9
- package/dist/utils/ArrayHelper.d.ts +0 -7
- package/dist/utils/ArrayHelper.spec.d.ts +0 -1
- package/dist/utils/CookieHelper.d.ts +0 -9
- package/dist/utils/ObjectHelper.spec.d.ts +0 -1
- package/dist/utils/ParamHelper.spec.d.ts +0 -1
- package/dist/utils/StringHelper.spec.d.ts +0 -1
- package/dist/utils/TimeHelper.spec.d.ts +0 -1
- package/dist/utils/faker.d.ts +0 -2
- package/dist/utils/index.d.ts +0 -9
- package/dist/utils/types.d.ts +0 -8
- /package/dist/{lib → runtime/lib}/api/config.d.ts +0 -0
- /package/dist/{utils → runtime/utils}/FileHelper.d.ts +0 -0
- /package/dist/{utils → runtime/utils}/StringHelper.d.ts +0 -0
- /package/dist/{utils → runtime/utils}/TimeHelper.d.ts +0 -0
- /package/dist/{utils → runtime/utils}/lodash.d.ts +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import urlJoin from "url-join";
|
|
2
|
+
export class StringHelper {
|
|
3
|
+
static genString = (length = 5) => {
|
|
4
|
+
let result = "";
|
|
5
|
+
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
6
|
+
const charactersLength = characters.length;
|
|
7
|
+
for (let i = 0; i < length; i++) {
|
|
8
|
+
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
9
|
+
}
|
|
10
|
+
return result;
|
|
11
|
+
};
|
|
12
|
+
static withComma = (value = 0) => {
|
|
13
|
+
return (+(value || 0)).toLocaleString();
|
|
14
|
+
};
|
|
15
|
+
static split = (str, separator) => {
|
|
16
|
+
return `${str || ""}`.split(separator).filter((item) => item).map((item) => item.trim());
|
|
17
|
+
};
|
|
18
|
+
static joinURL = (value, value2) => {
|
|
19
|
+
return urlJoin(value, value2);
|
|
20
|
+
};
|
|
21
|
+
static truncate = (str, num = 300) => {
|
|
22
|
+
const newStr = str || "";
|
|
23
|
+
if (newStr.length > num) {
|
|
24
|
+
return newStr.slice(0, num) + "...";
|
|
25
|
+
}
|
|
26
|
+
return newStr;
|
|
27
|
+
};
|
|
28
|
+
static getError = (errorData, defaultErrorMessage = "\u0E21\u0E35\u0E1A\u0E32\u0E07\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E1C\u0E34\u0E14\u0E1E\u0E25\u0E32\u0E14") => {
|
|
29
|
+
let msg = errorData?.message;
|
|
30
|
+
if (!errorData.code || !msg) {
|
|
31
|
+
return defaultErrorMessage;
|
|
32
|
+
}
|
|
33
|
+
if (errorData.code !== "INVALID_PARAMS" && !errorData.fields) {
|
|
34
|
+
return msg;
|
|
35
|
+
}
|
|
36
|
+
for (const [_, value] of Object.entries(errorData.fields)) {
|
|
37
|
+
msg = value.message;
|
|
38
|
+
}
|
|
39
|
+
return msg;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
import relativeTime from "dayjs/plugin/relativeTime";
|
|
3
|
+
import utc from "dayjs/plugin/utc";
|
|
4
|
+
import duration from "dayjs/plugin/duration";
|
|
5
|
+
dayjs.extend(relativeTime);
|
|
6
|
+
dayjs.extend(utc);
|
|
7
|
+
dayjs.extend(duration);
|
|
8
|
+
const isTimeError = (time) => time === "Invalid Date";
|
|
9
|
+
const timeWrapper = (time, defaultTime) => isTimeError(time) ? defaultTime : time;
|
|
10
|
+
const dateFormat = "YYYY-MM-DD";
|
|
11
|
+
const dateTimeFormat = "YYYY-MM-DD HH:mm:ss";
|
|
12
|
+
const timeFormat = "HH:mm";
|
|
13
|
+
export class TimeHelper {
|
|
14
|
+
static toUTC = (time) => {
|
|
15
|
+
if (!time) {
|
|
16
|
+
return time;
|
|
17
|
+
}
|
|
18
|
+
try {
|
|
19
|
+
const newTime = dayjs(time).subtract(7, "hour").format(dateTimeFormat);
|
|
20
|
+
return timeWrapper(newTime, time);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return time.toString();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
static toLocal = (time) => {
|
|
26
|
+
if (!time) {
|
|
27
|
+
return time;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
const newTime = dayjs(time).add(7, "hour").format(dateTimeFormat);
|
|
31
|
+
return timeWrapper(newTime, time);
|
|
32
|
+
} catch (e) {
|
|
33
|
+
return time;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
static getCurrentDate = () => {
|
|
37
|
+
const newTime = dayjs().format(dateFormat);
|
|
38
|
+
return timeWrapper(newTime, "");
|
|
39
|
+
};
|
|
40
|
+
static getDateFormTime = (time) => {
|
|
41
|
+
if (!time) {
|
|
42
|
+
return time;
|
|
43
|
+
}
|
|
44
|
+
const newTime = dayjs(time).format(dateFormat);
|
|
45
|
+
return timeWrapper(newTime, time);
|
|
46
|
+
};
|
|
47
|
+
static getDateFormTimeWithLocal = (time) => {
|
|
48
|
+
if (!time) {
|
|
49
|
+
return time;
|
|
50
|
+
}
|
|
51
|
+
const newTime = dayjs(TimeHelper.toLocal(time)).format(dateFormat);
|
|
52
|
+
return timeWrapper(newTime, time);
|
|
53
|
+
};
|
|
54
|
+
static getISODateTimeFormTime = (time) => {
|
|
55
|
+
if (!time) {
|
|
56
|
+
return time;
|
|
57
|
+
}
|
|
58
|
+
const testTime = dayjs(time).format(dateTimeFormat);
|
|
59
|
+
if (isTimeError(testTime)) {
|
|
60
|
+
return time;
|
|
61
|
+
}
|
|
62
|
+
const newTime = dayjs(time).toISOString();
|
|
63
|
+
return isTimeError(newTime) || !newTime ? time : newTime;
|
|
64
|
+
};
|
|
65
|
+
static getDateTimeFormTime = (time) => {
|
|
66
|
+
if (!time) {
|
|
67
|
+
return time;
|
|
68
|
+
}
|
|
69
|
+
const newTime = dayjs(time).format(dateTimeFormat);
|
|
70
|
+
return timeWrapper(newTime, time);
|
|
71
|
+
};
|
|
72
|
+
static getTimeFormTime = (time) => {
|
|
73
|
+
if (!time) {
|
|
74
|
+
return time;
|
|
75
|
+
}
|
|
76
|
+
const newTime = dayjs(time).format(timeFormat);
|
|
77
|
+
return timeWrapper(newTime, time);
|
|
78
|
+
};
|
|
79
|
+
static getCurrentDateTime = () => {
|
|
80
|
+
const newTime = dayjs().format(dateTimeFormat);
|
|
81
|
+
return timeWrapper(newTime, "");
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as lodash from "lodash";
|
|
2
|
+
export const _get = lodash.get;
|
|
3
|
+
export const _range = lodash.range;
|
|
4
|
+
export const _concat = lodash.concat;
|
|
5
|
+
export const _toNumber = lodash.toNumber;
|
|
6
|
+
export const _isUndefined = lodash.isUndefined;
|
|
7
|
+
export const _dropRight = lodash.dropRight;
|
|
8
|
+
export const _intersection = lodash.intersection;
|
|
9
|
+
export const _set = lodash.set;
|
|
10
|
+
export const _map = lodash.map;
|
|
11
|
+
export const _flatDeep = lodash.flattenDeep;
|
|
12
|
+
export const _uniq = lodash.uniq;
|
|
13
|
+
export const _sortBy = lodash.sortBy;
|
|
14
|
+
export const _uniqBy = lodash.uniqBy;
|
|
15
|
+
export const _random = lodash.random;
|
|
16
|
+
export const _cloneDeep = lodash.cloneDeep;
|
|
17
|
+
export const _isEmpty = lodash.isEmpty;
|
|
18
|
+
export const _isObject = lodash.isObject;
|
|
19
|
+
export const _isArray = lodash.isArray;
|
|
20
|
+
export const _findIndex = lodash.findIndex;
|
|
21
|
+
export const _isEqual = lodash.isEqual;
|
|
22
|
+
export const _difference = lodash.difference;
|
|
23
|
+
export const _shuffle = lodash.shuffle;
|
|
24
|
+
export const _size = lodash.size;
|
|
25
|
+
export const _toPairs = lodash.toPairs;
|
|
26
|
+
export const _orderBy = lodash.orderBy;
|
|
27
|
+
export const _fromPairs = lodash.fromPairs;
|
|
28
|
+
export const _xor = lodash.xor;
|
|
29
|
+
export const _clone = (object) => {
|
|
30
|
+
try {
|
|
31
|
+
return JSON.parse(JSON.stringify(object || {}));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export const _debounce = (func, wait = 150) => {
|
|
37
|
+
return lodash.debounce(func, wait);
|
|
38
|
+
};
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
import { ModuleOptions } from './module'
|
|
3
|
+
|
|
4
|
+
declare module '@nuxt/schema' {
|
|
5
|
+
interface NuxtConfig { ['core']?: Partial<ModuleOptions> }
|
|
6
|
+
interface NuxtOptions { ['core']?: ModuleOptions }
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare module 'nuxt/schema' {
|
|
10
|
+
interface NuxtConfig { ['core']?: Partial<ModuleOptions> }
|
|
11
|
+
interface NuxtOptions { ['core']?: ModuleOptions }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export { ModuleOptions, default } from './module'
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
import { ModuleOptions } from './module'
|
|
3
|
+
|
|
4
|
+
declare module '@nuxt/schema' {
|
|
5
|
+
interface NuxtConfig { ['core']?: Partial<ModuleOptions> }
|
|
6
|
+
interface NuxtOptions { ['core']?: ModuleOptions }
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare module 'nuxt/schema' {
|
|
10
|
+
interface NuxtConfig { ['core']?: Partial<ModuleOptions> }
|
|
11
|
+
interface NuxtOptions { ['core']?: ModuleOptions }
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export { ModuleOptions, default } from './module'
|
package/package.json
CHANGED
|
@@ -1,45 +1,78 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finema/core",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
|
+
"repository": "https://gitlab.finema.co/finema/ui-kit",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Finema Development Team",
|
|
4
7
|
"type": "module",
|
|
5
|
-
"files": [
|
|
6
|
-
"dist"
|
|
7
|
-
],
|
|
8
|
-
"main": "./dist/core.umd.cjs",
|
|
9
|
-
"module": "./dist/core.js",
|
|
10
8
|
"exports": {
|
|
11
9
|
".": {
|
|
12
|
-
"
|
|
13
|
-
"
|
|
10
|
+
"types": "./dist/types.d.ts",
|
|
11
|
+
"import": "./dist/module.mjs",
|
|
12
|
+
"require": "./dist/module.cjs"
|
|
14
13
|
}
|
|
15
14
|
},
|
|
16
|
-
"
|
|
15
|
+
"main": "./dist/module.cjs",
|
|
16
|
+
"types": "./dist/types.d.ts",
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18.0.0"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"prepack": "nuxt-module-build build",
|
|
25
|
+
"dev": "nuxi dev playground",
|
|
26
|
+
"dev:build": "nuxi build playground",
|
|
27
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
28
|
+
"lint": "eslint .",
|
|
29
|
+
"lint:fix": "eslint . --fix",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:watch": "vitest watch",
|
|
32
|
+
"release": "release-it"
|
|
33
|
+
},
|
|
17
34
|
"dependencies": {
|
|
18
|
-
"@
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"dayjs": "^1.11.7",
|
|
35
|
+
"@nuxt/kit": "^3.7.4",
|
|
36
|
+
"@pinia/nuxt": "^0.4.11",
|
|
37
|
+
"axios": "^1.5.1",
|
|
38
|
+
"dayjs": "^1.11.10",
|
|
23
39
|
"lodash": "^4.17.21",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
40
|
+
"pinia": "^2.1.6",
|
|
41
|
+
"url-join": "^5.0.0"
|
|
26
42
|
},
|
|
27
43
|
"devDependencies": {
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
"@nuxt/devtools": "latest",
|
|
45
|
+
"@nuxt/eslint-config": "^0.2.0",
|
|
46
|
+
"@nuxt/module-builder": "^0.5.2",
|
|
47
|
+
"@nuxt/schema": "^3.7.4",
|
|
48
|
+
"@nuxt/test-utils": "^3.7.4",
|
|
49
|
+
"@nuxtjs/eslint-config-typescript": "^12.1.0",
|
|
50
|
+
"@release-it/conventional-changelog": "^7.0.2",
|
|
51
|
+
"@types/lodash": "^4.14.199",
|
|
52
|
+
"@types/node": "^18.18.1",
|
|
53
|
+
"changelogen": "^0.5.5",
|
|
54
|
+
"eslint": "^8.50.0",
|
|
55
|
+
"eslint-config-prettier": "^9.0.0",
|
|
56
|
+
"eslint-config-standard-with-typescript": "^39.1.0",
|
|
57
|
+
"eslint-plugin-import": "^2.28.1",
|
|
58
|
+
"eslint-plugin-n": "^16.1.0",
|
|
59
|
+
"eslint-plugin-nuxt": "^4.0.0",
|
|
60
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
61
|
+
"eslint-plugin-unused-imports": "^3.0.0",
|
|
62
|
+
"eslint-plugin-vue": "^9.17.0",
|
|
63
|
+
"husky": "^8.0.3",
|
|
64
|
+
"lint-staged": "^14.0.1",
|
|
36
65
|
"nuxt": "^3.7.4",
|
|
37
|
-
"
|
|
66
|
+
"prettier": "^3.0.3",
|
|
67
|
+
"release-it": "^16.2.1",
|
|
68
|
+
"stylelint": "^15.10.3",
|
|
69
|
+
"stylelint-config-prettier-scss": "^1.0.0",
|
|
70
|
+
"stylelint-config-standard-scss": "^11.0.0",
|
|
71
|
+
"vitest": "^0.33.0"
|
|
38
72
|
},
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"preview": "vite preview"
|
|
73
|
+
"lint-staged": {
|
|
74
|
+
"*.{ts,vue,tsx,js}": "eslint --fix",
|
|
75
|
+
"*.{css,scss}": "stylelint --fix",
|
|
76
|
+
"*.{html,json}": "prettier --write"
|
|
44
77
|
}
|
|
45
|
-
}
|
|
78
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useWatch';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { CookieOptions, CookieRef } from 'nuxt/app';
|
|
2
|
-
export declare const useStatefulCookie: <T = string>(name: string, opts?: CookieOptions<T> | undefined) => CookieRef<T | null>;
|
|
3
|
-
export declare const useCookie6Hours: <T = string>(name: string, opts?: CookieOptions<T> | undefined) => CookieRef<T | null>;
|
|
4
|
-
export declare const useCookie7Days: <T = string | null>(name: string, opts?: CookieOptions<T> | undefined) => CookieRef<T | null>;
|
|
5
|
-
export declare const useCookie365Days: <T = string | null>(name: string, opts?: CookieOptions<T> | undefined) => CookieRef<T | null>;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare const useWatchTrue: (source: () => boolean, cb: (v: boolean, o: boolean) => any) => void;
|
|
2
|
-
export declare const useWatchFalse: (source: () => boolean, cb: (v: boolean, o: boolean) => any) => void;
|
|
3
|
-
export declare const useWatchChange: (source: () => any, cb: (v: any, o: any) => any) => void;
|