fix(types): improve type safety by replacing 'any' with specific types in getInstalledPackages and PackageDefinition

This commit is contained in:
2025-12-29 23:58:00 +00:00
parent 4201940930
commit d517d04537
2 changed files with 25 additions and 3 deletions
@@ -1,5 +1,18 @@
type InstalledPackageRecord = {
packageId: string
name?: string
version?: string
installedAt?: number
}
type InstalledPackageIndex = Record<string, InstalledPackageRecord>
type InstalledPackageStore = {
getAll(table: 'installed_packages'): Promise<InstalledPackageIndex | null>
}
// Get all installed packages
export async function getInstalledPackages(db: any): Promise<string[]> {
export async function getInstalledPackages(db: InstalledPackageStore): Promise<string[]> {
try {
const installed = await db.getAll('installed_packages')
return Object.keys(installed || {})
@@ -1,3 +1,5 @@
import type { JsonObject, JsonValue } from '@/types/utility-types'
export interface LuaScriptFile {
name: string
path: string
@@ -6,6 +8,13 @@ export interface LuaScriptFile {
description?: string
}
export type PackageComponent = {
id: string
[key: string]: JsonValue
}
export type PackageExamples = JsonObject
export interface PackageDefinition {
packageId: string
name: string
@@ -21,10 +30,10 @@ export interface PackageDefinition {
handlers?: string[]
}
shadowcnComponents?: string[]
components: any[]
components: PackageComponent[]
scripts?: string
scriptFiles?: LuaScriptFile[]
examples?: any
examples?: PackageExamples
}
export interface PackageRegistry {