@lark-apaas/miaoda-core 0.1.0-alpha.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/LICENSE +13 -0
- package/README.md +8 -0
- package/lib/apis/components/AppContainer.d.ts +1 -0
- package/lib/apis/components/AppContainer.js +2 -0
- package/lib/apis/components/ErrorRender.d.ts +1 -0
- package/lib/apis/components/ErrorRender.js +2 -0
- package/lib/apis/components/NotFoundRender.d.ts +1 -0
- package/lib/apis/components/NotFoundRender.js +2 -0
- package/lib/apis/components/SidebarNav.d.ts +1 -0
- package/lib/apis/components/SidebarNav.js +2 -0
- package/lib/apis/components/TopNav.d.ts +1 -0
- package/lib/apis/components/TopNav.js +2 -0
- package/lib/apis/components/User.d.ts +1 -0
- package/lib/apis/components/User.js +1 -0
- package/lib/apis/components/Welcome.d.ts +1 -0
- package/lib/apis/components/Welcome.js +2 -0
- package/lib/apis/constants/img-resources/avatar.d.ts +11 -0
- package/lib/apis/constants/img-resources/avatar.js +12 -0
- package/lib/apis/constants/img-resources/banner.d.ts +24 -0
- package/lib/apis/constants/img-resources/banner.js +25 -0
- package/lib/apis/constants/img-resources/cover.d.ts +36 -0
- package/lib/apis/constants/img-resources/cover.js +37 -0
- package/lib/apis/dataloom.d.ts +1 -0
- package/lib/apis/dataloom.js +2 -0
- package/lib/apis/hooks/useCurrentAppInfo.d.ts +1 -0
- package/lib/apis/hooks/useCurrentAppInfo.js +1 -0
- package/lib/apis/hooks/useCurrentUserProfile.d.ts +1 -0
- package/lib/apis/hooks/useCurrentUserProfile.js +1 -0
- package/lib/apis/logger.d.ts +1 -0
- package/lib/apis/logger.js +1 -0
- package/lib/apis/tools/generateImage.d.ts +1 -0
- package/lib/apis/tools/generateImage.js +1 -0
- package/lib/apis/tools/generateTextStream.d.ts +1 -0
- package/lib/apis/tools/generateTextStream.js +1 -0
- package/lib/apis/tools/getAppInfo.d.ts +1 -0
- package/lib/apis/tools/getAppInfo.js +1 -0
- package/lib/apis/tools/getCurrentUserProfile.d.ts +1 -0
- package/lib/apis/tools/getCurrentUserProfile.js +1 -0
- package/lib/apis/tools/storage.d.ts +1 -0
- package/lib/apis/tools/storage.js +4 -0
- package/lib/apis/udt-types.d.ts +16 -0
- package/lib/apis/udt-types.js +0 -0
- package/lib/apis/utils/registerChinaMap.d.ts +1 -0
- package/lib/apis/utils/registerChinaMap.js +103319 -0
- package/lib/components/AppContainer/IframeBridge.d.ts +2 -0
- package/lib/components/AppContainer/IframeBridge.js +80 -0
- package/lib/components/AppContainer/PageHoc.d.ts +4 -0
- package/lib/components/AppContainer/PageHoc.js +20 -0
- package/lib/components/AppContainer/dayjsPlugins.d.ts +1 -0
- package/lib/components/AppContainer/dayjsPlugins.js +69 -0
- package/lib/components/AppContainer/index.d.ts +7 -0
- package/lib/components/AppContainer/index.js +65 -0
- package/lib/components/AppContainer/sonner.css +101 -0
- package/lib/components/AppContainer/sonner.d.ts +8 -0
- package/lib/components/AppContainer/sonner.js +26 -0
- package/lib/components/ErrorRender/index.d.ts +5 -0
- package/lib/components/ErrorRender/index.js +79 -0
- package/lib/components/NotFoundRender/index.d.ts +3 -0
- package/lib/components/NotFoundRender/index.js +59 -0
- package/lib/components/SidebarNav/DrawerNav.d.ts +3 -0
- package/lib/components/SidebarNav/DrawerNav.js +64 -0
- package/lib/components/SidebarNav/DropdownNav.d.ts +3 -0
- package/lib/components/SidebarNav/DropdownNav.js +40 -0
- package/lib/components/SidebarNav/Sidebar.d.ts +3 -0
- package/lib/components/SidebarNav/Sidebar.js +33 -0
- package/lib/components/SidebarNav/index.d.ts +5 -0
- package/lib/components/SidebarNav/index.js +61 -0
- package/lib/components/TopNav/BottomNav.d.ts +12 -0
- package/lib/components/TopNav/BottomNav.js +81 -0
- package/lib/components/TopNav/TitleBar.d.ts +10 -0
- package/lib/components/TopNav/TitleBar.js +127 -0
- package/lib/components/TopNav/TopNav.d.ts +10 -0
- package/lib/components/TopNav/TopNav.js +86 -0
- package/lib/components/TopNav/index.d.ts +12 -0
- package/lib/components/TopNav/index.js +65 -0
- package/lib/components/User/UserDisplay.d.ts +9 -0
- package/lib/components/User/UserDisplay.js +39 -0
- package/lib/components/User/UserProfile/UserProfile.css +34 -0
- package/lib/components/User/UserProfile/UserProfile.d.ts +6 -0
- package/lib/components/User/UserProfile/UserProfile.js +41 -0
- package/lib/components/User/UserProfile/UserProfileContainer.d.ts +4 -0
- package/lib/components/User/UserProfile/UserProfileContainer.js +8 -0
- package/lib/components/User/UserProfile/UserProfileSkeleton.d.ts +3 -0
- package/lib/components/User/UserProfile/UserProfileSkeleton.js +36 -0
- package/lib/components/User/UserProfile/UserProfileUI.d.ts +8 -0
- package/lib/components/User/UserProfile/UserProfileUI.js +113 -0
- package/lib/components/User/UserProfile/index.d.ts +1 -0
- package/lib/components/User/UserProfile/index.js +2 -0
- package/lib/components/User/UserProfile/type.d.ts +8 -0
- package/lib/components/User/UserProfile/type.js +0 -0
- package/lib/components/User/UserProfile/utils.d.ts +5 -0
- package/lib/components/User/UserProfile/utils.js +26 -0
- package/lib/components/User/UserSelect.css +11 -0
- package/lib/components/User/UserSelect.d.ts +11 -0
- package/lib/components/User/UserSelect.js +171 -0
- package/lib/components/User/UserWithAvatar.d.ts +3 -0
- package/lib/components/User/UserWithAvatar.js +41 -0
- package/lib/components/User/index.d.ts +7 -0
- package/lib/components/User/index.js +5 -0
- package/lib/components/User/type.d.ts +13 -0
- package/lib/components/User/type.js +0 -0
- package/lib/components/Welcome/index.d.ts +3 -0
- package/lib/components/Welcome/index.js +33 -0
- package/lib/components/common/LogoInfo.d.ts +5 -0
- package/lib/components/common/LogoInfo.js +30 -0
- package/lib/components/common/NavItem.d.ts +20 -0
- package/lib/components/common/NavItem.js +112 -0
- package/lib/components/common/NavMenu.d.ts +9 -0
- package/lib/components/common/NavMenu.js +50 -0
- package/lib/components/common/UserAvatarLayout.d.ts +4 -0
- package/lib/components/common/UserAvatarLayout.js +41 -0
- package/lib/components/common/UserAvatarMenu.d.ts +4 -0
- package/lib/components/common/UserAvatarMenu.js +58 -0
- package/lib/components/common/index.d.ts +9 -0
- package/lib/components/common/index.js +10 -0
- package/lib/components/index.d.ts +9 -0
- package/lib/components/index.js +7 -0
- package/lib/components/theme/ThemeProvider.d.ts +20 -0
- package/lib/components/theme/ThemeProvider.js +75 -0
- package/lib/components/theme/constants.d.ts +48 -0
- package/lib/components/theme/constants.js +556 -0
- package/lib/components/theme/index.d.ts +4 -0
- package/lib/components/theme/index.js +5 -0
- package/lib/components/theme/miaoDarkTheme.d.ts +2 -0
- package/lib/components/theme/miaoDarkTheme.js +310 -0
- package/lib/components/theme/miaoLightTheme.d.ts +2 -0
- package/lib/components/theme/miaoLightTheme.js +296 -0
- package/lib/components/theme/ui-config.d.ts +49 -0
- package/lib/components/theme/ui-config.js +758 -0
- package/lib/components/theme/util.d.ts +20 -0
- package/lib/components/theme/util.js +188 -0
- package/lib/hooks/index.d.ts +5 -0
- package/lib/hooks/index.js +5 -0
- package/lib/hooks/useCurrentAppInfo.d.ts +6 -0
- package/lib/hooks/useCurrentAppInfo.js +20 -0
- package/lib/hooks/useCurrentUserProfile.d.ts +12 -0
- package/lib/hooks/useCurrentUserProfile.js +26 -0
- package/lib/hooks/useIsMobile.d.ts +1 -0
- package/lib/hooks/useIsMobile.js +20 -0
- package/lib/hooks/useLogout.d.ts +4 -0
- package/lib/hooks/useLogout.js +23 -0
- package/lib/hooks/useTheme.d.ts +4 -0
- package/lib/hooks/useTheme.js +8 -0
- package/lib/hooks/useUpdatingRef.d.ts +1 -0
- package/lib/hooks/useUpdatingRef.js +7 -0
- package/lib/index.css +3 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +5 -0
- package/lib/integrations/dataloom.d.ts +1 -0
- package/lib/integrations/dataloom.js +18 -0
- package/lib/integrations/generateImage.d.ts +1 -0
- package/lib/integrations/generateImage.js +32 -0
- package/lib/integrations/generateTextStream.d.ts +26 -0
- package/lib/integrations/generateTextStream.js +83 -0
- package/lib/integrations/getAppInfo.d.ts +2 -0
- package/lib/integrations/getAppInfo.js +4 -0
- package/lib/integrations/getCurrentUserProfile.d.ts +6 -0
- package/lib/integrations/getCurrentUserProfile.js +5 -0
- package/lib/logger/index.d.ts +6 -0
- package/lib/logger/index.js +54 -0
- package/lib/override.css +29 -0
- package/lib/tailwind-theme.css +435 -0
- package/lib/types/common.d.ts +11 -0
- package/lib/types/common.js +0 -0
- package/lib/types/index.d.ts +40 -0
- package/lib/types/index.js +0 -0
- package/lib/utils/copyToClipboard.d.ts +6 -0
- package/lib/utils/copyToClipboard.js +32 -0
- package/lib/utils/getAppId.d.ts +11 -0
- package/lib/utils/getAppId.js +9 -0
- package/lib/utils/getEnvPath.d.ts +4 -0
- package/lib/utils/getEnvPath.js +4 -0
- package/lib/utils/getParentOrigin.d.ts +5 -0
- package/lib/utils/getParentOrigin.js +7 -0
- package/lib/utils/getUserProfile.d.ts +47 -0
- package/lib/utils/getUserProfile.js +33 -0
- package/lib/utils/url.d.ts +8 -0
- package/lib/utils/url.js +22 -0
- package/lib/utils/utils.d.ts +11 -0
- package/lib/utils/utils.js +9 -0
- package/package.json +130 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getAppId } from "./getAppId.js";
|
|
2
|
+
import { getEnvPath } from "./getEnvPath.js";
|
|
3
|
+
async function getUserProfile(request, headers = {}) {
|
|
4
|
+
const appId = getAppId(window.location.pathname);
|
|
5
|
+
if (!appId) return {
|
|
6
|
+
code: 1,
|
|
7
|
+
msg: 'appId is required',
|
|
8
|
+
userProfile: {}
|
|
9
|
+
};
|
|
10
|
+
const defaultHeaders = {
|
|
11
|
+
'Content-Type': 'application/json'
|
|
12
|
+
};
|
|
13
|
+
const mergedHeaders = {
|
|
14
|
+
...defaultHeaders,
|
|
15
|
+
...headers,
|
|
16
|
+
'X-Kunlun-Token': window.token,
|
|
17
|
+
'x-miaoda-token': window.MIAODA_BUILTIN_TTT,
|
|
18
|
+
'x-lgw-csrf-token': window.lgw_csrf_token,
|
|
19
|
+
...window.CSRF_HEADERS || {}
|
|
20
|
+
};
|
|
21
|
+
const envPath = getEnvPath();
|
|
22
|
+
const endpoint = `/ai/api/${envPath}/v1/apps/${appId}/user/profile`;
|
|
23
|
+
const response = await fetch(`${window.location.origin}${endpoint}`, {
|
|
24
|
+
method: 'POST',
|
|
25
|
+
headers: mergedHeaders,
|
|
26
|
+
credentials: 'include',
|
|
27
|
+
body: JSON.stringify({
|
|
28
|
+
userID: request.userID
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
return await response.json();
|
|
32
|
+
}
|
|
33
|
+
export { getUserProfile };
|
package/lib/utils/url.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { logger } from "../logger/index.js";
|
|
2
|
+
function splitWorkspaceUrl(fullUrl) {
|
|
3
|
+
try {
|
|
4
|
+
const url = new URL(fullUrl);
|
|
5
|
+
const pathParts = url.pathname.split('/');
|
|
6
|
+
const workspacesIndex = pathParts.findIndex((part)=>'workspaces' === part);
|
|
7
|
+
if (-1 === workspacesIndex) throw new Error('Invalid workspace URL format');
|
|
8
|
+
const basePathParts = pathParts.slice(0, workspacesIndex);
|
|
9
|
+
const workspace = pathParts[workspacesIndex + 1];
|
|
10
|
+
return {
|
|
11
|
+
baseUrl: `${url.origin}${basePathParts.join('/')}`,
|
|
12
|
+
workspace
|
|
13
|
+
};
|
|
14
|
+
} catch (error) {
|
|
15
|
+
logger.error('Error splitting workspace URL:', error);
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
baseUrl: fullUrl,
|
|
19
|
+
workspace: 'workspace'
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export { splitWorkspaceUrl };
|
package/package.json
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lark-apaas/miaoda-core",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"types": "./lib/index.d.ts",
|
|
5
|
+
"main": "./lib/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"lib"
|
|
8
|
+
],
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./lib/index.js",
|
|
15
|
+
"require": "./lib/index.js",
|
|
16
|
+
"types": "./lib/index.d.ts"
|
|
17
|
+
},
|
|
18
|
+
"./dataloom": {
|
|
19
|
+
"import": "./lib/apis/dataloom.js",
|
|
20
|
+
"require": "./lib/apis/dataloom.js",
|
|
21
|
+
"types": "./lib/apis/dataloom.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./logger": {
|
|
24
|
+
"import": "./lib/apis/logger.js",
|
|
25
|
+
"require": "./lib/apis/logger.js",
|
|
26
|
+
"types": "./lib/apis/logger.d.ts"
|
|
27
|
+
},
|
|
28
|
+
"./udt-types": {
|
|
29
|
+
"import": "./lib/apis/udt-types.js",
|
|
30
|
+
"require": "./lib/apis/udt-types.js",
|
|
31
|
+
"types": "./lib/apis/udt-types.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./components/*": {
|
|
34
|
+
"import": "./lib/apis/components/*.js",
|
|
35
|
+
"require": "./lib/apis/components/*.js",
|
|
36
|
+
"types": "./lib/apis/components/*.d.ts"
|
|
37
|
+
},
|
|
38
|
+
"./constants/*": {
|
|
39
|
+
"import": "./lib/apis/constants/**/*.js",
|
|
40
|
+
"require": "./lib/apis/constants/**/*.js",
|
|
41
|
+
"types": "./lib/apis/constants/**/*.d.ts"
|
|
42
|
+
},
|
|
43
|
+
"./hooks/*": {
|
|
44
|
+
"import": "./lib/apis/hooks/*.js",
|
|
45
|
+
"require": "./lib/apis/hooks/*.js",
|
|
46
|
+
"types": "./lib/apis/hooks/*.d.ts"
|
|
47
|
+
},
|
|
48
|
+
"./tools/*": {
|
|
49
|
+
"import": "./lib/apis/tools/*.js",
|
|
50
|
+
"require": "./lib/apis/tools/*.js",
|
|
51
|
+
"types": "./lib/apis/tools/*.d.ts"
|
|
52
|
+
},
|
|
53
|
+
"./utils/*": {
|
|
54
|
+
"import": "./lib/apis/utils/*.js",
|
|
55
|
+
"require": "./lib/apis/utils/*.js",
|
|
56
|
+
"types": "./lib/apis/utils/*.d.ts"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"tsc": "tsc --declaration",
|
|
61
|
+
"build": "rslib build",
|
|
62
|
+
"build:storybook": "storybook build",
|
|
63
|
+
"bump": "changeset version",
|
|
64
|
+
"change": "changeset",
|
|
65
|
+
"check": "biome check --write",
|
|
66
|
+
"dev": "rslib build --watch",
|
|
67
|
+
"format": "biome format --write",
|
|
68
|
+
"storybook": "storybook dev",
|
|
69
|
+
"test": "echo 0",
|
|
70
|
+
"lint": "eslint src --ext .js,.jsx,.ts,.tsx",
|
|
71
|
+
"lint:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
|
|
72
|
+
"prepublishOnly": "npm run build"
|
|
73
|
+
},
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"@ant-design/colors": "^7.2.1",
|
|
76
|
+
"@ant-design/cssinjs": "^1.24.0",
|
|
77
|
+
"@lark-apaas/miaoda-inspector": "workspace:*",
|
|
78
|
+
"@data-loom/js": "0.2.3",
|
|
79
|
+
"clsx": "~2.0.1",
|
|
80
|
+
"dayjs": "^1.11.13",
|
|
81
|
+
"echarts": "^6.0.0",
|
|
82
|
+
"html2canvas-pro": "^1.5.11",
|
|
83
|
+
"lodash": "^4.17.21",
|
|
84
|
+
"sonner": "~2.0.0",
|
|
85
|
+
"tailwind-merge": "~2.0.0",
|
|
86
|
+
"tailwind-variants": "0.3.1",
|
|
87
|
+
"tailwindcss-animate": "^1.0.7"
|
|
88
|
+
},
|
|
89
|
+
"devDependencies": {
|
|
90
|
+
"@biomejs/biome": "2.0.6",
|
|
91
|
+
"@changesets/cli": "^2.29.5",
|
|
92
|
+
"@rsbuild/core": "~1.4.13",
|
|
93
|
+
"@rsbuild/plugin-react": "^1.3.4",
|
|
94
|
+
"@rslib/core": "^0.12.0",
|
|
95
|
+
"@storybook/addon-essentials": "^8.6.14",
|
|
96
|
+
"@storybook/addon-interactions": "^8.6.14",
|
|
97
|
+
"@storybook/addon-links": "^8.6.14",
|
|
98
|
+
"@storybook/addon-onboarding": "^8.6.14",
|
|
99
|
+
"@storybook/blocks": "^8.6.14",
|
|
100
|
+
"@storybook/react": "^8.6.14",
|
|
101
|
+
"@storybook/test": "^8.6.14",
|
|
102
|
+
"@testing-library/jest-dom": "^6.6.4",
|
|
103
|
+
"@testing-library/react": "^16.3.0",
|
|
104
|
+
"@types/lodash": "^4.17.20",
|
|
105
|
+
"@types/node": "^22.10.2",
|
|
106
|
+
"@types/react": "^18.3.23",
|
|
107
|
+
"@types/react-dom": "^18.3.7",
|
|
108
|
+
"antd": "^5.26.6",
|
|
109
|
+
"eslint": "^8.57.0",
|
|
110
|
+
"jsdom": "^26.1.0",
|
|
111
|
+
"lucide-react": "^0.541.0",
|
|
112
|
+
"react": "^18.3.1",
|
|
113
|
+
"react-dom": "^18.3.1",
|
|
114
|
+
"react-router-dom": "^6.26.2",
|
|
115
|
+
"storybook": "^8.6.14",
|
|
116
|
+
"storybook-addon-rslib": "^1.0.2",
|
|
117
|
+
"storybook-react-rsbuild": "^1.0.2",
|
|
118
|
+
"tailwindcss": "^4.1.13",
|
|
119
|
+
"tsc-watch": "^7.1.1",
|
|
120
|
+
"typescript": "^5.9.2",
|
|
121
|
+
"vitest": "^3.2.4"
|
|
122
|
+
},
|
|
123
|
+
"peerDependencies": {
|
|
124
|
+
"antd": ">=5.26.6",
|
|
125
|
+
"lucide-react": "^0.541.0",
|
|
126
|
+
"react": ">=16.14.0",
|
|
127
|
+
"react-dom": ">=16.14.0",
|
|
128
|
+
"react-router-dom": ">=6.26.2"
|
|
129
|
+
}
|
|
130
|
+
}
|