mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
fix: Repair DBAL TypeScript compilation errors and generate types
FIXED ISSUES: 1. Generated missing types.generated.ts file (364 lines) - Codegen script creates 14 entity types from YAML schemas - All import errors resolved 2. Fixed blob/index.ts window reference (browser API in Node.js) - Removed typeof window check - Use try-catch for require() fallback 3. Fixed adapter-factory.ts exactOptionalPropertyTypes errors - Only include queryTimeout in options when defined - Prisma, Postgres, MySQL adapters updated 4. Fixed factory.ts type assignments - Build PrismaClientConfig conditionally - Only assign defined values to avoid undefined violations 5. Fixed KV operations - batch.ts: Remove explicit undefined from nextCursor return - write.ts: Use spread operator to conditionally include expiresAt 6. Fixed websocket-bridge/state.ts - Use spread operator to conditionally include auth 7. Fixed workflow-operations.ts description handling - Remove explicit undefined assignments - Conditionally include optional description field RESULT: ✅ DBAL compiles successfully to /dbal/development/dist/ ✅ All exports available in index.d.ts ✅ Build artifacts complete Next: Initialize database with db:push Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -52,7 +52,8 @@
|
||||
"Bash(npm run build:*)",
|
||||
"Bash(npm run codegen:*)",
|
||||
"Bash(npm:*)",
|
||||
"Bash(__NEW_LINE_5881b1d201560748__ echo \"\")"
|
||||
"Bash(__NEW_LINE_5881b1d201560748__ echo \"\")",
|
||||
"Bash(grep:*)"
|
||||
]
|
||||
},
|
||||
"spinnerTipsEnabled": false
|
||||
|
||||
@@ -23,12 +23,13 @@ export function createBlobStorage(config: BlobStorageConfig): BlobStorage {
|
||||
|
||||
case 'filesystem':
|
||||
// Dynamically import FilesystemStorage only on server (Node.js)
|
||||
if (typeof window === 'undefined') {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
// In browser environments, this storage type should never be requested
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires, global-require
|
||||
const { FilesystemStorage } = require('./providers/filesystem')
|
||||
return new FilesystemStorage(config)
|
||||
} else {
|
||||
throw new Error('FilesystemStorage is not available in browser environments')
|
||||
} catch (error) {
|
||||
throw new Error('FilesystemStorage is not available in this environment. Use \'memory\' or \'s3\' instead.')
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
@@ -13,6 +13,6 @@ export const createBridgeState = (
|
||||
): BridgeState => ({
|
||||
ws: null,
|
||||
endpoint,
|
||||
auth,
|
||||
...(auth && { auth }),
|
||||
pendingRequests: new Map<string, PendingRequest>(),
|
||||
})
|
||||
|
||||
@@ -24,9 +24,7 @@ export const createAdapter = (config: DBALConfig): DBALAdapter => {
|
||||
case 'prisma':
|
||||
baseAdapter = new PrismaAdapter(
|
||||
config.database?.url,
|
||||
{
|
||||
queryTimeout: config.performance?.queryTimeout
|
||||
}
|
||||
config.performance?.queryTimeout ? { queryTimeout: config.performance.queryTimeout } : undefined
|
||||
)
|
||||
break
|
||||
case 'memory':
|
||||
@@ -35,17 +33,13 @@ export const createAdapter = (config: DBALConfig): DBALAdapter => {
|
||||
case 'postgres':
|
||||
baseAdapter = new PostgresAdapter(
|
||||
config.database?.url,
|
||||
{
|
||||
queryTimeout: config.performance?.queryTimeout
|
||||
}
|
||||
config.performance?.queryTimeout ? { queryTimeout: config.performance.queryTimeout } : undefined
|
||||
)
|
||||
break
|
||||
case 'mysql':
|
||||
baseAdapter = new MySQLAdapter(
|
||||
config.database?.url,
|
||||
{
|
||||
queryTimeout: config.performance?.queryTimeout
|
||||
}
|
||||
config.performance?.queryTimeout ? { queryTimeout: config.performance.queryTimeout } : undefined
|
||||
)
|
||||
break
|
||||
case 'sqlite':
|
||||
|
||||
@@ -34,21 +34,27 @@ const globalDBAL = globalThis as { dbalClient?: DBALClient }
|
||||
*/
|
||||
export function createDBALClient(config?: DBALClientFactoryConfig): DBALClient {
|
||||
// Get or create Prisma client
|
||||
const prisma = createPrismaClient({
|
||||
databaseUrl: config?.databaseUrl,
|
||||
environment: config?.environment,
|
||||
})
|
||||
const prismaConfig: PrismaClientConfig = {}
|
||||
if (config?.databaseUrl) {
|
||||
prismaConfig.databaseUrl = config.databaseUrl
|
||||
}
|
||||
if (config?.environment) {
|
||||
prismaConfig.environment = config.environment
|
||||
}
|
||||
const prisma = createPrismaClient(prismaConfig)
|
||||
|
||||
// Create DBAL client with Prisma
|
||||
return new DBALClient({
|
||||
const databaseUrl = config?.databaseUrl || config?.database?.url
|
||||
const dbalConfig: DBALConfig = {
|
||||
mode: config?.mode || 'production',
|
||||
adapter: 'prisma',
|
||||
...config,
|
||||
database: {
|
||||
...config?.database,
|
||||
url: config?.databaseUrl || config?.database?.url,
|
||||
...(databaseUrl && { url: databaseUrl }),
|
||||
},
|
||||
})
|
||||
}
|
||||
return new DBALClient(dbalConfig)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,9 +25,9 @@ const assertValidId = (id: string) => {
|
||||
}
|
||||
|
||||
const assertValidCreate = (data: CreateWorkflowInput | Workflow) => {
|
||||
const normalized = {
|
||||
...data,
|
||||
description: data.description ?? undefined,
|
||||
const normalized: Record<string, unknown> = { ...data }
|
||||
if (!data.description) {
|
||||
delete normalized.description
|
||||
}
|
||||
const errors = validateWorkflowCreate(normalized as Partial<Workflow>)
|
||||
if (errors.length > 0) {
|
||||
@@ -36,9 +36,9 @@ const assertValidCreate = (data: CreateWorkflowInput | Workflow) => {
|
||||
}
|
||||
|
||||
const assertValidUpdate = (data: UpdateWorkflowInput) => {
|
||||
const normalized = {
|
||||
...data,
|
||||
description: data.description ?? undefined,
|
||||
const normalized: Record<string, unknown> = { ...data }
|
||||
if (!data.description) {
|
||||
delete normalized.description
|
||||
}
|
||||
const errors = validateWorkflowUpdate(normalized as Partial<Workflow>)
|
||||
if (errors.length > 0) {
|
||||
@@ -69,11 +69,10 @@ const resolveTenantFilter = (
|
||||
|
||||
const withWorkflowDefaults = (data: CreateWorkflowInput): Workflow => {
|
||||
const now = BigInt(Date.now())
|
||||
return {
|
||||
const base = {
|
||||
id: data.id ?? randomUUID(),
|
||||
tenantId: data.tenantId ?? null,
|
||||
name: data.name,
|
||||
description: data.description ?? undefined,
|
||||
nodes: data.nodes,
|
||||
edges: data.edges,
|
||||
enabled: data.enabled,
|
||||
@@ -82,6 +81,11 @@ const withWorkflowDefaults = (data: CreateWorkflowInput): Workflow => {
|
||||
updatedAt: data.updatedAt ?? now,
|
||||
createdBy: data.createdBy ?? null,
|
||||
}
|
||||
const workflow: Workflow = {
|
||||
...base,
|
||||
...(data.description && { description: data.description }),
|
||||
}
|
||||
return workflow
|
||||
}
|
||||
|
||||
export const createWorkflowOperations = (adapter: DBALAdapter, tenantId?: string): WorkflowOperations => ({
|
||||
|
||||
@@ -18,7 +18,7 @@ export const createWorkflow = async (
|
||||
id: input.id ?? store.generateId('workflow'),
|
||||
tenantId: input.tenantId ?? null,
|
||||
name: input.name,
|
||||
description: input.description ?? undefined,
|
||||
...(input.description && { description: input.description }),
|
||||
nodes: input.nodes,
|
||||
edges: input.edges,
|
||||
enabled: input.enabled ?? true,
|
||||
|
||||
@@ -59,7 +59,6 @@ export async function listEntries(
|
||||
return {
|
||||
entries,
|
||||
hasMore: false,
|
||||
nextCursor: undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ export async function setValue(
|
||||
sizeBytes,
|
||||
createdAt: existing?.createdAt || now,
|
||||
updatedAt: now,
|
||||
expiresAt: ttl ? new Date(now.getTime() + ttl * 1000) : undefined
|
||||
...(ttl && { expiresAt: new Date(now.getTime() + ttl * 1000) })
|
||||
}
|
||||
|
||||
state.data.set(scoped, entry)
|
||||
|
||||
Reference in New Issue
Block a user