This commit is contained in:
2026-08-20 18:02:52 +08:00
parent 4ae5e7c672
commit 80947cd9ce
65 changed files with 1386 additions and 1083 deletions
@@ -1,9 +1,9 @@
import { http, unwrapApiResponse, type ApiEnvelope } from '@/shared/api/http'
import type {
CarrierScheduleQueryAttempt,
CarrierScheduleQueryDetail,
CarrierScheduleQueryFilter,
CarrierScheduleQueryHistory,
CarrierScheduleNodeFact,
CarrierScheduleQueryPage,
CarrierScheduleQueryResource,
CarrierScheduleQueryView,
@@ -22,21 +22,20 @@ function resource(raw: CarrierScheduleQueryResource): CarrierScheduleQueryResour
oceanBookingId: String(raw.oceanBookingId),
containerBookingId: optionalId(raw.containerBookingId),
resultPortScheduleId: optionalId(raw.resultPortScheduleId),
attemptCount: numberValue(raw.attemptCount),
version: numberValue(raw.version),
}
}
function view(raw: CarrierScheduleQueryView): CarrierScheduleQueryView {
return { ...raw, query: resource(raw.query), maxAttempts: numberValue(raw.maxAttempts), nextAllowedAt: raw.nextAllowedAt ?? raw.query.nextAllowedAt ?? null }
return { ...raw, query: resource(raw.query) }
}
function attempt(raw: CarrierScheduleQueryAttempt): CarrierScheduleQueryAttempt {
return { ...raw, id: String(raw.id), queryId: String(raw.queryId), windowAttemptNo: numberValue(raw.windowAttemptNo), coverageGap: Boolean(raw.coverageGap) }
function node(raw: CarrierScheduleNodeFact): CarrierScheduleNodeFact {
return { ...raw, id: String(raw.id), nodeSequence: numberValue(raw.nodeSequence) }
}
function history(raw: CarrierScheduleQueryHistory): CarrierScheduleQueryHistory {
return { ...raw, id: String(raw.id), queryId: String(raw.queryId), fromVersion: raw.fromVersion == null ? null : numberValue(raw.fromVersion), toVersion: raw.toVersion == null ? null : numberValue(raw.toVersion) }
return { ...raw, id: String(raw.id), fromVersion: raw.fromVersion == null ? null : numberValue(raw.fromVersion), toVersion: raw.toVersion == null ? null : numberValue(raw.toVersion), operatorId: optionalId(raw.operatorId) }
}
export async function listCarrierScheduleQueries(filter: CarrierScheduleQueryFilter): Promise<CarrierScheduleQueryPage> {
@@ -48,5 +47,5 @@ export async function listCarrierScheduleQueries(filter: CarrierScheduleQueryFil
export async function getCarrierScheduleQuery(queryId: string): Promise<CarrierScheduleQueryDetail> {
const response = await http.get<ApiEnvelope<CarrierScheduleQueryDetail>, ApiEnvelope<CarrierScheduleQueryDetail>>(`${basePath}/${encodeURIComponent(queryId)}`)
const result = unwrapApiResponse(response)
return { ...result, query: view(result.query), attempts: (result.attempts || []).map(attempt), histories: (result.histories || []).map(history) }
return { ...result, query: view(result.query), nodes: (result.nodes || []).map(node), histories: (result.histories || []).map(history) }
}