import type { CodegenConfig } from '@graphql-codegen/cli'

const plugins = [
  'typescript',
  'typescript-operations',
  'typed-document-node',
]

const pluginConfig = {
  scalars: {
    DateTime: 'string',
  },
  useTypeImports: true,
}

const config: CodegenConfig = {
  overwrite: true,
  generates: {
    // Public operations (no token)
    './app/composables/graphql/public/exchange-generated.ts': {
      schema: 'https://exchange.optovia.ru/graphql/public/',
      documents: './graphql/operations/public/exchange/*.graphql',
      plugins,
      config: pluginConfig,
    },
    './app/composables/graphql/public/geo-generated.ts': {
      schema: 'https://geo.optovia.ru/graphql/public/',
      documents: './graphql/operations/public/geo/*.graphql',
      plugins,
      config: pluginConfig,
    },

    // User-level operations (ID Token)
    './app/composables/graphql/user/teams-generated.ts': {
      schema: 'https://teams.optovia.ru/graphql/user/',
      documents: './graphql/operations/user/teams/*.graphql',
      plugins,
      config: pluginConfig,
    },
    './app/composables/graphql/user/kyc-generated.ts': {
      schema: 'https://kyc.optovia.ru/graphql/user/',
      documents: './graphql/operations/user/kyc/*.graphql',
      plugins,
      config: pluginConfig,
    },

    // Team-level operations (Access Token)
    './app/composables/graphql/team/teams-generated.ts': {
      schema: 'https://teams.optovia.ru/graphql/team/',
      documents: './graphql/operations/team/teams/*.graphql',
      plugins,
      config: pluginConfig,
    },
    './app/composables/graphql/team/orders-generated.ts': {
      schema: 'https://orders.optovia.ru/graphql/team/',
      documents: './graphql/operations/team/orders/*.graphql',
      plugins,
      config: pluginConfig,
    },
    './app/composables/graphql/team/exchange-generated.ts': {
      schema: 'https://exchange.optovia.ru/graphql/team/',
      documents: './graphql/operations/team/exchange/*.graphql',
      plugins,
      config: pluginConfig,
    },
    './app/composables/graphql/team/billing-generated.ts': {
      schema: 'https://billing.optovia.ru/graphql/team/',
      documents: './graphql/operations/team/billing/*.graphql',
      plugins,
      config: pluginConfig,
    },
  },
}

export default config
