import "reflect-metadata"
import { initializeDataSource, AppDataSource as SharedAppDataSource } from '@d8d/shared-utils'

// 导入所有实体模块
import { UserEntityMt, RoleMt } from '@d8d/user-module-mt'
import { FileMt } from '@d8d/file-module-mt'
import { TenantEntityMt } from '@d8d/tenant-module-mt'
import { SystemConfigMt } from '@d8d/core-module-mt/system-config-module-mt'
import { AreaEntityMt } from '@d8d/geo-areas-mt'
import { PaymentMtEntity } from '@d8d/mini-payment-mt'
import { Advertisement, AdvertisementType } from '@d8d/advertisements-module-mt'
import { DeliveryAddressMt } from '@d8d/delivery-address-module-mt'
import { GoodsMt, GoodsCategoryMt } from '@d8d/goods-module-mt'
import { MerchantMt } from '@d8d/merchant-module-mt'
import { OrderMt, OrderGoodsMt, OrderRefundMt } from '@d8d/orders-module-mt'
import { SupplierMt } from '@d8d/supplier-module-mt'
import { CreditBalanceMt, CreditBalanceLogMt } from '@d8d/credit-balance-module-mt'

// 初始化数据源
initializeDataSource([
  // 已实现的包实体
  UserEntityMt, RoleMt, FileMt,
  TenantEntityMt,
  AreaEntityMt, PaymentMtEntity,
  Advertisement, AdvertisementType,
  DeliveryAddressMt,
  GoodsMt, GoodsCategoryMt,
  MerchantMt,
  OrderMt, OrderGoodsMt, OrderRefundMt,
  SupplierMt, SystemConfigMt,
  CreditBalanceMt, CreditBalanceLogMt
])

// 导出数据源实例供TypeORM CLI使用
export const AppDataSource = SharedAppDataSource