@blocklet/pages-kit 0.2.286 → 0.2.288
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/builtin/async/ai-runtime/api/assistant.js +26 -0
- package/lib/cjs/builtin/async/ai-runtime/api/dataset.js +127 -0
- package/lib/cjs/builtin/async/ai-runtime/api/message.js +33 -0
- package/lib/cjs/builtin/async/ai-runtime/api/request.js +55 -0
- package/lib/cjs/builtin/async/ai-runtime/api/session.js +121 -0
- package/lib/cjs/builtin/async/ai-runtime/api/subscription.js +32 -0
- package/lib/cjs/builtin/async/ai-runtime/components/ActionButton.js +63 -0
- package/lib/cjs/builtin/async/ai-runtime/components/GlobalLoading.js +24 -0
- package/lib/cjs/builtin/async/ai-runtime/components/LoadingButton.js +40 -0
- package/lib/cjs/builtin/async/ai-runtime/components/LoadingListItemButton.js +49 -0
- package/lib/cjs/builtin/async/ai-runtime/components/MarkdownRenderer.js +156 -0
- package/lib/cjs/builtin/async/ai-runtime/components/MenuButton.js +43 -0
- package/lib/cjs/builtin/async/ai-runtime/components/PoweredBy.js +30 -0
- package/lib/cjs/builtin/async/ai-runtime/components/RuntimeProvider.js +22 -0
- package/lib/cjs/builtin/async/ai-runtime/components/ScrollView.js +109 -0
- package/lib/cjs/builtin/async/ai-runtime/components/SocialShare.js +102 -0
- package/lib/cjs/builtin/async/ai-runtime/components/ThemeProvider.js +193 -0
- package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +92 -0
- package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionListView.js +197 -0
- package/lib/cjs/builtin/async/ai-runtime/components/collection/CollectionView.js +122 -0
- package/lib/cjs/builtin/async/ai-runtime/components/collection/DocumentListView.js +152 -0
- package/lib/cjs/builtin/async/ai-runtime/components/collection/DocumentView.js +135 -0
- package/lib/cjs/builtin/async/ai-runtime/components/common/ChatBot.js +104 -0
- package/lib/cjs/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.js +21 -0
- package/lib/cjs/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.js +35 -0
- package/lib/cjs/builtin/async/ai-runtime/components/common/index.js +12 -0
- package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterForm.js +89 -0
- package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +66 -0
- package/lib/cjs/builtin/async/ai-runtime/components/form/ParameterFormFields.js +57 -0
- package/lib/cjs/builtin/async/ai-runtime/components/form/QuestionField.js +44 -0
- package/lib/cjs/builtin/async/ai-runtime/components/form/SettingButton.js +81 -0
- package/lib/cjs/builtin/async/ai-runtime/components/lottie/index.js +34 -0
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageActions.js +38 -0
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageErrorView.js +30 -0
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageItemView.js +129 -0
- package/lib/cjs/builtin/async/ai-runtime/components/message/MessageListView.js +47 -0
- package/lib/cjs/builtin/async/ai-runtime/components/message/ReferenceLinks.js +11 -0
- package/lib/cjs/builtin/async/ai-runtime/components/parameters/LanguageField.js +55 -0
- package/lib/cjs/builtin/async/ai-runtime/components/parameters/NumberField.js +21 -0
- package/lib/cjs/builtin/async/ai-runtime/components/parameters/SelectField.js +24 -0
- package/lib/cjs/builtin/async/ai-runtime/components/parameters/StringField.js +21 -0
- package/lib/cjs/builtin/async/ai-runtime/components/parameters/index.js +37 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +111 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +60 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +52 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-chat/index.js +28 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +120 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +22 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +72 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.js +31 -0
- package/lib/cjs/builtin/async/ai-runtime/components/runtime-form/index.js +22 -0
- package/lib/cjs/builtin/async/ai-runtime/components/session/CheckSession.js +65 -0
- package/lib/cjs/builtin/async/ai-runtime/components/session/SessionListView.js +88 -0
- package/lib/cjs/builtin/async/ai-runtime/constants.js +5 -0
- package/lib/cjs/builtin/async/ai-runtime/error.js +10 -0
- package/lib/cjs/builtin/async/ai-runtime/hooks/header.js +32 -0
- package/lib/cjs/builtin/async/ai-runtime/hooks/navigate.js +38 -0
- package/lib/cjs/builtin/async/ai-runtime/hooks/subscribe.js +35 -0
- package/lib/cjs/builtin/async/ai-runtime/hooks/useAsync.js +32 -0
- package/lib/cjs/builtin/async/ai-runtime/index.js +81 -0
- package/lib/cjs/builtin/async/ai-runtime/locales/index.js +147 -0
- package/lib/cjs/builtin/async/ai-runtime/state/assistant.js +59 -0
- package/lib/cjs/builtin/async/ai-runtime/state/index.js +423 -0
- package/lib/cjs/builtin/async/ai-runtime/state/loading.js +39 -0
- package/lib/cjs/builtin/async/ai-runtime/state/session.js +217 -0
- package/lib/cjs/builtin/async/ai-runtime/state/subscription.js +52 -0
- package/lib/cjs/builtin/async/ai-runtime/utils.js +49 -0
- package/lib/cjs/builtin/async/react-scroll-to-bottom.js +1 -1
- package/lib/cjs/utils/builtin.js +1 -0
- package/lib/cjs/utils/inject-global-components.js +2 -0
- package/lib/esm/builtin/async/ai-runtime/api/assistant.js +22 -0
- package/lib/esm/builtin/async/ai-runtime/api/dataset.js +113 -0
- package/lib/esm/builtin/async/ai-runtime/api/message.js +28 -0
- package/lib/esm/builtin/async/ai-runtime/api/request.js +51 -0
- package/lib/esm/builtin/async/ai-runtime/api/session.js +112 -0
- package/lib/esm/builtin/async/ai-runtime/api/subscription.js +27 -0
- package/lib/esm/builtin/async/ai-runtime/components/ActionButton.js +56 -0
- package/lib/esm/builtin/async/ai-runtime/components/GlobalLoading.js +21 -0
- package/lib/esm/builtin/async/ai-runtime/components/LoadingButton.js +38 -0
- package/lib/esm/builtin/async/ai-runtime/components/LoadingListItemButton.js +46 -0
- package/lib/esm/builtin/async/ai-runtime/components/MarkdownRenderer.js +129 -0
- package/lib/esm/builtin/async/ai-runtime/components/MenuButton.js +40 -0
- package/lib/esm/builtin/async/ai-runtime/components/PoweredBy.js +27 -0
- package/lib/esm/builtin/async/ai-runtime/components/RuntimeProvider.js +16 -0
- package/lib/esm/builtin/async/ai-runtime/components/ScrollView.js +101 -0
- package/lib/esm/builtin/async/ai-runtime/components/SocialShare.js +93 -0
- package/lib/esm/builtin/async/ai-runtime/components/ThemeProvider.js +190 -0
- package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionEditDialog.js +92 -0
- package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionListView.js +197 -0
- package/lib/esm/builtin/async/ai-runtime/components/collection/CollectionView.js +122 -0
- package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentListView.js +152 -0
- package/lib/esm/builtin/async/ai-runtime/components/collection/DocumentView.js +135 -0
- package/lib/esm/builtin/async/ai-runtime/components/common/ChatBot.js +98 -0
- package/lib/esm/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.js +15 -0
- package/lib/esm/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.js +30 -0
- package/lib/esm/builtin/async/ai-runtime/components/common/index.js +3 -0
- package/lib/esm/builtin/async/ai-runtime/components/form/ParameterForm.js +60 -0
- package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormDialog.js +59 -0
- package/lib/esm/builtin/async/ai-runtime/components/form/ParameterFormFields.js +50 -0
- package/lib/esm/builtin/async/ai-runtime/components/form/QuestionField.js +38 -0
- package/lib/esm/builtin/async/ai-runtime/components/form/SettingButton.js +75 -0
- package/lib/esm/builtin/async/ai-runtime/components/lottie/index.js +8 -0
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageActions.js +35 -0
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageErrorView.js +24 -0
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageItemView.js +100 -0
- package/lib/esm/builtin/async/ai-runtime/components/message/MessageListView.js +41 -0
- package/lib/esm/builtin/async/ai-runtime/components/message/ReferenceLinks.js +8 -0
- package/lib/esm/builtin/async/ai-runtime/components/parameters/LanguageField.js +53 -0
- package/lib/esm/builtin/async/ai-runtime/components/parameters/NumberField.js +19 -0
- package/lib/esm/builtin/async/ai-runtime/components/parameters/SelectField.js +22 -0
- package/lib/esm/builtin/async/ai-runtime/components/parameters/StringField.js +19 -0
- package/lib/esm/builtin/async/ai-runtime/components/parameters/index.js +31 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/InitialForm.js +103 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.js +34 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.js +46 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-chat/index.js +22 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.js +114 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.js +19 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.js +66 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.js +25 -0
- package/lib/esm/builtin/async/ai-runtime/components/runtime-form/index.js +16 -0
- package/lib/esm/builtin/async/ai-runtime/components/session/CheckSession.js +59 -0
- package/lib/esm/builtin/async/ai-runtime/components/session/SessionListView.js +88 -0
- package/lib/esm/builtin/async/ai-runtime/constants.js +2 -0
- package/lib/esm/builtin/async/ai-runtime/error.js +6 -0
- package/lib/esm/builtin/async/ai-runtime/hooks/header.js +25 -0
- package/lib/esm/builtin/async/ai-runtime/hooks/navigate.js +32 -0
- package/lib/esm/builtin/async/ai-runtime/hooks/subscribe.js +31 -0
- package/lib/esm/builtin/async/ai-runtime/hooks/useAsync.js +29 -0
- package/lib/esm/builtin/async/ai-runtime/index.js +72 -0
- package/lib/esm/builtin/async/ai-runtime/locales/index.js +144 -0
- package/lib/esm/builtin/async/ai-runtime/state/assistant.js +54 -0
- package/lib/esm/builtin/async/ai-runtime/state/index.js +423 -0
- package/lib/esm/builtin/async/ai-runtime/state/loading.js +36 -0
- package/lib/esm/builtin/async/ai-runtime/state/session.js +209 -0
- package/lib/esm/builtin/async/ai-runtime/state/subscription.js +47 -0
- package/lib/esm/builtin/async/ai-runtime/utils.js +42 -0
- package/lib/esm/builtin/async/react-scroll-to-bottom.js +1 -1
- package/lib/esm/utils/builtin.js +1 -0
- package/lib/esm/utils/inject-global-components.js +2 -0
- package/lib/types/builtin/async/ai-runtime/api/assistant.d.ts +18 -0
- package/lib/types/builtin/async/ai-runtime/api/dataset.d.ts +39 -0
- package/lib/types/builtin/async/ai-runtime/api/message.d.ts +39 -0
- package/lib/types/builtin/async/ai-runtime/api/request.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/api/session.d.ts +54 -0
- package/lib/types/builtin/async/ai-runtime/api/subscription.d.ts +15 -0
- package/lib/types/builtin/async/ai-runtime/components/ActionButton.d.ts +11 -0
- package/lib/types/builtin/async/ai-runtime/components/GlobalLoading.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/components/LoadingButton.d.ts +3 -0
- package/lib/types/builtin/async/ai-runtime/components/LoadingListItemButton.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/components/MarkdownRenderer.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/components/MenuButton.d.ts +9 -0
- package/lib/types/builtin/async/ai-runtime/components/PoweredBy.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/RuntimeProvider.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/ScrollView.d.ts +61 -0
- package/lib/types/builtin/async/ai-runtime/components/SocialShare.d.ts +17 -0
- package/lib/types/builtin/async/ai-runtime/components/ThemeProvider.d.ts +6 -0
- package/lib/types/builtin/async/ai-runtime/components/collection/CollectionEditDialog.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/components/collection/CollectionListView.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/components/collection/CollectionView.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/components/collection/DocumentListView.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/components/collection/DocumentView.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/components/common/ChatBot.d.ts +13 -0
- package/lib/types/builtin/async/ai-runtime/components/common/MessageMetadataRenderer.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/common/MessageSuggestedQuestions.d.ts +7 -0
- package/lib/types/builtin/async/ai-runtime/components/common/index.d.ts +3 -0
- package/lib/types/builtin/async/ai-runtime/components/form/ParameterForm.d.ts +12 -0
- package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormDialog.d.ts +28 -0
- package/lib/types/builtin/async/ai-runtime/components/form/ParameterFormFields.d.ts +11 -0
- package/lib/types/builtin/async/ai-runtime/components/form/QuestionField.d.ts +13 -0
- package/lib/types/builtin/async/ai-runtime/components/form/SettingButton.d.ts +6 -0
- package/lib/types/builtin/async/ai-runtime/components/lottie/index.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/message/MessageActions.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/message/MessageErrorView.d.ts +6 -0
- package/lib/types/builtin/async/ai-runtime/components/message/MessageItemView.d.ts +8 -0
- package/lib/types/builtin/async/ai-runtime/components/message/MessageListView.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/components/message/ReferenceLinks.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/parameters/LanguageField.d.ts +9 -0
- package/lib/types/builtin/async/ai-runtime/components/parameters/NumberField.d.ts +9 -0
- package/lib/types/builtin/async/ai-runtime/components/parameters/SelectField.d.ts +9 -0
- package/lib/types/builtin/async/ai-runtime/components/parameters/StringField.d.ts +9 -0
- package/lib/types/builtin/async/ai-runtime/components/parameters/index.d.ts +7 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/InitialForm.d.ts +10 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatHeader.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/RuntimeChatSession.d.ts +6 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-chat/index.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormForms.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormHeader.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormResult.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/RuntimeFormSubmit.d.ts +5 -0
- package/lib/types/builtin/async/ai-runtime/components/runtime-form/index.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/components/session/CheckSession.d.ts +8 -0
- package/lib/types/builtin/async/ai-runtime/components/session/SessionListView.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/constants.d.ts +2 -0
- package/lib/types/builtin/async/ai-runtime/error.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/hooks/header.d.ts +4 -0
- package/lib/types/builtin/async/ai-runtime/hooks/navigate.d.ts +25 -0
- package/lib/types/builtin/async/ai-runtime/hooks/subscribe.d.ts +6 -0
- package/lib/types/builtin/async/ai-runtime/hooks/useAsync.d.ts +1 -0
- package/lib/types/builtin/async/ai-runtime/index.d.ts +17 -0
- package/lib/types/builtin/async/ai-runtime/locales/index.d.ts +126 -0
- package/lib/types/builtin/async/ai-runtime/state/assistant.d.ts +17 -0
- package/lib/types/builtin/async/ai-runtime/state/index.d.ts +0 -0
- package/lib/types/builtin/async/ai-runtime/state/loading.d.ts +10 -0
- package/lib/types/builtin/async/ai-runtime/state/session.d.ts +40 -0
- package/lib/types/builtin/async/ai-runtime/state/subscription.d.ts +15 -0
- package/lib/types/builtin/async/ai-runtime/utils.d.ts +20 -0
- package/lib/types/builtin/async/react-scroll-to-bottom.d.ts +3 -2
- package/lib/types/builtin/page/header.d.ts +1 -6
- package/lib/types/builtin/session.d.ts +11 -1
- package/lib/types/components/CustomComponentRenderer/state.d.ts +1 -116
- package/lib/types/utils/builtin.d.ts +1 -0
- package/package.json +14 -9
- package/tsconfig.json +5 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.useSubscriptionState = exports.createAssistantState = void 0;
|
|
13
|
+
const zustand_1 = require("zustand");
|
|
14
|
+
const immer_1 = require("zustand/middleware/immer");
|
|
15
|
+
const subscription_1 = require("../api/subscription");
|
|
16
|
+
const STATES = {};
|
|
17
|
+
const createAssistantState = ({ aid }) => {
|
|
18
|
+
var _a;
|
|
19
|
+
(_a = STATES[aid]) !== null && _a !== void 0 ? _a : (STATES[aid] = (0, zustand_1.create)()((0, immer_1.immer)((set) => ({
|
|
20
|
+
load: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
set((state) => {
|
|
22
|
+
state.loading = true;
|
|
23
|
+
});
|
|
24
|
+
try {
|
|
25
|
+
const [{ subscription }, release] = yield Promise.all([(0, subscription_1.getSubscription)({ aid }), (0, subscription_1.getRelease)({ aid })]);
|
|
26
|
+
set((state) => {
|
|
27
|
+
state.subscription = subscription;
|
|
28
|
+
state.release = release;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
set((state) => {
|
|
33
|
+
state.loading = false;
|
|
34
|
+
state.loaded = true;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}),
|
|
38
|
+
}))));
|
|
39
|
+
return STATES[aid];
|
|
40
|
+
};
|
|
41
|
+
exports.createAssistantState = createAssistantState;
|
|
42
|
+
const LOADING_TASKS = {};
|
|
43
|
+
function useSubscriptionState({ aid }) {
|
|
44
|
+
var _a;
|
|
45
|
+
const state = (0, exports.createAssistantState)({ aid })();
|
|
46
|
+
if (!state.loaded && !state.subscription) {
|
|
47
|
+
(_a = LOADING_TASKS[aid]) !== null && _a !== void 0 ? _a : (LOADING_TASKS[aid] = state.load());
|
|
48
|
+
throw LOADING_TASKS[aid];
|
|
49
|
+
}
|
|
50
|
+
return [state.subscription, state];
|
|
51
|
+
}
|
|
52
|
+
exports.useSubscriptionState = useSubscriptionState;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeSx = exports.deepMerge = exports.stringifyIdentity = exports.parseIdentity = void 0;
|
|
4
|
+
const js_base64_1 = require("js-base64");
|
|
5
|
+
function parseIdentity(aid, options) {
|
|
6
|
+
let projectId;
|
|
7
|
+
let projectRef;
|
|
8
|
+
let assistantId;
|
|
9
|
+
try {
|
|
10
|
+
const s = js_base64_1.Base64.decode(aid).split('/');
|
|
11
|
+
[projectId, projectRef, assistantId] = s.length === 3 ? s : s.length === 2 ? [s[0], 'main', s[1]] : [];
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
console.error('parse assistantId error', { error });
|
|
15
|
+
}
|
|
16
|
+
if (projectId && projectRef && assistantId)
|
|
17
|
+
return { projectId, projectRef, assistantId };
|
|
18
|
+
if (options === null || options === void 0 ? void 0 : options.rejectWhenError)
|
|
19
|
+
throw new Error(`Invalid assistant identity ${aid}`);
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
exports.parseIdentity = parseIdentity;
|
|
23
|
+
function stringifyIdentity({ projectId, projectRef, assistantId, }) {
|
|
24
|
+
return js_base64_1.Base64.encodeURI([projectId, projectRef, assistantId].join('/'));
|
|
25
|
+
}
|
|
26
|
+
exports.stringifyIdentity = stringifyIdentity;
|
|
27
|
+
function isObject(obj) {
|
|
28
|
+
return typeof obj === 'object' && !Array.isArray(obj);
|
|
29
|
+
}
|
|
30
|
+
function deepMerge(target, source) {
|
|
31
|
+
if (isObject(target) && isObject(source)) {
|
|
32
|
+
for (const key of Object.keys(source)) {
|
|
33
|
+
if (isObject(source[key])) {
|
|
34
|
+
if (!target[key] || !isObject(target[key]))
|
|
35
|
+
target[key] = source[key];
|
|
36
|
+
deepMerge(target[key], source[key]);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
target[key] = source[key];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.deepMerge = deepMerge;
|
|
45
|
+
const mergeSx = (initial, sx) => {
|
|
46
|
+
const mergedSx = [initial, ...(Array.isArray(sx) ? sx : [sx])];
|
|
47
|
+
return mergedSx;
|
|
48
|
+
};
|
|
49
|
+
exports.mergeSx = mergeSx;
|
|
@@ -29,4 +29,4 @@ exports.default = () => Promise.all([
|
|
|
29
29
|
? // @ts-ignore
|
|
30
30
|
Promise.resolve().then(() => __importStar(require('react-scroll-to-bottom/lib/esm/hooks/internal/useInternalContext'))) : // @ts-ignore
|
|
31
31
|
Promise.resolve().then(() => __importStar(require('react-scroll-to-bottom/lib/hooks/internal/useInternalContext'))),
|
|
32
|
-
]).then(([mod, { default: useInternalContext }]) => (Object.assign(Object.assign({}, mod), { useInternalContext })));
|
|
32
|
+
]).then(([mod, { default: useInternalContext }]) => (Object.assign(Object.assign({}, mod), { Composer: mod.Composer, useInternalContext })));
|
package/lib/cjs/utils/builtin.js
CHANGED
|
@@ -69,4 +69,5 @@ exports.BuiltinModules = {
|
|
|
69
69
|
'@blocklet/pages-kit/builtin/async/react-markdown': {},
|
|
70
70
|
'@blocklet/pages-kit/builtin/async/react-syntax-highlighter': {},
|
|
71
71
|
'@blocklet/pages-kit/builtin/async/image-preview': {},
|
|
72
|
+
'@blocklet/pages-kit/builtin/async/ai-runtime': {},
|
|
72
73
|
};
|
|
@@ -24,6 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const arcblockUx = __importStar(require("../builtin/arcblock/ux"));
|
|
27
|
+
const aiRuntime = __importStar(require("../builtin/async/ai-runtime"));
|
|
27
28
|
const imagePreview = __importStar(require("../builtin/async/image-preview"));
|
|
28
29
|
const reactMarkdown = __importStar(require("../builtin/async/react-markdown"));
|
|
29
30
|
const reactScrollToBottom = __importStar(require("../builtin/async/react-scroll-to-bottom"));
|
|
@@ -75,6 +76,7 @@ function injectGlobalComponents() {
|
|
|
75
76
|
'@blocklet/pages-kit/builtin/async/react-markdown': reactMarkdown,
|
|
76
77
|
'@blocklet/pages-kit/builtin/async/react-syntax-highlighter': reactSyntaxHighlighter,
|
|
77
78
|
'@blocklet/pages-kit/builtin/async/image-preview': imagePreview,
|
|
79
|
+
'@blocklet/pages-kit/builtin/async/ai-runtime': aiRuntime,
|
|
78
80
|
},
|
|
79
81
|
require(module) {
|
|
80
82
|
return win[builtin_1.BuiltinModulesGlobalVariableName].modules[module];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { joinURL } from 'ufo';
|
|
11
|
+
import { getComponentMountPoint } from '../../../utils';
|
|
12
|
+
import { AI_STUDIO_DID } from '../constants';
|
|
13
|
+
import { parseIdentity } from '../utils';
|
|
14
|
+
import { request } from './request';
|
|
15
|
+
export function getAssistant(_a) {
|
|
16
|
+
return __awaiter(this, arguments, void 0, function* ({ assistantId: id }) {
|
|
17
|
+
const { projectId, projectRef, assistantId } = parseIdentity(id, { rejectWhenError: true });
|
|
18
|
+
return request({
|
|
19
|
+
url: joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/projects', projectId, 'refs', projectRef, 'assistants', assistantId),
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { joinURL, withQuery } from 'ufo';
|
|
11
|
+
import { getComponentMountPoint } from '../../../utils';
|
|
12
|
+
import { AI_STUDIO_DID } from '../constants';
|
|
13
|
+
import { request } from './request';
|
|
14
|
+
export function getDataset(_a) {
|
|
15
|
+
return __awaiter(this, arguments, void 0, function* ({ datasetId }) {
|
|
16
|
+
const url = joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/datasets/', datasetId);
|
|
17
|
+
const result = yield request({ url });
|
|
18
|
+
if (!result)
|
|
19
|
+
throw new Error('Collection not found!');
|
|
20
|
+
return result;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export function getDatasets(_a) {
|
|
24
|
+
return __awaiter(this, arguments, void 0, function* ({ appId }) {
|
|
25
|
+
const url = withQuery(joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/datasets'), { appId });
|
|
26
|
+
return request({ url });
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
export function createDataset(_a) {
|
|
30
|
+
return __awaiter(this, arguments, void 0, function* ({ appId, name, description, }) {
|
|
31
|
+
return request({
|
|
32
|
+
method: 'POST',
|
|
33
|
+
url: joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/datasets'),
|
|
34
|
+
body: {
|
|
35
|
+
appId,
|
|
36
|
+
name,
|
|
37
|
+
description,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export function updateDataset(datasetId, input) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
return request({
|
|
45
|
+
method: 'PUT',
|
|
46
|
+
url: joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/datasets', datasetId),
|
|
47
|
+
body: input,
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
export function deleteDataset(datasetId) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
const url = joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/datasets', datasetId);
|
|
54
|
+
return request({ method: 'DELETE', url });
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export function deleteDocument(datasetId, documentId) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
return request({
|
|
60
|
+
method: 'DELETE',
|
|
61
|
+
url: joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/datasets', datasetId, 'documents', documentId),
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export function getDocuments(datasetId) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
return request({
|
|
68
|
+
url: joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/datasets', datasetId, 'documents'),
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
export function getDocument(datasetId, documentId) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const result = yield request({
|
|
75
|
+
url: joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/datasets', datasetId, 'documents', documentId),
|
|
76
|
+
});
|
|
77
|
+
if (!(result === null || result === void 0 ? void 0 : result.document))
|
|
78
|
+
throw new Error('Document not found!');
|
|
79
|
+
return result;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
export function createDocument(datasetId, type, input) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
if (type === 'file')
|
|
85
|
+
return createDocumentFile(datasetId, input);
|
|
86
|
+
return request({
|
|
87
|
+
method: 'POST',
|
|
88
|
+
url: joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/datasets', datasetId, 'documents', type),
|
|
89
|
+
body: input,
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
export function createDocumentFile(datasetId, file) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
const form = new FormData();
|
|
96
|
+
form.append('data', file);
|
|
97
|
+
form.append('type', 'file');
|
|
98
|
+
form.append('filename', file.name);
|
|
99
|
+
return fetch(joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/datasets', datasetId, 'documents/file'), {
|
|
100
|
+
method: 'POST',
|
|
101
|
+
body: form,
|
|
102
|
+
}).then((res) => res.json());
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
export function updateDocument(datasetId, documentId, type, input) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
return request({
|
|
108
|
+
method: 'PUT',
|
|
109
|
+
url: joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/datasets', datasetId, 'documents', documentId, type),
|
|
110
|
+
body: input,
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { joinURL } from 'ufo';
|
|
11
|
+
import { getComponentMountPoint } from '../../../utils';
|
|
12
|
+
import { AI_STUDIO_DID } from '../constants';
|
|
13
|
+
import { request } from './request';
|
|
14
|
+
export function getMessages(_a) {
|
|
15
|
+
return __awaiter(this, arguments, void 0, function* ({ sessionId, }) {
|
|
16
|
+
return request({
|
|
17
|
+
url: joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/sessions', sessionId, 'messages'),
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function deleteMessages(_a) {
|
|
22
|
+
return __awaiter(this, arguments, void 0, function* ({ sessionId }) {
|
|
23
|
+
yield request({
|
|
24
|
+
method: 'DELETE',
|
|
25
|
+
url: joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/sessions', sessionId, 'messages'),
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
import { createFetch } from '@blocklet/js-sdk';
|
|
22
|
+
let isDEV = false;
|
|
23
|
+
try {
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
isDEV = import.meta.env.DEV;
|
|
26
|
+
}
|
|
27
|
+
catch (_a) {
|
|
28
|
+
// ignore
|
|
29
|
+
}
|
|
30
|
+
export const fetch = createFetch({}, { lazy: isDEV, lazyTime: 1000 });
|
|
31
|
+
export function request(_a) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
var _b, _c, _d;
|
|
34
|
+
var { url, body } = _a, init = __rest(_a, ["url", "body"]);
|
|
35
|
+
const result = yield fetch(url, Object.assign(Object.assign({}, init), { headers: {
|
|
36
|
+
'Content-Type': 'application/json',
|
|
37
|
+
}, body: typeof body === 'object' ? JSON.stringify(body) : body }));
|
|
38
|
+
if (!(result.status >= 200 && result.status < 300)) {
|
|
39
|
+
let json;
|
|
40
|
+
try {
|
|
41
|
+
json = yield result.json();
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
console.error('parse response error', error);
|
|
45
|
+
}
|
|
46
|
+
const message = (_d = (_c = (_b = json === null || json === void 0 ? void 0 : json.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : json === null || json === void 0 ? void 0 : json.message) !== null && _d !== void 0 ? _d : json === null || json === void 0 ? void 0 : json.error;
|
|
47
|
+
throw new Error(typeof message === 'string' ? message : `request error ${result.status}`);
|
|
48
|
+
}
|
|
49
|
+
return result.json();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
11
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
12
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
14
|
+
return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
15
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
16
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
17
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
18
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
19
|
+
function fulfill(value) { resume("next", value); }
|
|
20
|
+
function reject(value) { resume("throw", value); }
|
|
21
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
22
|
+
};
|
|
23
|
+
import { joinURL, withQuery } from 'ufo';
|
|
24
|
+
import { EventSourceParserStream } from '../../../stream';
|
|
25
|
+
import { getComponentMountPoint } from '../../../utils';
|
|
26
|
+
import { AI_STUDIO_DID } from '../constants';
|
|
27
|
+
import { parseIdentity } from '../utils';
|
|
28
|
+
import { fetch, request } from './request';
|
|
29
|
+
export function getSessions(_a) {
|
|
30
|
+
return __awaiter(this, arguments, void 0, function* ({ projectId, projectRef, assistantId, }) {
|
|
31
|
+
return request({
|
|
32
|
+
url: withQuery(joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/sessions'), {
|
|
33
|
+
projectId,
|
|
34
|
+
projectRef,
|
|
35
|
+
assistantId,
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export function getSession(_a) {
|
|
41
|
+
return __awaiter(this, arguments, void 0, function* ({ sessionId }) {
|
|
42
|
+
return request({
|
|
43
|
+
url: joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/sessions', sessionId),
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export function createSession(_a) {
|
|
48
|
+
return __awaiter(this, arguments, void 0, function* ({ assistantId, name, parameters, entry, }) {
|
|
49
|
+
return request({
|
|
50
|
+
method: 'POST',
|
|
51
|
+
url: joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/sessions'),
|
|
52
|
+
body: Object.assign(Object.assign({}, parseIdentity(assistantId)), { name,
|
|
53
|
+
parameters,
|
|
54
|
+
entry }),
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export function updateSession(_a) {
|
|
59
|
+
return __awaiter(this, arguments, void 0, function* ({ sessionId, name, parameters, }) {
|
|
60
|
+
return request({
|
|
61
|
+
method: 'PATCH',
|
|
62
|
+
url: joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/sessions', sessionId),
|
|
63
|
+
body: { name, parameters },
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
export function deleteSession(_a) {
|
|
68
|
+
return __awaiter(this, arguments, void 0, function* ({ sessionId, }) {
|
|
69
|
+
return request({
|
|
70
|
+
method: 'DELETE',
|
|
71
|
+
url: joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/sessions', sessionId),
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export function runAssistant(_a) {
|
|
76
|
+
return __asyncGenerator(this, arguments, function* runAssistant_1({ sessionId, identity, parameters, }) {
|
|
77
|
+
var _b;
|
|
78
|
+
const res = yield __await(fetch(joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/ai/call'), {
|
|
79
|
+
method: 'POST',
|
|
80
|
+
headers: {
|
|
81
|
+
'Content-Type': 'application/json',
|
|
82
|
+
Accept: 'text/event-stream',
|
|
83
|
+
},
|
|
84
|
+
body: JSON.stringify(Object.assign(Object.assign({ sessionId, parameters: Object.assign(Object.assign({}, parameters), { $clientTime: new Date().toISOString() }) }, identity), { ref: identity.projectRef, working: true })),
|
|
85
|
+
}));
|
|
86
|
+
if (!(res.status >= 200 && res.status < 300)) {
|
|
87
|
+
let json;
|
|
88
|
+
try {
|
|
89
|
+
json = yield __await(res.json());
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
// ignore
|
|
93
|
+
}
|
|
94
|
+
const message = (_b = json === null || json === void 0 ? void 0 : json.error) === null || _b === void 0 ? void 0 : _b.message;
|
|
95
|
+
if (typeof message === 'string') {
|
|
96
|
+
throw new Error(message);
|
|
97
|
+
}
|
|
98
|
+
throw new Error(`Unknown Error: ${res.status}`);
|
|
99
|
+
}
|
|
100
|
+
const stream = res
|
|
101
|
+
.body.pipeThrough(new TextDecoderStream())
|
|
102
|
+
.pipeThrough(new EventSourceParserStream())
|
|
103
|
+
.getReader();
|
|
104
|
+
for (;;) {
|
|
105
|
+
const { value, done } = yield __await(stream.read());
|
|
106
|
+
if (value)
|
|
107
|
+
yield yield __await(value);
|
|
108
|
+
if (done)
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { joinURL, withQuery } from 'ufo';
|
|
11
|
+
import { getComponentMountPoint } from '../../../utils';
|
|
12
|
+
import { AI_STUDIO_DID } from '../constants';
|
|
13
|
+
import { request } from './request';
|
|
14
|
+
export function getSubscription(_a) {
|
|
15
|
+
return __awaiter(this, arguments, void 0, function* ({ aid }) {
|
|
16
|
+
return request({
|
|
17
|
+
url: withQuery(joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/subscriptions/by-aid'), { aid }),
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function getRelease(_a) {
|
|
22
|
+
return __awaiter(this, arguments, void 0, function* ({ aid }) {
|
|
23
|
+
return request({
|
|
24
|
+
url: withQuery(joinURL(getComponentMountPoint(AI_STUDIO_DID), '/api/releases/by-aid'), { aid }),
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
import { Icon } from '@iconify/react';
|
|
23
|
+
import { Box, Tooltip } from '@mui/material';
|
|
24
|
+
import { useRef, useState } from 'react';
|
|
25
|
+
import LoadingButton from './LoadingButton';
|
|
26
|
+
export function ActionButton(_a) {
|
|
27
|
+
var { tip, tipSucceed, title, titleSucceed, icon, iconSucceed, autoReset } = _a, props = __rest(_a, ["tip", "tipSucceed", "title", "titleSucceed", "icon", "iconSucceed", "autoReset"]);
|
|
28
|
+
const [copied, setCopied] = useState(false);
|
|
29
|
+
const [error, setError] = useState();
|
|
30
|
+
const timer = useRef();
|
|
31
|
+
const onClose = () => {
|
|
32
|
+
setError(undefined);
|
|
33
|
+
if (autoReset) {
|
|
34
|
+
timer.current = window.setTimeout(() => {
|
|
35
|
+
setCopied(false);
|
|
36
|
+
}, 3000);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const onOpen = () => {
|
|
40
|
+
clearTimeout(timer.current);
|
|
41
|
+
};
|
|
42
|
+
const realIcon = copied ? iconSucceed : icon;
|
|
43
|
+
const toolTipTitleText = error ? _jsx(Box, { color: "error", children: error.message }) : (copied && tipSucceed) || tip;
|
|
44
|
+
const buttonText = copied ? titleSucceed : title;
|
|
45
|
+
return (_jsx(Tooltip, { title: toolTipTitleText, disableInteractive: true, placement: "top", onClose: onClose, onOpen: onOpen, children: _jsx("span", { children: _jsx(LoadingButton, Object.assign({ startIcon: realIcon && (typeof realIcon === 'string' ? _jsx(Icon, { icon: realIcon }) : realIcon), loadingPosition: realIcon ? 'start' : undefined }, props, { onClick: (e) => __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
if (!props.onClick)
|
|
47
|
+
return;
|
|
48
|
+
try {
|
|
49
|
+
yield props.onClick(e);
|
|
50
|
+
setCopied(true);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
setError(error);
|
|
54
|
+
}
|
|
55
|
+
}), children: buttonText })) }) }));
|
|
56
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { LinearProgress } from '@mui/material';
|
|
14
|
+
import { globalLoadingState } from '../state/loading';
|
|
15
|
+
export default function GlobalLoading(_a) {
|
|
16
|
+
var props = __rest(_a, []);
|
|
17
|
+
const state = globalLoadingState();
|
|
18
|
+
if (!state.loading)
|
|
19
|
+
return null;
|
|
20
|
+
return _jsx(LinearProgress, Object.assign({}, props));
|
|
21
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
import { LoadingButton as MuiLoadingButton } from '@mui/lab';
|
|
23
|
+
import { forwardRef, useCallback, useState } from 'react';
|
|
24
|
+
const LoadingButton = forwardRef((_a, ref) => {
|
|
25
|
+
var { onClick } = _a, props = __rest(_a, ["onClick"]);
|
|
26
|
+
const [loading, setLoading] = useState(false);
|
|
27
|
+
const handleClick = useCallback((e) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
try {
|
|
29
|
+
setLoading(true);
|
|
30
|
+
yield (onClick === null || onClick === void 0 ? void 0 : onClick(e));
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
setLoading(false);
|
|
34
|
+
}
|
|
35
|
+
}), [onClick]);
|
|
36
|
+
return _jsx(MuiLoadingButton, Object.assign({ ref: ref }, props, { loading: props.loading || loading, onClick: handleClick }));
|
|
37
|
+
});
|
|
38
|
+
export default LoadingButton;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
import { CircularProgress, ListItemButton, Stack } from '@mui/material';
|
|
23
|
+
import { useState } from 'react';
|
|
24
|
+
export default function LoadingListItemButton(_a) {
|
|
25
|
+
var { children, confirmation } = _a, props = __rest(_a, ["children", "confirmation"]);
|
|
26
|
+
const [clicked, setClicked] = useState(false);
|
|
27
|
+
const [loading, setLoading] = useState(false);
|
|
28
|
+
const handleClick = (e) => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
var _b;
|
|
30
|
+
if (loading)
|
|
31
|
+
return;
|
|
32
|
+
if (!clicked && confirmation) {
|
|
33
|
+
setClicked(true);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
setLoading(true);
|
|
38
|
+
yield ((_b = props.onClick) === null || _b === void 0 ? void 0 : _b.call(props, e));
|
|
39
|
+
}
|
|
40
|
+
finally {
|
|
41
|
+
setClicked(false);
|
|
42
|
+
setLoading(false);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return (_jsxs(ListItemButton, Object.assign({}, props, { onClick: handleClick, sx: Object.assign(Object.assign({}, props.sx), { display: 'flex', alignItems: 'center', gap: 1 }), children: [(clicked && confirmation) || children, _jsx(Stack, { direction: "row", alignItems: "center", justifyContent: "flex-end", sx: { width: 18 }, children: loading && _jsx(CircularProgress, { size: 14 }) })] })));
|
|
46
|
+
}
|