feat: implement DBAL adapter with Prisma; add closeAdapter and getAdapter functions

This commit is contained in:
2025-12-25 18:44:54 +00:00
parent 3110f1b176
commit 5e4e2a3ab5
4 changed files with 42 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
import { useState } from 'react'
import { useState, type ComponentType } from 'react'
import { Box, Card, InputAdornment, Stack, TextField, Typography } from '@mui/material'
import type { SvgIconProps } from '@mui/material'
import CropFreeIcon from '@mui/icons-material/CropFree'
@@ -26,7 +26,7 @@ import SearchIcon from '@mui/icons-material/Search'
import { componentCatalog } from '@/lib/component-catalog'
import type { ComponentDefinition } from '@/lib/builder-types'
const iconMap: Record<string, React.ComponentType<SvgIconProps>> = {
const iconMap: Record<string, ComponentType<SvgIconProps>> = {
FrameCorners: CropFreeIcon,
Columns: ViewColumnIcon,
GridFour: GridViewIcon,

View File

@@ -0,0 +1,8 @@
import { prismaAdapter } from './create-prisma-adapter'
/**
* Close the DBAL adapter connection
*/
export const closeAdapter = async (): Promise<void> => {
await prismaAdapter.close()
}

View File

@@ -0,0 +1,23 @@
import type { DBALAdapter } from './types'
import { closeConnection } from './close-connection'
import { createEntity } from './create-entity'
import { deleteEntity } from './delete-entity'
import { findFirstEntity } from './find-first-entity'
import { listEntities } from './list-entities'
import { readEntity } from './read-entity'
import { updateEntity } from './update-entity'
import { upsertEntity } from './upsert-entity'
/**
* DBAL Adapter implementation using Prisma
*/
export const prismaAdapter: DBALAdapter = {
create: createEntity,
read: readEntity,
update: updateEntity,
delete: deleteEntity,
list: listEntities,
findFirst: findFirstEntity,
upsert: upsertEntity,
close: closeConnection,
}

View File

@@ -0,0 +1,9 @@
import type { DBALAdapter } from './types'
import { prismaAdapter } from './create-prisma-adapter'
/**
* Get the DBAL adapter singleton for database operations
*/
export const getAdapter = (): DBALAdapter => {
return prismaAdapter
}