export type AdminDefaultUser = {
  username: string
  password: string
  role: string
  status?: string
}

export type KuaishouFeifeiProductRule = {
  id?: string
  productName: string
  normalizedProductName?: string
  productCode: string
  skuName?: string
  enabled?: boolean
  notes?: string
}

export type AffiliateDashSkuMapping = Record<string, string>

export type RuntimeConfig = {
  server: {
    port: number
  }
  data: {
    root: string
  }
  logging: {
    level: string
    /** integration 通道（外部对接日志文件）最低级别，默认 warn */
    integrationLevel: string
    retentionDays: number
  }
  database: {
    url: string
    ssl: boolean
    maxConnections: number
  }
  storage: {
    endpoint: string
    bucket: string
    accessKeyId: string
    secretAccessKey: string
    region: string
    maxUploadSizeMb: number
  }
  orders: {
    claimBaseUrl: string
    tokenTtlHours: number
  }
  admin: {
    sessionSecret: string
    sessionTtlHours: number
    defaultUsers: AdminDefaultUser[]
  }
  platforms: {
    ninetyone: {
      userId: string
      secret: string
      version: string
      shopId: string
      shopName: string
      timestampToleranceSeconds: number
      cardsEncoding: string
    }
    cloudtentacles: {
      baseUrl: string
      timeoutMs: number
      sendSmsPath: string
      loginPath: string
      userInfoPath: string
      assetPath: string
      permissionPath: string
      categoriesPath: string
      skuListPath: string
      skuBuyPath: string
      skuUsePath: string
      knapsackPath: string
      vnListPath: string
      vnAppointPath: string
      vnGenerateLoginCodePath: string
      vnVerifCodePath: string
      vnVerifyLoginCodePath: string
      vnBindUrlPath: string
      vnBindInfoPath: string
      vnBackPath: string
      bindUrlTtlSeconds: number
      bindUrlProbeIntervalSeconds: number
      bindUrlProbeTimeoutMs: number
      bindUrlProbeUserAgent: string
      bindUrlProbeEndpoint: string
      bindUrlProbeChartId: string
      bindUrlProbeSubChartId: string
      bindUrlProbeIdeToken: string
      bindUrlProbeActivityUrl: string
      bindUrlProbeReferer: string
      bindUrlProbeExtraCookie: string
      publicKeyPem: string
      clientSource: string
      deviceId: string
      deviceType: number
    }
    kuaishouIndustry: {
      appKey: string
      appSecret: string
      signSecret: string
      messageSecret: string
      provider: string
      platform: string
      shopId: string
      shopName: string
      version: string
    }
    kuaishouFeifei: {
      enabled: boolean
      baseUrl: string
      appKey: string
      appSecret: string
      timeoutMs: number
      notifyUrl: string
      productRules: KuaishouFeifeiProductRule[]
    }
    affiliateDash: {
      enabled: boolean
      baseUrl: string
      appKey: string
      appSecret: string
      callbackSecret: string
      timeoutMs: number
      notifyUrl: string
      timestampToleranceSeconds: number
      preferredMatchEnabled: boolean
      skuMapping: AffiliateDashSkuMapping
    }
  }
  worker: {
    sms: {
      provider: string
      accessKeyId: string
      accessKeySecret: string
      signName: string
      templateCode: string
      codeTtlSeconds: number
      cooldownSeconds: number
      dailyLimit: number
    }
  }
  cors: {
    allowedOrigins: string[]
  }
}
