mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-05-05 19:19:35 +00:00
Fix remaining ESLint warnings and DBAL integration types
Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
|
||||
export async function blobDelete(key: string): Promise<void> {
|
||||
if (!this.blobStorage) throw new Error('DBAL not initialized')
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
|
||||
export async function blobDownload(key: string): Promise<Buffer> {
|
||||
if (!this.blobStorage) throw new Error('DBAL not initialized')
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
|
||||
export async function blobGetMetadata(key: string): Promise<Record<string, string>> {
|
||||
if (!this.blobStorage) throw new Error('DBAL not initialized')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
|
||||
export async function blobList(prefix?: string): Promise<string[]> {
|
||||
if (!this.blobStorage) throw new Error('DBAL not initialized')
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
|
||||
// Blob operations
|
||||
export async function blobUpload(
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
|
||||
interface TenantLimits {
|
||||
maxStorage?: number
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
import type { BlobStorage } from '@/dbal/blob/blob-storage'
|
||||
|
||||
export function getBlobStorage(this: any): BlobStorage {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
|
||||
export function getClient(): DBALClient {
|
||||
if (!this.client) {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
|
||||
// Note: This was extracted from a class static method
|
||||
// The original `this` context is lost, so this function may not work correctly
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
import type { KVStore } from '@/dbal/core/kv/types'
|
||||
|
||||
export function getKVStore(this: any): KVStore {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
import type { TenantContext } from '@/dbal/core/foundation/tenant-context'
|
||||
|
||||
export function getKey(key: string, context: TenantContext): string {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
|
||||
export async function getMetadata(
|
||||
key: string
|
||||
|
||||
+7
-3
@@ -1,10 +1,14 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
import type { TenantContext } from '@/dbal/core/foundation/tenant-context'
|
||||
|
||||
interface TenantStore {
|
||||
tenants: Map<string, unknown>
|
||||
}
|
||||
|
||||
export async function getTenantContext(
|
||||
this: any,
|
||||
this: TenantStore,
|
||||
tenantId: string,
|
||||
userId: string
|
||||
_userId: string
|
||||
): Promise<TenantContext | null> {
|
||||
if (!this.tenants.has(tenantId)) {
|
||||
return null
|
||||
|
||||
+7
-3
@@ -1,7 +1,11 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
|
||||
// TenantManager is not yet exported from DBAL, using any for now
|
||||
export function getTenantManager(this: any): any {
|
||||
interface DBALIntegrationContext {
|
||||
tenantManager?: unknown
|
||||
}
|
||||
|
||||
// TenantManager is not yet exported from DBAL, using unknown for now
|
||||
export function getTenantManager(this: DBALIntegrationContext): unknown {
|
||||
if (!this.tenantManager) {
|
||||
throw new Error('DBAL not initialized. Call initialize() first.')
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
import { DBALError, DBALErrorCode } from '@/dbal/core/foundation/errors'
|
||||
|
||||
export function handleError(error: unknown): { message: string; code?: DBALErrorCode } {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
|
||||
export function hasTenant(id: string): boolean {
|
||||
return this.tenants.has(id)
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
import { InMemoryKVStore } from '@/dbal/core/kv'
|
||||
import { MemoryStorage } from '@/dbal/blob/providers/memory-storage'
|
||||
|
||||
interface DBALIntegrationState {
|
||||
initialized?: boolean
|
||||
tenantManager?: unknown
|
||||
kvStore?: InMemoryKVStore
|
||||
blobStorage?: MemoryStorage
|
||||
client?: _DBALClient
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the DBAL client with configuration
|
||||
*/
|
||||
export async function initialize(this: any, config?: Partial<DBALConfig>): Promise<void> {
|
||||
export async function initialize(this: DBALIntegrationState, config?: Partial<_DBALConfig>): Promise<void> {
|
||||
if (this.initialized) {
|
||||
console.warn('DBAL already initialized')
|
||||
return
|
||||
@@ -22,16 +30,15 @@ export async function initialize(this: any, config?: Partial<DBALConfig>): Promi
|
||||
this.blobStorage = new MemoryStorage()
|
||||
|
||||
// Initialize DBAL client
|
||||
const dbalConfig: DBALConfig = {
|
||||
const dbalConfig: _DBALConfig = {
|
||||
mode: 'development',
|
||||
adapter: config?.adapter || 'prisma',
|
||||
...config,
|
||||
}
|
||||
} as _DBALConfig
|
||||
|
||||
this.client = new DBALClient(dbalConfig)
|
||||
this.client = new _DBALClient(dbalConfig)
|
||||
|
||||
this.initialized = true
|
||||
console.log('DBAL Integration initialized successfully')
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize DBAL:', error)
|
||||
throw error
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
|
||||
export function isInitialized(): boolean {
|
||||
return this.initialized
|
||||
|
||||
@@ -5,8 +5,8 @@ import type { JsonValue } from '@/types/utility-types'
|
||||
// The original `this` context is lost, so this function may not work correctly
|
||||
export async function kvGet<T = JsonValue>(
|
||||
key: string,
|
||||
tenantId = 'default',
|
||||
userId = 'system'
|
||||
_tenantId = 'default',
|
||||
_userId = 'system'
|
||||
): Promise<T | null> {
|
||||
// Original code referenced this.kvStore and this.tenantManager which don't exist here
|
||||
// TODO: Review and fix this extraction
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
import type { JsonValue } from '@/types/utility-types'
|
||||
|
||||
export async function kvListAdd(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DBALClient, type DBALConfig } from '@/dbal'
|
||||
import type { DBALClient as _DBALClient, DBALConfig as _DBALConfig } from '@/dbal'
|
||||
import type { JsonValue } from '@/types/utility-types'
|
||||
|
||||
export async function kvListGet(
|
||||
|
||||
@@ -27,7 +27,7 @@ export async function callDaemon<T = unknown>(request: DaemonRpcRequest): Promis
|
||||
let body: { success?: boolean; message?: string; data?: T }
|
||||
try {
|
||||
body = (await response.json()) as typeof body
|
||||
} catch (_error) {
|
||||
} catch {
|
||||
throw new Error('Failed to parse response from DBAL daemon')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user