收紧后端 TypeScript:统一 Json 类型与 TaskContext 契约
关闭 allowJs;集中 JsonObject 定义并替换分散 any 别名;parseTaskContext 返回 TaskContext;任务详情 API 标注 AdminTaskDetailView;测试减少 as any。
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
import crypto from 'node:crypto'
|
||||
import { asJsonObject, type JsonObject } from '../../../types/json.js'
|
||||
|
||||
import { createHttpError } from '../../../utils/http.js'
|
||||
import { createRequestId, logExternalHttpPacket } from '../../../utils/logger.js'
|
||||
import { assertKuaishouFeifeiConfig } from './config.js'
|
||||
|
||||
type JsonObject = Record<string, any>
|
||||
|
||||
export async function kuaishouFeifeiRequest(pathname: string, payload: JsonObject = {}) {
|
||||
const config = assertKuaishouFeifeiConfig()
|
||||
const body = JSON.stringify(payload)
|
||||
@@ -189,7 +188,7 @@ export function isKuaishouFeifeiSuccessResponse(json: JsonObject) {
|
||||
function parseJsonObject(text: string): JsonObject {
|
||||
try {
|
||||
const parsed = JSON.parse(text || '{}')
|
||||
return parsed && typeof parsed === 'object' && !Array.isArray(parsed) ? parsed : {}
|
||||
return asJsonObject(parsed)
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import crypto from 'node:crypto'
|
||||
import type { JsonObject } from '../../../types/json.js'
|
||||
|
||||
import { createTaskEvent } from '../../../repositories/task-event-repo.js'
|
||||
import { findKuaishouFeifeiTaskByOrder } from '../../../repositories/task-repo.js'
|
||||
@@ -9,7 +10,6 @@ import { assertKuaishouFeifeiConfig } from './config.js'
|
||||
import { signKuaishouFeifeiPayload } from './http-client.js'
|
||||
import { mapKuaishouFeifeiOrder } from './order-service.js'
|
||||
|
||||
type JsonObject = Record<string, any>
|
||||
type NotifyHeaders = Record<string, string | string[] | undefined>
|
||||
|
||||
export async function handleKuaishouFeifeiNotify(input: {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { getKuaishouFeifeiConfig } from './config.js'
|
||||
import { kuaishouFeifeiRequest } from './http-client.js'
|
||||
|
||||
type JsonObject = Record<string, any>
|
||||
import type { JsonObject } from '../../../types/json.js'
|
||||
|
||||
export type KuaishouFeifeiProductListResult = ReturnType<typeof mapKuaishouFeifeiProductList>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import path from 'node:path'
|
||||
import type { JsonObject } from '../../../types/json.js'
|
||||
|
||||
import { APP_CONFIG_KEYS } from '../../../config/app-config-keys.js'
|
||||
import { PROJECT_ROOT } from '../../../config/runtime.js'
|
||||
@@ -16,8 +17,6 @@ const KUAISHOU_FEIFEI_CONFIG_FILE_PATH = path.join(
|
||||
'kuaishou-feifei-config.json',
|
||||
)
|
||||
|
||||
type JsonObject = Record<string, any>
|
||||
|
||||
export type KuaishouFeifeiSourceConfig = {
|
||||
enabled: boolean
|
||||
baseUrl: string
|
||||
|
||||
Reference in New Issue
Block a user