Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat: New Cap Apps tab, with S3 config page (including endpoints etc)
Richie McIlroyd58c7d7ecee1
diff --git a/apps/desktop/src/routes/(window-chrome)/(main).tsx b/apps/desktop/src/routes/(window-chrome)/(main).tsxindex 3d71e8b8e..07013faf1 100644--- a/apps/desktop/src/routes/(window-chrome)/(main).tsx+++ b/apps/desktop/src/routes/(window-chrome)/(main).tsx@@ -120,6 +120,25 @@ export default function () {<div class="flex items-center justify-between pb-[0.25rem]"><IconCapLogoFull class="w-[90px] h-auto" /><div class="flex items-center space-x-2">+ <Tooltip.Root openDelay={0}>+ <Tooltip.Trigger>+ <button+ type="button"+ onClick={() =>+ commands.showWindow({ Settings: { page: "apps" } })+ }+ >+ <IconLucideCable class="w-[1.25rem] h-[1.25rem] text-gray-400 hover:text-gray-500" />+ </button>+ </Tooltip.Trigger>+ <Tooltip.Portal>+ <Tooltip.Content class="z-50 px-2 py-1 text-xs text-gray-50 bg-gray-500 rounded shadow-lg animate-in fade-in duration-100">+ Cap Apps+ <Tooltip.Arrow class="fill-gray-500" />+ </Tooltip.Content>+ </Tooltip.Portal>+ </Tooltip.Root>+<Tooltip.Root openDelay={0}><Tooltip.Trigger><buttondiff --git a/apps/desktop/src/routes/(window-chrome)/settings.tsx b/apps/desktop/src/routes/(window-chrome)/settings.tsxindex 39b3a47e6..29e9bf9e8 100644--- a/apps/desktop/src/routes/(window-chrome)/settings.tsx+++ b/apps/desktop/src/routes/(window-chrome)/settings.tsx@@ -33,7 +33,7 @@ export default function Settings(props: RouteSectionProps) {{href: "apps",name: "Cap Apps",- icon: IconCapApps,+ icon: IconLucideCable,},{href: "feedback",diff --git a/apps/desktop/src/routes/(window-chrome)/settings/apps.tsx b/apps/desktop/src/routes/(window-chrome)/settings/apps.tsxdeleted file mode 100644index 12f8aeea8..000000000--- a/apps/desktop/src/routes/(window-chrome)/settings/apps.tsx+++ /dev/null@@ -1,3 +0,0 @@-export default function AppsTab() {- return <div></div>;-}diff --git a/apps/desktop/src/routes/(window-chrome)/settings/apps/index.tsx b/apps/desktop/src/routes/(window-chrome)/settings/apps/index.tsxnew file mode 100644index 000000000..32b5e6b1c--- /dev/null+++ b/apps/desktop/src/routes/(window-chrome)/settings/apps/index.tsx@@ -0,0 +1,60 @@+import { Button } from "@cap/ui-solid";+import { useNavigate } from "@solidjs/router";+import { For, createResource } from "solid-js";+import { commands } from "~/utils/tauri";++export default function AppsTab() {+ const navigate = useNavigate();+ const [isUpgraded] = createResource(() => commands.checkUpgradedAndUpdate());++ const apps = [+ {+ name: "S3 Config",+ description:+ "Connect your own S3 bucket. All new shareable link uploads will be uploaded here. Maintain complete ownership over your data.",+ icon: IconLucideDatabase,+ url: "/settings/apps/s3-config",+ pro: true,+ },+ ];++ const handleAppClick = async (app: (typeof apps)[number]) => {+ if (app.pro && !isUpgraded()) {+ await commands.showWindow("Upgrade");+ return;+ }+ navigate(app.url);+ };++ return (+ <div class="p-4">+ <For each={apps}>+ {(app) => (+ <div class="p-1.5 bg-white rounded-lg border border-gray-200">+ <div class="flex justify-between items-center border-b border-gray-200 pb-2">+ <div class="flex items-center gap-3">+ <div class="p-2 rounded-lg bg-gray-100">+ <app.icon class="w-4 h-4 text-gray-500" />+ </div>+ <div class="flex flex-col gap-1">+ <span class="text-sm font-medium text-gray-900">+ {app.name}+ </span>+ </div>+ </div>+ <Button+ variant={app.pro && !isUpgraded() ? "primary" : "secondary"}+ onClick={() => handleAppClick(app)}+ >+ {app.pro && !isUpgraded() ? "Upgrade to Pro" : "Configure"}+ </Button>+ </div>+ <div class="p-2">+ <p class="text-xs text-gray-400">{app.description}</p>+ </div>+ </div>+ )}+ </For>+ </div>+ );+}diff --git a/apps/desktop/src/routes/(window-chrome)/settings/apps/s3-config.tsx b/apps/desktop/src/routes/(window-chrome)/settings/apps/s3-config.tsxnew file mode 100644index 000000000..887586faf--- /dev/null+++ b/apps/desktop/src/routes/(window-chrome)/settings/apps/s3-config.tsx@@ -0,0 +1,226 @@+import { Button } from "@cap/ui-solid";+import { getCurrentWindow } from "@tauri-apps/api/window";+import { createSignal, onMount } from "solid-js";+import { authStore } from "~/store";+import { clientEnv } from "~/utils/env";+import { commands } from "~/utils/tauri";++interface S3Config {+ accessKeyId: string;+ secretAccessKey: string;+ endpoint: string;+ bucketName: string;+ region: string;+}++export default function S3ConfigPage() {+ const [accessKeyId, setAccessKeyId] = createSignal("");+ const [secretAccessKey, setSecretAccessKey] = createSignal("");+ const [endpoint, setEndpoint] = createSignal("https://s3.amazonaws.com");+ const [bucketName, setBucketName] = createSignal("");+ const [region, setRegion] = createSignal("us-east-1");+ const [saving, setSaving] = createSignal(false);+ const [loading, setLoading] = createSignal(true);++ onMount(async () => {+ try {+ const auth = await authStore.get();++ if (!auth) {+ console.error("User not authenticated");+ const window = getCurrentWindow();+ window.close();+ return;+ }++ const response = await fetch(+ `${clientEnv.VITE_SERVER_URL}/api/desktop/s3/config/get?origin=${window.location.origin}`,+ {+ method: "GET",+ credentials: "include",+ headers: {+ Authorization: `Bearer ${auth.token}`,+ },+ }+ );++ if (!response.ok) {+ throw new Error("Failed to fetch S3 configuration");+ }++ const data = await response.json();+ if (data.config) {+ const config = data.config as S3Config;+ setAccessKeyId(config.accessKeyId);+ setSecretAccessKey(config.secretAccessKey);+ setEndpoint(config.endpoint || "https://s3.amazonaws.com");+ setBucketName(config.bucketName);+ setRegion(config.region || "us-east-1");+ }+ } catch (error) {+ console.error("Failed to fetch S3 config:", error);+ } finally {+ setLoading(false);+ }+ });++ const handleSave = async () => {+ setSaving(true);+ try {+ const auth = await authStore.get();++ if (!auth) {+ console.error("User not authenticated");+ const window = getCurrentWindow();+ window.close();+ return;+ }++ const response = await fetch(+ `${clientEnv.VITE_SERVER_URL}/api/desktop/s3/config?origin=${window.location.origin}`,+ {+ method: "POST",+ credentials: "include",+ headers: {+ "Content-Type": "application/json",+ Authorization: `Bearer ${auth.token}`,+ },+ body: JSON.stringify({+ accessKeyId: accessKeyId(),+ secretAccessKey: secretAccessKey(),+ endpoint: endpoint(),+ bucketName: bucketName(),+ region: region(),+ }),+ }+ );++ if (!response.ok) {+ throw new Error("Failed to save S3 configuration");+ }++ await commands.globalMessageDialog("S3 configuration saved successfully");+ } catch (error) {+ console.error("Failed to save S3 config:", error);+ await commands.globalMessageDialog(+ "Failed to save S3 configuration. Please check your settings and try again."+ );+ } finally {+ setSaving(false);+ }+ };++ return (+ <div class="h-full flex flex-col">+ <div class="flex-1 overflow-y-auto">+ <div class="p-4 space-y-4">+ {loading() ? (+ <div class="flex items-center justify-center h-32">+ <div class="animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900"></div>+ </div>+ ) : (+ <div class="space-y-4">+ <div>+ <label class="text-gray-500 text-sm">Access Key ID</label>+ <input+ type="text"+ value={accessKeyId()}+ onInput={(+ e: InputEvent & { currentTarget: HTMLInputElement }+ ) => setAccessKeyId(e.currentTarget.value)}+ placeholder="PL31OADSQNK"+ class="w-full px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"+ autocomplete="off"+ autocapitalize="off"+ autocorrect="off"+ spellcheck={false}+ />+ </div>++ <div>+ <label class="text-gray-500 text-sm">Secret Access Key</label>+ <input+ type="password"+ value={secretAccessKey()}+ onInput={(+ e: InputEvent & { currentTarget: HTMLInputElement }+ ) => setSecretAccessKey(e.currentTarget.value)}+ placeholder="PL31OADSQNK"+ class="w-full px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"+ autocomplete="off"+ autocapitalize="off"+ autocorrect="off"+ spellcheck={false}+ />+ </div>++ <div>+ <label class="text-gray-500 text-sm">Endpoint</label>+ <input+ type="text"+ value={endpoint()}+ onInput={(+ e: InputEvent & { currentTarget: HTMLInputElement }+ ) => setEndpoint(e.currentTarget.value)}+ placeholder="https://s3.amazonaws.com"+ class="w-full px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"+ autocomplete="off"+ autocapitalize="off"+ autocorrect="off"+ spellcheck={false}+ />+ </div>++ <div>+ <label class="text-gray-500 text-sm">Bucket Name</label>+ <input+ type="text"+ value={bucketName()}+ onInput={(+ e: InputEvent & { currentTarget: HTMLInputElement }+ ) => setBucketName(e.currentTarget.value)}+ placeholder="my-bucket"+ class="w-full px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"+ autocomplete="off"+ autocapitalize="off"+ autocorrect="off"+ spellcheck={false}+ />+ </div>++ <div>+ <label class="text-gray-500 text-sm">Region</label>+ <input+ type="text"+ value={region()}+ onInput={(+ e: InputEvent & { currentTarget: HTMLInputElement }+ ) => setRegion(e.currentTarget.value)}+ placeholder="us-east-1"+ class="w-full px-3 py-2 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"+ autocomplete="off"+ autocapitalize="off"+ autocorrect="off"+ spellcheck={false}+ />+ </div>+ </div>+ )}+ </div>+ </div>++ <div class="flex-shrink-0 p-4 border-t">+ <div class="flex justify-end">+ <Button+ variant="primary"+ onClick={handleSave}+ disabled={saving() || loading()}+ class={saving() || loading() ? "opacity-50 cursor-not-allowed" : ""}+ >+ {saving() ? "Saving..." : "Save"}+ </Button>+ </div>+ </div>+ </div>+ );+}diff --git a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx b/apps/desktop/src/routes/(window-chrome)/settings/general.tsxindex 2ab22cc21..0701e2c31 100644--- a/apps/desktop/src/routes/(window-chrome)/settings/general.tsx+++ b/apps/desktop/src/routes/(window-chrome)/settings/general.tsx@@ -12,48 +12,51 @@ const settingsList: Array<{key: keyof GeneralSettingsStore;label: string;description: string;- platforms?: OsType[],+ platforms?: OsType[];requiresPermission?: boolean;+ pro?: boolean;}> = [- {- key: "uploadIndividualFiles",- label: "Upload individual recording files when creating shareable link",- description:- 'Warning: this will cause shareable link uploads to become significantly slower, since all individual recording files will be uploaded. Shows "Download Assets" button in Share page.',- },- {- key: "openEditorAfterRecording",- label: "Open editor automatically after recording stops",- description:- "The editor will be shown immediately after you finish recording.",- },- {- key: "hideDockIcon",- label: "Hide dock icon",- platforms: ["macos"],- description:- "The dock icon will be hidden when there are no windows available to close.",- },- {- key: "autoCreateShareableLink",- label: "Cap Pro: Automatically create shareable link after recording",- description:- "When enabled, a shareable link will be created automatically after stopping the recording. You'll be redirected to the URL while the upload continues in the background.",- },- {- key: "disableAutoOpenLinks",- label: "Cap Pro: Disable automatic link opening",- description:- "When enabled, Cap will not automatically open links in your browser (e.g. after creating a shareable link).",- },- {- key: "enableNotifications",- label: "Enable System Notifications",- description:- "Show system notifications for events like copying to clipboard, saving files, and more. You may need to manually allow Cap access via your system's notification settings.",- requiresPermission: true,- },- ];+ {+ key: "uploadIndividualFiles",+ label: "Upload individual recording files when creating shareable link",+ description:+ 'Warning: this will cause shareable link uploads to become significantly slower, since all individual recording files will be uploaded. Shows "Download Assets" button in Share page.',+ },+ {+ key: "openEditorAfterRecording",+ label: "Open editor automatically after recording stops",+ description:+ "The editor will be shown immediately after you finish recording.",+ },+ {+ key: "hideDockIcon",+ label: "Hide dock icon",+ platforms: ["macos"],+ description:+ "The dock icon will be hidden when there are no windows available to close.",+ },+ {+ key: "autoCreateShareableLink",+ label: "Automatically create shareable link after recording",+ description:+ "When enabled, a shareable link will be created automatically after stopping the recording. You'll be redirected to the URL while the upload continues in the background.",+ pro: true,+ },+ {+ key: "disableAutoOpenLinks",+ label: "Disable automatic link opening",+ description:+ "When enabled, Cap will not automatically open links in your browser (e.g. after creating a shareable link).",+ pro: true,+ },+ {+ key: "enableNotifications",+ label: "Enable System Notifications",+ description:+ "Show system notifications for events like copying to clipboard, saving files, and more. You may need to manually allow Cap access via your system's notification settings.",+ requiresPermission: true,+ },+];export default function GeneralSettings() {const [store] = createResource(() => generalSettingsStore.get());@@ -112,10 +115,19 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {<div class="p-4 space-y-2 divide-y divide-gray-200"><For each={settingsList}>{(setting) => (- <Show when={!setting.platforms || setting.platforms.includes(ostype)}>+ <Show+ when={!setting.platforms || setting.platforms.includes(ostype)}+ ><div class="space-y-2 py-3">+ {setting.pro && (+ <span class="text-xs font-medium bg-blue-400 text-gray-50 px-2 py-1 rounded-lg">+ Cap Pro+ </span>+ )}<div class="flex items-center justify-between">- <p>{setting.label}</p>+ <div class="flex items-center gap-2">+ <p>{setting.label}</p>+ </div><buttontype="button"role="switch"@@ -132,10 +144,11 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {? "on": "off"}- class={`peer inline-flex h-4 w-8 shrink-0 cursor-pointer items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 ${settings[setting.key as keyof GeneralSettingsStore]- ? "bg-blue-400 border-blue-400"- : "bg-gray-300 border-gray-300"- }`}+ class={`peer inline-flex h-4 w-8 shrink-0 cursor-pointer items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 ${+ settings[setting.key as keyof GeneralSettingsStore]+ ? "bg-blue-400 border-blue-400"+ : "bg-gray-300 border-gray-300"+ }`}onClick={() =>handleChange(setting.key,@@ -149,10 +162,11 @@ function Inner(props: { initialStore: GeneralSettingsStore | null }) {? "checked": "unchecked"}- class={`pointer-events-none block h-4 w-4 rounded-full bg-gray-50 shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0 border-2 ${settings[setting.key as keyof GeneralSettingsStore]- ? "border-blue-400"- : "border-gray-300"- }`}+ class={`pointer-events-none block h-4 w-4 rounded-full bg-gray-50 shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0 border-2 ${+ settings[setting.key as keyof GeneralSettingsStore]+ ? "border-blue-400"+ : "border-gray-300"+ }`}/></button></div>diff --git a/apps/desktop/src/routes/(window-chrome)/upgrade.tsx b/apps/desktop/src/routes/(window-chrome)/upgrade.tsxindex e49585a56..cb0b15c6a 100644--- a/apps/desktop/src/routes/(window-chrome)/upgrade.tsx+++ b/apps/desktop/src/routes/(window-chrome)/upgrade.tsx@@ -39,8 +39,6 @@ export default function Page() {return;}- console.log("auth:", auth);-const response = await fetch(`${clientEnv.VITE_SERVER_URL}/api/desktop/subscribe?origin=${window.location.origin}`,{diff --git a/apps/web/app/api/desktop/s3/config/get/route.ts b/apps/web/app/api/desktop/s3/config/get/route.tsnew file mode 100644index 000000000..b4a886db2--- /dev/null+++ b/apps/web/app/api/desktop/s3/config/get/route.ts@@ -0,0 +1,119 @@+import { type NextRequest } from "next/server";+import { db } from "@cap/database";+import { s3Buckets } from "@cap/database/schema";+import { getCurrentUser } from "@cap/database/auth/session";+import { eq } from "drizzle-orm";+import { cookies } from "next/headers";++const allowedOrigins = [+ process.env.NEXT_PUBLIC_URL,+ "http://localhost:3001",+ "http://localhost:3000",+ "tauri://localhost",+ "http://tauri.localhost",+ "https://tauri.localhost",+];++export async function OPTIONS(req: NextRequest) {+ const params = req.nextUrl.searchParams;+ const origin = params.get("origin") || null;+ const originalOrigin = req.nextUrl.origin;++ return new Response(null, {+ status: 200,+ headers: {+ "Access-Control-Allow-Origin":+ origin && allowedOrigins.includes(origin)+ ? origin+ : allowedOrigins.includes(originalOrigin)+ ? originalOrigin+ : "null",+ "Access-Control-Allow-Credentials": "true",+ "Access-Control-Allow-Methods": "GET, OPTIONS",+ "Access-Control-Allow-Headers":+ "Content-Type, Authorization, sentry-trace, baggage",+ },+ });+}++export async function GET(request: NextRequest) {+ const token = request.headers.get("authorization")?.split(" ")[1];+ if (token) {+ cookies().set({+ name: "next-auth.session-token",+ value: token,+ path: "/",+ sameSite: "none",+ secure: true,+ httpOnly: true,+ });+ }++ const params = request.nextUrl.searchParams;+ const origin = params.get("origin") || null;+ const originalOrigin = request.nextUrl.origin;++ try {+ const user = await getCurrentUser();+ if (!user) {+ return new Response(JSON.stringify({ error: "Not authenticated" }), {+ status: 401,+ headers: {+ "Access-Control-Allow-Origin":+ origin && allowedOrigins.includes(origin)+ ? origin+ : allowedOrigins.includes(originalOrigin)+ ? originalOrigin+ : "null",+ "Access-Control-Allow-Credentials": "true",+ },+ });+ }++ const config = await db+ .select({+ accessKeyId: s3Buckets.accessKeyId,+ secretAccessKey: s3Buckets.secretAccessKey,+ endpoint: s3Buckets.endpoint,+ bucketName: s3Buckets.bucketName,+ region: s3Buckets.region,+ })+ .from(s3Buckets)+ .where(eq(s3Buckets.ownerId, user.id));++ return new Response(+ JSON.stringify({+ config: config[0] || null,+ }),+ {+ status: 200,+ headers: {+ "Access-Control-Allow-Origin":+ origin && allowedOrigins.includes(origin)+ ? origin+ : allowedOrigins.includes(originalOrigin)+ ? originalOrigin+ : "null",+ "Access-Control-Allow-Credentials": "true",+ },+ }+ );+ } catch (error) {+ console.error("Error fetching S3 config:", error);+ return new Response(+ JSON.stringify({ error: "Failed to fetch S3 configuration" }),+ {+ status: 500,+ headers: {+ "Access-Control-Allow-Origin":+ origin && allowedOrigins.includes(origin)+ ? origin+ : allowedOrigins.includes(originalOrigin)+ ? originalOrigin+ : "null",+ "Access-Control-Allow-Credentials": "true",+ },+ }+ );+ }+}\ No newline at end of filediff --git a/apps/web/app/api/desktop/s3/config/route.ts b/apps/web/app/api/desktop/s3/config/route.tsnew file mode 100644index 000000000..e8ec9c392--- /dev/null+++ b/apps/web/app/api/desktop/s3/config/route.ts@@ -0,0 +1,187 @@+import { type NextRequest } from "next/server";+import { db } from "@cap/database";+import { s3Buckets, users } from "@cap/database/schema";+import { getCurrentUser } from "@cap/database/auth/session";+import { eq } from "drizzle-orm";+import { nanoId } from "@cap/database/helpers";+import { cookies } from "next/headers";++const allowedOrigins = [+ process.env.NEXT_PUBLIC_URL,+ "http://localhost:3001",+ "http://localhost:3000",+ "tauri://localhost",+ "http://tauri.localhost",+ "https://tauri.localhost",+];++export async function OPTIONS(req: NextRequest) {+ const params = req.nextUrl.searchParams;+ const origin = params.get("origin") || null;+ const originalOrigin = req.nextUrl.origin;++ console.log("Handling OPTIONS request");+ console.log("OPTIONS request params:", { origin, originalOrigin });++ return new Response(null, {+ status: 200,+ headers: {+ "Access-Control-Allow-Origin":+ origin && allowedOrigins.includes(origin)+ ? origin+ : allowedOrigins.includes(originalOrigin)+ ? originalOrigin+ : "null",+ "Access-Control-Allow-Credentials": "true",+ "Access-Control-Allow-Methods": "POST, OPTIONS",+ "Access-Control-Allow-Headers":+ "Content-Type, Authorization, sentry-trace, baggage",+ },+ });+}++export async function POST(request: NextRequest) {+ console.log("Handling POST request");++ const token = request.headers.get("authorization")?.split(" ")[1];+ if (token) {+ console.log("Setting session token cookie");+ cookies().set({+ name: "next-auth.session-token",+ value: token,+ path: "/",+ sameSite: "none",+ secure: true,+ httpOnly: true,+ });+ }++ const params = request.nextUrl.searchParams;+ const origin = params.get("origin") || null;+ const originalOrigin = request.nextUrl.origin;++ console.log("POST request params:", { origin, originalOrigin });++ try {+ console.log("Attempting to save S3 configuration");+ const user = await getCurrentUser();+ if (!user) {+ console.log("User not authenticated");+ return new Response(JSON.stringify({ error: "Not authenticated" }), {+ status: 401,+ headers: {+ "Access-Control-Allow-Origin":+ origin && allowedOrigins.includes(origin)+ ? origin+ : allowedOrigins.includes(originalOrigin)+ ? originalOrigin+ : "null",+ "Access-Control-Allow-Credentials": "true",+ },+ });+ }++ console.log("User authenticated:", user.id);++ const body = await request.json();+ const { accessKeyId, secretAccessKey, endpoint, bucketName, region } = body;++ console.log("Received S3 config request:", { endpoint, bucketName, region });++ // Validate required fields+ if (!accessKeyId || !secretAccessKey || !bucketName) {+ return new Response(+ JSON.stringify({ error: "Missing required fields" }),+ {+ status: 400,+ headers: {+ "Access-Control-Allow-Origin":+ origin && allowedOrigins.includes(origin)+ ? origin+ : allowedOrigins.includes(originalOrigin)+ ? originalOrigin+ : "null",+ "Access-Control-Allow-Credentials": "true",+ },+ }+ );+ }++ console.log("Checking for existing S3 configuration");+ const existingConfigs = await db+ .select()+ .from(s3Buckets)+ .where(eq(s3Buckets.ownerId, user.id));++ const existingConfig = existingConfigs[0];+ console.log("Existing config found:", !!existingConfig);++ let bucketId: string;+ if (existingConfig) {+ bucketId = existingConfig.id;+ console.log("Updating existing S3 configuration");+ await db+ .update(s3Buckets)+ .set({+ accessKeyId,+ secretAccessKey,+ endpoint,+ bucketName,+ region,+ })+ .where(eq(s3Buckets.id, bucketId));+ } else {+ console.log("Creating new S3 configuration for user:", user.id);+ bucketId = nanoId();+ await db.insert(s3Buckets).values({+ id: bucketId,+ ownerId: user.id,+ region: region || "us-east-1",+ endpoint,+ bucketName,+ accessKeyId,+ secretAccessKey,+ });+ console.log("Successfully created new S3 configuration");+ }++ console.log("Updating user's customBucket field");+ await db+ .update(users)+ .set({+ customBucket: bucketId,+ })+ .where(eq(users.id, user.id));++ console.log("S3 configuration saved successfully");+ return new Response(JSON.stringify({ success: true }), {+ status: 200,+ headers: {+ "Access-Control-Allow-Origin":+ origin && allowedOrigins.includes(origin)+ ? origin+ : allowedOrigins.includes(originalOrigin)+ ? originalOrigin+ : "null",+ "Access-Control-Allow-Credentials": "true",+ },+ });+ } catch (error) {+ console.error("Error saving S3 config:", error);+ return new Response(+ JSON.stringify({ error: "Failed to save S3 configuration" }),+ {+ status: 500,+ headers: {+ "Access-Control-Allow-Origin":+ origin && allowedOrigins.includes(origin)+ ? origin+ : allowedOrigins.includes(originalOrigin)+ ? originalOrigin+ : "null",+ "Access-Control-Allow-Credentials": "true",+ },+ }+ );+ }+}\ No newline at end of filediff --git a/packages/ui-solid/src/auto-imports.d.ts b/packages/ui-solid/src/auto-imports.d.tsindex 978386591..2ef6a89af 100644--- a/packages/ui-solid/src/auto-imports.d.ts+++ b/packages/ui-solid/src/auto-imports.d.ts@@ -6,6 +6,7 @@// biome-ignore lint: disableexport {}declare global {+ const IconCapApps: typeof import('~icons/cap/apps.jsx')['default']const IconCapArrows: typeof import('~icons/cap/arrows.jsx')['default']const IconCapAudioOn: typeof import('~icons/cap/audio-on.jsx')['default']const IconCapBlur: typeof import('~icons/cap/blur.jsx')['default']@@ -46,8 +47,12 @@ declare global {const IconCapUndo: typeof import('~icons/cap/undo.jsx')['default']const IconCapUpload: typeof import('~icons/cap/upload.jsx')['default']const IconLucideBell: typeof import('~icons/lucide/bell.jsx')['default']+ const IconLucideCable: typeof import('~icons/lucide/cable.jsx')['default']const IconLucideCamera: typeof import('~icons/lucide/camera.jsx')['default']const IconLucideCheck: typeof import('~icons/lucide/check.jsx')['default']+ const IconLucideCloud: typeof import('~icons/lucide/cloud.jsx')['default']+ const IconLucideDatabase: typeof import('~icons/lucide/database.jsx')['default']+ const IconLucideDevice: typeof import('~icons/lucide/device.jsx')['default']const IconLucideEdit: typeof import('~icons/lucide/edit.jsx')['default']const IconLucideEye: typeof import('~icons/lucide/eye.jsx')['default']const IconLucideFolder: typeof import('~icons/lucide/folder.jsx')['default']@@ -56,6 +61,7 @@ declare global {const IconLucideRabbit: typeof import('~icons/lucide/rabbit.jsx')['default']const IconLucideRotateCcw: typeof import('~icons/lucide/rotate-ccw.jsx')['default']const IconLucideSearch: typeof import('~icons/lucide/search.jsx')['default']+ const IconLucideSettings: typeof import('~icons/lucide/settings.jsx')['default']const IconLucideSquarePlay: typeof import('~icons/lucide/square-play.jsx')['default']const IconLucideVolume2: typeof import('~icons/lucide/volume2.jsx')['default']const IconLucideVolumeX: typeof import('~icons/lucide/volume-x.jsx')['default']