diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 704d59c0c..2ab83522e 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -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 diff --git a/dbal/development/src/blob/index.ts b/dbal/development/src/blob/index.ts index a4376271b..eb8e78197 100644 --- a/dbal/development/src/blob/index.ts +++ b/dbal/development/src/blob/index.ts @@ -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: diff --git a/dbal/development/src/bridges/websocket-bridge/state.ts b/dbal/development/src/bridges/websocket-bridge/state.ts index 7fad0365a..32d3c066f 100644 --- a/dbal/development/src/bridges/websocket-bridge/state.ts +++ b/dbal/development/src/bridges/websocket-bridge/state.ts @@ -13,6 +13,6 @@ export const createBridgeState = ( ): BridgeState => ({ ws: null, endpoint, - auth, + ...(auth && { auth }), pendingRequests: new Map(), }) diff --git a/dbal/development/src/core/client/adapter-factory.ts b/dbal/development/src/core/client/adapter-factory.ts index 73a6e1bae..f92230cee 100644 --- a/dbal/development/src/core/client/adapter-factory.ts +++ b/dbal/development/src/core/client/adapter-factory.ts @@ -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': diff --git a/dbal/development/src/core/client/factory.ts b/dbal/development/src/core/client/factory.ts index bd193104e..ab353d9d3 100644 --- a/dbal/development/src/core/client/factory.ts +++ b/dbal/development/src/core/client/factory.ts @@ -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) } /** diff --git a/dbal/development/src/core/entities/operations/core/workflow-operations.ts b/dbal/development/src/core/entities/operations/core/workflow-operations.ts index 497f9b5bd..7acacc050 100644 --- a/dbal/development/src/core/entities/operations/core/workflow-operations.ts +++ b/dbal/development/src/core/entities/operations/core/workflow-operations.ts @@ -25,9 +25,9 @@ const assertValidId = (id: string) => { } const assertValidCreate = (data: CreateWorkflowInput | Workflow) => { - const normalized = { - ...data, - description: data.description ?? undefined, + const normalized: Record = { ...data } + if (!data.description) { + delete normalized.description } const errors = validateWorkflowCreate(normalized as Partial) 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 = { ...data } + if (!data.description) { + delete normalized.description } const errors = validateWorkflowUpdate(normalized as Partial) 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 => ({ diff --git a/dbal/development/src/core/entities/workflow/crud/create-workflow.ts b/dbal/development/src/core/entities/workflow/crud/create-workflow.ts index c5ed0b54d..41c7c522b 100644 --- a/dbal/development/src/core/entities/workflow/crud/create-workflow.ts +++ b/dbal/development/src/core/entities/workflow/crud/create-workflow.ts @@ -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, diff --git a/dbal/development/src/core/kv/operations/batch.ts b/dbal/development/src/core/kv/operations/batch.ts index 90befac44..2bf54e561 100644 --- a/dbal/development/src/core/kv/operations/batch.ts +++ b/dbal/development/src/core/kv/operations/batch.ts @@ -59,7 +59,6 @@ export async function listEntries( return { entries, hasMore: false, - nextCursor: undefined } } diff --git a/dbal/development/src/core/kv/operations/write.ts b/dbal/development/src/core/kv/operations/write.ts index 1506645fc..812b22ba8 100644 --- a/dbal/development/src/core/kv/operations/write.ts +++ b/dbal/development/src/core/kv/operations/write.ts @@ -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)