import type {
  AdminInventoryItemListItem,
  AdminInventorySkuSuggestion,
} from './admin-read-models.js'

export type { AdminInventoryItemListItem, AdminInventorySkuSuggestion }

export type AdminInventoryMutationResponse = {
  inventoryItem: AdminInventoryItemListItem | null
}

export type AdminInventoryImportResponse = {
  total: number
  created: number
  duplicated: number
}

export type AdminInventoryGroupListResponse = {
  items: AdminInventorySkuSuggestion[]
}

export type AdminAgisoMessagingDefaults = {
  messageTemplate: string
  autoDeliveryMessageTemplate: string
}

export type AdminAgisoShopConfigItem = {
  shopId: string
  shopName: string
  accessToken: string
  accessTokenMasked: string
  enabled: boolean | null
  messageTemplate: string
  autoDeliveryMessageTemplate: string
  appSecretConfigured: boolean
  apiVersion: string
  sendMessageEndpoint: string
}

export type AdminAgisoShopConfigSaveResponse = {
  filePath: string
  defaults: AdminAgisoMessagingDefaults
  shops: AdminAgisoShopConfigItem[]
}

export type AdminWebhookReplayResponse = {
  eventId: number
  replayed: boolean
  result: unknown
}

export type AdminTaskActionPayload = {
  taskId: number
  taskNo: string
  status: string
  deliveryStatus: string
  resultCode: string
  resultMessage: string
  inventoryItemId: number | null
  primaryClaimTokenId: number | null
  lastError: string
  updatedAt: string
}

export type AdminTaskActionResponse = {
  task: AdminTaskActionPayload
  claimUrl?: string
  token?: string
}

export type AdminTaskBindingReleaseResponse = AdminTaskActionResponse & {
  bindingId: number
  inventoryItemId: number
}

export type AdminManualDispatchOutcome = 'delivered' | 'failed'

export type AdminTaskManualDispatchResponse = AdminTaskActionResponse & {
  outcome: AdminManualDispatchOutcome
}
