index.ts 729 B

1234567891011121314151617181920212223242526
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { keyBy } from 'lodash-es'
  3. import type { EnumChannelArea } from '#shared/graphql/types.ts'
  4. import type { TicketChannelPlugin } from './types.ts'
  5. const pluginModules = import.meta.glob<TicketChannelPlugin>(
  6. ['./*.ts', '!./initialize.ts', '!./types.ts', '!./__tests__/**/*.ts'],
  7. {
  8. eager: true,
  9. import: 'default',
  10. },
  11. )
  12. const ticketChannelPluginFiles = Object.values(pluginModules)
  13. export const ticketChannelPlugins = keyBy(ticketChannelPluginFiles, 'area')
  14. export const getTicketChannelPlugin = (
  15. ticketChannel?: Maybe<EnumChannelArea>,
  16. ) => {
  17. if (!ticketChannel) return null
  18. return ticketChannelPlugins[ticketChannel]
  19. }