增强后端 TypeScript 严格类型检查

This commit is contained in:
yml2213
2026-05-26 10:07:19 +08:00
parent 6d9f267593
commit a2bce8b272
14 changed files with 66 additions and 31 deletions
@@ -26,9 +26,9 @@ export async function notifyInternalSafely(payload: InternalNotificationPayload)
try {
const result = await sendInternalNotification({
title: payload.title,
body: payload.body,
category: payload.category,
url: payload.url,
...(payload.body !== undefined ? { body: payload.body } : {}),
...(payload.category !== undefined ? { category: payload.category } : {}),
...(payload.url !== undefined ? { url: payload.url } : {}),
})
markNotificationCooldown(cooldownKey)
return result
@@ -40,12 +40,12 @@ export async function sendInternalNotification(input: NotificationInput = {}) {
...(await Promise.all(barkRecipients.map(async (recipient: JsonObject) => {
try {
const result = await sendBarkNotification({
serverUrl: bark.serverUrl,
recipient,
title,
body,
group: `订单系统/${category}`,
url: input.url,
...(bark.serverUrl !== undefined ? { serverUrl: bark.serverUrl } : {}),
...(input.url !== undefined ? { url: input.url } : {}),
})
return mapNotificationResult('bark', recipient, recipient.deviceKey, true, '', result.status, result.response)
} catch (error) {
@@ -115,8 +115,8 @@ export async function upsertOrderFromSource(
provider: event.provider,
platform: event.platform,
shopId: event.shopId,
shopIdAliases: event.shopIdAliases,
item,
...(event.shopIdAliases !== undefined ? { shopIdAliases: event.shopIdAliases } : {}),
})),
)
const configuredItems = (resolvedItems as FulfillmentOrderItem[]).filter((item) => item.isConfigured)
@@ -155,7 +155,7 @@ export async function upsertOrderFromSource(
totalAmount: event.totalAmount,
currency: event.currency,
rawPayloadJson: JSON.stringify(event.rawPayload),
paidAt: event.paidAt,
...(event.paidAt !== undefined ? { paidAt: event.paidAt } : {}),
}
const mergedPayload = mergeSourceOrderState(existing, basePayload)
@@ -34,11 +34,12 @@ export async function cloudtentaclesRequest(pathname: unknown, options: JsonObje
})
try {
const body = normalizeRequestBody(options.body, headers['content-type'])
const response = await requestViaNodeHttp(url, {
method,
headers,
body: normalizeRequestBody(options.body, headers['content-type']),
signal: controller.signal,
...(body !== undefined ? { body } : {}),
})
const rawText = response.bodyText
@@ -42,15 +42,16 @@ export async function kuaishouEticketRequest(pathname: string, options: Kuaishou
userAgent: config.userAgent,
cookie: options.cookie ?? config.cookie,
contentType: options.contentType === null ? '' : options.contentType || inferContentType(options.body),
extra: options.headers,
...(options.headers !== undefined ? { extra: options.headers } : {}),
})
try {
const body = normalizeRequestBody(options.body, headers['content-type'])
const response = await requestViaNodeHttp(url, {
method,
headers,
body: normalizeRequestBody(options.body, headers['content-type']),
signal: controller.signal,
...(body !== undefined ? { body } : {}),
})
const rawText = response.bodyText
@@ -113,6 +113,13 @@ export async function upsertOpen91PendingOrder(payload: JsonObject = {}, config:
}
const [item] = event.items
if (!item) {
throw createHttpError('91卡券订单商品明细为空', {
statusCode: 400,
errorCode: 'open91_order_item_required',
})
}
const orderItems = await replaceOrderItems(order.id, [
{
skuCode: item.skuCode,