@blocklet/aigne-hub 0.2.7
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 +29 -0
- package/lib/cjs/api/ai-kit.js +60 -0
- package/lib/cjs/api/api.js +17 -0
- package/lib/cjs/api/app.js +57 -0
- package/lib/cjs/api/call/api.js +51 -0
- package/lib/cjs/api/call/app.js +74 -0
- package/lib/cjs/api/call/index.js +19 -0
- package/lib/cjs/api/call/proxy.js +64 -0
- package/lib/cjs/api/call/v1.js +166 -0
- package/lib/cjs/api/call/v2.js +101 -0
- package/lib/cjs/api/config.js +46 -0
- package/lib/cjs/api/constants.js +4 -0
- package/lib/cjs/api/error.js +42 -0
- package/lib/cjs/api/index.js +19 -0
- package/lib/cjs/api/types/audio.js +2 -0
- package/lib/cjs/api/types/chat.js +14 -0
- package/lib/cjs/api/types/embedding.js +2 -0
- package/lib/cjs/api/types/image.js +2 -0
- package/lib/cjs/api/types/index.js +19 -0
- package/lib/cjs/api/types/status.js +2 -0
- package/lib/cjs/api/utils/auth.js +90 -0
- package/lib/cjs/api/utils/event-stream.js +59 -0
- package/lib/cjs/components/conversation/conversation.js +71 -0
- package/lib/cjs/components/conversation/index.js +25 -0
- package/lib/cjs/components/conversation/message.js +120 -0
- package/lib/cjs/components/conversation/prompt.js +43 -0
- package/lib/cjs/components/conversation/use-conversation.js +100 -0
- package/lib/cjs/components/credit/alert.js +40 -0
- package/lib/cjs/components/credit/balance.js +95 -0
- package/lib/cjs/components/credit/button.js +69 -0
- package/lib/cjs/components/credit/index.js +12 -0
- package/lib/cjs/components/form-label.js +27 -0
- package/lib/cjs/components/image-preview.js +116 -0
- package/lib/cjs/components/index.js +45 -0
- package/lib/cjs/components/loading-image.js +37 -0
- package/lib/cjs/components/subscribe/alert.js +53 -0
- package/lib/cjs/components/subscribe/button.js +92 -0
- package/lib/cjs/components/subscribe/state.js +42 -0
- package/lib/cjs/components/switch-button.js +48 -0
- package/lib/cjs/components/table.js +203 -0
- package/lib/cjs/index.js +2 -0
- package/lib/cjs/libs/logger.js +8 -0
- package/lib/cjs/utils/withLocaleProvider.js +11 -0
- package/lib/esm/api/ai-kit.js +54 -0
- package/lib/esm/api/api.js +11 -0
- package/lib/esm/api/app.js +42 -0
- package/lib/esm/api/call/api.js +24 -0
- package/lib/esm/api/call/app.js +68 -0
- package/lib/esm/api/call/index.js +3 -0
- package/lib/esm/api/call/proxy.js +58 -0
- package/lib/esm/api/call/v1.js +155 -0
- package/lib/esm/api/call/v2.js +93 -0
- package/lib/esm/api/config.js +41 -0
- package/lib/esm/api/constants.js +1 -0
- package/lib/esm/api/error.js +37 -0
- package/lib/esm/api/index.js +3 -0
- package/lib/esm/api/types/audio.js +1 -0
- package/lib/esm/api/types/chat.js +9 -0
- package/lib/esm/api/types/embedding.js +1 -0
- package/lib/esm/api/types/image.js +1 -0
- package/lib/esm/api/types/index.js +3 -0
- package/lib/esm/api/types/status.js +1 -0
- package/lib/esm/api/utils/auth.js +79 -0
- package/lib/esm/api/utils/event-stream.js +50 -0
- package/lib/esm/components/conversation/conversation.js +65 -0
- package/lib/esm/components/conversation/index.js +4 -0
- package/lib/esm/components/conversation/message.js +114 -0
- package/lib/esm/components/conversation/prompt.js +40 -0
- package/lib/esm/components/conversation/use-conversation.js +97 -0
- package/lib/esm/components/credit/alert.js +35 -0
- package/lib/esm/components/credit/balance.js +90 -0
- package/lib/esm/components/credit/button.js +64 -0
- package/lib/esm/components/credit/index.js +3 -0
- package/lib/esm/components/form-label.js +24 -0
- package/lib/esm/components/image-preview.js +110 -0
- package/lib/esm/components/index.js +14 -0
- package/lib/esm/components/loading-image.js +35 -0
- package/lib/esm/components/subscribe/alert.js +48 -0
- package/lib/esm/components/subscribe/button.js +87 -0
- package/lib/esm/components/subscribe/state.js +39 -0
- package/lib/esm/components/switch-button.js +46 -0
- package/lib/esm/components/table.js +198 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/libs/logger.js +3 -0
- package/lib/esm/utils/withLocaleProvider.js +8 -0
- package/lib/types/api/ai-kit.d.ts +70 -0
- package/lib/types/api/api.d.ts +4 -0
- package/lib/types/api/app.d.ts +113 -0
- package/lib/types/api/call/api.d.ts +2 -0
- package/lib/types/api/call/app.d.ts +50 -0
- package/lib/types/api/call/index.d.ts +3 -0
- package/lib/types/api/call/proxy.d.ts +6 -0
- package/lib/types/api/call/v1.d.ts +51 -0
- package/lib/types/api/call/v2.d.ts +30 -0
- package/lib/types/api/config.d.ts +14 -0
- package/lib/types/api/constants.d.ts +1 -0
- package/lib/types/api/error.d.ts +18 -0
- package/lib/types/api/index.d.ts +3 -0
- package/lib/types/api/types/audio.d.ts +18 -0
- package/lib/types/api/types/chat.d.ts +97 -0
- package/lib/types/api/types/embedding.d.ts +9 -0
- package/lib/types/api/types/image.d.ts +23 -0
- package/lib/types/api/types/index.d.ts +3 -0
- package/lib/types/api/types/status.d.ts +3 -0
- package/lib/types/api/utils/auth.d.ts +33 -0
- package/lib/types/api/utils/event-stream.d.ts +7 -0
- package/lib/types/components/conversation/conversation.d.ts +30 -0
- package/lib/types/components/conversation/index.d.ts +4 -0
- package/lib/types/components/conversation/message.d.ts +10 -0
- package/lib/types/components/conversation/prompt.d.ts +10 -0
- package/lib/types/components/conversation/use-conversation.d.ts +44 -0
- package/lib/types/components/credit/alert.d.ts +10 -0
- package/lib/types/components/credit/balance.d.ts +7 -0
- package/lib/types/components/credit/button.d.ts +11 -0
- package/lib/types/components/credit/index.d.ts +3 -0
- package/lib/types/components/form-label.d.ts +7 -0
- package/lib/types/components/image-preview.d.ts +17 -0
- package/lib/types/components/index.d.ts +12 -0
- package/lib/types/components/loading-image.d.ts +6 -0
- package/lib/types/components/subscribe/alert.d.ts +5 -0
- package/lib/types/components/subscribe/button.d.ts +5 -0
- package/lib/types/components/subscribe/state.d.ts +14 -0
- package/lib/types/components/switch-button.d.ts +7 -0
- package/lib/types/components/table.d.ts +3 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/libs/logger.d.ts +2 -0
- package/lib/types/utils/withLocaleProvider.d.ts +9 -0
- package/package.json +158 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
+
import { Alert, CircularProgress, Stack } from '@mui/material';
|
|
4
|
+
import { SubscriptionErrorType } from '../../api/error';
|
|
5
|
+
import withLocaleProvider from '../../utils/withLocaleProvider';
|
|
6
|
+
import SubscribeButton from './button';
|
|
7
|
+
import { useAIKitServiceStatus } from './state';
|
|
8
|
+
function SubscribeErrorAlert({ error, ...props }) {
|
|
9
|
+
const { t } = useLocaleContext();
|
|
10
|
+
const isUnsubscribeError = (error === null || error === void 0 ? void 0 : error.type) === SubscriptionErrorType.UNSUBSCRIBED;
|
|
11
|
+
const loading = useAIKitServiceStatus((i) => i.loading);
|
|
12
|
+
const subscription = useAIKitServiceStatus((i) => { var _a; return (_a = i.app) === null || _a === void 0 ? void 0 : _a.subscription; });
|
|
13
|
+
const useAIKitService = useAIKitServiceStatus((i) => { var _a, _b; return (_b = (_a = i.app) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.useAIKitService; });
|
|
14
|
+
const isPastDue = (subscription === null || subscription === void 0 ? void 0 : subscription.status) === 'past_due';
|
|
15
|
+
const message = !isUnsubscribeError
|
|
16
|
+
? error.message
|
|
17
|
+
: !subscription
|
|
18
|
+
? t('notSubscribeTip')
|
|
19
|
+
: isPastDue
|
|
20
|
+
? t('pastDueTip')
|
|
21
|
+
: !useAIKitService
|
|
22
|
+
? t('notEnableAIServiceTip')
|
|
23
|
+
: t('successTip');
|
|
24
|
+
return (_jsxs(Alert, { severity: isUnsubscribeError && subscription && useAIKitService ? 'info' : 'warning', ...props, sx: {
|
|
25
|
+
px: 1,
|
|
26
|
+
py: 0,
|
|
27
|
+
'& .MuiAlert-message': {
|
|
28
|
+
width: '100%',
|
|
29
|
+
},
|
|
30
|
+
...props.sx,
|
|
31
|
+
}, children: [isUnsubscribeError && loading ? _jsx(CircularProgress, { size: 18 }) : message, isUnsubscribeError && (_jsx(Stack, { direction: "row", sx: { justifyContent: 'flex-end' }, children: _jsx(SubscribeButton, { shouldOpenInNewTab: true, showUseAIServiceButton: true }) }))] }));
|
|
32
|
+
}
|
|
33
|
+
export default withLocaleProvider(SubscribeErrorAlert, {
|
|
34
|
+
translations: {
|
|
35
|
+
en: {
|
|
36
|
+
notSubscribeTip: 'Hello, please subscribe to AI service first!',
|
|
37
|
+
pastDueTip: 'Your AI service has expired, please renew it first!',
|
|
38
|
+
notEnableAIServiceTip: 'You have not enabled AI service, please enable AI service first!',
|
|
39
|
+
successTip: 'Congratulations, your subscription is successful!',
|
|
40
|
+
},
|
|
41
|
+
zh: {
|
|
42
|
+
notSubscribeTip: '你好,请订阅 AI 服务后继续!',
|
|
43
|
+
pastDueTip: '您的 AI 服务已过期,请续订后继续!',
|
|
44
|
+
notEnableAIServiceTip: '您尚未启用AI服务,请启用 AI 服务后继续!',
|
|
45
|
+
successTip: '恭喜,您的订阅已生效!',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
4
|
+
import { LoadingButton } from '@mui/lab';
|
|
5
|
+
import { Typography } from '@mui/material';
|
|
6
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
7
|
+
import { joinURL, withQuery } from 'ufo';
|
|
8
|
+
import { appServiceRegister } from '../../api/app';
|
|
9
|
+
import withLocaleProvider from '../../utils/withLocaleProvider';
|
|
10
|
+
import { useAIKitServiceStatus } from './state';
|
|
11
|
+
function SubscribeButton({ shouldOpenInNewTab = false, showUseAIServiceButton = false, }) {
|
|
12
|
+
const { t } = useLocaleContext();
|
|
13
|
+
const fetch = useAIKitServiceStatus((i) => i.fetch);
|
|
14
|
+
const isSubscriptionAvailable = useAIKitServiceStatus((i) => { var _a; return (_a = i.computed) === null || _a === void 0 ? void 0 : _a.isSubscriptionAvailable; });
|
|
15
|
+
const loading = useAIKitServiceStatus((i) => i.loading);
|
|
16
|
+
const setConfig = useAIKitServiceStatus((i) => i.setConfig);
|
|
17
|
+
const subscription = useAIKitServiceStatus((i) => { var _a; return (_a = i.app) === null || _a === void 0 ? void 0 : _a.subscription; });
|
|
18
|
+
const useAIKitService = useAIKitServiceStatus((i) => { var _a, _b; return (_b = (_a = i.app) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.useAIKitService; });
|
|
19
|
+
const subscriptionDetailUrl = useAIKitServiceStatus((i) => { var _a; return (_a = i.app) === null || _a === void 0 ? void 0 : _a.subscriptionDetailUrl; });
|
|
20
|
+
const isPastDue = (subscription === null || subscription === void 0 ? void 0 : subscription.status) === 'past_due';
|
|
21
|
+
const [submitting, setSubmitting] = useState(false);
|
|
22
|
+
const linkToAiKit = useCallback(async () => {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
setSubmitting(true);
|
|
25
|
+
try {
|
|
26
|
+
const res = await appServiceRegister();
|
|
27
|
+
if (res.paymentLink) {
|
|
28
|
+
const { origin, href } = window.location;
|
|
29
|
+
const prefix = ((_b = (_a = window.blocklet) === null || _a === void 0 ? void 0 : _a.componentMountPoints.find((i) => i.name === 'ai-kit')) === null || _b === void 0 ? void 0 : _b.mountPoint) || '/';
|
|
30
|
+
const payLink = withQuery(res.paymentLink, {
|
|
31
|
+
redirect: withQuery(joinURL(origin, prefix, '/api/app/client/subscription/success'), { redirect: href }),
|
|
32
|
+
});
|
|
33
|
+
if (shouldOpenInNewTab) {
|
|
34
|
+
const win = window.open(payLink, '_blank');
|
|
35
|
+
win === null || win === void 0 ? void 0 : win.focus();
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
window.location.href = payLink;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
Toast.error(error.message);
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
finally {
|
|
47
|
+
setSubmitting(false);
|
|
48
|
+
}
|
|
49
|
+
}, [shouldOpenInNewTab]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
fetch();
|
|
52
|
+
}, [fetch]);
|
|
53
|
+
if (!loading && !isSubscriptionAvailable) {
|
|
54
|
+
return (_jsx(LoadingButton, { onClick: isPastDue && subscriptionDetailUrl ? undefined : linkToAiKit, href: subscriptionDetailUrl, size: "small", variant: "outlined", color: isPastDue ? 'error' : 'primary', type: "button", sx: { mx: 0.5, minWidth: 0 }, loading: submitting, children: _jsx(Typography, { noWrap: true, children: t(isPastDue ? 'aiServicePastDue' : 'subscribeAIService') }) }, "button"));
|
|
55
|
+
}
|
|
56
|
+
if (showUseAIServiceButton && isSubscriptionAvailable && !useAIKitService) {
|
|
57
|
+
return (_jsx(LoadingButton, { loading: submitting, onClick: async () => {
|
|
58
|
+
setSubmitting(true);
|
|
59
|
+
try {
|
|
60
|
+
await setConfig({ useAIKitService: true });
|
|
61
|
+
Toast.success('Successfully changed to AI service!');
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
Toast.error(error.message);
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
setSubmitting(false);
|
|
69
|
+
}
|
|
70
|
+
}, children: t('useAIService') }));
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
export default withLocaleProvider(SubscribeButton, {
|
|
75
|
+
translations: {
|
|
76
|
+
en: {
|
|
77
|
+
subscribeAIService: 'Subscribe AI Service',
|
|
78
|
+
aiServicePastDue: 'Pay for overdue AI service',
|
|
79
|
+
useAIService: 'Enable AI Service',
|
|
80
|
+
},
|
|
81
|
+
zh: {
|
|
82
|
+
subscribeAIService: '订阅 AI 服务',
|
|
83
|
+
aiServicePastDue: '支付 AI 服务欠费',
|
|
84
|
+
useAIService: '启用 AI 服务',
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { create } from 'zustand';
|
|
2
|
+
import { immer } from 'zustand/middleware/immer';
|
|
3
|
+
import { appStatus, setAppConfig } from '../../api/app';
|
|
4
|
+
export const useAIKitServiceStatus = create()(immer((set, get) => ({
|
|
5
|
+
loading: true,
|
|
6
|
+
fetch: async () => {
|
|
7
|
+
set((state) => {
|
|
8
|
+
state.loading = true;
|
|
9
|
+
});
|
|
10
|
+
try {
|
|
11
|
+
const app = await appStatus();
|
|
12
|
+
set((state) => {
|
|
13
|
+
state.app = app;
|
|
14
|
+
state.error = undefined;
|
|
15
|
+
state.loading = false;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
set((state) => {
|
|
20
|
+
state.error = error;
|
|
21
|
+
state.loading = false;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
setConfig: async (config) => {
|
|
26
|
+
const result = await setAppConfig(config);
|
|
27
|
+
set((state) => {
|
|
28
|
+
if (state.app)
|
|
29
|
+
state.app.config = result;
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
computed: {
|
|
33
|
+
get isSubscriptionAvailable() {
|
|
34
|
+
var _a;
|
|
35
|
+
const subscription = (_a = get().app) === null || _a === void 0 ? void 0 : _a.subscription;
|
|
36
|
+
return subscription && ['active', 'trialing'].includes(subscription.status);
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
})));
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Switch } from '@mui/material';
|
|
2
|
+
import { styled } from '@mui/system';
|
|
3
|
+
const SwitchButton = styled(Switch)(({ variant = 'success', theme }) => {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
return ({
|
|
6
|
+
width: 28,
|
|
7
|
+
height: 16,
|
|
8
|
+
padding: 0,
|
|
9
|
+
display: 'inline-flex',
|
|
10
|
+
'&:active': {
|
|
11
|
+
'& .MuiSwitch-thumb': {
|
|
12
|
+
width: 15,
|
|
13
|
+
},
|
|
14
|
+
'& .MuiSwitch-switchBase.Mui-checked': {
|
|
15
|
+
transform: 'translateX(9px)',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
'& .MuiSwitch-switchBase': {
|
|
19
|
+
padding: 2,
|
|
20
|
+
'&.Mui-checked': {
|
|
21
|
+
transform: 'translateX(12px)',
|
|
22
|
+
color: '#fff',
|
|
23
|
+
'& + .MuiSwitch-track': {
|
|
24
|
+
opacity: 1,
|
|
25
|
+
backgroundColor: (_a = theme.palette[variant]) === null || _a === void 0 ? void 0 : _a.light,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
'& .MuiSwitch-thumb': {
|
|
30
|
+
boxShadow: '0 2px 4px 0 rgb(0 35 11 / 20%)',
|
|
31
|
+
width: 12,
|
|
32
|
+
height: 12,
|
|
33
|
+
borderRadius: 6,
|
|
34
|
+
transition: (_b = theme.transitions) === null || _b === void 0 ? void 0 : _b.create(['width'], {
|
|
35
|
+
duration: 200,
|
|
36
|
+
}),
|
|
37
|
+
},
|
|
38
|
+
'& .MuiSwitch-track': {
|
|
39
|
+
borderRadius: 16 / 2,
|
|
40
|
+
opacity: 1,
|
|
41
|
+
backgroundColor: theme.palette.mode === 'dark' ? 'rgba(255,255,255,.35)' : 'rgba(0,0,0,.25)',
|
|
42
|
+
boxSizing: 'border-box',
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
export default SwitchButton;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Datatable from '@arcblock/ux/lib/Datatable';
|
|
3
|
+
import Empty from '@arcblock/ux/lib/Empty';
|
|
4
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
5
|
+
import { useMediaQuery, useTheme } from '@mui/material';
|
|
6
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
7
|
+
import { styled } from '@mui/system';
|
|
8
|
+
/* eslint-disable @typescript-eslint/indent */
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import withLocaleProvider from '../utils/withLocaleProvider';
|
|
11
|
+
function EmptyStub() {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const Table = React.memo(({ options, columns, toolbar = true, footer = true, hasRowLink = false, emptyNodeText = '', ...rest }) => {
|
|
15
|
+
const { locale, t } = useLocaleContext();
|
|
16
|
+
const theme = useTheme();
|
|
17
|
+
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
18
|
+
const defaultOptions = {
|
|
19
|
+
print: false,
|
|
20
|
+
download: false,
|
|
21
|
+
filter: false,
|
|
22
|
+
selectableRows: 'none',
|
|
23
|
+
rowsPerPage: isMobile ? 5 : 10,
|
|
24
|
+
rowsPerPageOptions: [5, 10, 20, 50, 100],
|
|
25
|
+
searchDebounceTime: 300,
|
|
26
|
+
tableBodyHeight: '100%',
|
|
27
|
+
loading: true,
|
|
28
|
+
};
|
|
29
|
+
const components = {};
|
|
30
|
+
if (!toolbar) {
|
|
31
|
+
components.TableToolbar = EmptyStub;
|
|
32
|
+
}
|
|
33
|
+
if (!footer) {
|
|
34
|
+
components.TableFooter = EmptyStub;
|
|
35
|
+
}
|
|
36
|
+
// components.TableHead = EmptyStub2
|
|
37
|
+
return (_jsx(Wrapped, { locale: locale, options: { ...defaultOptions, ...options }, columns: columns.map((x) => {
|
|
38
|
+
x.options = x.options || {};
|
|
39
|
+
x.options.filter = x.options.filter || false;
|
|
40
|
+
x.options.sort = x.options.sort || false;
|
|
41
|
+
return x;
|
|
42
|
+
}), emptyNode: _jsx(Empty, { children: emptyNodeText || t('empty') }), ...rest, components: components, hasRowLink: hasRowLink, isMobile: isMobile }));
|
|
43
|
+
});
|
|
44
|
+
const Wrapped = styled(Datatable) `
|
|
45
|
+
${(props) => (props === null || props === void 0 ? void 0 : props.hasRowLink)
|
|
46
|
+
? `.MuiTableCell-root {
|
|
47
|
+
font-size: 0.875rem !important;
|
|
48
|
+
}`
|
|
49
|
+
: ''}
|
|
50
|
+
.MuiPaper-root {
|
|
51
|
+
border-radius: 8px;
|
|
52
|
+
overflow: hidden;
|
|
53
|
+
}
|
|
54
|
+
table.MuiTable-root {
|
|
55
|
+
outline: 1px solid;
|
|
56
|
+
outline-color: ${({ theme }) => theme.palette.grey[100]};
|
|
57
|
+
border-radius: ${({ theme }) => `${2 * theme.shape.borderRadius}px`};
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
}
|
|
60
|
+
[class*='MUIDataTable-responsiveBase'] {
|
|
61
|
+
outline: 1px solid;
|
|
62
|
+
outline-color: ${({ theme }) => theme.palette.grey[100]};
|
|
63
|
+
border-radius: ${({ theme }) => `${2 * theme.shape.borderRadius}px`};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
th.MuiTableCell-head {
|
|
67
|
+
padding: 8px 16px 8px 16px;
|
|
68
|
+
text-transform: inherit;
|
|
69
|
+
background: ${({ theme }) => theme.palette.grey[50]};
|
|
70
|
+
border-bottom: none;
|
|
71
|
+
&:first-of-type {
|
|
72
|
+
border-top-left-radius: 8px;
|
|
73
|
+
padding-left: 20px;
|
|
74
|
+
}
|
|
75
|
+
&:last-of-type {
|
|
76
|
+
border-top-right-radius: 8px;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
tr.MuiTableRow-root:not(.MuiTableRow-footer):hover {
|
|
81
|
+
background: ${({ theme }) => theme.palette.grey[100]};
|
|
82
|
+
}
|
|
83
|
+
tr.MuiTableRow-root:last-of-type td:first-of-type {
|
|
84
|
+
border-bottom-left-radius: 8px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
tr.MuiTableRow-root:last-of-type td:last-of-type {
|
|
88
|
+
border-bottom-right-radius: 8px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
tr.MuiTableRow-root:nth-of-type(even) {
|
|
92
|
+
background: ${({ theme }) => theme.palette.grey[50]};
|
|
93
|
+
}
|
|
94
|
+
td.MuiTableCell-root {
|
|
95
|
+
border-bottom: none;
|
|
96
|
+
padding-top: 12px;
|
|
97
|
+
padding-bottom: 12px;
|
|
98
|
+
padding-left: 16px;
|
|
99
|
+
padding-right: 16px;
|
|
100
|
+
&:first-of-type {
|
|
101
|
+
padding-left: 20px;
|
|
102
|
+
}
|
|
103
|
+
&.MuiTableCell-footer {
|
|
104
|
+
border: none;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.datatable-footer {
|
|
109
|
+
.MuiTableRow-root.MuiTableRow-footer {
|
|
110
|
+
border: none;
|
|
111
|
+
}
|
|
112
|
+
table.MuiTable-root {
|
|
113
|
+
outline: none;
|
|
114
|
+
overflow: hidden;
|
|
115
|
+
}
|
|
116
|
+
.MuiTablePagination-input {
|
|
117
|
+
background: none;
|
|
118
|
+
}
|
|
119
|
+
div.MuiSelect-select {
|
|
120
|
+
padding: 0 24px 0 0;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
th a,
|
|
125
|
+
td a {
|
|
126
|
+
text-decoration: none;
|
|
127
|
+
display: block;
|
|
128
|
+
color: inherit;
|
|
129
|
+
&:first-of-type {
|
|
130
|
+
padding-left: 0;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
> div {
|
|
135
|
+
overflow: auto;
|
|
136
|
+
}
|
|
137
|
+
.custom-toobar-title-inner {
|
|
138
|
+
display: flex;
|
|
139
|
+
align-items: center;
|
|
140
|
+
}
|
|
141
|
+
@media (max-width: ${({ theme }) => theme.breakpoints.values.md}px) {
|
|
142
|
+
th a,
|
|
143
|
+
td a {
|
|
144
|
+
text-decoration: none;
|
|
145
|
+
display: block;
|
|
146
|
+
color: inherit;
|
|
147
|
+
padding-top: 0;
|
|
148
|
+
padding-bottom: 0;
|
|
149
|
+
padding-right: 0;
|
|
150
|
+
}
|
|
151
|
+
tr.MuiTableRow-root {
|
|
152
|
+
border: none;
|
|
153
|
+
padding: 20px;
|
|
154
|
+
display: block;
|
|
155
|
+
}
|
|
156
|
+
td.MuiTableCell-root:first-of-type {
|
|
157
|
+
padding-left: 0;
|
|
158
|
+
margin-top: 0;
|
|
159
|
+
}
|
|
160
|
+
td.MuiTableCell-root {
|
|
161
|
+
margin: 0;
|
|
162
|
+
margin-top: 8px;
|
|
163
|
+
align-items: center;
|
|
164
|
+
padding: 0;
|
|
165
|
+
flex-wrap: wrap;
|
|
166
|
+
flex-direction: ${({ mobileTDFlexDirection = 'column' }) => mobileTDFlexDirection || 'row'};
|
|
167
|
+
align-items: ${({ mobileTDFlexDirection = 'column' }) => mobileTDFlexDirection === 'column' ? 'flex-start' : 'center'};
|
|
168
|
+
justify-content: ${({ mobileTDFlexDirection = 'column' }) => mobileTDFlexDirection === 'column' ? 'flex-start' : 'space-between'};
|
|
169
|
+
}
|
|
170
|
+
td.MuiTableCell-root > div {
|
|
171
|
+
margin-bottom: 4px;
|
|
172
|
+
}
|
|
173
|
+
.MuiTable-root > .MuiTableBody-root > .MuiTableRow-root > td.MuiTableCell-root {
|
|
174
|
+
display: flex;
|
|
175
|
+
flex-direction: ${({ mobileTDFlexDirection = 'column' }) => mobileTDFlexDirection || 'row'};
|
|
176
|
+
align-items: flex-start;
|
|
177
|
+
justify-content: ${({ mobileTDFlexDirection = 'column' }) => mobileTDFlexDirection === 'row' ? 'space-between' : 'flex-start'};
|
|
178
|
+
flex-wrap: ${({ mobileTDFlexDirection = 'column' }) => (mobileTDFlexDirection === 'row' ? 'nowrap' : 'wrap')};
|
|
179
|
+
word-break: break-all;
|
|
180
|
+
&.datatables-noprint {
|
|
181
|
+
justify-content: center;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
[class*='MUIDataTable-responsiveBase'] tr:not([class*='responsiveSimple']) td.MuiTableCell-body > div {
|
|
185
|
+
width: inherit;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
`;
|
|
189
|
+
export default withLocaleProvider(Table, {
|
|
190
|
+
translations: {
|
|
191
|
+
en: {
|
|
192
|
+
empty: 'No data',
|
|
193
|
+
},
|
|
194
|
+
zh: {
|
|
195
|
+
empty: '暂无数据',
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
});
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { LocaleProvider, useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
3
|
+
export default function withLocaleProvider(C, { translations, fallbackLocale = 'en', }) {
|
|
4
|
+
return ((args) => {
|
|
5
|
+
const { locale } = useLocaleContext();
|
|
6
|
+
return (_jsx(LocaleProvider, { translations: translations, fallbackLocale: fallbackLocale, locale: locale, onLoadingTranslation: undefined, languages: undefined, children: _jsx(C, { ...args }) }));
|
|
7
|
+
});
|
|
8
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { ChatCompletionMessageParam } from 'openai/resources/index';
|
|
3
|
+
export declare const createStatusApi: ({ axios, path }: {
|
|
4
|
+
axios: AxiosInstance;
|
|
5
|
+
path: string;
|
|
6
|
+
}) => (() => Promise<{
|
|
7
|
+
available: boolean;
|
|
8
|
+
}>);
|
|
9
|
+
export interface TextCompletions {
|
|
10
|
+
text?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface TextCompletionOptions {
|
|
13
|
+
model?: string;
|
|
14
|
+
temperature?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface TextCompletionFn<P extends {}> {
|
|
17
|
+
(options: {
|
|
18
|
+
stream: true;
|
|
19
|
+
} & TextCompletionOptions & P): Promise<ReadableStream<Uint8Array>>;
|
|
20
|
+
(options: {
|
|
21
|
+
stream?: boolean;
|
|
22
|
+
} & TextCompletionOptions & P): Promise<TextCompletions>;
|
|
23
|
+
(options: {
|
|
24
|
+
stream?: boolean;
|
|
25
|
+
} & TextCompletionOptions & P): Promise<TextCompletions | ReadableStream<Uint8Array>>;
|
|
26
|
+
}
|
|
27
|
+
export declare const createTextCompletionApi: <P extends {} = {
|
|
28
|
+
prompt: string;
|
|
29
|
+
} | {
|
|
30
|
+
messages: ChatCompletionMessageParam[];
|
|
31
|
+
}>({ fetch, path, timeout, }: {
|
|
32
|
+
fetch: typeof globalThis.fetch;
|
|
33
|
+
path: string;
|
|
34
|
+
timeout?: number;
|
|
35
|
+
}) => TextCompletionFn<P>;
|
|
36
|
+
export interface ImageGenerations<T extends {
|
|
37
|
+
url: string;
|
|
38
|
+
} | {
|
|
39
|
+
b64_json: string;
|
|
40
|
+
}> {
|
|
41
|
+
data: T[];
|
|
42
|
+
}
|
|
43
|
+
export type ImageGenerationSize = '256x256' | '512x512' | '1024x1024' | '1024x1792' | '1792x1024' | '1536x1024' | '1024x1536' | 'auto';
|
|
44
|
+
export interface ImageGenerationFn<P extends {}> {
|
|
45
|
+
(options: P & {
|
|
46
|
+
response_format?: 'url';
|
|
47
|
+
}): Promise<ImageGenerations<{
|
|
48
|
+
url: string;
|
|
49
|
+
}>>;
|
|
50
|
+
(options: P & {
|
|
51
|
+
response_format?: 'b64_json';
|
|
52
|
+
}): Promise<ImageGenerations<{
|
|
53
|
+
b64_json: string;
|
|
54
|
+
}>>;
|
|
55
|
+
(options: P & {
|
|
56
|
+
response_format?: 'url' | 'b64_json';
|
|
57
|
+
}): Promise<ImageGenerations<{
|
|
58
|
+
url: string;
|
|
59
|
+
} | {
|
|
60
|
+
b64_json: string;
|
|
61
|
+
}>>;
|
|
62
|
+
}
|
|
63
|
+
export declare const createImageGenerationApi: <P extends {} = {
|
|
64
|
+
prompt: string;
|
|
65
|
+
size: ImageGenerationSize;
|
|
66
|
+
n: number;
|
|
67
|
+
}>({ axios, path, }: {
|
|
68
|
+
axios: AxiosInstance;
|
|
69
|
+
path: string;
|
|
70
|
+
}) => ImageGenerationFn<P>;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export interface AppStatusResult {
|
|
2
|
+
id: string;
|
|
3
|
+
subscription?: any;
|
|
4
|
+
subscriptionDetailUrl?: string;
|
|
5
|
+
config?: AIKitServiceConfig | null;
|
|
6
|
+
}
|
|
7
|
+
export declare function appStatus(): Promise<AppStatusResult>;
|
|
8
|
+
export interface AIKitServiceConfig {
|
|
9
|
+
useAIKitService?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function appConfig(): Promise<AIKitServiceConfig | null>;
|
|
12
|
+
export declare function setAppConfig(payload: AIKitServiceConfig): Promise<AIKitServiceConfig>;
|
|
13
|
+
export interface AppRegisterResult {
|
|
14
|
+
appId: string;
|
|
15
|
+
paymentLink?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function appServiceRegister(): Promise<AppRegisterResult>;
|
|
18
|
+
export interface AppUsedCreditsResult {
|
|
19
|
+
model: string;
|
|
20
|
+
date: string;
|
|
21
|
+
usedCredits: string;
|
|
22
|
+
promptTokens: number;
|
|
23
|
+
completionTokens: number;
|
|
24
|
+
numberOfImageGeneration: number;
|
|
25
|
+
}
|
|
26
|
+
export declare function appUsedCredits(query: {
|
|
27
|
+
startTime?: string;
|
|
28
|
+
endTime: string;
|
|
29
|
+
}, options?: {
|
|
30
|
+
useAIKitService?: boolean;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
list: AppUsedCreditsResult[];
|
|
33
|
+
}>;
|
|
34
|
+
export declare function unsubscribe(): Promise<void>;
|
|
35
|
+
export declare function getCreditPaymentLink(options?: {
|
|
36
|
+
useAIKitService?: boolean;
|
|
37
|
+
}): Promise<string>;
|
|
38
|
+
export interface CreditBalanceResult {
|
|
39
|
+
balance: string;
|
|
40
|
+
currency: {
|
|
41
|
+
id: string;
|
|
42
|
+
symbol: string;
|
|
43
|
+
name: string;
|
|
44
|
+
decimal: number;
|
|
45
|
+
maximum_precision: number;
|
|
46
|
+
};
|
|
47
|
+
total: string;
|
|
48
|
+
grantCount: number;
|
|
49
|
+
}
|
|
50
|
+
export interface CreditGrant {
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
status: string;
|
|
54
|
+
remainingCredit: number;
|
|
55
|
+
scope: string;
|
|
56
|
+
effectiveDate: string;
|
|
57
|
+
expirationDate?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface CreditGrantsResult {
|
|
60
|
+
creditGrants: {
|
|
61
|
+
data: CreditGrant[];
|
|
62
|
+
pagination: {
|
|
63
|
+
page: number;
|
|
64
|
+
pageSize: number;
|
|
65
|
+
total: number;
|
|
66
|
+
totalPages: number;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export interface CreditTransaction {
|
|
71
|
+
id: string;
|
|
72
|
+
quantity: string;
|
|
73
|
+
credit_amount: string;
|
|
74
|
+
remaining_balance: string;
|
|
75
|
+
description: string;
|
|
76
|
+
created_at: string;
|
|
77
|
+
creditGrant: {
|
|
78
|
+
id: string;
|
|
79
|
+
name: string;
|
|
80
|
+
};
|
|
81
|
+
paymentCurrency: {
|
|
82
|
+
id: string;
|
|
83
|
+
symbol: string;
|
|
84
|
+
decimal: number;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export interface CreditTransactionsResult {
|
|
88
|
+
count: number;
|
|
89
|
+
list: CreditTransaction[];
|
|
90
|
+
paging: {
|
|
91
|
+
page: number;
|
|
92
|
+
pageSize: number;
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export declare function getCreditBalance(options?: {
|
|
96
|
+
useAIKitService?: boolean;
|
|
97
|
+
}): Promise<CreditBalanceResult>;
|
|
98
|
+
export declare function getCreditGrants(params?: {
|
|
99
|
+
page?: number;
|
|
100
|
+
pageSize?: number;
|
|
101
|
+
start?: number;
|
|
102
|
+
end?: number;
|
|
103
|
+
}, options?: {
|
|
104
|
+
useAIKitService?: boolean;
|
|
105
|
+
}): Promise<CreditGrantsResult>;
|
|
106
|
+
export declare function getCreditTransactions(params?: {
|
|
107
|
+
page?: number;
|
|
108
|
+
pageSize?: number;
|
|
109
|
+
start?: number;
|
|
110
|
+
end?: number;
|
|
111
|
+
}, options?: {
|
|
112
|
+
useAIKitService?: boolean;
|
|
113
|
+
}): Promise<CreditTransactionsResult>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { IncomingMessage } from 'http';
|
|
2
|
+
import { TSubscriptionExpanded } from '@blocklet/payment-js';
|
|
3
|
+
import { AxiosResponse } from 'axios';
|
|
4
|
+
export interface AppStatusResult {
|
|
5
|
+
id: string;
|
|
6
|
+
subscription?: TSubscriptionExpanded;
|
|
7
|
+
}
|
|
8
|
+
export declare function appStatus({ description }: {
|
|
9
|
+
description?: string;
|
|
10
|
+
}, options?: {
|
|
11
|
+
useAIKitService?: boolean;
|
|
12
|
+
responseType?: undefined;
|
|
13
|
+
}): Promise<AppStatusResult | null>;
|
|
14
|
+
export declare function appStatus({ description }: {
|
|
15
|
+
description?: string;
|
|
16
|
+
}, options: {
|
|
17
|
+
useAIKitService?: boolean;
|
|
18
|
+
responseType: 'stream';
|
|
19
|
+
}): Promise<AxiosResponse<IncomingMessage, any>>;
|
|
20
|
+
export interface RegisterPayload {
|
|
21
|
+
publicKey: string;
|
|
22
|
+
}
|
|
23
|
+
export interface RegisterResult {
|
|
24
|
+
appId: string;
|
|
25
|
+
paymentLink?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function appRegister(payload: RegisterPayload, options?: {
|
|
28
|
+
useAIKitService?: boolean;
|
|
29
|
+
responseType?: undefined;
|
|
30
|
+
}): Promise<RegisterResult>;
|
|
31
|
+
export declare function appRegister(payload: RegisterPayload, options: {
|
|
32
|
+
useAIKitService?: boolean;
|
|
33
|
+
responseType: 'stream';
|
|
34
|
+
}): Promise<AxiosResponse<IncomingMessage, any>>;
|
|
35
|
+
export declare function cancelSubscription(options?: {
|
|
36
|
+
useAIKitService?: boolean;
|
|
37
|
+
responseType?: undefined;
|
|
38
|
+
}): Promise<null>;
|
|
39
|
+
export declare function cancelSubscription(options: {
|
|
40
|
+
useAIKitService?: boolean;
|
|
41
|
+
responseType: 'stream';
|
|
42
|
+
}): Promise<AxiosResponse<IncomingMessage, any>>;
|
|
43
|
+
export declare function recoverSubscription(options?: {
|
|
44
|
+
useAIKitService?: boolean;
|
|
45
|
+
responseType?: undefined;
|
|
46
|
+
}): Promise<null>;
|
|
47
|
+
export declare function recoverSubscription(options: {
|
|
48
|
+
useAIKitService?: boolean;
|
|
49
|
+
responseType: 'stream';
|
|
50
|
+
}): Promise<AxiosResponse<IncomingMessage, any>>;
|