/** * Integration Key Request Mapper * * Transforms domain IntegrationKey objects to API request schemas. * Maps domain representation to CreateIntegrationKeyRequest format required by API. * * @layer Infrastructure - API Client */ import { createIntegrationKeyRequestSchema } from '@archer/api-interface'; import type { CreateIntegrationKeyRequest } from '@archer/api-interface'; import type { IntegrationKey } from '@/domain/entities/IntegrationKey'; /** * IntegrationKeyRequestMapper * * Handles transformation of domain objects to API request schemas. * Internal implementation - not exposed to UI layer. */ export class IntegrationKeyRequestMapper { /** * Transforms IntegrationKey domain object to CreateIntegrationKeyRequest schema * * @param tenantId - Tenant ID that owns the key * @param key - IntegrationKey domain object with key properties * @returns Validated CreateIntegrationKeyRequest schema * @throws ZodError if validation fails */ static toCreateRequest( tenantId: string, key: Pick ): CreateIntegrationKeyRequest { const request = { tenantId, expiresAt: key.expiresAt, }; // Validate with Zod schema before returning return createIntegrationKeyRequestSchema.parse(request); } }