ts类型检查
This commit is contained in:
@@ -32,6 +32,29 @@ const CLAIM_TERMINAL_STATUSES = new Set(['expired', 'closed'])
|
||||
const REDEEM_REPLACEMENT_LIMIT = 10
|
||||
const KUAISHOU_CLOUD_CLAIM_GUIDE_BASE_PATH = '/kuaishou-cloud-guide'
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* taskStatus: string
|
||||
* inventoryStatus: string
|
||||
* deliveryStatus: string
|
||||
* lastError: string
|
||||
* attempts: unknown[]
|
||||
* classification: { retCode?: unknown } | null
|
||||
* }} RedeemTaskState
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* statusCode?: number
|
||||
* errorCode?: string
|
||||
* taskStatus?: string
|
||||
* inventoryStatus?: string
|
||||
* deliveryStatus?: string
|
||||
* attempts?: unknown[]
|
||||
* classification?: { retCode?: unknown } | null
|
||||
* }} RedeemTaskStatePayload
|
||||
*/
|
||||
|
||||
export async function getClaimDetail(token, { includeQrImage = true } = {}) {
|
||||
const context = await getClaimContext(token)
|
||||
let { task, session } = await loadTaskSession(context.task, { includeQrImage })
|
||||
@@ -531,7 +554,11 @@ async function finalizeClaimTaskRedeem(context) {
|
||||
} catch (error) {
|
||||
const now = nowIso()
|
||||
const nextRetryCount = Number(context.task.attempt_count || 0) + 1
|
||||
const failureState = error?.redeemTaskState || {
|
||||
const failureState = (
|
||||
error && typeof error === 'object'
|
||||
? /** @type {{ redeemTaskState?: RedeemTaskState }} */ (error).redeemTaskState
|
||||
: null
|
||||
) || {
|
||||
taskStatus: 'retry_pending',
|
||||
inventoryStatus: inventoryItem ? 'reserved' : 'pending',
|
||||
deliveryStatus: 'pending',
|
||||
@@ -1102,11 +1129,15 @@ export async function redeemClaimTaskWithInventoryFallbackWithDeps(
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} message
|
||||
* @param {RedeemTaskStatePayload} [payload]
|
||||
*/
|
||||
function createRedeemTaskStateError(message, payload = {}) {
|
||||
const error = createHttpError(message, {
|
||||
const error = /** @type {Error & import('../../utils/http.js').HttpErrorLike & { redeemTaskState: RedeemTaskState }} */ (createHttpError(message, {
|
||||
statusCode: payload.statusCode || 409,
|
||||
errorCode: payload.errorCode || 'claim_redeem_failed',
|
||||
})
|
||||
}))
|
||||
|
||||
error.redeemTaskState = {
|
||||
taskStatus: payload.taskStatus || 'retry_pending',
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
import { queryKuaishouEticketConsumeDetail } from '../platforms/kuaishou-eticket/consume-service.js'
|
||||
import {
|
||||
dispatchKuaishouCloudFulfillmentTask,
|
||||
maskCode,
|
||||
normalizeKuaishouCloudFlow,
|
||||
prepareKuaishouCloudFulfillmentTask,
|
||||
refreshKuaishouCloudTaskRoleInfo,
|
||||
|
||||
Reference in New Issue
Block a user