refactor: dead-code cleanup + drop the lib/types shim (slice 9)
- Delete orphaned components (theme-provider, task-claim-button), the unused roleDisplayName helper, the fully-dead cleanupRateLimits, the 6 never-imported validation schemas (signIn/signUp/createSpace/joinSpace — a replaced auth flow; proposalStatuses; updateAreaLeadRoleSchema). - Migrate all @/lib/types importers to the canonical @/types/domain and delete the compatibility shim. tsc 0, 635 tests green, lint clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
71ba558522
commit
f775f954ad
@@ -1,7 +1,7 @@
|
|||||||
import { redirect } from 'next/navigation'
|
import { redirect } from 'next/navigation'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { createClient } from '@/lib/supabase/server'
|
import { createClient } from '@/lib/supabase/server'
|
||||||
import type { FinancialVisibility, Payment, Space } from '@/lib/types'
|
import type { FinancialVisibility, Payment, Space } from '@/types/domain'
|
||||||
import { Receipt } from 'lucide-react'
|
import { Receipt } from 'lucide-react'
|
||||||
import { PageTitle } from '@/components/ui/page-title'
|
import { PageTitle } from '@/components/ui/page-title'
|
||||||
import { Empty, EmptyHeader, EmptyMedia, EmptyTitle, EmptyDescription } from '@/components/ui/empty'
|
import { Empty, EmptyHeader, EmptyMedia, EmptyTitle, EmptyDescription } from '@/components/ui/empty'
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
addIncidentUpdate,
|
addIncidentUpdate,
|
||||||
appealIncident,
|
appealIncident,
|
||||||
} from '@/lib/actions'
|
} from '@/lib/actions'
|
||||||
import type { IncidentStatus } from '@/lib/types'
|
import type { IncidentStatus } from '@/types/domain'
|
||||||
import { incidentStatuses, incidentUpdateVisibilities } from '@/lib/validations'
|
import { incidentStatuses, incidentUpdateVisibilities } from '@/lib/validations'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { redirect, notFound } from 'next/navigation'
|
import { redirect, notFound } from 'next/navigation'
|
||||||
import { createClient } from '@/lib/supabase/server'
|
import { createClient } from '@/lib/supabase/server'
|
||||||
import type { Incident, IncidentUpdateRow } from '@/lib/types'
|
import type { Incident, IncidentUpdateRow } from '@/types/domain'
|
||||||
import { IncidentActions } from './incident-actions'
|
import { IncidentActions } from './incident-actions'
|
||||||
import { MarkdownBody } from '@/components/markdown'
|
import { MarkdownBody } from '@/components/markdown'
|
||||||
import { CommentThread } from '@/components/comments/comment-thread'
|
import { CommentThread } from '@/components/comments/comment-thread'
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Link from 'next/link'
|
|||||||
import { redirect } from 'next/navigation'
|
import { redirect } from 'next/navigation'
|
||||||
import { ShieldCheck } from 'lucide-react'
|
import { ShieldCheck } from 'lucide-react'
|
||||||
import { createClient } from '@/lib/supabase/server'
|
import { createClient } from '@/lib/supabase/server'
|
||||||
import type { Incident, IncidentStatus } from '@/lib/types'
|
import type { Incident, IncidentStatus } from '@/types/domain'
|
||||||
import { PageTitle } from '@/components/ui/page-title'
|
import { PageTitle } from '@/components/ui/page-title'
|
||||||
import { Empty, EmptyHeader, EmptyMedia, EmptyTitle } from '@/components/ui/empty'
|
import { Empty, EmptyHeader, EmptyMedia, EmptyTitle } from '@/components/ui/empty'
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { redirect, notFound } from 'next/navigation'
|
import { redirect, notFound } from 'next/navigation'
|
||||||
import { createClient } from '@/lib/supabase/server'
|
import { createClient } from '@/lib/supabase/server'
|
||||||
import type { Policy } from '@/lib/types'
|
import type { Policy } from '@/types/domain'
|
||||||
import { PolicyActions } from './policy-actions'
|
import { PolicyActions } from './policy-actions'
|
||||||
import { MarkdownBody } from '@/components/markdown'
|
import { MarkdownBody } from '@/components/markdown'
|
||||||
import { CommentThread } from '@/components/comments/comment-thread'
|
import { CommentThread } from '@/components/comments/comment-thread'
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useState, useTransition } from 'react'
|
|||||||
import { useRouter } from 'next/navigation'
|
import { useRouter } from 'next/navigation'
|
||||||
import { supersedePolicy, updatePolicyStatus } from '@/lib/actions'
|
import { supersedePolicy, updatePolicyStatus } from '@/lib/actions'
|
||||||
import { policyStatuses } from '@/lib/validations'
|
import { policyStatuses } from '@/lib/validations'
|
||||||
import type { Policy } from '@/lib/types'
|
import type { Policy } from '@/types/domain'
|
||||||
|
|
||||||
export function PolicyActions({ policy }: { policy: Policy }) {
|
export function PolicyActions({ policy }: { policy: Policy }) {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { redirect } from 'next/navigation'
|
import { redirect } from 'next/navigation'
|
||||||
import { createClient } from '@/lib/supabase/server'
|
import { createClient } from '@/lib/supabase/server'
|
||||||
import type { Policy, PolicyStatus } from '@/lib/types'
|
import type { Policy, PolicyStatus } from '@/types/domain'
|
||||||
import { PageTitle } from '@/components/ui/page-title'
|
import { PageTitle } from '@/components/ui/page-title'
|
||||||
|
|
||||||
export const dynamic = 'force-dynamic'
|
export const dynamic = 'force-dynamic'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { redirect, notFound } from 'next/navigation'
|
import { redirect, notFound } from 'next/navigation'
|
||||||
import { createClient } from '@/lib/supabase/server'
|
import { createClient } from '@/lib/supabase/server'
|
||||||
import type { Proposal, ProposalVote } from '@/lib/types'
|
import type { Proposal, ProposalVote } from '@/types/domain'
|
||||||
import { ProposalStatusBadge } from '../proposal-badges'
|
import { ProposalStatusBadge } from '../proposal-badges'
|
||||||
import { ProposalActions } from './proposal-actions'
|
import { ProposalActions } from './proposal-actions'
|
||||||
import { MarkdownBody } from '@/components/markdown'
|
import { MarkdownBody } from '@/components/markdown'
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
openProposal,
|
openProposal,
|
||||||
withdrawProposal,
|
withdrawProposal,
|
||||||
} from '@/lib/actions'
|
} from '@/lib/actions'
|
||||||
import type { ProposalStatus, ProposalVote, VotePosition } from '@/lib/types'
|
import type { ProposalStatus, ProposalVote, VotePosition } from '@/types/domain'
|
||||||
import { votePositions } from '@/lib/validations'
|
import { votePositions } from '@/lib/validations'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Link from 'next/link'
|
|||||||
import { redirect } from 'next/navigation'
|
import { redirect } from 'next/navigation'
|
||||||
import { Vote } from 'lucide-react'
|
import { Vote } from 'lucide-react'
|
||||||
import { createClient } from '@/lib/supabase/server'
|
import { createClient } from '@/lib/supabase/server'
|
||||||
import type { Proposal } from '@/lib/types'
|
import type { Proposal } from '@/types/domain'
|
||||||
import { ProposalStatusBadge } from './proposal-badges'
|
import { ProposalStatusBadge } from './proposal-badges'
|
||||||
import { PageTitle } from '@/components/ui/page-title'
|
import { PageTitle } from '@/components/ui/page-title'
|
||||||
import { Empty, EmptyHeader, EmptyMedia, EmptyTitle } from '@/components/ui/empty'
|
import { Empty, EmptyHeader, EmptyMedia, EmptyTitle } from '@/components/ui/empty'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { ProposalStatus } from '@/lib/types'
|
import type { ProposalStatus } from '@/types/domain'
|
||||||
|
|
||||||
const STATUS_STYLE: Record<ProposalStatus, string> = {
|
const STATUS_STYLE: Record<ProposalStatus, string> = {
|
||||||
draft: 'text-muted-foreground bg-muted',
|
draft: 'text-muted-foreground bg-muted',
|
||||||
|
|||||||
@@ -1,64 +0,0 @@
|
|||||||
'use client'
|
|
||||||
|
|
||||||
import { useState } from 'react'
|
|
||||||
import { claimTask, completeTask } from '@/lib/actions'
|
|
||||||
|
|
||||||
export function ClaimButton({ taskId }: { taskId: string }) {
|
|
||||||
const [loading, setLoading] = useState(false)
|
|
||||||
const [done, setDone] = useState(false)
|
|
||||||
|
|
||||||
async function handleClaim() {
|
|
||||||
setLoading(true)
|
|
||||||
const result = await claimTask(taskId)
|
|
||||||
if (!result.error) setDone(true)
|
|
||||||
setLoading(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (done) {
|
|
||||||
return (
|
|
||||||
<span className="font-mono text-[10px] text-primary bg-primary/10 px-2 py-0.5 rounded">
|
|
||||||
CLAIMED
|
|
||||||
</span>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
onClick={handleClaim}
|
|
||||||
disabled={loading}
|
|
||||||
className="font-mono text-[10px] border border-border px-2 py-0.5 rounded hover:border-primary hover:text-primary transition disabled:opacity-50"
|
|
||||||
>
|
|
||||||
{loading ? '...' : 'CLAIM'}
|
|
||||||
</button>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export function CompleteButton({ taskId }: { taskId: string }) {
|
|
||||||
const [loading, setLoading] = useState(false)
|
|
||||||
const [done, setDone] = useState(false)
|
|
||||||
|
|
||||||
async function handleComplete() {
|
|
||||||
setLoading(true)
|
|
||||||
const result = await completeTask(taskId)
|
|
||||||
if (!result.error) setDone(true)
|
|
||||||
setLoading(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (done) {
|
|
||||||
return (
|
|
||||||
<span className="font-mono text-[10px] text-muted-foreground bg-muted px-2 py-0.5 rounded">
|
|
||||||
DONE
|
|
||||||
</span>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
onClick={handleComplete}
|
|
||||||
disabled={loading}
|
|
||||||
className="font-mono text-[10px] border border-green-200 text-green-700 px-2 py-0.5 rounded hover:bg-green-50 transition disabled:opacity-50"
|
|
||||||
>
|
|
||||||
{loading ? '...' : 'DONE'}
|
|
||||||
</button>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
'use client'
|
|
||||||
|
|
||||||
import * as React from 'react'
|
|
||||||
import {
|
|
||||||
ThemeProvider as NextThemesProvider,
|
|
||||||
type ThemeProviderProps,
|
|
||||||
} from 'next-themes'
|
|
||||||
|
|
||||||
export function ThemeProvider({ children, ...props }: ThemeProviderProps) {
|
|
||||||
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
|
|
||||||
}
|
|
||||||
@@ -47,8 +47,3 @@ export async function getRoleLabelMap(
|
|||||||
return map
|
return map
|
||||||
}
|
}
|
||||||
|
|
||||||
export function roleDisplayName(map: Record<string, RoleLabel> | null | undefined, role: string): string {
|
|
||||||
if (map && map[role]) return map[role].name
|
|
||||||
const d = DEFAULT_ROLE_LABELS[role as BuiltinRole]
|
|
||||||
return d ? d.name : role
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -139,18 +139,6 @@ export function checkRateLimit(
|
|||||||
return { allowed: true, remaining: maxRequests - entry.count, resetIn: entry.resetTime - now }
|
return { allowed: true, remaining: maxRequests - entry.count, resetIn: entry.resetTime - now }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear expired rate limit entries (call periodically)
|
|
||||||
*/
|
|
||||||
export function cleanupRateLimits(): void {
|
|
||||||
const now = Date.now()
|
|
||||||
for (const [key, entry] of rateLimitStore.entries()) {
|
|
||||||
if (now > entry.resetTime) {
|
|
||||||
rateLimitStore.delete(key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validate content length
|
* Validate content length
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
/**
|
|
||||||
* Compatibility shim. The hand-written domain types moved to `types/domain/*`
|
|
||||||
* (kept separate from the generated `types/database.ts`). This re-export keeps
|
|
||||||
* the `@/lib/types` specifier working for existing importers; prefer importing
|
|
||||||
* from `@/types/domain` in new code.
|
|
||||||
*/
|
|
||||||
export * from '@/types/domain'
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
import { z } from 'zod'
|
|
||||||
import { emailField } from './primitives'
|
|
||||||
|
|
||||||
export const signInSchema = z.object({
|
|
||||||
email: emailField(),
|
|
||||||
password: z.string().min(1, 'Password is required'),
|
|
||||||
})
|
|
||||||
|
|
||||||
export const signUpSchema = z.object({
|
|
||||||
email: emailField(),
|
|
||||||
password: z.string().min(8, 'Password must be at least 8 characters'),
|
|
||||||
fullName: z.string().min(1, 'Full name is required').max(100, 'Name is too long'),
|
|
||||||
action: z.enum(['create', 'join']),
|
|
||||||
spaceName: z.string().max(100).optional(),
|
|
||||||
spaceSlug: z.string().regex(/^[a-z0-9]+$/, 'Slug must be lowercase letters and numbers only').max(50).optional(),
|
|
||||||
city: z.string().max(100).optional(),
|
|
||||||
inviteCode: z.string().max(20).optional(),
|
|
||||||
})
|
|
||||||
|
|
||||||
export const createSpaceSchema = z.object({
|
|
||||||
spaceName: z.string().min(1, 'Space name is required').max(100, 'Name is too long'),
|
|
||||||
spaceSlug: z.string().min(1, 'Slug is required').max(50).regex(/^[a-z0-9]+$/, 'Slug must be lowercase letters and numbers only'),
|
|
||||||
spaceCity: z.string().max(100).optional(),
|
|
||||||
displayName: z.string().min(1, 'Display name is required').max(100),
|
|
||||||
})
|
|
||||||
|
|
||||||
export const joinSpaceSchema = z.object({
|
|
||||||
inviteCode: z.string().min(1, 'Invite code is required').max(20),
|
|
||||||
displayName: z.string().min(1, 'Display name is required').max(100),
|
|
||||||
})
|
|
||||||
@@ -4,7 +4,6 @@ import { flexibleDateTime } from './primitives'
|
|||||||
// ─── Governance: proposals ───────────────────────────────────────────────────
|
// ─── Governance: proposals ───────────────────────────────────────────────────
|
||||||
|
|
||||||
export const proposalTypes = ['bylaw_change','board_action','membership_vote','advisory_poll','recall','budget'] as const
|
export const proposalTypes = ['bylaw_change','board_action','membership_vote','advisory_poll','recall','budget'] as const
|
||||||
export const proposalStatuses = ['draft','open','decided','withdrawn','expired'] as const
|
|
||||||
export const thresholdRules = ['simple_majority','two_thirds','three_fourths','unanimous'] as const
|
export const thresholdRules = ['simple_majority','two_thirds','three_fourths','unanimous'] as const
|
||||||
export const votePositions = ['yes','no','abstain','recused'] as const
|
export const votePositions = ['yes','no','abstain','recused'] as const
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
export * from './primitives'
|
export * from './primitives'
|
||||||
export * from './auth'
|
|
||||||
export * from './tasks'
|
export * from './tasks'
|
||||||
export * from './projects'
|
export * from './projects'
|
||||||
export * from './members'
|
export * from './members'
|
||||||
|
|||||||
@@ -24,11 +24,6 @@ export const createAreaLeadRoleSchema = z.object({
|
|||||||
color: z.string().max(20).optional().nullable(),
|
color: z.string().max(20).optional().nullable(),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const updateAreaLeadRoleSchema = z.object({
|
|
||||||
name: z.string().min(1).max(100).optional(),
|
|
||||||
color: z.string().max(20).optional().nullable(),
|
|
||||||
})
|
|
||||||
|
|
||||||
export const assignAreaLeadSchema = z.object({
|
export const assignAreaLeadSchema = z.object({
|
||||||
area_lead_role_id: z.string().uuid('Invalid role ID'),
|
area_lead_role_id: z.string().uuid('Invalid role ID'),
|
||||||
member_id: z.string().uuid('Invalid member ID'),
|
member_id: z.string().uuid('Invalid member ID'),
|
||||||
|
|||||||
Reference in New Issue
Block a user