diff --git a/.posthog/wizard-spellbook-3Pm3hv/skills/mcp-analytics/SKILL.md b/.posthog/wizard-spellbook-3Pm3hv/skills/mcp-analytics/SKILL.md index 21016f6..f2198c7 100644 --- a/.posthog/wizard-spellbook-3Pm3hv/skills/mcp-analytics/SKILL.md +++ b/.posthog/wizard-spellbook-3Pm3hv/skills/mcp-analytics/SKILL.md @@ -1,15 +1,16 @@ --- + name: mcp-analytics description: >- - Add PostHog MCP analytics to a TypeScript, JavaScript, or Python MCP server. - Captures tool calls, agent intent, failures, and protocol revision, plus - self-reported model identity on supported TypeScript paths. Both SDKs support - legacy sessions and the handshake-free 2026-07-28 revision. Detects the server - style and wires in compatible instrumentation, credentials, conversation - correlation, and graceful shutdown. +Add PostHog MCP analytics to a TypeScript, JavaScript, or Python MCP server. +Captures tool calls, agent intent, failures, and protocol revision, plus +self-reported model identity on supported TypeScript paths. Both SDKs support +legacy sessions and the handshake-free 2026-07-28 revision. Detects the server +style and wires in compatible instrumentation, credentials, conversation +correlation, and graceful shutdown. metadata: - author: PostHog - version: 1.59.0 +author: PostHog +version: 1.59.0 --- # Add PostHog MCP analytics @@ -204,7 +205,12 @@ const serverTools = getServerTools(); const advertisedTools = posthog.prepareToolList(serverTools); // only on a 2025-11-25 initialize handshake: -posthog.captureInitialize({ clientName, clientVersion, distinctId, protocolVersion: "2025-11-25" }); +posthog.captureInitialize({ + clientName, + clientVersion, + distinctId, + protocolVersion: "2025-11-25", +}); // after each tools/call resolves (wrap the existing handler, time it): const start = Date.now(); @@ -212,7 +218,9 @@ const originalTool = serverTools.find((tool) => tool.name === request.params.nam const { args, intent, intentSource, llmModel, llmModelSource } = posthog.prepareToolCall( request.params.name, request.params.arguments, - { originalTool }, + { + originalTool, + }, ); const result = await runTool(request.params.name, args); posthog.captureToolCall({ diff --git a/.posthog/wizard-spellbook-WsJDnA/skills/integration-sveltekit/references/EXAMPLE.md b/.posthog/wizard-spellbook-WsJDnA/skills/integration-sveltekit/references/EXAMPLE.md index 0d48c3c..97f204e 100644 --- a/.posthog/wizard-spellbook-WsJDnA/skills/integration-sveltekit/references/EXAMPLE.md +++ b/.posthog/wizard-spellbook-WsJDnA/skills/integration-sveltekit/references/EXAMPLE.md @@ -294,7 +294,7 @@ export const handleError: HandleClientError = async ({ error, status, message }) ```ts import type { Handle, HandleServerError } from "@sveltejs/kit"; -import { getPostHogClient } from "$lib/server/posthog"; +import { getPostHogClient } from "#lib/server/posthog"; // Handle requests - includes reverse proxy for PostHog export const handle: Handle = async ({ event, resolve }) => { @@ -451,7 +451,7 @@ export function getAuthContext(): AuthState { ```svelte @@ -481,7 +481,7 @@ export function getAuthContext(): AuthState { ## src/lib/index.ts ```ts -// place files you want to import through the `$lib` alias in this folder. +// place files you want to import through the `#lib` alias in this folder. ``` --- @@ -517,8 +517,8 @@ export async function shutdownPostHog() { ```svelte + {/if} + + + + {mediaType} + + + + {#if activeTab === "upload"} + +
+ void handleFiles(e.currentTarget.files)} + class="hidden" + /> + + {#if isUploading} +
+ + {uploadStatus} +
+ {:else} +
+ + + + + +
+ {#if mediaType === "video"} +
+ +
+ +
+
+ +
+ + Click to upload {mediaType} + + or drag and drop +
+ +

Maximum 3 files, {mediaConstraint.label} each.

+ {/if}
{:else} - -
- - - - - - - -
- {#if mediaType === "video"} -
diff --git a/src/lib/components/edra/shadcn/components/Mermaid.svelte b/src/lib/components/edra/shadcn/components/Mermaid.svelte index 017fc06..6411617 100644 --- a/src/lib/components/edra/shadcn/components/Mermaid.svelte +++ b/src/lib/components/edra/shadcn/components/Mermaid.svelte @@ -1,15 +1,15 @@ diff --git a/src/lib/components/edra/shadcn/toc.ts b/src/lib/components/edra/shadcn/toc.ts index be45fdc..8a84392 100644 --- a/src/lib/components/edra/shadcn/toc.ts +++ b/src/lib/components/edra/shadcn/toc.ts @@ -1 +1 @@ -export { getTocItems, setTocItems } from "./toc.state.svelte.js"; +export { getTocItems, setTocItems } from "./toc.state.svelte"; diff --git a/src/lib/components/edra/strings.ts b/src/lib/components/edra/strings.ts index 0e8fddc..11668fc 100644 --- a/src/lib/components/edra/strings.ts +++ b/src/lib/components/edra/strings.ts @@ -1,2 +1,2 @@ // Re-export from the split strings module -export { default } from "./strings/index.js"; +export { default } from "./strings/index"; diff --git a/src/lib/components/edra/strings/commands.ts b/src/lib/components/edra/strings/commands.ts index 1de6d3b..56d558d 100644 --- a/src/lib/components/edra/strings/commands.ts +++ b/src/lib/components/edra/strings/commands.ts @@ -27,6 +27,7 @@ export const commandStrings = { videoPlaceholder: "Video Placeholder", audioPlaceholder: "Audio Placeholder", iframePlaceholder: "Iframe Placeholder", + youtubePlaceholder: "YouTube Video", table: "Table", inlineExpression: "Inline Expression", blockExpression: "Block Expression", diff --git a/src/lib/components/edra/strings/index.ts b/src/lib/components/edra/strings/index.ts index 5c1b358..43fe514 100644 --- a/src/lib/components/edra/strings/index.ts +++ b/src/lib/components/edra/strings/index.ts @@ -1,5 +1,5 @@ -import { commandStrings } from "./commands.js"; -import { dragHandleStrings, editorStrings } from "./editor.js"; +import { commandStrings } from "./commands"; +import { dragHandleStrings, editorStrings } from "./editor"; import { audioStrings, codeStrings, @@ -8,8 +8,8 @@ import { mediaStrings, tableStrings, videoStrings, -} from "./extensions.js"; -import { menuStrings, toolbarStrings } from "./menu-toolbar.js"; +} from "./extensions"; +import { menuStrings, toolbarStrings } from "./menu-toolbar"; const strings = { command: commandStrings, diff --git a/src/lib/components/edra/tiptap/components/Tiptap.svelte b/src/lib/components/edra/tiptap/components/Tiptap.svelte index fbd896b..177890b 100644 --- a/src/lib/components/edra/tiptap/components/Tiptap.svelte +++ b/src/lib/components/edra/tiptap/components/Tiptap.svelte @@ -1,7 +1,7 @@ diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 191aef1..8bc428d 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -3,10 +3,11 @@ import ArrowRight from "@lucide/svelte/icons/arrow-right"; import BookOpen from "@lucide/svelte/icons/book-open"; import Sparkles from "@lucide/svelte/icons/sparkles"; import { onMount } from "svelte"; -import DemoPreview from "$lib/components/DemoPreview.svelte"; -import Hero from "$lib/components/Hero.svelte"; -import { localizeHref } from "$lib/i18n"; -import * as m from "$lib/i18n/messages"; +import DemoPreview from "#lib/components/DemoPreview.svelte"; +import Hero from "#lib/components/Hero.svelte"; +import Supademo from "#lib/components/Supademo.svelte"; +import { localizeHref } from "#lib/i18n"; +import * as m from "#lib/i18n/messages"; interface SupademoWindow { Supademo?: { @@ -92,6 +93,8 @@ onMount(() => {
+ + diff --git a/src/routes/+page.ts b/src/routes/+page.ts index 5d4d49d..11b2e22 100644 --- a/src/routes/+page.ts +++ b/src/routes/+page.ts @@ -1,10 +1,7 @@ -import type { PageSeoOverride } from "$lib/seo"; -import { HOME_DESCRIPTION, SITE } from "$lib/seo"; +import type { PageSeoOverride } from "#lib/seo"; +import { HOME_DESCRIPTION, SITE } from "#lib/seo"; -// since there's no dynamic data here, we can prerender -// it so that it gets served as a static asset in production export const prerender = true; - export const load = (): { seo: PageSeoOverride } => ({ seo: { jsonLd: [ @@ -41,7 +38,7 @@ export const load = (): { seo: PageSeoOverride } => ({ name: "Does LightCMS require an external database?", acceptedAnswer: { "@type": "Answer", - text: "No. LightCMS is completely database-free for content storage. All posts and assets live directly inside your Git repository as flat files.", + text: "No. LightCMS is 100% database free for content storage. All posts and assets live directly inside your Git repository as flat files.", }, }, ], diff --git a/src/routes/about/+page.svelte b/src/routes/about/+page.svelte index c51271f..3abc3f5 100644 --- a/src/routes/about/+page.svelte +++ b/src/routes/about/+page.svelte @@ -4,10 +4,10 @@ import Heart from "@lucide/svelte/icons/heart"; import Mail from "@lucide/svelte/icons/mail"; import MessageCircle from "@lucide/svelte/icons/message-circle"; import ShieldCheck from "@lucide/svelte/icons/shield-check"; -import { Button } from "$lib/components/ui/button"; -import { localizeHref } from "$lib/i18n"; -import * as m from "$lib/i18n/messages"; -import { SITE } from "$lib/seo"; +import { Button } from "#lib/components/ui/button"; +import { localizeHref } from "#lib/i18n"; +import * as m from "#lib/i18n/messages"; +import { SITE } from "#lib/seo"; type FooterAction = { href: string; diff --git a/src/routes/api/github/webhook/+server.ts b/src/routes/api/github/webhook/+server.ts index b5604d4..3c9b4b0 100644 --- a/src/routes/api/github/webhook/+server.ts +++ b/src/routes/api/github/webhook/+server.ts @@ -1,6 +1,6 @@ import type { EmitterWebhookEventName } from "@octokit/webhooks"; -import { getProbot } from "$lib/server/probot.js"; -import type { RequestHandler } from "./$types.js"; +import { getProbot } from "#lib/server/probot"; +import type { RequestHandler } from "./$types"; function missingHeadersResponse(): Response { return Response.json({ error: "Missing required GitHub webhook headers" }, { status: 400 }); diff --git a/src/routes/api/rpc/[...rest]/+server.ts b/src/routes/api/rpc/[...rest]/+server.ts index 0a249b6..67d35c8 100644 --- a/src/routes/api/rpc/[...rest]/+server.ts +++ b/src/routes/api/rpc/[...rest]/+server.ts @@ -1,6 +1,6 @@ import { onError } from "@orpc/server"; import { RPCHandler } from "@orpc/server/fetch"; -import { router } from "$lib/server/orpc/router"; +import { router } from "#lib/server/orpc/router"; import type { RequestHandler } from "./$types"; const handler = new RPCHandler(router, { diff --git a/src/routes/auth/+page.server.ts b/src/routes/auth/+page.server.ts index 6b2b67f..46638c6 100644 --- a/src/routes/auth/+page.server.ts +++ b/src/routes/auth/+page.server.ts @@ -2,7 +2,7 @@ import { fail } from "@sveltejs/kit"; import { message, superValidate } from "sveltekit-superforms"; import { zod4 } from "sveltekit-superforms/adapters"; import { z } from "zod"; -import { getAuth } from "$lib/server/auth"; +import { getAuth } from "#lib/server/auth"; import type { PageServerLoad } from "./$types"; diff --git a/src/routes/auth/+page.svelte b/src/routes/auth/+page.svelte index 259273d..fd28dce 100644 --- a/src/routes/auth/+page.svelte +++ b/src/routes/auth/+page.svelte @@ -8,37 +8,37 @@ import ShieldCheck from "@lucide/svelte/icons/shield-check"; import Trash2 from "@lucide/svelte/icons/trash-2"; import { untrack } from "svelte"; import { superForm } from "sveltekit-superforms"; +import { authClient, signIn, signOut } from "#lib/auth-client"; +import { Button } from "#lib/components/ui/button"; +import { Input } from "#lib/components/ui/input"; +import * as m from "#lib/i18n/messages"; +import { getAuthenticatorName } from "#lib/passkey"; import { goto } from "$app/navigation"; import { page } from "$app/state"; -import { authClient, signIn, signOut } from "$lib/auth-client"; -import { Button } from "$lib/components/ui/button"; -import { Input } from "$lib/components/ui/input"; -import * as m from "$lib/i18n/messages"; -import { getAuthenticatorName } from "$lib/passkey"; import type { PageData } from "./$types"; type PasskeySummary = { - id: string; - name?: string | null; - aaguid?: string | null; - backedUp?: boolean | null; - createdAt?: Date | string | null; + id: string; + name?: string | null; + aaguid?: string | null; + backedUp?: boolean | null; + createdAt?: Date | string | null; }; type PasskeyError = { - code?: string; - message?: string; + code?: string; + message?: string; }; let { data }: { data: PageData } = $props(); const nextPath = $derived(data.next ?? "/cms"); const authForm = untrack(() => superForm(data.form)); const { - form: authValues, - errors: authErrors, - enhance: authEnhance, - message: authMessage, - submitting: authSubmitting, + form: authValues, + errors: authErrors, + enhance: authEnhance, + message: authMessage, + submitting: authSubmitting, } = authForm; let isUsingPasskey = $state(false); @@ -59,337 +59,343 @@ let passkeyNotice = $state(null); let conditionalPasskeyStarted = false; const headingTitle = $derived( - data.session ? m.auth_account_title() : m.auth_sign_in_title(), + data.session ? m.auth_account_title() : m.auth_sign_in_title(), ); const headingDesc = $derived( - data.session ? m.auth_account_desc() : m.auth_sign_in_desc(), + data.session ? m.auth_account_desc() : m.auth_sign_in_desc(), ); const githubButtonText = $derived( - isSigningInWithGitHub - ? m.auth_redirecting_github() - : m.auth_continue_github(), + isSigningInWithGitHub + ? m.auth_redirecting_github() + : m.auth_continue_github(), ); const passkeyButtonText = $derived( - isUsingPasskey - ? m.auth_authenticating_passkey() - : m.auth_use_passkey(), + isUsingPasskey ? m.auth_authenticating_passkey() : m.auth_use_passkey(), ); const submitButtonText = $derived( - $authSubmitting ? m.auth_email_submitting() : m.auth_email_submit(), + $authSubmitting ? m.auth_email_submitting() : m.auth_email_submit(), ); const passkeyDateFormatter = new Intl.DateTimeFormat(undefined, { - dateStyle: "medium", + dateStyle: "medium", }); function describePasskeyError(error: PasskeyError | null | undefined): string { - if (!error) { - return m.auth_passkey_error(); - } - - if (error.code === "AUTH_CANCELLED" || error.code === "REGISTRATION_CANCELLED") { - return m.auth_passkey_canceled(); - } - - return error.message || m.auth_passkey_error(); + if (!error) { + return m.auth_passkey_error(); + } + + if ( + error.code === "AUTH_CANCELLED" || + error.code === "REGISTRATION_CANCELLED" + ) { + return m.auth_passkey_canceled(); + } + + return error.message || m.auth_passkey_error(); } function getPasskeyLabel(passkey: PasskeySummary): string { - return ( - passkey.name?.trim() || - getAuthenticatorName(passkey.aaguid) || - m.auth_passkey_unnamed() - ); + return ( + passkey.name?.trim() || + getAuthenticatorName(passkey.aaguid) || + m.auth_passkey_unnamed() + ); } -function formatPasskeyDate(createdAt: Date | string | null | undefined): string { - if (!createdAt) { - return ""; - } +function formatPasskeyDate( + createdAt: Date | string | null | undefined, +): string { + if (!createdAt) { + return ""; + } - const date = createdAt instanceof Date ? createdAt : new Date(createdAt); - if (Number.isNaN(date.getTime())) { - return ""; - } + const date = createdAt instanceof Date ? createdAt : new Date(createdAt); + if (Number.isNaN(date.getTime())) { + return ""; + } - return `${m.auth_passkey_created()} ${passkeyDateFormatter.format(date)}`; + return `${m.auth_passkey_created()} ${passkeyDateFormatter.format(date)}`; } function describePasskeyMeta(passkey: PasskeySummary): string { - const parts: string[] = []; - const authenticatorName = getAuthenticatorName(passkey.aaguid); + const parts: string[] = []; + const authenticatorName = getAuthenticatorName(passkey.aaguid); - if (passkey.name?.trim() && authenticatorName) { - parts.push(authenticatorName); - } + if (passkey.name?.trim() && authenticatorName) { + parts.push(authenticatorName); + } - parts.push( - passkey.backedUp ? m.auth_passkey_synced() : m.auth_passkey_device_bound(), - ); + parts.push( + passkey.backedUp ? m.auth_passkey_synced() : m.auth_passkey_device_bound(), + ); - const created = formatPasskeyDate(passkey.createdAt); - if (created) { - parts.push(created); - } + const created = formatPasskeyDate(passkey.createdAt); + if (created) { + parts.push(created); + } - return parts.join(" · "); + return parts.join(" · "); } async function refreshPasskeys() { - isLoadingPasskeys = true; - try { - const result = await authClient.passkey.listUserPasskeys(); - if (result.error) { - passkeyError = describePasskeyError(result.error); - return; - } - passkeys = result.data ?? []; - } catch (cause) { - passkeyError = - cause instanceof Error ? cause.message : m.auth_passkey_error(); - } finally { - isLoadingPasskeys = false; - } + isLoadingPasskeys = true; + try { + const result = await authClient.passkey.listUserPasskeys(); + if (result.error) { + passkeyError = describePasskeyError(result.error); + return; + } + passkeys = result.data ?? []; + } catch (cause) { + passkeyError = + cause instanceof Error ? cause.message : m.auth_passkey_error(); + } finally { + isLoadingPasskeys = false; + } } async function startConditionalPasskey() { - try { - const conditionalSupported = - typeof PublicKeyCredential !== "undefined" && - typeof PublicKeyCredential.isConditionalMediationAvailable === "function" && - (await PublicKeyCredential.isConditionalMediationAvailable()); - - if (!conditionalSupported) { - return; - } - - const result = await signIn.passkey({ autoFill: true }); - if (result.error) { - return; - } - - window.location.assign(nextPath); - } catch { - // Conditional UI is best-effort; the passkey button surfaces real errors. - } + try { + const conditionalSupported = + typeof PublicKeyCredential !== "undefined" && + typeof PublicKeyCredential.isConditionalMediationAvailable === + "function" && + (await PublicKeyCredential.isConditionalMediationAvailable()); + + if (!conditionalSupported) { + return; + } + + const result = await signIn.passkey({ autoFill: true }); + if (result.error) { + return; + } + + window.location.assign(nextPath); + } catch { + // Conditional UI is best-effort; the passkey button surfaces real errors. + } } async function signInWithGitHub() { - if (isSigningInWithGitHub) return; - isSigningInWithGitHub = true; - try { - await signIn.social({ - provider: "github", - callbackURL: nextPath, - errorCallbackURL: "/auth", - }); - } finally { - isSigningInWithGitHub = false; - } + if (isSigningInWithGitHub) return; + isSigningInWithGitHub = true; + try { + await signIn.social({ + provider: "github", + callbackURL: nextPath, + errorCallbackURL: "/auth", + }); + } finally { + isSigningInWithGitHub = false; + } } let _isLinkingGitHub = $state(false); async function _linkGitHub() { - _isLinkingGitHub = true; - try { - await authClient.linkSocial({ - provider: "github", - callbackURL: "/cms", - errorCallbackURL: "/auth", - }); - } finally { - _isLinkingGitHub = false; - } + _isLinkingGitHub = true; + try { + await authClient.linkSocial({ + provider: "github", + callbackURL: "/cms", + errorCallbackURL: "/auth", + }); + } finally { + _isLinkingGitHub = false; + } } async function _signOutUser() { - try { - await signOut(); - } finally { - await goto("/signout", { invalidateAll: true }); - } + try { + await signOut(); + } finally { + await goto("/signout", { invalidateAll: true }); + } } async function signInWithPasskey() { - if (isUsingPasskey) return; - isUsingPasskey = true; - passkeyError = null; - passkeyNotice = null; - - try { - const result = await signIn.passkey({ autoFill: false }); - if (result.error) { - passkeyError = describePasskeyError(result.error); - return; - } - - window.location.assign(nextPath); - } catch (cause) { - passkeyError = - cause instanceof Error ? cause.message : m.auth_passkey_error(); - } finally { - isUsingPasskey = false; - } + if (isUsingPasskey) return; + isUsingPasskey = true; + passkeyError = null; + passkeyNotice = null; + + try { + const result = await signIn.passkey({ autoFill: false }); + if (result.error) { + passkeyError = describePasskeyError(result.error); + return; + } + + window.location.assign(nextPath); + } catch (cause) { + passkeyError = + cause instanceof Error ? cause.message : m.auth_passkey_error(); + } finally { + isUsingPasskey = false; + } } function openPasskeyForm() { - if (isAddingPasskey) { - return; - } - - passkeyError = null; - passkeyNotice = null; - editingPasskeyId = null; - editingPasskeyName = ""; - newPasskeyName = ""; - isNamingPasskey = true; + if (isAddingPasskey) { + return; + } + + passkeyError = null; + passkeyNotice = null; + editingPasskeyId = null; + editingPasskeyName = ""; + newPasskeyName = ""; + isNamingPasskey = true; } function closePasskeyForm() { - if (isAddingPasskey) { - return; - } + if (isAddingPasskey) { + return; + } - isNamingPasskey = false; - newPasskeyName = ""; + isNamingPasskey = false; + newPasskeyName = ""; } async function createPasskey() { - if (isAddingPasskey) return; - isAddingPasskey = true; - passkeyError = null; - passkeyNotice = null; - - try { - const name = newPasskeyName.trim(); - const result = await authClient.passkey.addPasskey(name ? { name } : undefined); - if (result.error) { - passkeyError = describePasskeyError(result.error); - return; - } - - isNamingPasskey = false; - newPasskeyName = ""; - await refreshPasskeys(); - passkeyNotice = m.auth_passkey_added(); - } catch (cause) { - passkeyError = - cause instanceof Error ? cause.message : m.auth_passkey_error(); - } finally { - isAddingPasskey = false; - } + if (isAddingPasskey) return; + isAddingPasskey = true; + passkeyError = null; + passkeyNotice = null; + + try { + const name = newPasskeyName.trim(); + const result = await authClient.passkey.addPasskey( + name ? { name } : undefined, + ); + if (result.error) { + passkeyError = describePasskeyError(result.error); + return; + } + + isNamingPasskey = false; + newPasskeyName = ""; + await refreshPasskeys(); + passkeyNotice = m.auth_passkey_added(); + } catch (cause) { + passkeyError = + cause instanceof Error ? cause.message : m.auth_passkey_error(); + } finally { + isAddingPasskey = false; + } } function startRenamingPasskey(passkey: PasskeySummary) { - if (savingPasskeyId) { - return; - } - - passkeyError = null; - passkeyNotice = null; - isNamingPasskey = false; - newPasskeyName = ""; - editingPasskeyId = passkey.id; - editingPasskeyName = passkey.name?.trim() ?? ""; + if (savingPasskeyId) { + return; + } + + passkeyError = null; + passkeyNotice = null; + isNamingPasskey = false; + newPasskeyName = ""; + editingPasskeyId = passkey.id; + editingPasskeyName = passkey.name?.trim() ?? ""; } function cancelRenamingPasskey() { - if (savingPasskeyId) { - return; - } + if (savingPasskeyId) { + return; + } - editingPasskeyId = null; - editingPasskeyName = ""; + editingPasskeyId = null; + editingPasskeyName = ""; } async function renamePasskey(id: string) { - if (savingPasskeyId) return; - - const name = editingPasskeyName.trim(); - if (!name) { - passkeyError = m.auth_passkey_name_required(); - return; - } - - savingPasskeyId = id; - passkeyError = null; - passkeyNotice = null; - - try { - const result = await authClient.passkey.updatePasskey({ id, name }); - if (result.error) { - passkeyError = describePasskeyError(result.error); - return; - } - - editingPasskeyId = null; - editingPasskeyName = ""; - await refreshPasskeys(); - passkeyNotice = m.auth_passkey_renamed(); - } catch (cause) { - passkeyError = - cause instanceof Error ? cause.message : m.auth_passkey_error(); - } finally { - savingPasskeyId = null; - } + if (savingPasskeyId) return; + + const name = editingPasskeyName.trim(); + if (!name) { + passkeyError = m.auth_passkey_name_required(); + return; + } + + savingPasskeyId = id; + passkeyError = null; + passkeyNotice = null; + + try { + const result = await authClient.passkey.updatePasskey({ id, name }); + if (result.error) { + passkeyError = describePasskeyError(result.error); + return; + } + + editingPasskeyId = null; + editingPasskeyName = ""; + await refreshPasskeys(); + passkeyNotice = m.auth_passkey_renamed(); + } catch (cause) { + passkeyError = + cause instanceof Error ? cause.message : m.auth_passkey_error(); + } finally { + savingPasskeyId = null; + } } async function removePasskey(id: string) { - if (removingPasskeyId) return; - removingPasskeyId = id; - passkeyError = null; - passkeyNotice = null; - - try { - const result = await authClient.passkey.deletePasskey({ id }); - if (result.error) { - passkeyError = describePasskeyError(result.error); - return; - } - - if (editingPasskeyId === id) { - editingPasskeyId = null; - editingPasskeyName = ""; - } - - await refreshPasskeys(); - passkeyNotice = m.auth_passkey_removed(); - } catch (cause) { - passkeyError = - cause instanceof Error ? cause.message : m.auth_passkey_error(); - } finally { - removingPasskeyId = null; - } + if (removingPasskeyId) return; + removingPasskeyId = id; + passkeyError = null; + passkeyNotice = null; + + try { + const result = await authClient.passkey.deletePasskey({ id }); + if (result.error) { + passkeyError = describePasskeyError(result.error); + return; + } + + if (editingPasskeyId === id) { + editingPasskeyId = null; + editingPasskeyName = ""; + } + + await refreshPasskeys(); + passkeyNotice = m.auth_passkey_removed(); + } catch (cause) { + passkeyError = + cause instanceof Error ? cause.message : m.auth_passkey_error(); + } finally { + removingPasskeyId = null; + } } $effect(() => { - if (!data.session) { - passkeys = []; - return; - } + if (!data.session) { + passkeys = []; + return; + } - void refreshPasskeys(); + void refreshPasskeys(); }); $effect(() => { - if (data.session || conditionalPasskeyStarted) { - return; - } + if (data.session || conditionalPasskeyStarted) { + return; + } - conditionalPasskeyStarted = true; - void startConditionalPasskey(); + conditionalPasskeyStarted = true; + void startConditionalPasskey(); }); $effect(() => { - if (isNamingPasskey) { - passkeyNameInput?.focus(); - } + if (isNamingPasskey) { + passkeyNameInput?.focus(); + } }); $effect(() => { - if (editingPasskeyId) { - renamePasskeyInput?.focus(); - } + if (editingPasskeyId) { + renamePasskeyInput?.focus(); + } }); diff --git a/src/routes/cms/+page.server.ts b/src/routes/cms/+page.server.ts index 311fdad..a522e39 100644 --- a/src/routes/cms/+page.server.ts +++ b/src/routes/cms/+page.server.ts @@ -1,19 +1,19 @@ import { fail, redirect } from "@sveltejs/kit"; -import { createFolderAtPath, listDirectory, resolveRepository } from "$lib/server/cms"; -import { getCmsQuery, getCmsSelection, tryGetCmsSelection } from "$lib/server/cms-context"; -import { assertCollectionName, getCollection, type LightCmsCollection } from "$lib/server/config"; +import { createFolderAtPath, listDirectory, resolveRepository } from "#lib/server/cms"; +import { getCmsQuery, getCmsSelection, tryGetCmsSelection } from "#lib/server/cms-context"; +import { assertCollectionName, getCollection, type LightCmsCollection } from "#lib/server/config"; import { isGitHubStatus, listBranches as listRepoBranches, listRepositories, -} from "$lib/server/github"; -import { captureServerEvent } from "$lib/server/posthog"; +} from "#lib/server/github"; +import { captureServerEvent } from "#lib/server/posthog"; import { getCmsContext, listGitHubInstallations, removeStaleInstallation, -} from "$lib/server/session"; -import { fetchTemplates, type TemplatesResult } from "$lib/templates"; +} from "#lib/server/session"; +import { fetchTemplates, type TemplatesResult } from "#lib/templates"; import type { Actions, PageServerLoad } from "./$types"; const TEMPLATE_OWNER = "light-cms"; diff --git a/src/routes/cms/+page.svelte b/src/routes/cms/+page.svelte index ed55d57..8458a1f 100644 --- a/src/routes/cms/+page.svelte +++ b/src/routes/cms/+page.svelte @@ -11,13 +11,13 @@ import LayoutTemplate from "@lucide/svelte/icons/layout-template"; import Settings from "@lucide/svelte/icons/settings"; import Sparkles from "@lucide/svelte/icons/sparkles"; import { toast } from "svelte-sonner"; -import { goto, refreshAll } from "$app/navigation"; import { CreateBranchDialog, CreateFolderDialog, TemplateDrawer, -} from "$lib/components/custom"; -import { Button } from "$lib/components/ui/button"; +} from "#lib/components/custom"; +import { Button } from "#lib/components/ui/button"; +import { goto, refreshAll } from "$app/navigation"; import type { PageData } from "./$types"; let { data, form }: { data: PageData; form?: { error?: string } | null } = diff --git a/src/routes/cms/[collection]/+page.server.ts b/src/routes/cms/[collection]/+page.server.ts index 99e9011..b2b377f 100644 --- a/src/routes/cms/[collection]/+page.server.ts +++ b/src/routes/cms/[collection]/+page.server.ts @@ -5,11 +5,11 @@ import { initializeCollection, listCollectionEntries, moveCollectionEntry, -} from "$lib/server/cms"; +} from "#lib/server/cms"; -import { getConfiguredCollection } from "$lib/server/cms-context"; -import { joinPath, normalizeContentPath, normalizeFolder } from "$lib/server/paths"; -import { captureServerEvent } from "$lib/server/posthog"; +import { getConfiguredCollection } from "#lib/server/cms-context"; +import { joinPath, normalizeContentPath, normalizeFolder } from "#lib/server/paths"; +import { captureServerEvent } from "#lib/server/posthog"; import type { Actions, PageServerLoad } from "./$types"; function getInitializeErrorMessage(error: unknown): string { diff --git a/src/routes/cms/[collection]/+page.svelte b/src/routes/cms/[collection]/+page.svelte index 074193e..1e31ac9 100644 --- a/src/routes/cms/[collection]/+page.svelte +++ b/src/routes/cms/[collection]/+page.svelte @@ -14,10 +14,8 @@ import Sparkles from "@lucide/svelte/icons/sparkles"; import Trash from "@lucide/svelte/icons/trash"; import TriangleAlert from "@lucide/svelte/icons/triangle-alert"; import { toast } from "svelte-sonner"; -import { enhance } from "$app/forms"; -import { goto, refreshAll } from "$app/navigation"; -import { CreateFolderDialog } from "$lib/components/custom"; -import { Button } from "$lib/components/ui/button"; +import { CreateFolderDialog } from "#lib/components/custom"; +import { Button } from "#lib/components/ui/button"; import { Dialog, DialogContent, @@ -25,15 +23,16 @@ import { DialogFooter, DialogHeader, DialogTitle, -} from "$lib/components/ui/dialog"; - -import { createLightCmsClient } from "$lib/orpc-client"; +} from "#lib/components/ui/dialog"; +import { createLightCmsClient } from "#lib/orpc-client"; import { buildEntryUrl, buildFolderUrl, buildPayloadQuery, withFolder, -} from "$lib/utils/cms-url"; +} from "#lib/utils/cms-url"; +import { enhance } from "$app/forms"; +import { goto, refreshAll } from "$app/navigation"; import type { PageData } from "./$types"; let { data, form }: { data: PageData; form?: { folderError?: string } | null } = diff --git a/src/routes/cms/[collection]/[slug]/+page.server.ts b/src/routes/cms/[collection]/[slug]/+page.server.ts index 3baee41..f33e0dc 100644 --- a/src/routes/cms/[collection]/[slug]/+page.server.ts +++ b/src/routes/cms/[collection]/[slug]/+page.server.ts @@ -2,7 +2,8 @@ import { error, fail, redirect } from "@sveltejs/kit"; import { message, setError, superValidate } from "sveltekit-superforms"; import { zod4 } from "sveltekit-superforms/adapters"; import { z } from "zod"; -import { buildEntrySchema } from "$lib/schemas/entry"; +import { createDefaultFrontMatter } from "#lib/components/cms/frontmatter.types"; +import { buildEntrySchema } from "#lib/schemas/entry"; import { buildFrontMatter, createCollectionEntry, @@ -11,13 +12,11 @@ import { getCollectionEntry, moveCollectionEntry, updateCollectionEntry, -} from "$lib/server/cms"; - -import { createDefaultFrontMatter } from "$lib/components/cms/frontmatter.types"; -import { getConfiguredCollection } from "$lib/server/cms-context"; -import { isGitHubStatus } from "$lib/server/github"; -import { normalizeFolder, resolveEntryPath } from "$lib/server/paths"; -import { captureServerEvent } from "$lib/server/posthog"; +} from "#lib/server/cms"; +import { getConfiguredCollection } from "#lib/server/cms-context"; +import { isGitHubStatus } from "#lib/server/github"; +import { normalizeFolder, resolveEntryPath } from "#lib/server/paths"; +import { captureServerEvent } from "#lib/server/posthog"; import type { Actions, PageServerLoad } from "./$types"; const INLINE_FRONTMATTER_KEYS = new Set(["title", "slug", "description", "date", "draft", "tags"]); @@ -237,10 +236,14 @@ export const actions: Actions = { val === null || (typeof val === "string" && val.trim().length === 0) ) { - return fail(400, { error: `${field.label ?? field.name} is required.` }); + return fail(400, { + error: `${field.label ?? field.name} is required.`, + }); } if (field.list && Array.isArray(val) && val.length === 0) { - return fail(400, { error: `${field.label ?? field.name} is required.` }); + return fail(400, { + error: `${field.label ?? field.name} is required.`, + }); } } } @@ -268,7 +271,9 @@ export const actions: Actions = { try { await createCollectionEntry(collection, _slug, parsedFrontMatter, body, ctx, folder); } catch (cause) { - return fail(500, { error: cause instanceof Error ? cause.message : String(cause) }); + return fail(500, { + error: cause instanceof Error ? cause.message : String(cause), + }); } await captureServerEvent(locals.session.userId, "collection_entry_created"); throw redirect(303, collectionUrl); diff --git a/src/routes/cms/[collection]/[slug]/+page.svelte b/src/routes/cms/[collection]/[slug]/+page.svelte index ec6d51b..1dc985d 100644 --- a/src/routes/cms/[collection]/[slug]/+page.svelte +++ b/src/routes/cms/[collection]/[slug]/+page.svelte @@ -1,9 +1,9 @@