chore: remove unused Supabase auth store, archive stub services

- shared-auth-stores: delete createSupabaseAuthStore (zero usage across monorepo,
  all apps use createManaAuthStore). Remove export + types from index.ts.
- services: move ollama-metrics-proxy (stub — just a Grafana dashboard JSON) and
  it-landing (Astro landing page, not a service) to services-archived/
- lint-staged: add services-archived/ to eslint ignore pattern

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-04-02 13:59:53 +02:00
parent 4f70e1ca6c
commit e11aa50106
23 changed files with 6 additions and 291 deletions

View file

@ -1,6 +1,6 @@
export default {
'*.{ts,tsx,js,jsx,mjs,cjs}': [
'eslint --fix --ignore-pattern "apps-archived/**"',
'eslint --fix --ignore-pattern "apps-archived/**" --ignore-pattern "services-archived/**"',
'prettier --config .prettierrc.json --write',
],
'*.{json,md,svelte,astro}': ['prettier --config .prettierrc.json --write'],

View file

@ -1,271 +0,0 @@
/**
* Supabase Auth Store Factory
*
* Creates a reactive auth store that works directly with Supabase client.
* Useful for apps that use Supabase directly without middleware.
*
* @example
* ```ts
* import { createSupabaseAuthStore } from '@manacore/shared-auth-stores';
* import { createBrowserClient } from '@supabase/ssr';
*
* const supabase = createBrowserClient(url, key);
* export const authStore = createSupabaseAuthStore(supabase);
* ```
*/
import type { BaseUser, AuthResult } from './types';
/**
* Minimal Supabase client interface
* Only requires the auth methods we use
*/
interface SupabaseClientLike {
auth: {
getSession(): Promise<{ data: { session: { user: { id: string; email?: string } } | null } }>;
signInWithPassword(credentials: {
email: string;
password: string;
}): Promise<{ error: { message: string } | null }>;
signUp(credentials: {
email: string;
password: string;
}): Promise<{ data: { session: unknown }; error: { message: string } | null }>;
resetPasswordForEmail(
email: string,
options?: { redirectTo?: string }
): Promise<{ error: { message: string } | null }>;
signOut(): Promise<{ error: { message: string } | null }>;
};
}
/**
* Options for creating a Supabase auth store
*/
export interface CreateSupabaseAuthStoreOptions {
/** URL to redirect to after password reset */
passwordResetRedirectUrl?: string;
}
/**
* Default user type for Supabase auth
*/
export interface SupabaseUser extends BaseUser {
id: string;
email: string;
}
/**
* Create a Svelte 5 runes-based auth store for Supabase
*
* @param getSupabaseClient - Function that returns a Supabase client
* @param options - Configuration options
* @returns Reactive auth store with state and actions
*/
export function createSupabaseAuthStore(
getSupabaseClient: () => SupabaseClientLike,
options: CreateSupabaseAuthStoreOptions = {}
) {
// Reactive state using Svelte 5 runes
let user = $state<SupabaseUser | null>(null);
let loading = $state(true);
let error = $state<string | null>(null);
/**
* Get user from current session
*/
async function getUserFromSession(): Promise<SupabaseUser | null> {
const supabase = getSupabaseClient();
const {
data: { session },
} = await supabase.auth.getSession();
if (!session?.user) return null;
return {
id: session.user.id,
email: session.user.email || '',
};
}
return {
// Reactive getters
get user() {
return user;
},
get loading() {
return loading;
},
get error() {
return error;
},
get isAuthenticated() {
return !!user;
},
/**
* Initialize auth state from Supabase session
*/
async initialize() {
loading = true;
error = null;
try {
user = await getUserFromSession();
} catch (e) {
console.error('Failed to initialize auth:', e);
error = e instanceof Error ? e.message : 'Failed to initialize authentication';
user = null;
} finally {
loading = false;
}
},
/**
* Set user manually
*/
setUser(newUser: SupabaseUser | null) {
user = newUser;
error = null;
},
/**
* Sign in with email and password
*/
async signIn(email: string, password: string): Promise<AuthResult<SupabaseUser>> {
loading = true;
error = null;
try {
const supabase = getSupabaseClient();
const { error: authError } = await supabase.auth.signInWithPassword({
email,
password,
});
if (authError) {
error = authError.message;
return { success: false, error: authError.message };
}
user = await getUserFromSession();
return { success: true, user: user || undefined };
} catch (e) {
const errorMessage = e instanceof Error ? e.message : 'Sign in failed';
error = errorMessage;
return { success: false, error: errorMessage };
} finally {
loading = false;
}
},
/**
* Sign up with email and password
*/
async signUp(email: string, password: string): Promise<AuthResult<SupabaseUser>> {
loading = true;
error = null;
try {
const supabase = getSupabaseClient();
const { data, error: authError } = await supabase.auth.signUp({
email,
password,
});
if (authError) {
error = authError.message;
return { success: false, error: authError.message };
}
// Check if email confirmation is required
const needsVerification = !data.session;
if (!needsVerification) {
user = await getUserFromSession();
}
return {
success: true,
needsVerification,
user: user || undefined,
};
} catch (e) {
const errorMessage = e instanceof Error ? e.message : 'Sign up failed';
error = errorMessage;
return { success: false, error: errorMessage };
} finally {
loading = false;
}
},
/**
* Send password reset email
*/
async forgotPassword(email: string): Promise<{ success: boolean; error?: string }> {
loading = true;
error = null;
try {
const supabase = getSupabaseClient();
const redirectTo =
options.passwordResetRedirectUrl || `${window.location.origin}/reset-password`;
const { error: authError } = await supabase.auth.resetPasswordForEmail(email, {
redirectTo,
});
if (authError) {
error = authError.message;
return { success: false, error: authError.message };
}
return { success: true };
} catch (e) {
const errorMessage = e instanceof Error ? e.message : 'Password reset failed';
error = errorMessage;
return { success: false, error: errorMessage };
} finally {
loading = false;
}
},
/**
* Sign out user
*/
async signOut() {
loading = true;
error = null;
try {
const supabase = getSupabaseClient();
await supabase.auth.signOut();
user = null;
} catch (e) {
console.error('Sign out failed:', e);
error = e instanceof Error ? e.message : 'Sign out failed';
} finally {
loading = false;
}
},
/**
* Check authentication status
*/
async checkAuth(): Promise<boolean> {
try {
const sessionUser = await getUserFromSession();
if (!sessionUser) {
user = null;
return false;
}
user = sessionUser;
return true;
} catch (e) {
console.error('Auth check failed:', e);
user = null;
return false;
}
},
/**
* Clear error state
*/
clearError() {
error = null;
},
};
}

View file

@ -3,38 +3,24 @@
*
* Svelte 5 auth store factories for the ManaCore monorepo.
*
* Provides two approaches:
* 1. createAuthStore - Generic factory that works with any auth service adapter
* 2. createSupabaseAuthStore - Direct Supabase integration for simpler setups
* @example ManaCore auth store (recommended)
* ```ts
* import { createManaAuthStore } from '@manacore/shared-auth-stores';
* export const authStore = createManaAuthStore();
* ```
*
* @example Generic auth store with custom adapter
* ```ts
* import { createAuthStore } from '@manacore/shared-auth-stores';
* import { authService } from '$lib/auth';
* import type { AppUser } from '$lib/types';
*
* export const authStore = createAuthStore<AppUser>(authService);
* ```
*
* @example Supabase auth store
* ```ts
* import { createSupabaseAuthStore } from '@manacore/shared-auth-stores';
* import { createBrowserClient } from '@supabase/ssr';
*
* const getClient = () => createBrowserClient(url, key);
* export const authStore = createSupabaseAuthStore(getClient);
* ```
*/
// Factory functions
export { createManaAuthStore } from './createManaAuthStore.svelte';
export type { ManaAuthStoreConfig, ManaAuthStore } from './createManaAuthStore.svelte';
export { createAuthStore } from './createAuthStore.svelte';
export { createSupabaseAuthStore } from './createSupabaseAuthStore.svelte';
export type {
CreateSupabaseAuthStoreOptions,
SupabaseUser,
} from './createSupabaseAuthStore.svelte';
// Types
export type {

View file

Before

Width:  |  Height:  |  Size: 256 B

After

Width:  |  Height:  |  Size: 256 B

Before After
Before After