@blocklet/aigne-hub 0.2.12 → 0.2.14
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/lib/cjs/api/call/proxy.js +5 -4
- package/lib/cjs/api/error.js +4 -2
- package/lib/cjs/components/conversation/conversation.js +4 -2
- package/lib/cjs/components/conversation/use-conversation.js +1 -1
- package/lib/esm/api/call/proxy.js +2 -1
- package/lib/esm/api/error.js +4 -2
- package/lib/esm/components/conversation/conversation.js +4 -2
- package/lib/esm/components/conversation/use-conversation.js +1 -1
- package/lib/types/api/error.d.ts +3 -1
- package/lib/types/components/conversation/use-conversation.d.ts +1 -1
- package/package.json +3 -3
|
@@ -8,7 +8,8 @@ const http_1 = __importDefault(require("http"));
|
|
|
8
8
|
const https_1 = __importDefault(require("https"));
|
|
9
9
|
const component_1 = require("@blocklet/sdk/lib/component");
|
|
10
10
|
const verify_sign_1 = require("@blocklet/sdk/lib/util/verify-sign");
|
|
11
|
-
const
|
|
11
|
+
const isNil_1 = __importDefault(require("lodash/isNil"));
|
|
12
|
+
const pick_1 = __importDefault(require("lodash/pick"));
|
|
12
13
|
const ufo_1 = require("ufo");
|
|
13
14
|
const constants_1 = require("../constants");
|
|
14
15
|
const auth_1 = require("../utils/auth");
|
|
@@ -20,7 +21,7 @@ function proxyToAIKit(path, { useAIKitService, proxyReqHeaders = ['accept', 'con
|
|
|
20
21
|
const userDid = ((_a = req.user) === null || _a === void 0 ? void 0 : _a.did) || (req === null || req === void 0 ? void 0 : req.get('x-app-user-did'));
|
|
21
22
|
const proxyReq = (url.protocol === 'https:' ? https_1.default : http_1.default).request((0, ufo_1.stringifyParsedURL)(url), {
|
|
22
23
|
headers: {
|
|
23
|
-
...(0,
|
|
24
|
+
...(0, pick_1.default)(req.headers, ...proxyReqHeaders),
|
|
24
25
|
...(useAIKitService
|
|
25
26
|
? (0, auth_1.getRemoteComponentCallHeaders)(req.body || {}, userDid)
|
|
26
27
|
: (() => {
|
|
@@ -43,8 +44,8 @@ function proxyToAIKit(path, { useAIKitService, proxyReqHeaders = ['accept', 'con
|
|
|
43
44
|
if (proxyRes.statusCode)
|
|
44
45
|
res.status(proxyRes.statusCode);
|
|
45
46
|
res.setHeader('X-Accel-Buffering', 'no');
|
|
46
|
-
for (const [k, v] of Object.entries((0,
|
|
47
|
-
if (!(0,
|
|
47
|
+
for (const [k, v] of Object.entries((0, pick_1.default)(proxyRes.headers, ...proxyResHeaders))) {
|
|
48
|
+
if (!(0, isNil_1.default)(v))
|
|
48
49
|
res.setHeader(k, v);
|
|
49
50
|
}
|
|
50
51
|
proxyRes.pipe(res);
|
package/lib/cjs/api/error.js
CHANGED
|
@@ -29,14 +29,16 @@ const CreditErrors = {
|
|
|
29
29
|
[CreditErrorType.UNKNOWN]: 'An unknown error occurred',
|
|
30
30
|
};
|
|
31
31
|
class CreditError extends Error {
|
|
32
|
-
constructor(type, link) {
|
|
32
|
+
constructor(statusCode, type, link) {
|
|
33
33
|
let message = CreditErrors[type] || CreditErrors[CreditErrorType.UNKNOWN];
|
|
34
34
|
if (type === CreditErrorType.NOT_ENOUGH && link) {
|
|
35
|
-
message += `\n
|
|
35
|
+
message += `\n${link}`;
|
|
36
36
|
}
|
|
37
37
|
super(message);
|
|
38
38
|
this.timestamp = new Date().toISOString();
|
|
39
39
|
this.type = type;
|
|
40
|
+
this.statusCode = statusCode || 500;
|
|
41
|
+
this.link = link;
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
exports.CreditError = CreditError;
|
|
@@ -8,8 +8,8 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
8
8
|
const material_1 = require("@mui/material");
|
|
9
9
|
const isNil_1 = __importDefault(require("lodash/isNil"));
|
|
10
10
|
const react_1 = require("react");
|
|
11
|
+
const alert_1 = __importDefault(require("../credit/alert"));
|
|
11
12
|
const image_preview_1 = __importDefault(require("../image-preview"));
|
|
12
|
-
const alert_1 = __importDefault(require("../subscribe/alert"));
|
|
13
13
|
const message_1 = __importDefault(require("./message"));
|
|
14
14
|
const prompt_1 = __importDefault(require("./prompt"));
|
|
15
15
|
function Conversation({ ref, messages, onSubmit, customActions = () => [], renderAvatar = undefined, maxWidth = 1000, scrollContainer = undefined, promptProps = {}, ...props }) {
|
|
@@ -32,7 +32,9 @@ function Conversation({ ref, messages, onSubmit, customActions = () => [], rende
|
|
|
32
32
|
src: url,
|
|
33
33
|
onLoad: () => scrollToBottom(),
|
|
34
34
|
};
|
|
35
|
-
}) })), msg.error ? (
|
|
35
|
+
}) })), msg.error ? (
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
(0, jsx_runtime_1.jsx)(alert_1.default, { error: msg.error })) : (msg.loading &&
|
|
36
38
|
!msg.response && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
37
39
|
minHeight: 24,
|
|
38
40
|
display: 'flex',
|
|
@@ -2,7 +2,8 @@ import http from 'http';
|
|
|
2
2
|
import https from 'https';
|
|
3
3
|
import { getComponentWebEndpoint } from '@blocklet/sdk/lib/component';
|
|
4
4
|
import { getSignData } from '@blocklet/sdk/lib/util/verify-sign';
|
|
5
|
-
import
|
|
5
|
+
import isNil from 'lodash/isNil';
|
|
6
|
+
import pick from 'lodash/pick';
|
|
6
7
|
import { joinURL, parseURL, stringifyParsedURL, withQuery } from 'ufo';
|
|
7
8
|
import { AI_KIT_BASE_URL } from '../constants';
|
|
8
9
|
import { getRemoteComponentCallHeaders } from '../utils/auth';
|
package/lib/esm/api/error.js
CHANGED
|
@@ -25,14 +25,16 @@ const CreditErrors = {
|
|
|
25
25
|
[CreditErrorType.UNKNOWN]: 'An unknown error occurred',
|
|
26
26
|
};
|
|
27
27
|
export class CreditError extends Error {
|
|
28
|
-
constructor(type, link) {
|
|
28
|
+
constructor(statusCode, type, link) {
|
|
29
29
|
let message = CreditErrors[type] || CreditErrors[CreditErrorType.UNKNOWN];
|
|
30
30
|
if (type === CreditErrorType.NOT_ENOUGH && link) {
|
|
31
|
-
message += `\n
|
|
31
|
+
message += `\n${link}`;
|
|
32
32
|
}
|
|
33
33
|
super(message);
|
|
34
34
|
this.timestamp = new Date().toISOString();
|
|
35
35
|
this.type = type;
|
|
36
|
+
this.statusCode = statusCode || 500;
|
|
37
|
+
this.link = link;
|
|
36
38
|
}
|
|
37
39
|
}
|
|
38
40
|
export class StatusCodeError extends Error {
|
|
@@ -2,8 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { Avatar, Box, CircularProgress } from '@mui/material';
|
|
3
3
|
import isNil from 'lodash/isNil';
|
|
4
4
|
import { useCallback, useEffect, useImperativeHandle, useRef } from 'react';
|
|
5
|
+
import CreditErrorAlert from '../credit/alert';
|
|
5
6
|
import ImagePreview from '../image-preview';
|
|
6
|
-
import SubscribeErrorAlert from '../subscribe/alert';
|
|
7
7
|
import Message from './message';
|
|
8
8
|
import Prompt from './prompt';
|
|
9
9
|
export default function Conversation({ ref, messages, onSubmit, customActions = () => [], renderAvatar = undefined, maxWidth = 1000, scrollContainer = undefined, promptProps = {}, ...props }) {
|
|
@@ -26,7 +26,9 @@ export default function Conversation({ ref, messages, onSubmit, customActions =
|
|
|
26
26
|
src: url,
|
|
27
27
|
onLoad: () => scrollToBottom(),
|
|
28
28
|
};
|
|
29
|
-
}) })), msg.error ? (
|
|
29
|
+
}) })), msg.error ? (
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
_jsx(CreditErrorAlert, { error: msg.error })) : (msg.loading &&
|
|
30
32
|
!msg.response && (_jsx(Box, { sx: {
|
|
31
33
|
minHeight: 24,
|
|
32
34
|
display: 'flex',
|
package/lib/types/api/error.d.ts
CHANGED
|
@@ -14,7 +14,9 @@ export declare class SubscriptionError extends Error {
|
|
|
14
14
|
export declare class CreditError extends Error {
|
|
15
15
|
timestamp: string;
|
|
16
16
|
type: CreditErrorType;
|
|
17
|
-
|
|
17
|
+
statusCode: number;
|
|
18
|
+
link?: string;
|
|
19
|
+
constructor(statusCode: number, type: CreditErrorType, link?: string);
|
|
18
20
|
}
|
|
19
21
|
export declare class StatusCodeError extends Error {
|
|
20
22
|
statusCode: number;
|
|
@@ -38,7 +38,7 @@ export default function useConversation({ scrollToBottom, textCompletions, image
|
|
|
38
38
|
url: string;
|
|
39
39
|
}[];
|
|
40
40
|
data?: undefined;
|
|
41
|
-
}>;
|
|
41
|
+
} | null>;
|
|
42
42
|
cancel: ({ id }: Pick<MessageItem, "id">) => void;
|
|
43
43
|
setMessages: import("react").Dispatch<import("react").SetStateAction<MessageItem[]>>;
|
|
44
44
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/aigne-hub",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
4
4
|
"description": "The react.js component library for AIGNE Hub",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
86
|
"@arcblock/did": "^1.21.0",
|
|
87
|
-
"@arcblock/ux": "^3.0.
|
|
87
|
+
"@arcblock/ux": "^3.0.33",
|
|
88
88
|
"@blocklet/logger": "^1.16.46",
|
|
89
|
-
"@blocklet/payment-js": "^1.19.
|
|
89
|
+
"@blocklet/payment-js": "^1.19.6",
|
|
90
90
|
"@blocklet/sdk": "^1.16.46",
|
|
91
91
|
"@emotion/css": "^11.13.5",
|
|
92
92
|
"@emotion/react": "^11.14.0",
|