chat-js 1.0.0-alpha.7 → 1.0.0-alpha.8
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 +4 -4
- package/dist/index.js +433 -658
- package/package.json +1 -1
- package/templates/chat-app/AGENTS.md +1 -1
- package/templates/chat-app/agent/hooks/followup-suggestions.ts +1 -1
- package/templates/chat-app/agent/hooks/projects.ts +1 -1
- package/templates/chat-app/agent/hooks/search.ts +1 -1
- package/templates/chat-app/agent/instructions/projects.ts +1 -1
- package/templates/chat-app/agent/tools/mcp.ts +1 -1
- package/templates/chat-app/app/(auth)/device-login/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/api/files/upload/route.ts +1 -1
- package/templates/chat-app/app/(chat)/chat/{[id] → [chatId]}/page.tsx +4 -4
- package/templates/chat-app/app/(chat)/project/[projectId]/chat/[chatId]/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/project/[projectId]/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/settings/connectors/[connectorId]/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/settings/connectors/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/settings/models/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/share/[id]/page.tsx +1 -1
- package/templates/chat-app/app/api/agent-conversations/route.test.ts +5 -5
- package/templates/chat-app/app/api/agent-conversations/route.ts +2 -2
- package/templates/chat-app/app/api/agent-response-groups/route.test.ts +5 -5
- package/templates/chat-app/app/api/agent-response-groups/route.ts +1 -1
- package/templates/chat-app/app/api/eve/[...path]/route.test.ts +133 -4
- package/templates/chat-app/app/api/eve/[...path]/route.ts +175 -49
- package/templates/chat-app/app/api/eve-guest/route.ts +1 -1
- package/templates/chat-app/app/api/mcp/oauth/callback/route.ts +1 -1
- package/templates/chat-app/chatjs/core/chat/compose.ts +4 -4
- package/templates/chat-app/chatjs/core/chat/contracts.ts +6 -6
- package/templates/chat-app/chatjs/core/installation/contracts.ts +0 -7
- package/templates/chat-app/chatjs/generated/installed-auth-ui.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-auth.ts +4 -2
- package/templates/chat-app/chatjs/generated/installed-billing.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-chat-ui.ts +24 -24
- package/templates/chat-app/chatjs/generated/installed-chat.ts +12 -12
- package/templates/chat-app/chatjs/generated/installed-cleanup.ts +4 -4
- package/templates/chat-app/chatjs/generated/installed-instrumentation.ts +8 -2
- package/templates/chat-app/chatjs/generated/installed-layout.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-model-visibility.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-navigation.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-routers.ts +18 -19
- package/templates/chat-app/chatjs/generated/installed-session-profiles.ts +5 -3
- package/templates/chat-app/chatjs/generated/installed-sign-out.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-signed-out.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-uploads.ts +2 -2
- package/templates/chat-app/chatjs/plugins/ai-titles/{chat.ts → chat-server.ts} +3 -1
- package/templates/chat-app/chatjs/plugins/ai-titles/generate-title.ts +7 -9
- package/templates/chat-app/chatjs/plugins/ai-titles/{chatjs.json → plugin.json} +3 -4
- package/templates/chat-app/chatjs/plugins/ai-titles/title-queries.ts +4 -4
- package/templates/chat-app/chatjs/plugins/attachment-uploads/{client-plugin.ts → chat-ui.ts} +1 -3
- package/templates/chat-app/chatjs/plugins/attachment-uploads/plugin.json +16 -0
- package/templates/chat-app/chatjs/plugins/credits/billing.ts +3 -1
- package/templates/chat-app/chatjs/plugins/credits/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/credits/{chatjs.json → plugin.json} +4 -13
- package/templates/chat-app/chatjs/plugins/credits/router.ts +4 -2
- package/templates/chat-app/chatjs/plugins/desktop/auth-form.tsx +3 -1
- package/templates/chat-app/chatjs/plugins/desktop/auth-server.ts +3 -1
- package/templates/chat-app/chatjs/plugins/desktop/{client-plugin.ts → layout-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/desktop/navigation.ts +3 -1
- package/templates/chat-app/chatjs/plugins/desktop/{chatjs.json → plugin.json} +4 -16
- package/templates/chat-app/chatjs/plugins/desktop/sign-out.ts +3 -1
- package/templates/chat-app/chatjs/plugins/feedback/chat-server.ts +13 -0
- package/templates/chat-app/chatjs/plugins/feedback/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/feedback/feedback-actions.tsx +4 -4
- package/templates/chat-app/chatjs/plugins/feedback/feedback-queries.ts +11 -11
- package/templates/chat-app/chatjs/plugins/feedback/feedback-schema.ts +2 -2
- package/templates/chat-app/chatjs/plugins/feedback/{chatjs.json → plugin.json} +5 -14
- package/templates/chat-app/chatjs/plugins/feedback/router.ts +9 -7
- package/templates/chat-app/chatjs/plugins/feedback/vote-message.ts +3 -6
- package/templates/chat-app/chatjs/plugins/followup-suggestions/{chat.ts → chat-server.ts} +3 -1
- package/templates/chat-app/chatjs/plugins/followup-suggestions/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/followup-suggestions/followup-queries.ts +2 -2
- package/templates/chat-app/chatjs/plugins/followup-suggestions/{chatjs.json → plugin.json} +5 -17
- package/templates/chat-app/chatjs/plugins/followup-suggestions/router.ts +8 -9
- package/templates/chat-app/chatjs/plugins/followup-suggestions/suggestions.tsx +2 -7
- package/templates/chat-app/chatjs/plugins/followup-suggestions/use-followups.ts +2 -2
- package/templates/chat-app/chatjs/plugins/guest-chat/cleanup.ts +1 -7
- package/templates/chat-app/chatjs/plugins/guest-chat/guest-auth.ts +1 -0
- package/templates/chat-app/chatjs/plugins/guest-chat/instrumentation.ts +6 -0
- package/templates/chat-app/chatjs/plugins/guest-chat/{chatjs.json → plugin.json} +6 -12
- package/templates/chat-app/chatjs/plugins/guest-chat/session-profile.ts +3 -1
- package/templates/chat-app/chatjs/plugins/guest-chat/signed-out.tsx +46 -20
- package/templates/chat-app/chatjs/plugins/image-viewer/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/image-viewer/plugin.json +11 -0
- package/templates/chat-app/chatjs/plugins/mcp/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/mcp/db/encrypted-text.ts +1 -1
- package/templates/chat-app/chatjs/plugins/mcp/{chatjs.json → plugin.json} +5 -13
- package/templates/chat-app/chatjs/plugins/mcp/router.ts +4 -2
- package/templates/chat-app/chatjs/plugins/mcp/setup.ts +2 -2
- package/templates/chat-app/chatjs/plugins/mcp/{mcp-env.ts → validate-env.ts} +2 -1
- package/templates/chat-app/chatjs/plugins/model-preferences/{client-plugin.ts → chat-ui.ts} +1 -3
- package/templates/chat-app/chatjs/plugins/model-preferences/{use-model-preferences.ts → model-visibility.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/model-preferences/{chatjs.json → plugin.json} +5 -13
- package/templates/chat-app/chatjs/plugins/model-preferences/router.ts +5 -1
- package/templates/chat-app/chatjs/plugins/projects/{chat.ts → chat-server.ts} +3 -1
- package/templates/chat-app/chatjs/plugins/projects/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/projects/conversation-hook.ts +1 -1
- package/templates/chat-app/chatjs/plugins/projects/db/project-queries.ts +2 -2
- package/templates/chat-app/chatjs/plugins/projects/{chatjs.json → plugin.json} +5 -14
- package/templates/chat-app/chatjs/plugins/projects/router.ts +7 -7
- package/templates/chat-app/chatjs/plugins/projects/ui/chat-contributions.tsx +3 -3
- package/templates/chat-app/chatjs/plugins/projects/ui/eve-move-project-dialog.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/projects/ui/sidebar-projects.tsx +12 -11
- package/templates/chat-app/chatjs/plugins/search/{chat.ts → chat-server.ts} +8 -6
- package/templates/chat-app/chatjs/plugins/search/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/search/{chatjs.json → plugin.json} +5 -14
- package/templates/chat-app/chatjs/plugins/search/router.ts +4 -2
- package/templates/chat-app/chatjs/plugins/search/search-backfill.ts +4 -4
- package/templates/chat-app/chatjs/plugins/search/search-chats.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/search/search-hook.ts +2 -2
- package/templates/chat-app/chatjs/plugins/search/search-queries.ts +13 -13
- package/templates/chat-app/chatjs/plugins/search/search-results-view.tsx +2 -2
- package/templates/chat-app/chatjs/plugins/search/search-schema.ts +3 -3
- package/templates/chat-app/chatjs/plugins/sharing/{chat.ts → chat-server.ts} +3 -1
- package/templates/chat-app/chatjs/plugins/sharing/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/sharing/{chatjs.json → plugin.json} +5 -14
- package/templates/chat-app/chatjs/plugins/sharing/router.ts +4 -2
- package/templates/chat-app/chatjs/plugins/sharing/ui/chat-contributions.tsx +9 -11
- package/templates/chat-app/chatjs/plugins/sharing/ui/share-button.tsx +6 -6
- package/templates/chat-app/chatjs/plugins/sharing/ui/share-dialog.tsx +9 -9
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/plugin.json +12 -0
- package/templates/chat-app/chatjs/plugins/video-viewer/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/video-viewer/plugin.json +10 -0
- package/templates/chat-app/chatjs/tools/attach-workspace-file/tool.ts +2 -2
- package/templates/chat-app/components/chat/chat-composer.tsx +35 -7
- package/templates/chat-app/components/chat/chat-conversation-screen.tsx +3 -3
- package/templates/chat-app/components/chat/chat-navigation.tsx +11 -1
- package/templates/chat-app/components/chat/chat-sidebar.tsx +3 -6
- package/templates/chat-app/components/chat/chat-transcript.tsx +52 -23
- package/templates/chat-app/components/chat-slots.tsx +1 -1
- package/templates/chat-app/components/composer/composer-menu.tsx +5 -4
- package/templates/chat-app/components/eve/eve-chat-header.tsx +5 -7
- package/templates/chat-app/components/eve/eve-chat-page.tsx +9 -9
- package/templates/chat-app/components/eve/eve-composer.tsx +16 -5
- package/templates/chat-app/components/eve/eve-conversation.tsx +160 -96
- package/templates/chat-app/components/eve/eve-creation-recovery.tsx +21 -2
- package/templates/chat-app/components/eve/eve-deletion-provider.tsx +10 -12
- package/templates/chat-app/components/eve/eve-history-list.tsx +3 -8
- package/templates/chat-app/components/eve/eve-logical-context.tsx +1 -0
- package/templates/chat-app/components/eve/eve-logical-navigation.tsx +3 -3
- package/templates/chat-app/components/eve/eve-message-content.tsx +252 -0
- package/templates/chat-app/components/eve/eve-message-part.tsx +13 -58
- package/templates/chat-app/components/eve/eve-pending-input.tsx +82 -5
- package/templates/chat-app/components/eve/eve-runtime-provider.tsx +74 -15
- package/templates/chat-app/components/eve/use-eve-composer-draft.ts +64 -26
- package/templates/chat-app/components/eve/use-eve-fork.ts +14 -16
- package/templates/chat-app/components/eve/use-logical-commands.ts +3 -3
- package/templates/chat-app/components/eve/use-new-eve-conversation.tsx +42 -7
- package/templates/chat-app/components/parallel-responses/model-picker.tsx +5 -1
- package/templates/chat-app/components/parallel-responses/responses.tsx +2 -2
- package/templates/chat-app/integrations/routers.ts +1 -1
- package/templates/chat-app/lib/chat-after-create.test.ts +1 -1
- package/templates/chat-app/lib/chat-after-create.ts +1 -1
- package/templates/chat-app/lib/db/eve-creation-failure.ts +3 -3
- package/templates/chat-app/lib/db/eve-current-copy.ts +11 -11
- package/templates/chat-app/lib/db/eve-deletion.ts +19 -19
- package/templates/chat-app/lib/db/eve-dispatch.ts +115 -18
- package/templates/chat-app/lib/db/eve-file-purge.ts +4 -4
- package/templates/chat-app/lib/db/eve-files.ts +13 -13
- package/templates/chat-app/lib/db/eve-queries.ts +28 -43
- package/templates/chat-app/lib/db/eve-response-groups.ts +30 -112
- package/templates/chat-app/lib/db/eve-subagents.ts +8 -8
- package/templates/chat-app/lib/db/eve-title.ts +2 -2
- package/templates/chat-app/lib/db/eve-workspace-deletion.ts +3 -3
- package/templates/chat-app/lib/db/eve-workspace-turns.ts +37 -5
- package/templates/chat-app/lib/db/eve-workspaces.ts +3 -3
- package/templates/chat-app/lib/db/migrations/0029_branch_identifiers.sql +23 -0
- package/templates/chat-app/lib/db/migrations/meta/0029_snapshot.json +2547 -0
- package/templates/chat-app/lib/db/migrations/meta/_journal.json +7 -0
- package/templates/chat-app/lib/db/schema.ts +19 -25
- package/templates/chat-app/lib/eve/completed-copy-source.test.ts +12 -2
- package/templates/chat-app/lib/eve/completed-copy-source.ts +5 -2
- package/templates/chat-app/lib/eve/contracts.test.ts +5 -5
- package/templates/chat-app/lib/eve/contracts.ts +1 -1
- package/templates/chat-app/lib/eve/conversation-scope.test.ts +2 -2
- package/templates/chat-app/lib/eve/conversation-scope.ts +4 -4
- package/templates/chat-app/lib/eve/create-conversation-operation.test.ts +1 -1
- package/templates/chat-app/lib/eve/create-response-group.test.ts +3 -3
- package/templates/chat-app/lib/eve/delete-local-conversation.ts +3 -3
- package/templates/chat-app/lib/eve/generated-files.test.ts +1 -1
- package/templates/chat-app/lib/eve/generated-files.ts +2 -2
- package/templates/chat-app/lib/eve/logical-chat.test.ts +17 -17
- package/templates/chat-app/lib/eve/logical-chat.ts +27 -31
- package/templates/chat-app/lib/eve/logical-response-slots.ts +4 -7
- package/templates/chat-app/lib/eve/message-delivery.ts +1 -0
- package/templates/chat-app/lib/eve/pending-create.test.ts +46 -7
- package/templates/chat-app/lib/eve/pending-create.ts +36 -4
- package/templates/chat-app/lib/eve/persisted-wire-order.test.ts +2 -2
- package/templates/chat-app/lib/eve/prepare-deletion.ts +3 -3
- package/templates/chat-app/lib/eve/purge-local-resources.ts +3 -3
- package/templates/chat-app/lib/eve/reconcile-workspace-turn.ts +2 -2
- package/templates/chat-app/lib/eve/request-policy.ts +1 -0
- package/templates/chat-app/lib/eve/resolve-creation-request.ts +1 -1
- package/templates/chat-app/lib/eve/response-group-contracts.ts +1 -1
- package/templates/chat-app/lib/eve/response-group-lineage.test.ts +12 -12
- package/templates/chat-app/lib/eve/response-group-lineage.ts +21 -24
- package/templates/chat-app/lib/eve/response-group.test.ts +2 -2
- package/templates/chat-app/lib/eve/response-group.ts +1 -1
- package/templates/chat-app/lib/eve/response-model.ts +11 -1
- package/templates/chat-app/lib/eve/restore-message-attachments.test.ts +1 -1
- package/templates/chat-app/lib/eve/restore-message-attachments.ts +3 -3
- package/templates/chat-app/lib/eve/retire-session.ts +3 -3
- package/templates/chat-app/lib/eve/steer-rejected.ts +7 -0
- package/templates/chat-app/lib/eve/workspace-turn-evidence.test.ts +27 -0
- package/templates/chat-app/lib/eve/workspace-turn-evidence.ts +20 -13
- package/templates/chat-app/playwright.config.ts +5 -1
- package/templates/chat-app/scripts/agent-status.ts +6 -19
- package/templates/chat-app/scripts/check-env.ts +75 -56
- package/templates/chat-app/scripts/installed-environment-validation.ts +14 -15
- package/templates/chat-app/trpc/init.ts +2 -0
- package/templates/chat-app/trpc/routers/_app.test.ts +56 -0
- package/templates/chat-app/trpc/routers/_app.ts +12 -11
- package/templates/chat-app/trpc/routers/eve.router.ts +2 -2
- package/templates/chat-app/chatjs/core/installation/plugin.ts +0 -13
- package/templates/chat-app/chatjs/plugins/attachment-uploads/chatjs.json +0 -22
- package/templates/chat-app/chatjs/plugins/credits/server-plugin.ts +0 -5
- package/templates/chat-app/chatjs/plugins/feedback/chat.ts +0 -13
- package/templates/chat-app/chatjs/plugins/feedback/server-plugin.ts +0 -8
- package/templates/chat-app/chatjs/plugins/followup-suggestions/server-plugin.ts +0 -8
- package/templates/chat-app/chatjs/plugins/guest-chat/server-plugin.ts +0 -12
- package/templates/chat-app/chatjs/plugins/image-viewer/chatjs.json +0 -17
- package/templates/chat-app/chatjs/plugins/mcp/server-plugin.ts +0 -5
- package/templates/chat-app/chatjs/plugins/model-preferences/server-plugin.ts +0 -8
- package/templates/chat-app/chatjs/plugins/projects/server-plugin.ts +0 -8
- package/templates/chat-app/chatjs/plugins/search/server-plugin.ts +0 -5
- package/templates/chat-app/chatjs/plugins/sharing/server-plugin.ts +0 -5
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/chatjs.json +0 -18
- package/templates/chat-app/chatjs/plugins/video-viewer/chatjs.json +0 -16
- package/templates/chat-app/lib/chat-route.ts +0 -18
- package/templates/chat-app/providers/parse-chat-id-from-pathname.test.ts +0 -126
- package/templates/chat-app/providers/parse-chat-id-from-pathname.ts +0 -51
- /package/templates/chat-app/chatjs/plugins/attachment-uploads/{integration.tsx → uploads.ts} +0 -0
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
// Generated by chat-js sync. Do not edit. Customize integrations/ or plugin source; inspect ownership with chat-js status.
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} satisfies InstalledRouters;
|
|
2
|
+
import { router as creditsRouter } from "@/chatjs/plugins/credits/router";
|
|
3
|
+
import { router as feedbackRouter } from "@/chatjs/plugins/feedback/router";
|
|
4
|
+
import { router as followupSuggestionsRouter } from "@/chatjs/plugins/followup-suggestions/router";
|
|
5
|
+
import { router as mcpRouter } from "@/chatjs/plugins/mcp/router";
|
|
6
|
+
import { router as modelPreferencesRouter } from "@/chatjs/plugins/model-preferences/router";
|
|
7
|
+
import { router as projectsRouter } from "@/chatjs/plugins/projects/router";
|
|
8
|
+
import { router as searchRouter } from "@/chatjs/plugins/search/router";
|
|
9
|
+
import { router as sharingRouter } from "@/chatjs/plugins/sharing/router";
|
|
10
|
+
export const installedRouters = [
|
|
11
|
+
creditsRouter,
|
|
12
|
+
feedbackRouter,
|
|
13
|
+
followupSuggestionsRouter,
|
|
14
|
+
mcpRouter,
|
|
15
|
+
modelPreferencesRouter,
|
|
16
|
+
projectsRouter,
|
|
17
|
+
searchRouter,
|
|
18
|
+
sharingRouter,
|
|
19
|
+
] as const;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Generated by chat-js sync. Do not edit. Customize integrations/ or plugin source; inspect ownership with chat-js status.
|
|
2
|
-
import
|
|
2
|
+
import guestChatProfile from "@/chatjs/plugins/guest-chat/session-profile";
|
|
3
3
|
import type { SessionProfile } from "@/chatjs/core/session/contracts";
|
|
4
|
-
if (
|
|
4
|
+
if (guestChatProfile.authenticator !== "chatjs-disposable-guest")
|
|
5
5
|
throw new Error("Session profile identity disagrees with its descriptor.");
|
|
6
|
-
export const installedSessionProfiles: readonly SessionProfile[] = [
|
|
6
|
+
export const installedSessionProfiles: readonly SessionProfile[] = [
|
|
7
|
+
guestChatProfile,
|
|
8
|
+
];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Generated by chat-js sync. Do not edit. Customize integrations/ or plugin source; inspect ownership with chat-js status.
|
|
2
|
-
import
|
|
2
|
+
import desktopSignOut from "@/chatjs/plugins/desktop/sign-out";
|
|
3
3
|
import type { AuthenticationUi } from "@/chatjs/core/authentication/contracts";
|
|
4
4
|
export const installedSignOutHandlers: readonly AuthenticationUi["signOut"][] =
|
|
5
|
-
[
|
|
5
|
+
[desktopSignOut];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by chat-js sync. Do not edit. Customize integrations/ or plugin source; inspect ownership with chat-js status.
|
|
2
|
-
import
|
|
2
|
+
import guestChatScreen from "@/chatjs/plugins/guest-chat/signed-out";
|
|
3
3
|
import type { ComponentType } from "react";
|
|
4
4
|
export const installedSignedOutScreens: readonly ComponentType[] = [
|
|
5
|
-
|
|
5
|
+
guestChatScreen,
|
|
6
6
|
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by chat-js sync. Do not edit. Customize integrations/ or plugin source; inspect ownership with chat-js status.
|
|
2
|
-
import {
|
|
2
|
+
import { attachmentUploads } from "@/chatjs/plugins/attachment-uploads/uploads";
|
|
3
3
|
import type { AttachmentUploadIntegration } from "@/chatjs/core/installation/contracts";
|
|
4
4
|
export const installedUploads: readonly AttachmentUploadIntegration[] = [
|
|
5
|
-
|
|
5
|
+
attachmentUploads,
|
|
6
6
|
];
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ChatServerIntegration } from "@/chatjs/core/chat/contracts";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const aiTitlesChat = {
|
|
4
4
|
afterCreate: async (context) => {
|
|
5
5
|
const { persistGeneratedEveConversationTitle } =
|
|
6
6
|
await import("./generate-title");
|
|
7
7
|
await persistGeneratedEveConversationTitle(context);
|
|
8
8
|
},
|
|
9
9
|
} satisfies ChatServerIntegration;
|
|
10
|
+
|
|
11
|
+
export default aiTitlesChat;
|
|
@@ -61,25 +61,23 @@ Rules (strictly follow all):
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
const persistGeneratedEveConversationTitle = async ({
|
|
64
|
-
|
|
64
|
+
branchId,
|
|
65
65
|
message,
|
|
66
66
|
ownerId,
|
|
67
67
|
}: Readonly<{
|
|
68
|
-
|
|
68
|
+
branchId: string;
|
|
69
69
|
message: ReadonlyEveMessageInput;
|
|
70
70
|
ownerId: string;
|
|
71
71
|
}>): Promise<EveTitleResult | undefined> => {
|
|
72
72
|
const fallbackTitle = eveConversationTitleFallback(message);
|
|
73
73
|
try {
|
|
74
|
-
if (
|
|
75
|
-
!(await isEveRootTitlePending(ownerId, conversationId, fallbackTitle))
|
|
76
|
-
) {
|
|
74
|
+
if (!(await isEveRootTitlePending(ownerId, branchId, fallbackTitle))) {
|
|
77
75
|
return undefined;
|
|
78
76
|
}
|
|
79
77
|
} catch (error) {
|
|
80
78
|
log.warn(
|
|
81
79
|
{
|
|
82
|
-
|
|
80
|
+
branchId,
|
|
83
81
|
errorName: error instanceof Error ? error.name : typeof error,
|
|
84
82
|
},
|
|
85
83
|
"Eve title eligibility check failed"
|
|
@@ -91,15 +89,15 @@ const persistGeneratedEveConversationTitle = async ({
|
|
|
91
89
|
await (generated.source === "generated"
|
|
92
90
|
? replaceEveRootFallbackTitle(
|
|
93
91
|
ownerId,
|
|
94
|
-
|
|
92
|
+
branchId,
|
|
95
93
|
fallbackTitle,
|
|
96
94
|
generated.title
|
|
97
95
|
)
|
|
98
|
-
: settleEveRootFallbackTitle(ownerId,
|
|
96
|
+
: settleEveRootFallbackTitle(ownerId, branchId, fallbackTitle));
|
|
99
97
|
} catch (error) {
|
|
100
98
|
log.warn(
|
|
101
99
|
{
|
|
102
|
-
|
|
100
|
+
branchId,
|
|
103
101
|
errorName: error instanceof Error ? error.name : typeof error,
|
|
104
102
|
},
|
|
105
103
|
"Eve title persistence failed"
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
+
"contractVersion": 3,
|
|
2
3
|
"id": "ai-titles",
|
|
3
4
|
"kind": "plugin",
|
|
4
5
|
"files": [
|
|
5
|
-
"chatjs/plugins/ai-titles/chat.ts",
|
|
6
|
+
"chatjs/plugins/ai-titles/chat-server.ts",
|
|
6
7
|
"chatjs/plugins/ai-titles/generate-title.ts",
|
|
7
8
|
"chatjs/plugins/ai-titles/title-queries.ts"
|
|
8
|
-
]
|
|
9
|
-
"chat": { "export": "aiTitlesChat" },
|
|
10
|
-
"contractVersion": 1
|
|
9
|
+
]
|
|
11
10
|
}
|
|
@@ -5,7 +5,7 @@ import { eveChat, eveConversation } from "@/lib/db/schema";
|
|
|
5
5
|
const SINGLE_MATCH_LIMIT = 1;
|
|
6
6
|
const isEveRootTitlePending = async (
|
|
7
7
|
ownerId: string,
|
|
8
|
-
|
|
8
|
+
branchId: string,
|
|
9
9
|
fallbackTitle: string
|
|
10
10
|
): Promise<boolean> => {
|
|
11
11
|
const [row] = await db
|
|
@@ -20,7 +20,7 @@ const isEveRootTitlePending = async (
|
|
|
20
20
|
)
|
|
21
21
|
.where(
|
|
22
22
|
and(
|
|
23
|
-
eq(eveConversation.id,
|
|
23
|
+
eq(eveConversation.id, branchId),
|
|
24
24
|
eq(eveConversation.ownerId, ownerId),
|
|
25
25
|
eq(eveConversation.state, "bound"),
|
|
26
26
|
eq(eveChat.title, fallbackTitle),
|
|
@@ -33,7 +33,7 @@ const isEveRootTitlePending = async (
|
|
|
33
33
|
|
|
34
34
|
const replaceEveRootFallbackTitle = async (
|
|
35
35
|
ownerId: string,
|
|
36
|
-
|
|
36
|
+
branchId: string,
|
|
37
37
|
fallbackTitle: string,
|
|
38
38
|
generatedTitle: string
|
|
39
39
|
): Promise<boolean> => {
|
|
@@ -43,7 +43,7 @@ const replaceEveRootFallbackTitle = async (
|
|
|
43
43
|
.from(eveConversation)
|
|
44
44
|
.where(
|
|
45
45
|
and(
|
|
46
|
-
eq(eveConversation.id,
|
|
46
|
+
eq(eveConversation.id, branchId),
|
|
47
47
|
eq(eveConversation.ownerId, ownerId),
|
|
48
48
|
eq(eveConversation.state, "bound"),
|
|
49
49
|
eq(eveChat.id, eveConversation.chatId),
|
package/templates/chat-app/chatjs/plugins/attachment-uploads/{client-plugin.ts → chat-ui.ts}
RENAMED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { definePlugin, slot } from "@/chatjs/core/ui/slots";
|
|
3
3
|
import { ComposerAttachments } from "@/components/chat-slots";
|
|
4
|
-
import { attachmentUploads } from "./integration";
|
|
5
4
|
import { AttachFilesControl, TakePhotoControl } from "./controls";
|
|
6
5
|
|
|
7
|
-
export const
|
|
6
|
+
export const chatUi = definePlugin({
|
|
8
7
|
id: "attachment-uploads",
|
|
9
8
|
slots: [
|
|
10
9
|
slot(ComposerAttachments, AttachFilesControl),
|
|
11
10
|
slot(ComposerAttachments, TakePhotoControl),
|
|
12
11
|
],
|
|
13
|
-
uploads: attachmentUploads,
|
|
14
12
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contractVersion": 3,
|
|
3
|
+
"uiBase": "base",
|
|
4
|
+
"id": "attachment-uploads",
|
|
5
|
+
"kind": "plugin",
|
|
6
|
+
"files": [
|
|
7
|
+
"chatjs/plugins/attachment-uploads/controls.tsx",
|
|
8
|
+
"chatjs/plugins/attachment-uploads/uploads.ts",
|
|
9
|
+
"chatjs/plugins/attachment-uploads/upload.ts",
|
|
10
|
+
"chatjs/plugins/attachment-uploads/upload-prep.ts",
|
|
11
|
+
"app/(chat)/api/files/upload/route.ts",
|
|
12
|
+
"chatjs/plugins/attachment-uploads/routes/upload.ts",
|
|
13
|
+
"chatjs/plugins/attachment-uploads/chat-ui.ts"
|
|
14
|
+
],
|
|
15
|
+
"requiresStorage": true
|
|
16
|
+
}
|
|
@@ -4,7 +4,7 @@ import { getBalanceCents } from "./credits-queries";
|
|
|
4
4
|
import { userCredit } from "./credits-schema";
|
|
5
5
|
|
|
6
6
|
/** Core supplies its usage transaction, with the registered owner already locked. */
|
|
7
|
-
|
|
7
|
+
const creditsBilling = {
|
|
8
8
|
canSpend: async (ownerId) => (await getBalanceCents(ownerId)) > 0,
|
|
9
9
|
debit: async (tx, { ownerId, cents }) => {
|
|
10
10
|
await tx
|
|
@@ -17,3 +17,5 @@ export const creditsBilling = {
|
|
|
17
17
|
.where(eq(userCredit.userId, ownerId));
|
|
18
18
|
},
|
|
19
19
|
} satisfies UsageBilling;
|
|
20
|
+
|
|
21
|
+
export default creditsBilling;
|
|
@@ -3,7 +3,7 @@ import { definePlugin, slot } from "@/chatjs/core/ui/slots";
|
|
|
3
3
|
import { AccountSummary } from "@/components/chat-slots";
|
|
4
4
|
import { CreditBalance } from "./balance";
|
|
5
5
|
|
|
6
|
-
export const
|
|
6
|
+
export const chatUi = definePlugin({
|
|
7
7
|
id: "credits",
|
|
8
8
|
slots: [slot(AccountSummary, CreditBalance)],
|
|
9
9
|
});
|
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
+
"contractVersion": 3,
|
|
3
|
+
"uiBase": "base",
|
|
2
4
|
"id": "credits",
|
|
3
5
|
"kind": "plugin",
|
|
4
6
|
"files": [
|
|
5
7
|
"chatjs/plugins/credits/balance.tsx",
|
|
6
8
|
"chatjs/plugins/credits/billing.ts",
|
|
7
|
-
"chatjs/plugins/credits/
|
|
9
|
+
"chatjs/plugins/credits/chat-ui.ts",
|
|
8
10
|
"chatjs/plugins/credits/credits-queries.ts",
|
|
9
11
|
"chatjs/plugins/credits/credits-schema.ts",
|
|
10
12
|
"chatjs/plugins/credits/router.ts",
|
|
11
|
-
"chatjs/plugins/credits/server-plugin.ts",
|
|
12
13
|
"chatjs/plugins/credits/use-credits.ts"
|
|
13
14
|
],
|
|
14
|
-
"databaseSchemas": ["chatjs/plugins/credits/credits-schema.ts"]
|
|
15
|
-
"billing": { "export": "creditsBilling" },
|
|
16
|
-
"server": { "export": "credits", "routers": ["credits"] },
|
|
17
|
-
"client": {
|
|
18
|
-
"export": "creditsClient",
|
|
19
|
-
"composerControls": [],
|
|
20
|
-
"settingsItems": [],
|
|
21
|
-
"accountSummary": true
|
|
22
|
-
},
|
|
23
|
-
"contractVersion": 2,
|
|
24
|
-
"uiBase": "base"
|
|
15
|
+
"databaseSchemas": ["chatjs/plugins/credits/credits-schema.ts"]
|
|
25
16
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getBalanceCents } from "./credits-queries";
|
|
2
2
|
import { createTRPCRouter, protectedProcedure } from "@/trpc/init";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const creditsProcedures = {
|
|
5
5
|
getAvailableCredits: protectedProcedure.query(
|
|
6
6
|
async ({
|
|
7
7
|
ctx,
|
|
@@ -12,4 +12,6 @@ export const creditsRouter = createTRPCRouter({
|
|
|
12
12
|
return { balanceCents };
|
|
13
13
|
}
|
|
14
14
|
),
|
|
15
|
-
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const router = createTRPCRouter({ credits: creditsProcedures });
|
|
@@ -44,7 +44,7 @@ const BrowserTransfer = ({
|
|
|
44
44
|
);
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
const DesktopAuthForm = ({
|
|
48
48
|
mode,
|
|
49
49
|
children,
|
|
50
50
|
}: {
|
|
@@ -79,3 +79,5 @@ export const DesktopAuthForm = ({
|
|
|
79
79
|
}
|
|
80
80
|
return children;
|
|
81
81
|
};
|
|
82
|
+
|
|
83
|
+
export default DesktopAuthForm;
|
|
@@ -39,7 +39,7 @@ const electronAuthPlugin = {
|
|
|
39
39
|
},
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
const desktopAuth = {
|
|
43
43
|
plugins: [electronAuthPlugin],
|
|
44
44
|
trustedOrigins: [`${ELECTRON_APP_SCHEME}:/`],
|
|
45
45
|
isAuthRoute: (url) =>
|
|
@@ -48,3 +48,5 @@ export const desktopAuth = {
|
|
|
48
48
|
url.searchParams.get("client_id") === ELECTRON_AUTH_CLIENT_ID),
|
|
49
49
|
} satisfies AuthenticationIntegration;
|
|
50
50
|
export { electronAuthPlugin };
|
|
51
|
+
|
|
52
|
+
export default desktopAuth;
|
|
@@ -3,7 +3,7 @@ import { definePlugin, slot } from "@/chatjs/core/ui/slots";
|
|
|
3
3
|
import { LayoutEffects } from "@/components/layout-slots";
|
|
4
4
|
import { ElectronAuthHandler } from "./auth-handler";
|
|
5
5
|
|
|
6
|
-
export const
|
|
6
|
+
export const layoutUi = definePlugin({
|
|
7
7
|
id: "desktop",
|
|
8
8
|
slots: [slot(LayoutEffects, ElectronAuthHandler)],
|
|
9
9
|
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
+
"contractVersion": 3,
|
|
3
|
+
"uiBase": "base",
|
|
2
4
|
"id": "desktop",
|
|
3
5
|
"kind": "plugin",
|
|
4
6
|
"files": [
|
|
@@ -8,7 +10,7 @@
|
|
|
8
10
|
"chatjs/plugins/desktop/auth-server.ts",
|
|
9
11
|
"chatjs/plugins/desktop/auth-ui.tsx",
|
|
10
12
|
"chatjs/plugins/desktop/bridge.ts",
|
|
11
|
-
"chatjs/plugins/desktop/
|
|
13
|
+
"chatjs/plugins/desktop/layout-ui.ts",
|
|
12
14
|
"chatjs/plugins/desktop/navigation.ts",
|
|
13
15
|
"chatjs/plugins/desktop/protocol.ts",
|
|
14
16
|
"chatjs/plugins/desktop/device-login-page.tsx",
|
|
@@ -16,19 +18,5 @@
|
|
|
16
18
|
"chatjs/plugins/desktop/electron-auth.ts",
|
|
17
19
|
"chatjs/plugins/desktop/sign-out.ts",
|
|
18
20
|
"app/(auth)/device-login/page.tsx"
|
|
19
|
-
]
|
|
20
|
-
"authentication": { "export": "desktopAuth" },
|
|
21
|
-
"authenticationUi": {
|
|
22
|
-
"form": "DesktopAuthForm",
|
|
23
|
-
"signOut": "signOutDesktop"
|
|
24
|
-
},
|
|
25
|
-
"navigation": { "export": "desktopNavigation" },
|
|
26
|
-
"client": {
|
|
27
|
-
"export": "desktopClient",
|
|
28
|
-
"composerControls": [],
|
|
29
|
-
"settingsItems": [],
|
|
30
|
-
"layout": true
|
|
31
|
-
},
|
|
32
|
-
"contractVersion": 2,
|
|
33
|
-
"uiBase": "base"
|
|
21
|
+
]
|
|
34
22
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isElectronRenderer } from "./bridge";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const signOutDesktop = async (): Promise<boolean> => {
|
|
4
4
|
if (!isElectronRenderer()) {
|
|
5
5
|
return false;
|
|
6
6
|
}
|
|
@@ -16,3 +16,5 @@ export const signOutDesktop = async (): Promise<boolean> => {
|
|
|
16
16
|
}
|
|
17
17
|
return true;
|
|
18
18
|
};
|
|
19
|
+
|
|
20
|
+
export default signOutDesktop;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { inArray } from "drizzle-orm";
|
|
2
|
+
import type { ChatServerIntegration } from "@/chatjs/core/chat/contracts";
|
|
3
|
+
import { eveVote } from "./feedback-schema";
|
|
4
|
+
|
|
5
|
+
const feedbackChat = {
|
|
6
|
+
onDeleteConversations: async (tx, { branchIds }) => {
|
|
7
|
+
if (branchIds.length > 0) {
|
|
8
|
+
await tx.delete(eveVote).where(inArray(eveVote.branchId, [...branchIds]));
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
} satisfies ChatServerIntegration;
|
|
12
|
+
|
|
13
|
+
export default feedbackChat;
|
|
@@ -3,7 +3,7 @@ import { definePlugin, slot } from "@/chatjs/core/ui/slots";
|
|
|
3
3
|
import { MessageActions } from "@/components/chat-slots";
|
|
4
4
|
import { FeedbackActions } from "./feedback-actions";
|
|
5
5
|
|
|
6
|
-
export const
|
|
6
|
+
export const chatUi = definePlugin({
|
|
7
7
|
id: "feedback",
|
|
8
8
|
slots: [slot(MessageActions, FeedbackActions)],
|
|
9
9
|
});
|
|
@@ -8,11 +8,11 @@ import { MessageVoteActions } from "./message-vote-actions";
|
|
|
8
8
|
import { useTRPC } from "@/trpc/react";
|
|
9
9
|
|
|
10
10
|
export const FeedbackActions = ({
|
|
11
|
-
|
|
11
|
+
branchId,
|
|
12
12
|
messageId,
|
|
13
13
|
disabled,
|
|
14
14
|
}: {
|
|
15
|
-
readonly
|
|
15
|
+
readonly branchId: string;
|
|
16
16
|
readonly messageId: string;
|
|
17
17
|
readonly disabled: boolean;
|
|
18
18
|
}): ReactJSX.Element => {
|
|
@@ -20,7 +20,7 @@ export const FeedbackActions = ({
|
|
|
20
20
|
const trpc = useTRPC();
|
|
21
21
|
const queryClient = useQueryClient();
|
|
22
22
|
// All messages share one cached query and one request per conversation.
|
|
23
|
-
const options = trpc.feedback.votes.queryOptions({
|
|
23
|
+
const options = trpc.feedback.votes.queryOptions({ branchId });
|
|
24
24
|
const votes = useQuery(options);
|
|
25
25
|
const mutation = useMutation(
|
|
26
26
|
trpc.feedback.vote.mutationOptions({
|
|
@@ -60,7 +60,7 @@ export const FeedbackActions = ({
|
|
|
60
60
|
<MessageVoteActions
|
|
61
61
|
disabled={disabled || votes.isPending || mutation.isPending}
|
|
62
62
|
onVote={async (type) =>
|
|
63
|
-
await mutation.mutateAsync({
|
|
63
|
+
await mutation.mutateAsync({ branchId, messageId, type })
|
|
64
64
|
}
|
|
65
65
|
vote={votes.data?.find((vote) => vote.messageId === messageId)}
|
|
66
66
|
/>
|
|
@@ -14,12 +14,12 @@ type WriteTransaction = Readonly<
|
|
|
14
14
|
* Reads vote state for messages in one bound conversation owned by the user.
|
|
15
15
|
* Public sharing does not grant access to these owner-only votes.
|
|
16
16
|
* @param {string} ownerId Owner whose vote state is requested.
|
|
17
|
-
* @param {string}
|
|
17
|
+
* @param {string} branchId Bound conversation to read.
|
|
18
18
|
* @returns {PromiseLike<Pick<typeof eveVote.$inferSelect, "isUpvoted" | "messageId">[]>} Lazy owner-filtered query. Await it or consume it with .then or .execute to read matching rows; Drizzle query methods remain available before consumption.
|
|
19
19
|
*/
|
|
20
20
|
export const getEveMessageVotes = (
|
|
21
21
|
ownerId: string,
|
|
22
|
-
|
|
22
|
+
branchId: string
|
|
23
23
|
): PgSelectWithout<
|
|
24
24
|
PgSelectBase<
|
|
25
25
|
GetSelectTableName<typeof eveVote>,
|
|
@@ -37,10 +37,10 @@ export const getEveMessageVotes = (
|
|
|
37
37
|
db
|
|
38
38
|
.select({ isUpvoted: eveVote.isUpvoted, messageId: eveVote.messageId })
|
|
39
39
|
.from(eveVote)
|
|
40
|
-
.innerJoin(eveConversation, eq(eveConversation.id, eveVote.
|
|
40
|
+
.innerJoin(eveConversation, eq(eveConversation.id, eveVote.branchId))
|
|
41
41
|
.where(
|
|
42
42
|
and(
|
|
43
|
-
eq(eveConversation.id,
|
|
43
|
+
eq(eveConversation.id, branchId),
|
|
44
44
|
eq(eveConversation.ownerId, ownerId),
|
|
45
45
|
eq(eveConversation.state, "bound")
|
|
46
46
|
)
|
|
@@ -50,14 +50,14 @@ export const getEveMessageVotes = (
|
|
|
50
50
|
* Saves a message vote after validating the message against the native Eve snapshot.
|
|
51
51
|
* The owner and bound-conversation check runs under the conversation-family lock.
|
|
52
52
|
* @param {string} ownerId Owner submitting the vote.
|
|
53
|
-
* @param {string}
|
|
53
|
+
* @param {string} branchId Bound conversation containing the message.
|
|
54
54
|
* @param {string} messageId Native message ID being rated.
|
|
55
55
|
* @param {boolean} isUpvoted Whether the message received a positive vote.
|
|
56
56
|
* @returns {Promise<{ isUpvoted: boolean; messageId: string } | null>} The saved vote, or null when the conversation is no longer bound to the owner.
|
|
57
57
|
*/
|
|
58
58
|
export const saveEveMessageVote = async (
|
|
59
59
|
ownerId: string,
|
|
60
|
-
|
|
60
|
+
branchId: string,
|
|
61
61
|
messageId: string,
|
|
62
62
|
isUpvoted: boolean
|
|
63
63
|
): Promise<Pick<
|
|
@@ -73,7 +73,7 @@ export const saveEveMessageVote = async (
|
|
|
73
73
|
.from(eveConversation)
|
|
74
74
|
.where(
|
|
75
75
|
and(
|
|
76
|
-
eq(eveConversation.id,
|
|
76
|
+
eq(eveConversation.id, branchId),
|
|
77
77
|
eq(eveConversation.ownerId, ownerId),
|
|
78
78
|
eq(eveConversation.state, "bound")
|
|
79
79
|
)
|
|
@@ -83,10 +83,10 @@ export const saveEveMessageVote = async (
|
|
|
83
83
|
}
|
|
84
84
|
const [saved] = await tx
|
|
85
85
|
.insert(eveVote)
|
|
86
|
-
.values({
|
|
86
|
+
.values({ branchId, isUpvoted, messageId })
|
|
87
87
|
.onConflictDoUpdate({
|
|
88
88
|
set: { isUpvoted },
|
|
89
|
-
target: [eveVote.
|
|
89
|
+
target: [eveVote.branchId, eveVote.messageId],
|
|
90
90
|
})
|
|
91
91
|
.returning({
|
|
92
92
|
isUpvoted: eveVote.isUpvoted,
|
|
@@ -97,7 +97,7 @@ export const saveEveMessageVote = async (
|
|
|
97
97
|
|
|
98
98
|
export const getFeedbackConversation = async (
|
|
99
99
|
ownerId: string,
|
|
100
|
-
|
|
100
|
+
branchId: string
|
|
101
101
|
) => {
|
|
102
102
|
const conversations = await db
|
|
103
103
|
.select({
|
|
@@ -107,7 +107,7 @@ export const getFeedbackConversation = async (
|
|
|
107
107
|
.from(eveConversation)
|
|
108
108
|
.where(
|
|
109
109
|
and(
|
|
110
|
-
eq(eveConversation.id,
|
|
110
|
+
eq(eveConversation.id, branchId),
|
|
111
111
|
eq(eveConversation.ownerId, ownerId),
|
|
112
112
|
eq(eveConversation.state, "bound")
|
|
113
113
|
)
|
|
@@ -5,11 +5,11 @@ import { eveConversation } from "@/lib/db/schema";
|
|
|
5
5
|
export const eveVote = pgTable(
|
|
6
6
|
"EveVote",
|
|
7
7
|
{
|
|
8
|
-
|
|
8
|
+
branchId: uuid("branchId")
|
|
9
9
|
.notNull()
|
|
10
10
|
.references(() => eveConversation.id, { onDelete: "cascade" }),
|
|
11
11
|
isUpvoted: boolean("isUpvoted").notNull(),
|
|
12
12
|
messageId: text("messageId").notNull(),
|
|
13
13
|
},
|
|
14
|
-
(table) => [primaryKey({ columns: [table.
|
|
14
|
+
(table) => [primaryKey({ columns: [table.branchId, table.messageId] })]
|
|
15
15
|
);
|
|
@@ -1,26 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
+
"contractVersion": 3,
|
|
3
|
+
"uiBase": "base",
|
|
2
4
|
"id": "feedback",
|
|
3
5
|
"kind": "plugin",
|
|
4
6
|
"files": [
|
|
5
|
-
"chatjs/plugins/feedback/chat.ts",
|
|
6
|
-
"chatjs/plugins/feedback/
|
|
7
|
+
"chatjs/plugins/feedback/chat-server.ts",
|
|
8
|
+
"chatjs/plugins/feedback/chat-ui.ts",
|
|
7
9
|
"chatjs/plugins/feedback/feedback-actions.tsx",
|
|
8
10
|
"chatjs/plugins/feedback/message-vote-actions.tsx",
|
|
9
11
|
"chatjs/plugins/feedback/feedback-queries.ts",
|
|
10
12
|
"chatjs/plugins/feedback/router.ts",
|
|
11
13
|
"chatjs/plugins/feedback/feedback-schema.ts",
|
|
12
|
-
"chatjs/plugins/feedback/server-plugin.ts",
|
|
13
14
|
"chatjs/plugins/feedback/vote-message.ts"
|
|
14
15
|
],
|
|
15
|
-
"databaseSchemas": ["chatjs/plugins/feedback/feedback-schema.ts"]
|
|
16
|
-
"chat": { "export": "feedbackChat" },
|
|
17
|
-
"server": { "export": "feedback", "routers": ["feedback"] },
|
|
18
|
-
"client": {
|
|
19
|
-
"export": "feedbackClient",
|
|
20
|
-
"composerControls": [],
|
|
21
|
-
"settingsItems": [],
|
|
22
|
-
"chat": true
|
|
23
|
-
},
|
|
24
|
-
"contractVersion": 2,
|
|
25
|
-
"uiBase": "base"
|
|
16
|
+
"databaseSchemas": ["chatjs/plugins/feedback/feedback-schema.ts"]
|
|
26
17
|
}
|
|
@@ -7,11 +7,11 @@ import { getEveMessageVotes } from "./feedback-queries";
|
|
|
7
7
|
import { voteEveMessage } from "./vote-message";
|
|
8
8
|
|
|
9
9
|
const MAX_MESSAGE_ID_LENGTH = 512;
|
|
10
|
-
|
|
10
|
+
const feedbackProcedures = {
|
|
11
11
|
vote: eveOwnedProcedure
|
|
12
12
|
.input(
|
|
13
13
|
z.object({
|
|
14
|
-
|
|
14
|
+
branchId: z.uuid(),
|
|
15
15
|
messageId: z.string().nonempty().max(MAX_MESSAGE_ID_LENGTH),
|
|
16
16
|
type: z.enum(["up", "down"]),
|
|
17
17
|
})
|
|
@@ -23,7 +23,7 @@ export const feedbackRouter = createTRPCRouter({
|
|
|
23
23
|
}: {
|
|
24
24
|
readonly ctx: { readonly eveOwnerId: string };
|
|
25
25
|
readonly input: ReadonlyNativeSurface<{
|
|
26
|
-
|
|
26
|
+
branchId: string;
|
|
27
27
|
messageId: string;
|
|
28
28
|
type: "up" | "down";
|
|
29
29
|
}>;
|
|
@@ -39,14 +39,16 @@ export const feedbackRouter = createTRPCRouter({
|
|
|
39
39
|
}
|
|
40
40
|
),
|
|
41
41
|
votes: eveOwnedProcedure
|
|
42
|
-
.input(z.object({
|
|
42
|
+
.input(z.object({ branchId: z.uuid() }))
|
|
43
43
|
.query(
|
|
44
44
|
async ({
|
|
45
45
|
ctx,
|
|
46
46
|
input,
|
|
47
47
|
}: {
|
|
48
48
|
readonly ctx: { readonly eveOwnerId: string };
|
|
49
|
-
readonly input: { readonly
|
|
50
|
-
}) => await getEveMessageVotes(ctx.eveOwnerId, input.
|
|
49
|
+
readonly input: { readonly branchId: string };
|
|
50
|
+
}) => await getEveMessageVotes(ctx.eveOwnerId, input.branchId)
|
|
51
51
|
),
|
|
52
|
-
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const router = createTRPCRouter({ feedback: feedbackProcedures });
|