mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-05-03 02:04:54 +00:00
fix(types): improve type safety by replacing 'any' with specific types in getInstalledPackages and PackageDefinition
This commit is contained in:
+14
-1
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user