|
@@ -1,6 +1,11 @@
|
|
|
import { http, type ListEnvelope } from '../http/client'
|
|
import { http, type ListEnvelope } from '../http/client'
|
|
|
import { mockDb } from '../../mocks/db'
|
|
import { mockDb } from '../../mocks/db'
|
|
|
-import type { SimulationResultEntity } from './contracts'
|
|
|
|
|
|
|
+import type {
|
|
|
|
|
+ AiHairSimulationDetail,
|
|
|
|
|
+ CustomerSimulationGalleryItem,
|
|
|
|
|
+ SimulationResultEntity,
|
|
|
|
|
+ SimulationTemplateOption,
|
|
|
|
|
+} from './contracts'
|
|
|
|
|
|
|
|
export { uploadMedia } from './media'
|
|
export { uploadMedia } from './media'
|
|
|
|
|
|
|
@@ -27,6 +32,13 @@ export type SimulationJob = {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export type CreateSimulationInput = {
|
|
export type CreateSimulationInput = {
|
|
|
|
|
+ customerId?: string
|
|
|
|
|
+ originImage: string
|
|
|
|
|
+ templateIds: string[]
|
|
|
|
|
+ simulateRemark?: string
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export type LegacyCreateSimulationInput = {
|
|
|
customerMode: 'selected' | 'guest'
|
|
customerMode: 'selected' | 'guest'
|
|
|
customerId?: string
|
|
customerId?: string
|
|
|
sourcePhoto: string
|
|
sourcePhoto: string
|
|
@@ -43,8 +55,44 @@ export type AdjustmentInput = {
|
|
|
replacementPhoto?: string
|
|
replacementPhoto?: string
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-export async function createSimulation(input: CreateSimulationInput): Promise<SimulationJob> {
|
|
|
|
|
- return http.post<SimulationJob>('/simulations', input)
|
|
|
|
|
|
|
+export type ListSimulationTemplatesParams = {
|
|
|
|
|
+ source: 'STYLIST' | 'SYSTEM'
|
|
|
|
|
+ category?: 'LONG' | 'MEDIUM' | 'SHORT' | 'DYE'
|
|
|
|
|
+ q?: string
|
|
|
|
|
+ page?: number
|
|
|
|
|
+ pageSize?: number
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export async function listSimulationTemplates(
|
|
|
|
|
+ params: ListSimulationTemplatesParams,
|
|
|
|
|
+): Promise<ListEnvelope<SimulationTemplateOption> & { page: number; pageSize: number }> {
|
|
|
|
|
+ const query = new URLSearchParams()
|
|
|
|
|
+
|
|
|
|
|
+ query.set('source', params.source)
|
|
|
|
|
+ if (params.category) query.set('category', params.category)
|
|
|
|
|
+ if (params.q) query.set('q', params.q)
|
|
|
|
|
+ if (params.page) query.set('page', String(params.page))
|
|
|
|
|
+ if (params.pageSize) query.set('pageSize', String(params.pageSize))
|
|
|
|
|
+
|
|
|
|
|
+ return http.get(`/simulations/template-options?${query.toString()}`)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export function createSimulation(input: CreateSimulationInput): Promise<{ simulationId: string }>
|
|
|
|
|
+export function createSimulation(input: LegacyCreateSimulationInput): Promise<SimulationJob>
|
|
|
|
|
+export async function createSimulation(
|
|
|
|
|
+ input: CreateSimulationInput | LegacyCreateSimulationInput,
|
|
|
|
|
+): Promise<{ simulationId: string } | SimulationJob> {
|
|
|
|
|
+ return http.post('/simulations', input)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export async function getSimulationById(simulationId: string): Promise<AiHairSimulationDetail> {
|
|
|
|
|
+ return http.get(`/simulations/${simulationId}`)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+export async function listCustomerSimulationGallery(
|
|
|
|
|
+ customerId: string,
|
|
|
|
|
+): Promise<{ items: CustomerSimulationGalleryItem[] }> {
|
|
|
|
|
+ return http.get(`/simulations/customer/${customerId}/gallery`)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export async function getSimulationJob(jobId: number): Promise<SimulationJob> {
|
|
export async function getSimulationJob(jobId: number): Promise<SimulationJob> {
|