后端迁移快手Cloud核心履约
This commit is contained in:
+28
-10
@@ -1,5 +1,3 @@
|
||||
// @ts-check
|
||||
|
||||
import { createTaskEvent } from "../../repositories/task-event-repo.js";
|
||||
import { getOrderById } from "../../repositories/order-repo.js";
|
||||
import { updateTask } from "../../repositories/task-repo.js";
|
||||
@@ -46,6 +44,8 @@ import { nowIso } from "../../utils/time.js";
|
||||
|
||||
const KUAISHOU_CLOUD_FIXED_VN_KEY = "1";
|
||||
|
||||
type JsonObject = Record<string, any>;
|
||||
|
||||
export function isKuaishouCloudTask(task) {
|
||||
return String(task?.executor_key || "").trim() === "kuaishou_ct_assisted";
|
||||
}
|
||||
@@ -306,7 +306,10 @@ export async function ensureTaskClaimLink(task) {
|
||||
};
|
||||
}
|
||||
|
||||
export async function prepareKuaishouCloudFulfillmentTask(task, options = {}) {
|
||||
export async function prepareKuaishouCloudFulfillmentTask(
|
||||
task,
|
||||
options: JsonObject = {}
|
||||
) {
|
||||
if (!isKuaishouCloudTask(task)) {
|
||||
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
||||
statusCode: 409,
|
||||
@@ -534,7 +537,10 @@ export async function prepareKuaishouCloudFulfillmentTask(task, options = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
export async function refreshKuaishouCloudTaskBindUrl(task, options = {}) {
|
||||
export async function refreshKuaishouCloudTaskBindUrl(
|
||||
task,
|
||||
options: JsonObject = {}
|
||||
) {
|
||||
if (!isKuaishouCloudTask(task)) {
|
||||
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
||||
statusCode: 409,
|
||||
@@ -704,7 +710,10 @@ export async function refreshKuaishouCloudTaskBindUrl(task, options = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
export async function probeKuaishouCloudTaskBindUrl(task, options = {}) {
|
||||
export async function probeKuaishouCloudTaskBindUrl(
|
||||
task,
|
||||
options: JsonObject = {}
|
||||
) {
|
||||
if (!isKuaishouCloudTask(task)) {
|
||||
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
||||
statusCode: 409,
|
||||
@@ -800,7 +809,7 @@ export async function probeKuaishouCloudTaskBindUrl(task, options = {}) {
|
||||
*/
|
||||
async function markKuaishouCloudBindUrlRefreshFailed(
|
||||
task,
|
||||
{ taskContext, flow, now, actor, error } = {}
|
||||
{ taskContext, flow, now, actor, error }: JsonObject = {}
|
||||
) {
|
||||
const errorMessage =
|
||||
error instanceof Error
|
||||
@@ -864,7 +873,10 @@ async function markKuaishouCloudBindUrlRefreshFailed(
|
||||
return updatedTask;
|
||||
}
|
||||
|
||||
export async function refreshKuaishouCloudTaskRoleInfo(task, options = {}) {
|
||||
export async function refreshKuaishouCloudTaskRoleInfo(
|
||||
task,
|
||||
options: JsonObject = {}
|
||||
) {
|
||||
if (!isKuaishouCloudTask(task)) {
|
||||
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
||||
statusCode: 409,
|
||||
@@ -985,7 +997,10 @@ export async function refreshKuaishouCloudTaskRoleInfo(task, options = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
export async function dispatchKuaishouCloudFulfillmentTask(task, options = {}) {
|
||||
export async function dispatchKuaishouCloudFulfillmentTask(
|
||||
task,
|
||||
options: JsonObject = {}
|
||||
) {
|
||||
if (!isKuaishouCloudTask(task)) {
|
||||
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
||||
statusCode: 409,
|
||||
@@ -1117,7 +1132,10 @@ export async function dispatchKuaishouCloudFulfillmentTask(task, options = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
export async function returnKuaishouCloudFulfillmentTask(task, options = {}) {
|
||||
export async function returnKuaishouCloudFulfillmentTask(
|
||||
task,
|
||||
options: JsonObject = {}
|
||||
) {
|
||||
if (!isKuaishouCloudTask(task)) {
|
||||
throw createHttpError("当前任务不是快手 Cloud 履约任务", {
|
||||
statusCode: 409,
|
||||
@@ -1424,7 +1442,7 @@ function resolveKuaishouCloudVnKeyCandidates(_input = {}) {
|
||||
return [KUAISHOU_CLOUD_FIXED_VN_KEY];
|
||||
}
|
||||
|
||||
async function prepareKuaishouCloudBindResourceWithFallback(input = {}) {
|
||||
async function prepareKuaishouCloudBindResourceWithFallback(input: JsonObject = {}) {
|
||||
const { cloudContext = {}, vnKeyCandidates = [] } = input;
|
||||
const candidates = Array.isArray(vnKeyCandidates) ? vnKeyCandidates : [];
|
||||
let lastError = null;
|
||||
Reference in New Issue
Block a user