把 task 的 helper独立出来了
This commit is contained in:
@@ -3,7 +3,10 @@
|
||||
import { listMessageDeliveries } from '../../repositories/message-delivery-repo.js'
|
||||
import { normalizeDateQuery, normalizePage, normalizePageSize, safeParseJson } from './admin-query-utils.js'
|
||||
|
||||
export async function getAdminMessageDeliveries(query = {}) {
|
||||
/** @typedef {import('../../types/admin-read-inputs.js').AdminMessageDeliveryListQueryInput} AdminMessageDeliveryListQueryInput */
|
||||
|
||||
/** @param {AdminMessageDeliveryListQueryInput} [query] */
|
||||
export async function getAdminMessageDeliveries(query = /** @type {AdminMessageDeliveryListQueryInput} */ ({})) {
|
||||
const page = normalizePage(query.page)
|
||||
const pageSize = normalizePageSize(query.pageSize)
|
||||
const { items, total } = await listMessageDeliveries({
|
||||
|
||||
@@ -18,7 +18,11 @@ import { createHttpError } from '../../utils/http.js'
|
||||
import { formatFenToAmount } from '../../utils/money.js'
|
||||
import { syncConfiguredFulfillmentBindings } from '../bootstrap/fulfillment-bootstrap-service.js'
|
||||
import { normalizeProductName } from '../order/product-match-service.js'
|
||||
import { resolveDisplayShopName } from './admin-read-helpers.js'
|
||||
import { resolveDisplayShopName } from './admin-read-shared-helpers.js'
|
||||
|
||||
/** @typedef {import('../../types/admin-write-inputs.js').AdminAgisoShopConfigSaveInput} AdminAgisoShopConfigSaveInput */
|
||||
/** @typedef {import('../../types/admin-write-inputs.js').AdminFulfillmentBindingConfigSaveInput} AdminFulfillmentBindingConfigSaveInput */
|
||||
/** @typedef {import('../../types/admin-write-inputs.js').AdminFulfillmentBindingLookupInput} AdminFulfillmentBindingLookupInput */
|
||||
|
||||
export async function getAdminAgisoShopConfigs() {
|
||||
const configMap = getAgisoShopConfigMap()
|
||||
@@ -63,7 +67,8 @@ export async function getAdminAgisoShopConfigs() {
|
||||
}
|
||||
}
|
||||
|
||||
export function updateAdminAgisoShopConfigs(payload = {}) {
|
||||
/** @param {AdminAgisoShopConfigSaveInput} [payload] */
|
||||
export function updateAdminAgisoShopConfigs(payload = /** @type {AdminAgisoShopConfigSaveInput} */ ({})) {
|
||||
const rawItems = Array.isArray(payload.shops) ? payload.shops : []
|
||||
const nextMap = {}
|
||||
|
||||
@@ -179,7 +184,8 @@ export async function getAdminFulfillmentBindingConfigs() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function lookupAdminFulfillmentBindingOrder(payload = {}) {
|
||||
/** @param {AdminFulfillmentBindingLookupInput} [payload] */
|
||||
export async function lookupAdminFulfillmentBindingOrder(payload = /** @type {AdminFulfillmentBindingLookupInput} */ ({})) {
|
||||
const provider = String(payload.provider || 'agiso').trim() || 'agiso'
|
||||
const platform = String(payload.platform || 'xianyu').trim() || 'xianyu'
|
||||
const shopId = String(payload.shopId || '').trim()
|
||||
@@ -302,7 +308,10 @@ export async function lookupAdminFulfillmentBindingOrder(payload = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function updateAdminFulfillmentBindingConfigs(payload = {}) {
|
||||
/** @param {AdminFulfillmentBindingConfigSaveInput} [payload] */
|
||||
export async function updateAdminFulfillmentBindingConfigs(
|
||||
payload = /** @type {AdminFulfillmentBindingConfigSaveInput} */ ({}),
|
||||
) {
|
||||
const bindingsInput = Array.isArray(payload.bindings) ? payload.bindings : []
|
||||
await validateAdminFulfillmentBindingConfigs(bindingsInput)
|
||||
const saved = saveOrderFulfillmentBindingConfigs(bindingsInput)
|
||||
|
||||
@@ -1,54 +1,23 @@
|
||||
// @ts-check
|
||||
|
||||
import { getAgisoShopConfig } from '../platforms/agiso/shop-config-service.js'
|
||||
import { extractAgisoTradePayload, resolveAgisoTradePlatformOrderId } from '../order/agiso-trade-parsing.js'
|
||||
import { getInventoryItemById } from '../../repositories/inventory-repo.js'
|
||||
import { listOrderItemsByOrderId } from '../../repositories/order-item-repo.js'
|
||||
import { getOrderById } from '../../repositories/order-repo.js'
|
||||
import { getTaskById, listTasksByOrderId } from '../../repositories/task-repo.js'
|
||||
import { listTaskInventoryBindingSummariesByTaskIds } from '../../repositories/task-inventory-binding-repo.js'
|
||||
import { createHttpError } from '../../utils/http.js'
|
||||
import { formatFenToAmount, normalizeFen, parseAmountToFen } from '../../utils/money.js'
|
||||
import { safeParseJson } from './admin-query-utils.js'
|
||||
import { normalizeAdminRole } from './admin-auth-service.js'
|
||||
import { resolveDisplayShopName, resolveOrderItemTitle } from './admin-read-shared-helpers.js'
|
||||
import { buildOrderBindingSummary, getTaskBindingSummaryMap, mapAdminTaskSummary } from './admin-task-read-helpers.js'
|
||||
|
||||
/** @typedef {import('../../types/admin-read-models.js').AdminInventoryItemListItem} AdminInventoryItemListItem */
|
||||
/** @typedef {import('../../types/admin-read-models.js').AdminOrderListItem} AdminOrderListItem */
|
||||
/** @typedef {import('../../types/admin-read-models.js').AdminTaskBindingSummary} AdminTaskBindingSummary */
|
||||
/** @typedef {import('../../types/admin-read-models.js').AdminTaskListItem} AdminTaskListItem */
|
||||
/** @typedef {import('../../types/admin-read-models.js').AdminWebhookEventListItem} AdminWebhookEventListItem */
|
||||
/** @typedef {import('../../types/repository-rows.js').InventoryItemRow} InventoryItemRow */
|
||||
/** @typedef {import('../../types/repository-rows.js').OrderListRow} OrderListRow */
|
||||
/** @typedef {import('../../types/repository-rows.js').TaskEventRow} TaskEventRow */
|
||||
/** @typedef {import('../../types/repository-rows.js').TaskInventoryBindingRow} TaskInventoryBindingRow */
|
||||
/** @typedef {import('../../types/repository-rows.js').TaskRow} TaskRow */
|
||||
/** @typedef {import('../../types/repository-rows.js').WebhookEventRow} WebhookEventRow */
|
||||
|
||||
export function mapAdminTaskSummary(task, bindingSummary = createEmptyTaskBindingSummary()) {
|
||||
const binding = buildTaskBindingState(task)
|
||||
const taskContext = parseTaskContext(task)
|
||||
|
||||
return {
|
||||
taskId: task.id,
|
||||
taskNo: task.task_no,
|
||||
deliveryStatus: task.delivery_status || '',
|
||||
status: task.task_status,
|
||||
systemBindingStatus: binding.systemBindingStatus,
|
||||
userBindingStatus: binding.userBindingStatus,
|
||||
loginType: task.login_type,
|
||||
browserSessionId: task.browser_session_id,
|
||||
claimedAt: task.claimed_at,
|
||||
roleConfirmedAt: task.role_confirmed_at,
|
||||
redeemedAt: task.redeemed_at,
|
||||
lastError: task.last_error,
|
||||
retryCount: getTaskRetryCount(task),
|
||||
bindingSummary,
|
||||
agisoAutoDelivery: mapAgisoAutoDeliveryContext(taskContext.agisoAutoDelivery),
|
||||
createdAt: task.created_at,
|
||||
updatedAt: task.updated_at,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {WebhookEventRow} item
|
||||
* @returns {Promise<AdminWebhookEventListItem>}
|
||||
@@ -186,7 +155,7 @@ export async function mapAdminWebhookEvent(item, { includeRaw = false } = {}) {
|
||||
export async function mapAdminInventoryListItem(item) {
|
||||
const task = item.reserved_by_task_id ? await getTaskById(item.reserved_by_task_id) : null
|
||||
const order = task?.order_id ? await getOrderById(task.order_id) : null
|
||||
const binding = buildTaskBindingState(task)
|
||||
const taskSummary = task ? mapAdminTaskSummary(task) : null
|
||||
|
||||
return {
|
||||
inventoryItemId: item.id,
|
||||
@@ -198,8 +167,8 @@ export async function mapAdminInventoryListItem(item) {
|
||||
reservedByTaskId: item.reserved_by_task_id,
|
||||
reservedByTaskNo: task?.task_no || '',
|
||||
platformOrderId: order?.platform_order_id || '',
|
||||
systemBindingStatus: item.status === 'consumed' ? 'system_bound' : binding.systemBindingStatus,
|
||||
userBindingStatus: item.status === 'consumed' ? 'binding_completed' : binding.userBindingStatus,
|
||||
systemBindingStatus: item.status === 'consumed' ? 'system_bound' : (taskSummary?.systemBindingStatus || 'pending_binding'),
|
||||
userBindingStatus: item.status === 'consumed' ? 'binding_completed' : (taskSummary?.userBindingStatus || 'not_started'),
|
||||
invalidReason: item.invalid_reason || '',
|
||||
deliveredAt: item.delivered_at,
|
||||
createdAt: item.created_at,
|
||||
@@ -207,37 +176,6 @@ export async function mapAdminInventoryListItem(item) {
|
||||
}
|
||||
}
|
||||
|
||||
export function mapTaskActionPayload(task) {
|
||||
const inventoryItemId = getTaskPrimaryInventoryItemId(task)
|
||||
const primaryClaimTokenId = getTaskPrimaryClaimTokenId(task)
|
||||
|
||||
return {
|
||||
taskId: task.id,
|
||||
taskNo: task.task_no,
|
||||
status: task.task_status,
|
||||
deliveryStatus: task.delivery_status,
|
||||
resultCode: task.result_code,
|
||||
resultMessage: task.result_message,
|
||||
inventoryItemId,
|
||||
primaryClaimTokenId,
|
||||
lastError: task.last_error,
|
||||
updatedAt: task.updated_at,
|
||||
}
|
||||
}
|
||||
|
||||
export async function getRequiredTask(taskId) {
|
||||
const task = await getTaskById(Number(taskId))
|
||||
|
||||
if (!task) {
|
||||
throw createHttpError('任务不存在', {
|
||||
statusCode: 404,
|
||||
errorCode: 'admin_task_not_found',
|
||||
})
|
||||
}
|
||||
|
||||
return task
|
||||
}
|
||||
|
||||
export async function getRequiredInventoryItem(inventoryItemId) {
|
||||
const inventoryItem = await getInventoryItemById(Number(inventoryItemId))
|
||||
|
||||
@@ -251,133 +189,6 @@ export async function getRequiredInventoryItem(inventoryItemId) {
|
||||
return inventoryItem
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {TaskRow} task
|
||||
* @returns {AdminTaskListItem}
|
||||
*/
|
||||
export function mapAdminTaskListItem(task, bindingSummary = createEmptyTaskBindingSummary(), viewerContext = createAdminViewerContext()) {
|
||||
const binding = buildTaskBindingState(task)
|
||||
const taskContext = parseTaskContext(task)
|
||||
|
||||
return {
|
||||
taskId: task.id,
|
||||
taskNo: task.task_no,
|
||||
platformOrderId: task.platform_order_id,
|
||||
skuCode: task.sku_code || '',
|
||||
skuName: task.sku_name || '',
|
||||
status: task.task_status,
|
||||
executorKey: task.executor_key || '',
|
||||
deliveryStatus: task.delivery_status || '',
|
||||
resultCode: task.result_code || '',
|
||||
resultMessage: task.result_message || '',
|
||||
systemBindingStatus: binding.systemBindingStatus,
|
||||
userBindingStatus: binding.userBindingStatus,
|
||||
loginType: task.login_type,
|
||||
roleName: task.role_name,
|
||||
roleId: task.role_id,
|
||||
browserSessionId: task.browser_session_id,
|
||||
claimedAt: task.claimed_at,
|
||||
roleConfirmedAt: task.role_confirmed_at,
|
||||
redeemedAt: task.redeemed_at,
|
||||
retryCount: getTaskRetryCount(task),
|
||||
bindingSummary,
|
||||
agisoAutoDelivery: mapAgisoAutoDeliveryContext(taskContext.agisoAutoDelivery),
|
||||
lastError: task.last_error,
|
||||
createdAt: task.created_at,
|
||||
updatedAt: task.updated_at,
|
||||
inventoryDisplayMasked: viewerContext.canViewSensitiveTaskData ? maskCode(task.primary_inventory_display_value) : '',
|
||||
inventoryCredentialType: String(task.primary_inventory_credential_type || '').trim(),
|
||||
claimToken: viewerContext.canViewSensitiveTaskData ? (task.primary_claim_token || task.claim_token || '') : '',
|
||||
screenshotPath: viewerContext.role === 'support' ? '' : (task.screenshot_path || ''),
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {TaskEventRow} event */
|
||||
export function mapAdminTaskEvent(event) {
|
||||
const payload = safeParseJson(event.payload_json)
|
||||
|
||||
return {
|
||||
eventId: event.id,
|
||||
eventType: String(event.event_type || '').trim(),
|
||||
payload: normalizeRecord(payload),
|
||||
createdAt: event.created_at,
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns {AdminTaskBindingSummary} */
|
||||
export function createEmptyTaskBindingSummary() {
|
||||
return {
|
||||
totalBindingCount: 0,
|
||||
reservedBindingCount: 0,
|
||||
consumedBindingCount: 0,
|
||||
releasedBindingCount: 0,
|
||||
roleKeys: [],
|
||||
}
|
||||
}
|
||||
|
||||
export async function getTaskBindingSummaryMap(taskIds = []) {
|
||||
const rows = await listTaskInventoryBindingSummariesByTaskIds(taskIds)
|
||||
const output = new Map()
|
||||
|
||||
for (const row of rows) {
|
||||
output.set(Number(row.task_id), {
|
||||
totalBindingCount: Number(row.total_binding_count || 0),
|
||||
reservedBindingCount: Number(row.reserved_binding_count || 0),
|
||||
consumedBindingCount: Number(row.consumed_binding_count || 0),
|
||||
releasedBindingCount: Number(row.released_binding_count || 0),
|
||||
roleKeys: Array.isArray(row.role_keys)
|
||||
? row.role_keys.map((value) => String(value || '').trim()).filter(Boolean)
|
||||
: [],
|
||||
})
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
export function getTaskBindingSummary(summaryMap, taskId) {
|
||||
return summaryMap.get(Number(taskId)) || createEmptyTaskBindingSummary()
|
||||
}
|
||||
|
||||
export function createTaskBindingSummaryFromBindings(bindings = []) {
|
||||
const normalizedBindings = Array.isArray(bindings) ? bindings : []
|
||||
const roleKeys = Array.from(new Set(normalizedBindings
|
||||
.map((binding) => String(binding?.role_key || '').trim())
|
||||
.filter(Boolean)))
|
||||
|
||||
return {
|
||||
totalBindingCount: normalizedBindings.length,
|
||||
reservedBindingCount: normalizedBindings.filter((binding) => String(binding?.binding_status || '') === 'reserved').length,
|
||||
consumedBindingCount: normalizedBindings.filter((binding) => String(binding?.binding_status || '') === 'consumed').length,
|
||||
releasedBindingCount: normalizedBindings.filter((binding) => String(binding?.binding_status || '') === 'released').length,
|
||||
roleKeys,
|
||||
}
|
||||
}
|
||||
|
||||
export function mapAdminTaskInventoryBinding(binding, task, viewerContext = createAdminViewerContext()) {
|
||||
const metadata = safeParseJson(binding.metadata_json)
|
||||
|
||||
return {
|
||||
bindingId: binding.id,
|
||||
inventoryItemId: binding.inventory_item_id,
|
||||
roleKey: String(binding.role_key || '').trim(),
|
||||
quantity: Math.max(1, Number(binding.quantity || 1)),
|
||||
bindingStatus: String(binding.binding_status || '').trim(),
|
||||
inventoryStatus: String(binding.inventory_item_status || '').trim(),
|
||||
skuCode: String(binding.sku_code || '').trim(),
|
||||
batchNo: String(binding.batch_no || '').trim(),
|
||||
credentialType: String(binding.credential_type || 'tencent_code').trim() || 'tencent_code',
|
||||
displayValue: viewerContext.canViewSensitiveTaskData ? String(binding.display_value || '').trim() : '',
|
||||
invalidReason: String(binding.invalid_reason || '').trim(),
|
||||
consumedAt: binding.consumed_at || null,
|
||||
releasedAt: binding.released_at || null,
|
||||
createdAt: binding.created_at,
|
||||
updatedAt: binding.updated_at,
|
||||
metadata: normalizeRecord(metadata),
|
||||
isPrimary: Number(binding.inventory_item_id || 0) === getTaskPrimaryInventoryItemId(task),
|
||||
canRelease: viewerContext.canManageSensitiveInventory && canReleaseTaskInventoryBinding(task, binding),
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {OrderListRow} item
|
||||
* @returns {Promise<AdminOrderListItem>}
|
||||
@@ -442,451 +253,6 @@ export function summarizeOrderItems(items) {
|
||||
return `${firstLabel} 等 ${normalizedItems.length} 项`
|
||||
}
|
||||
|
||||
export function buildOrderBindingSummary(tasks, taskBindingSummaryMap = new Map()) {
|
||||
const normalizedTasks = Array.isArray(tasks) ? tasks : []
|
||||
const totalTaskCount = normalizedTasks.length
|
||||
const taskBindings = normalizedTasks.map((task) => buildTaskBindingState(task))
|
||||
const systemBoundTaskCount = normalizedTasks.filter((task) => isTaskSystemBound(task)).length
|
||||
const completedBindingTaskCount = normalizedTasks.filter((task) => String(task?.task_status || '') === 'redeemed').length
|
||||
const bindingSummaries = normalizedTasks.map((task) => getTaskBindingSummary(taskBindingSummaryMap, task.id))
|
||||
const totalBindingCount = bindingSummaries.reduce((sum, item) => sum + item.totalBindingCount, 0)
|
||||
const reservedBindingCount = bindingSummaries.reduce((sum, item) => sum + item.reservedBindingCount, 0)
|
||||
const consumedBindingCount = bindingSummaries.reduce((sum, item) => sum + item.consumedBindingCount, 0)
|
||||
const releasedBindingCount = bindingSummaries.reduce((sum, item) => sum + item.releasedBindingCount, 0)
|
||||
|
||||
let systemBindingStatus = 'pending_binding'
|
||||
let userBindingStatus = 'not_started'
|
||||
|
||||
if (totalTaskCount === 0) {
|
||||
return {
|
||||
totalTaskCount,
|
||||
systemBoundTaskCount,
|
||||
completedBindingTaskCount,
|
||||
totalBindingCount,
|
||||
reservedBindingCount,
|
||||
consumedBindingCount,
|
||||
releasedBindingCount,
|
||||
systemBindingStatus,
|
||||
userBindingStatus,
|
||||
}
|
||||
}
|
||||
|
||||
if (normalizedTasks.every((task) => String(task.task_status || '') === 'redeemed')) {
|
||||
systemBindingStatus = 'system_bound'
|
||||
userBindingStatus = 'binding_completed'
|
||||
} else if (taskBindings.some((item) => ['binding_in_progress', 'binding_confirmed', 'link_opened'].includes(item.userBindingStatus))) {
|
||||
systemBindingStatus = systemBoundTaskCount > 0 ? 'system_bound' : 'pending_binding'
|
||||
userBindingStatus = 'user_binding'
|
||||
} else if (taskBindings.some((item) => item.userBindingStatus === 'waiting_user_claim')) {
|
||||
systemBindingStatus = systemBoundTaskCount > 0 ? 'system_bound' : 'pending_binding'
|
||||
userBindingStatus = 'waiting_user_claim'
|
||||
} else if (taskBindings.some((item) => item.userBindingStatus === 'binding_exception')) {
|
||||
systemBindingStatus = systemBoundTaskCount > 0 ? 'system_bound' : 'pending_binding'
|
||||
userBindingStatus = 'binding_exception'
|
||||
} else if (systemBoundTaskCount > 0) {
|
||||
systemBindingStatus = 'system_bound'
|
||||
} else if (taskBindings.some((item) => ['manual_review', 'retry_pending', 'waiting_inventory'].includes(item.systemBindingStatus))) {
|
||||
systemBindingStatus = 'binding_exception'
|
||||
}
|
||||
|
||||
return {
|
||||
totalTaskCount,
|
||||
systemBoundTaskCount,
|
||||
completedBindingTaskCount,
|
||||
totalBindingCount,
|
||||
reservedBindingCount,
|
||||
consumedBindingCount,
|
||||
releasedBindingCount,
|
||||
systemBindingStatus,
|
||||
userBindingStatus,
|
||||
}
|
||||
}
|
||||
|
||||
export function buildOrderAgisoAutoDeliverySummary(order, tasks = []) {
|
||||
if (String(order?.provider || '').trim() !== 'agiso' || String(order?.platform || '').trim() !== 'xianyu') {
|
||||
return null
|
||||
}
|
||||
|
||||
const normalizedTasks = Array.isArray(tasks) ? tasks.filter(Boolean) : []
|
||||
const totalTaskCount = normalizedTasks.length
|
||||
const deliveredTaskCount = normalizedTasks.filter((task) => String(task?.delivery_status || '').trim() === 'delivered').length
|
||||
const latest = normalizedTasks.reduce((best, task) => {
|
||||
const autoDelivery = mapAgisoAutoDeliveryContext(parseTaskContext(task).agisoAutoDelivery)
|
||||
|
||||
if (!autoDelivery) {
|
||||
return best
|
||||
}
|
||||
|
||||
const candidate = {
|
||||
...autoDelivery,
|
||||
sourceTaskId: Number(task.id || 0) || null,
|
||||
sourceTaskNo: String(task.task_no || '').trim(),
|
||||
}
|
||||
const candidateTime = Date.parse(String(candidate.updatedAt || task.updated_at || ''))
|
||||
const bestTime = Date.parse(String(best?.updatedAt || ''))
|
||||
|
||||
if (!best || (Number.isFinite(candidateTime) && (!Number.isFinite(bestTime) || candidateTime >= bestTime))) {
|
||||
return candidate
|
||||
}
|
||||
|
||||
return best
|
||||
}, null)
|
||||
|
||||
if (latest) {
|
||||
return {
|
||||
...latest,
|
||||
totalTaskCount,
|
||||
deliveredTaskCount,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
status: totalTaskCount === 0 ? 'not_started' : deliveredTaskCount >= totalTaskCount ? 'pending' : 'waiting',
|
||||
trigger: '',
|
||||
reason: deliveredTaskCount >= totalTaskCount ? '' : 'waiting_other_tasks',
|
||||
platformOrderId: String(order?.platform_order_id || '').trim(),
|
||||
responseStatus: 0,
|
||||
errorMessage: '',
|
||||
requestId: '',
|
||||
aldsType: null,
|
||||
updatedAt: null,
|
||||
sourceTaskId: null,
|
||||
sourceTaskNo: '',
|
||||
totalTaskCount,
|
||||
deliveredTaskCount,
|
||||
}
|
||||
}
|
||||
|
||||
export function mapManualDispatchContext(value, viewerContext = createAdminViewerContext()) {
|
||||
if (!value || typeof value !== 'object') {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
outcome: String(value.outcome || '').trim(),
|
||||
deliveryReference: String(value.deliveryReference || '').trim(),
|
||||
deliveredCredential: viewerContext.canViewSensitiveTaskData ? String(value.deliveredCredential || '').trim() : '',
|
||||
resultMessage: String(value.resultMessage || '').trim(),
|
||||
completedAt: value.completedAt || null,
|
||||
completedBy: value.completedBy && typeof value.completedBy === 'object'
|
||||
? {
|
||||
userId: Number(value.completedBy.userId || 0) || 0,
|
||||
username: String(value.completedBy.username || '').trim(),
|
||||
role: String(value.completedBy.role || '').trim(),
|
||||
}
|
||||
: null,
|
||||
}
|
||||
}
|
||||
|
||||
export function mapRedeemResolutionContext(value) {
|
||||
if (!value || typeof value !== 'object') {
|
||||
return null
|
||||
}
|
||||
|
||||
const attempts = Array.isArray(value.attempts)
|
||||
? value.attempts
|
||||
.map((attempt) => mapRedeemResolutionAttempt(attempt))
|
||||
.filter(Boolean)
|
||||
: []
|
||||
|
||||
return {
|
||||
status: String(value.status || '').trim(),
|
||||
taskStatus: String(value.taskStatus || '').trim(),
|
||||
replacementCount: Math.max(0, Number(value.replacementCount || 0)),
|
||||
finishedAt: value.finishedAt || null,
|
||||
attempts,
|
||||
}
|
||||
}
|
||||
|
||||
export function getTaskPrimaryInventoryItemId(task) {
|
||||
const value = Number(task?.primary_inventory_item_id || 0)
|
||||
return Number.isFinite(value) && value > 0 ? value : null
|
||||
}
|
||||
|
||||
export function getTaskPrimaryClaimTokenId(task) {
|
||||
const value = Number(task?.primary_claim_token_id || 0)
|
||||
return Number.isFinite(value) && value > 0 ? value : null
|
||||
}
|
||||
|
||||
export function createAdminViewerContext(session = null) {
|
||||
const role = normalizeAdminRole(session?.role)
|
||||
|
||||
return {
|
||||
role,
|
||||
canViewSensitiveTaskData: role === 'admin' || role === 'operator',
|
||||
canManageSensitiveInventory: role === 'admin',
|
||||
canManageTaskLifecycle: role === 'admin' || role === 'operator',
|
||||
canOperateAssistedTask: role === 'admin' || role === 'operator' || role === 'support',
|
||||
}
|
||||
}
|
||||
|
||||
export async function resolveAdminTaskScreenshotUrl(task, viewerContext) {
|
||||
if (viewerContext.role === 'support') {
|
||||
return task.browser_session_id ? `/api/v1/admin/tasks/${task.id}/screenshot` : ''
|
||||
}
|
||||
|
||||
if (task.screenshot_path || task.browser_session_id) {
|
||||
return `/api/v1/admin/tasks/${task.id}/screenshot`
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
export function resolveDisplayShopName(provider, shopId, shopName) {
|
||||
const normalizedShopName = String(shopName || '').trim()
|
||||
if (normalizedShopName) {
|
||||
return normalizedShopName
|
||||
}
|
||||
|
||||
const normalizedShopId = String(shopId || '').trim()
|
||||
if (!normalizedShopId) {
|
||||
return ''
|
||||
}
|
||||
|
||||
if (String(provider || '').trim().toLowerCase() === 'agiso') {
|
||||
const configuredName = String(getAgisoShopConfig(normalizedShopId)?.shopName || '').trim()
|
||||
if (configuredName) {
|
||||
return configuredName
|
||||
}
|
||||
}
|
||||
|
||||
return normalizedShopId
|
||||
}
|
||||
|
||||
export function parseTaskContext(task) {
|
||||
const value = task?.context_json
|
||||
|
||||
if (!value) {
|
||||
return {}
|
||||
}
|
||||
|
||||
if (typeof value === 'object') {
|
||||
return value
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(String(value || '{}'))
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
export function parseTaskState(task) {
|
||||
const value = task?.state_json
|
||||
|
||||
if (!value) {
|
||||
return {}
|
||||
}
|
||||
|
||||
if (typeof value === 'object') {
|
||||
return value
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(String(value || '{}'))
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveOrderItemTitle(item) {
|
||||
if (!item) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const spec = safeParseJson(item.spec_json)
|
||||
|
||||
return pickFirstNonEmpty([
|
||||
spec.title,
|
||||
spec.Title,
|
||||
spec.itemTitle,
|
||||
spec.item_title,
|
||||
spec.goods_name,
|
||||
spec.goodsName,
|
||||
item.sku_name,
|
||||
item.sku_code,
|
||||
])
|
||||
}
|
||||
|
||||
export function resolveOrderItemDeliveryMode(tasks, orderItemId) {
|
||||
const task = (Array.isArray(tasks) ? tasks : []).find((item) => item.order_item_id === orderItemId)
|
||||
|
||||
if (!task) {
|
||||
return ''
|
||||
}
|
||||
|
||||
if (String(task.executor_key || '').trim() === 'manual_dispatch') {
|
||||
return 'manual_dispatch'
|
||||
}
|
||||
|
||||
if (task.requires_claim || getTaskPrimaryClaimTokenId(task) || task.primary_claim_token || task.claim_token) {
|
||||
return 'claim_link'
|
||||
}
|
||||
|
||||
return String(task.executor_key || '').trim()
|
||||
}
|
||||
|
||||
export function isManualDispatchTask(task) {
|
||||
return String(task?.executor_key || '').trim() === 'manual_dispatch'
|
||||
}
|
||||
|
||||
export function isAssistedClaimTask(task) {
|
||||
return String(task?.executor_key || '').trim() === 'tencent_claim_assisted'
|
||||
}
|
||||
|
||||
export function canRegenerateClaimLinkForViewer(task, viewerContext) {
|
||||
if (isManualDispatchTask(task)) {
|
||||
return false
|
||||
}
|
||||
|
||||
const baseAllowed = ['link_generated', 'claimed', 'role_confirmed', 'retry_pending', 'manual_review'].includes(task.task_status)
|
||||
|
||||
if (!baseAllowed) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (viewerContext.canManageTaskLifecycle) {
|
||||
return true
|
||||
}
|
||||
|
||||
return viewerContext.canOperateAssistedTask && isAssistedClaimTask(task)
|
||||
}
|
||||
|
||||
export function canViewerConfirmAssistedRole(task, viewerContext) {
|
||||
if (!viewerContext.canOperateAssistedTask || !isAssistedClaimTask(task)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return String(task?.task_status || '').trim() === 'claimed'
|
||||
}
|
||||
|
||||
export function canViewerRedeemAssistedTask(task, viewerContext) {
|
||||
if (!viewerContext.canOperateAssistedTask || !isAssistedClaimTask(task)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return ['role_confirmed', 'redeeming'].includes(String(task?.task_status || '').trim())
|
||||
}
|
||||
|
||||
function canReleaseTaskInventoryBinding(task, binding) {
|
||||
if (!task || !binding) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (String(binding.binding_status || '').trim() !== 'reserved') {
|
||||
return false
|
||||
}
|
||||
|
||||
return !['redeemed', 'expired'].includes(String(task.task_status || '').trim())
|
||||
}
|
||||
|
||||
function buildTaskBindingState(task) {
|
||||
const normalizedStatus = String(task?.task_status || '').trim()
|
||||
|
||||
if (!normalizedStatus) {
|
||||
return {
|
||||
systemBindingStatus: 'pending_binding',
|
||||
userBindingStatus: 'not_started',
|
||||
}
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'pending_payment') {
|
||||
return { systemBindingStatus: 'pending_payment', userBindingStatus: 'not_started' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'paid') {
|
||||
return { systemBindingStatus: 'pending_binding', userBindingStatus: 'not_started' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'waiting_inventory') {
|
||||
return { systemBindingStatus: 'waiting_inventory', userBindingStatus: 'not_started' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'manual_review') {
|
||||
return { systemBindingStatus: 'manual_review', userBindingStatus: 'binding_exception' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'retry_pending') {
|
||||
return { systemBindingStatus: 'retry_pending', userBindingStatus: 'binding_exception' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'closed') {
|
||||
return { systemBindingStatus: 'closed', userBindingStatus: 'closed' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'expired') {
|
||||
return { systemBindingStatus: 'expired', userBindingStatus: 'expired' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'link_generated') {
|
||||
return { systemBindingStatus: 'system_bound', userBindingStatus: 'waiting_user_claim' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'claimed') {
|
||||
return { systemBindingStatus: 'system_bound', userBindingStatus: 'link_opened' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'role_confirmed') {
|
||||
return { systemBindingStatus: 'system_bound', userBindingStatus: 'binding_confirmed' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'redeeming') {
|
||||
return { systemBindingStatus: 'system_bound', userBindingStatus: 'binding_in_progress' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'redeemed') {
|
||||
return { systemBindingStatus: 'system_bound', userBindingStatus: 'binding_completed' }
|
||||
}
|
||||
|
||||
if (isTaskSystemBound(task)) {
|
||||
return { systemBindingStatus: 'system_bound', userBindingStatus: 'waiting_user_claim' }
|
||||
}
|
||||
|
||||
return { systemBindingStatus: 'pending_binding', userBindingStatus: 'not_started' }
|
||||
}
|
||||
|
||||
function isTaskSystemBound(task) {
|
||||
return Boolean(task && (getTaskPrimaryInventoryItemId(task) || getTaskPrimaryClaimTokenId(task)))
|
||||
}
|
||||
|
||||
function mapAgisoAutoDeliveryContext(value) {
|
||||
if (!value || typeof value !== 'object') {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
status: String(value.status || '').trim(),
|
||||
trigger: String(value.trigger || '').trim(),
|
||||
reason: String(value.reason || '').trim(),
|
||||
platformOrderId: String(value.platformOrderId || '').trim(),
|
||||
responseStatus: Number(value.responseStatus || 0),
|
||||
errorMessage: String(value.errorMessage || '').trim(),
|
||||
requestId: String(value.requestId || '').trim(),
|
||||
aldsType: Number(value.aldsType || 0) || null,
|
||||
updatedAt: value.updatedAt || null,
|
||||
}
|
||||
}
|
||||
|
||||
function mapRedeemResolutionAttempt(value) {
|
||||
if (!value || typeof value !== 'object') {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
attempt: Math.max(1, Number(value.attempt || 1)),
|
||||
inventoryItemId: Number(value.inventoryItemId || 0) || null,
|
||||
codeMasked: String(value.codeMasked || '').trim(),
|
||||
credentialType: String(value.credentialType || '').trim(),
|
||||
outcome: String(value.outcome || '').trim(),
|
||||
resultCode: String(value.resultCode || '').trim(),
|
||||
resultMessage: String(value.resultMessage || '').trim(),
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeRecord(value) {
|
||||
return value && typeof value === 'object' && !Array.isArray(value) ? value : {}
|
||||
}
|
||||
|
||||
function extractWebhookPayload(body) {
|
||||
return extractAgisoTradePayload(body)
|
||||
}
|
||||
@@ -923,6 +289,10 @@ function extractWebhookItemSources(payload) {
|
||||
return []
|
||||
}
|
||||
|
||||
function normalizeRecord(value) {
|
||||
return value && typeof value === 'object' && !Array.isArray(value) ? value : {}
|
||||
}
|
||||
|
||||
function pickFirstNonEmpty(values) {
|
||||
for (const value of values) {
|
||||
if (typeof value === 'string' && value.trim()) {
|
||||
@@ -936,18 +306,3 @@ function pickFirstNonEmpty(values) {
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
function maskCode(value) {
|
||||
const text = String(value || '').trim()
|
||||
if (!text) {
|
||||
return ''
|
||||
}
|
||||
if (text.length <= 8) {
|
||||
return `${text.slice(0, 2)}****${text.slice(-2)}`
|
||||
}
|
||||
return `${text.slice(0, 4)}****${text.slice(-4)}`
|
||||
}
|
||||
|
||||
function getTaskRetryCount(task) {
|
||||
return Number(task?.attempt_count || 0)
|
||||
}
|
||||
|
||||
@@ -14,37 +14,41 @@ import { formatFenToAmount, normalizeFen } from '../../utils/money.js'
|
||||
import { getTencentBrowserSessionReviewScreenshotPath } from '../session/session.js'
|
||||
import { normalizeDateQuery, normalizePage, normalizePageSize, safeParseJson } from './admin-query-utils.js'
|
||||
import {
|
||||
buildOrderAgisoAutoDeliverySummary,
|
||||
buildOrderBindingSummary,
|
||||
canRegenerateClaimLinkForViewer,
|
||||
canViewerConfirmAssistedRole,
|
||||
canViewerRedeemAssistedTask,
|
||||
createAdminViewerContext,
|
||||
createTaskBindingSummaryFromBindings,
|
||||
getRequiredTask,
|
||||
getTaskBindingSummary,
|
||||
getTaskBindingSummaryMap,
|
||||
getTaskPrimaryClaimTokenId,
|
||||
getTaskPrimaryInventoryItemId,
|
||||
isAssistedClaimTask,
|
||||
isManualDispatchTask,
|
||||
mapManualDispatchContext,
|
||||
mapRedeemResolutionContext,
|
||||
parseTaskContext,
|
||||
parseTaskState,
|
||||
resolveAdminTaskScreenshotUrl,
|
||||
resolveDisplayShopName,
|
||||
resolveOrderItemDeliveryMode,
|
||||
resolveOrderItemTitle,
|
||||
} from './admin-read-shared-helpers.js'
|
||||
import {
|
||||
mapAdminInventoryListItem,
|
||||
mapAdminOrderListItem,
|
||||
mapAdminWebhookEvent,
|
||||
summarizeOrderItems,
|
||||
} from './admin-read-helpers.js'
|
||||
import {
|
||||
buildOrderAgisoAutoDeliverySummary,
|
||||
buildOrderBindingSummary,
|
||||
createTaskBindingSummaryFromBindings,
|
||||
getRequiredTask,
|
||||
getTaskBindingSummary,
|
||||
getTaskBindingSummaryMap,
|
||||
mapAdminTaskEvent,
|
||||
mapAdminTaskInventoryBinding,
|
||||
mapAdminTaskListItem,
|
||||
mapAdminTaskSummary,
|
||||
mapAdminWebhookEvent,
|
||||
mapManualDispatchContext,
|
||||
parseTaskContext,
|
||||
parseTaskState,
|
||||
mapRedeemResolutionContext,
|
||||
resolveOrderItemDeliveryMode,
|
||||
resolveOrderItemTitle,
|
||||
resolveAdminTaskScreenshotUrl,
|
||||
resolveDisplayShopName,
|
||||
summarizeOrderItems,
|
||||
} from './admin-read-helpers.js'
|
||||
} from './admin-task-read-helpers.js'
|
||||
|
||||
/** @typedef {import('../../types/admin-read-models.js').AdminInventoryListResponse} AdminInventoryListResponse */
|
||||
/** @typedef {import('../../types/admin-read-models.js').AdminInventorySkuSuggestionResponse} AdminInventorySkuSuggestionResponse */
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
// @ts-check
|
||||
|
||||
import { getAgisoShopConfig } from '../platforms/agiso/shop-config-service.js'
|
||||
import { safeParseJson } from './admin-query-utils.js'
|
||||
import { normalizeAdminRole } from './admin-auth-service.js'
|
||||
|
||||
export function mapManualDispatchContext(value, viewerContext = createAdminViewerContext()) {
|
||||
if (!value || typeof value !== 'object') {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
outcome: String(value.outcome || '').trim(),
|
||||
deliveryReference: String(value.deliveryReference || '').trim(),
|
||||
deliveredCredential: viewerContext.canViewSensitiveTaskData ? String(value.deliveredCredential || '').trim() : '',
|
||||
resultMessage: String(value.resultMessage || '').trim(),
|
||||
completedAt: value.completedAt || null,
|
||||
completedBy: value.completedBy && typeof value.completedBy === 'object'
|
||||
? {
|
||||
userId: Number(value.completedBy.userId || 0) || 0,
|
||||
username: String(value.completedBy.username || '').trim(),
|
||||
role: String(value.completedBy.role || '').trim(),
|
||||
}
|
||||
: null,
|
||||
}
|
||||
}
|
||||
|
||||
export function mapRedeemResolutionContext(value) {
|
||||
if (!value || typeof value !== 'object') {
|
||||
return null
|
||||
}
|
||||
|
||||
const attempts = Array.isArray(value.attempts)
|
||||
? value.attempts
|
||||
.map((attempt) => mapRedeemResolutionAttempt(attempt))
|
||||
.filter(Boolean)
|
||||
: []
|
||||
|
||||
return {
|
||||
status: String(value.status || '').trim(),
|
||||
taskStatus: String(value.taskStatus || '').trim(),
|
||||
replacementCount: Math.max(0, Number(value.replacementCount || 0)),
|
||||
finishedAt: value.finishedAt || null,
|
||||
attempts,
|
||||
}
|
||||
}
|
||||
|
||||
export function getTaskPrimaryInventoryItemId(task) {
|
||||
const value = Number(task?.primary_inventory_item_id || 0)
|
||||
return Number.isFinite(value) && value > 0 ? value : null
|
||||
}
|
||||
|
||||
export function getTaskPrimaryClaimTokenId(task) {
|
||||
const value = Number(task?.primary_claim_token_id || 0)
|
||||
return Number.isFinite(value) && value > 0 ? value : null
|
||||
}
|
||||
|
||||
export function createAdminViewerContext(session = null) {
|
||||
const role = normalizeAdminRole(session?.role)
|
||||
|
||||
return {
|
||||
role,
|
||||
canViewSensitiveTaskData: role === 'admin' || role === 'operator',
|
||||
canManageSensitiveInventory: role === 'admin',
|
||||
canManageTaskLifecycle: role === 'admin' || role === 'operator',
|
||||
canOperateAssistedTask: role === 'admin' || role === 'operator' || role === 'support',
|
||||
}
|
||||
}
|
||||
|
||||
export async function resolveAdminTaskScreenshotUrl(task, viewerContext) {
|
||||
if (viewerContext.role === 'support') {
|
||||
return task.browser_session_id ? `/api/v1/admin/tasks/${task.id}/screenshot` : ''
|
||||
}
|
||||
|
||||
if (task.screenshot_path || task.browser_session_id) {
|
||||
return `/api/v1/admin/tasks/${task.id}/screenshot`
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
|
||||
export function resolveDisplayShopName(provider, shopId, shopName) {
|
||||
const normalizedShopName = String(shopName || '').trim()
|
||||
if (normalizedShopName) {
|
||||
return normalizedShopName
|
||||
}
|
||||
|
||||
const normalizedShopId = String(shopId || '').trim()
|
||||
if (!normalizedShopId) {
|
||||
return ''
|
||||
}
|
||||
|
||||
if (String(provider || '').trim().toLowerCase() === 'agiso') {
|
||||
const configuredName = String(getAgisoShopConfig(normalizedShopId)?.shopName || '').trim()
|
||||
if (configuredName) {
|
||||
return configuredName
|
||||
}
|
||||
}
|
||||
|
||||
return normalizedShopId
|
||||
}
|
||||
|
||||
export function parseTaskContext(task) {
|
||||
const value = task?.context_json
|
||||
|
||||
if (!value) {
|
||||
return {}
|
||||
}
|
||||
|
||||
if (typeof value === 'object') {
|
||||
return value
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(String(value || '{}'))
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
export function parseTaskState(task) {
|
||||
const value = task?.state_json
|
||||
|
||||
if (!value) {
|
||||
return {}
|
||||
}
|
||||
|
||||
if (typeof value === 'object') {
|
||||
return value
|
||||
}
|
||||
|
||||
try {
|
||||
return JSON.parse(String(value || '{}'))
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
export function resolveOrderItemTitle(item) {
|
||||
if (!item) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const spec = safeParseJson(item.spec_json)
|
||||
|
||||
return pickFirstNonEmpty([
|
||||
spec.title,
|
||||
spec.Title,
|
||||
spec.itemTitle,
|
||||
spec.item_title,
|
||||
spec.goods_name,
|
||||
spec.goodsName,
|
||||
item.sku_name,
|
||||
item.sku_code,
|
||||
])
|
||||
}
|
||||
|
||||
export function resolveOrderItemDeliveryMode(tasks, orderItemId) {
|
||||
const task = (Array.isArray(tasks) ? tasks : []).find((item) => item.order_item_id === orderItemId)
|
||||
|
||||
if (!task) {
|
||||
return ''
|
||||
}
|
||||
|
||||
if (String(task.executor_key || '').trim() === 'manual_dispatch') {
|
||||
return 'manual_dispatch'
|
||||
}
|
||||
|
||||
if (task.requires_claim || getTaskPrimaryClaimTokenId(task) || task.primary_claim_token || task.claim_token) {
|
||||
return 'claim_link'
|
||||
}
|
||||
|
||||
return String(task.executor_key || '').trim()
|
||||
}
|
||||
|
||||
export function isManualDispatchTask(task) {
|
||||
return String(task?.executor_key || '').trim() === 'manual_dispatch'
|
||||
}
|
||||
|
||||
export function isAssistedClaimTask(task) {
|
||||
return String(task?.executor_key || '').trim() === 'tencent_claim_assisted'
|
||||
}
|
||||
|
||||
export function canRegenerateClaimLinkForViewer(task, viewerContext) {
|
||||
if (isManualDispatchTask(task)) {
|
||||
return false
|
||||
}
|
||||
|
||||
const baseAllowed = ['link_generated', 'claimed', 'role_confirmed', 'retry_pending', 'manual_review'].includes(task.task_status)
|
||||
|
||||
if (!baseAllowed) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (viewerContext.canManageTaskLifecycle) {
|
||||
return true
|
||||
}
|
||||
|
||||
return viewerContext.canOperateAssistedTask && isAssistedClaimTask(task)
|
||||
}
|
||||
|
||||
export function canViewerConfirmAssistedRole(task, viewerContext) {
|
||||
if (!viewerContext.canOperateAssistedTask || !isAssistedClaimTask(task)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return String(task?.task_status || '').trim() === 'claimed'
|
||||
}
|
||||
|
||||
export function canViewerRedeemAssistedTask(task, viewerContext) {
|
||||
if (!viewerContext.canOperateAssistedTask || !isAssistedClaimTask(task)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return ['role_confirmed', 'redeeming'].includes(String(task?.task_status || '').trim())
|
||||
}
|
||||
|
||||
function mapRedeemResolutionAttempt(value) {
|
||||
if (!value || typeof value !== 'object') {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
attempt: Math.max(1, Number(value.attempt || 1)),
|
||||
inventoryItemId: Number(value.inventoryItemId || 0) || null,
|
||||
codeMasked: String(value.codeMasked || '').trim(),
|
||||
credentialType: String(value.credentialType || '').trim(),
|
||||
outcome: String(value.outcome || '').trim(),
|
||||
resultCode: String(value.resultCode || '').trim(),
|
||||
resultMessage: String(value.resultMessage || '').trim(),
|
||||
}
|
||||
}
|
||||
|
||||
function pickFirstNonEmpty(values) {
|
||||
for (const value of values) {
|
||||
if (typeof value === 'string' && value.trim()) {
|
||||
return value.trim()
|
||||
}
|
||||
|
||||
if (typeof value === 'number' && Number.isFinite(value)) {
|
||||
return String(value)
|
||||
}
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
@@ -1,37 +1,45 @@
|
||||
// @ts-check
|
||||
|
||||
export {
|
||||
getRequiredInventoryItem,
|
||||
mapAdminInventoryListItem,
|
||||
mapAdminOrderListItem,
|
||||
mapAdminWebhookEvent,
|
||||
} from './admin-read-helpers.js'
|
||||
|
||||
export {
|
||||
buildOrderAgisoAutoDeliverySummary,
|
||||
buildOrderBindingSummary,
|
||||
canRegenerateClaimLinkForViewer,
|
||||
canViewerConfirmAssistedRole,
|
||||
canViewerRedeemAssistedTask,
|
||||
createAdminViewerContext,
|
||||
createEmptyTaskBindingSummary,
|
||||
createTaskBindingSummaryFromBindings,
|
||||
getRequiredInventoryItem,
|
||||
getRequiredTask,
|
||||
getTaskBindingSummary,
|
||||
getTaskBindingSummaryMap,
|
||||
getTaskPrimaryClaimTokenId,
|
||||
getTaskPrimaryInventoryItemId,
|
||||
mapAdminInventoryListItem,
|
||||
mapAdminOrderListItem,
|
||||
mapAdminTaskEvent,
|
||||
mapAdminTaskInventoryBinding,
|
||||
mapAdminTaskListItem,
|
||||
mapAdminTaskSummary,
|
||||
mapAdminWebhookEvent,
|
||||
mapTaskActionPayload,
|
||||
} from './admin-task-read-helpers.js'
|
||||
|
||||
export {
|
||||
canRegenerateClaimLinkForViewer,
|
||||
canViewerConfirmAssistedRole,
|
||||
canViewerRedeemAssistedTask,
|
||||
createAdminViewerContext,
|
||||
getTaskPrimaryClaimTokenId,
|
||||
getTaskPrimaryInventoryItemId,
|
||||
isAssistedClaimTask,
|
||||
isManualDispatchTask,
|
||||
mapManualDispatchContext,
|
||||
mapRedeemResolutionContext,
|
||||
mapTaskActionPayload,
|
||||
parseTaskContext,
|
||||
parseTaskState,
|
||||
resolveOrderItemDeliveryMode,
|
||||
resolveOrderItemTitle,
|
||||
resolveAdminTaskScreenshotUrl,
|
||||
resolveDisplayShopName,
|
||||
} from './admin-read-helpers.js'
|
||||
} from './admin-read-shared-helpers.js'
|
||||
|
||||
export {
|
||||
getAdminInventoryItems,
|
||||
|
||||
@@ -0,0 +1,434 @@
|
||||
// @ts-check
|
||||
|
||||
import { getTaskById } from '../../repositories/task-repo.js'
|
||||
import { listTaskInventoryBindingSummariesByTaskIds } from '../../repositories/task-inventory-binding-repo.js'
|
||||
import { createHttpError } from '../../utils/http.js'
|
||||
import { safeParseJson } from './admin-query-utils.js'
|
||||
import {
|
||||
createAdminViewerContext,
|
||||
getTaskPrimaryClaimTokenId,
|
||||
getTaskPrimaryInventoryItemId,
|
||||
parseTaskContext,
|
||||
} from './admin-read-shared-helpers.js'
|
||||
|
||||
/** @typedef {import('../../types/admin-read-models.js').AdminTaskBindingSummary} AdminTaskBindingSummary */
|
||||
/** @typedef {import('../../types/admin-read-models.js').AdminTaskListItem} AdminTaskListItem */
|
||||
/** @typedef {import('../../types/repository-rows.js').TaskEventRow} TaskEventRow */
|
||||
/** @typedef {import('../../types/repository-rows.js').TaskInventoryBindingRow} TaskInventoryBindingRow */
|
||||
/** @typedef {import('../../types/repository-rows.js').TaskRow} TaskRow */
|
||||
|
||||
export function mapAdminTaskSummary(task, bindingSummary = createEmptyTaskBindingSummary()) {
|
||||
const binding = buildTaskBindingState(task)
|
||||
const taskContext = parseTaskContext(task)
|
||||
|
||||
return {
|
||||
taskId: task.id,
|
||||
taskNo: task.task_no,
|
||||
deliveryStatus: task.delivery_status || '',
|
||||
status: task.task_status,
|
||||
systemBindingStatus: binding.systemBindingStatus,
|
||||
userBindingStatus: binding.userBindingStatus,
|
||||
loginType: task.login_type,
|
||||
browserSessionId: task.browser_session_id,
|
||||
claimedAt: task.claimed_at,
|
||||
roleConfirmedAt: task.role_confirmed_at,
|
||||
redeemedAt: task.redeemed_at,
|
||||
lastError: task.last_error,
|
||||
retryCount: getTaskRetryCount(task),
|
||||
bindingSummary,
|
||||
agisoAutoDelivery: mapAgisoAutoDeliveryContext(taskContext.agisoAutoDelivery),
|
||||
createdAt: task.created_at,
|
||||
updatedAt: task.updated_at,
|
||||
}
|
||||
}
|
||||
|
||||
export function mapTaskActionPayload(task) {
|
||||
const inventoryItemId = getTaskPrimaryInventoryItemId(task)
|
||||
const primaryClaimTokenId = getTaskPrimaryClaimTokenId(task)
|
||||
|
||||
return {
|
||||
taskId: task.id,
|
||||
taskNo: task.task_no,
|
||||
status: task.task_status,
|
||||
deliveryStatus: task.delivery_status,
|
||||
resultCode: task.result_code,
|
||||
resultMessage: task.result_message,
|
||||
inventoryItemId,
|
||||
primaryClaimTokenId,
|
||||
lastError: task.last_error,
|
||||
updatedAt: task.updated_at,
|
||||
}
|
||||
}
|
||||
|
||||
export async function getRequiredTask(taskId) {
|
||||
const task = await getTaskById(Number(taskId))
|
||||
|
||||
if (!task) {
|
||||
throw createHttpError('任务不存在', {
|
||||
statusCode: 404,
|
||||
errorCode: 'admin_task_not_found',
|
||||
})
|
||||
}
|
||||
|
||||
return task
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {TaskRow} task
|
||||
* @returns {AdminTaskListItem}
|
||||
*/
|
||||
export function mapAdminTaskListItem(task, bindingSummary = createEmptyTaskBindingSummary(), viewerContext = createAdminViewerContext()) {
|
||||
const binding = buildTaskBindingState(task)
|
||||
const taskContext = parseTaskContext(task)
|
||||
|
||||
return {
|
||||
taskId: task.id,
|
||||
taskNo: task.task_no,
|
||||
platformOrderId: task.platform_order_id,
|
||||
skuCode: task.sku_code || '',
|
||||
skuName: task.sku_name || '',
|
||||
status: task.task_status,
|
||||
executorKey: task.executor_key || '',
|
||||
deliveryStatus: task.delivery_status || '',
|
||||
resultCode: task.result_code || '',
|
||||
resultMessage: task.result_message || '',
|
||||
systemBindingStatus: binding.systemBindingStatus,
|
||||
userBindingStatus: binding.userBindingStatus,
|
||||
loginType: task.login_type,
|
||||
roleName: task.role_name,
|
||||
roleId: task.role_id,
|
||||
browserSessionId: task.browser_session_id,
|
||||
claimedAt: task.claimed_at,
|
||||
roleConfirmedAt: task.role_confirmed_at,
|
||||
redeemedAt: task.redeemed_at,
|
||||
retryCount: getTaskRetryCount(task),
|
||||
bindingSummary,
|
||||
agisoAutoDelivery: mapAgisoAutoDeliveryContext(taskContext.agisoAutoDelivery),
|
||||
lastError: task.last_error,
|
||||
createdAt: task.created_at,
|
||||
updatedAt: task.updated_at,
|
||||
inventoryDisplayMasked: viewerContext.canViewSensitiveTaskData ? maskCode(task.primary_inventory_display_value) : '',
|
||||
inventoryCredentialType: String(task.primary_inventory_credential_type || '').trim(),
|
||||
claimToken: viewerContext.canViewSensitiveTaskData ? (task.primary_claim_token || task.claim_token || '') : '',
|
||||
screenshotPath: viewerContext.role === 'support' ? '' : (task.screenshot_path || ''),
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {TaskEventRow} event */
|
||||
export function mapAdminTaskEvent(event) {
|
||||
const payload = safeParseJson(event.payload_json)
|
||||
|
||||
return {
|
||||
eventId: event.id,
|
||||
eventType: String(event.event_type || '').trim(),
|
||||
payload: normalizeRecord(payload),
|
||||
createdAt: event.created_at,
|
||||
}
|
||||
}
|
||||
|
||||
/** @returns {AdminTaskBindingSummary} */
|
||||
export function createEmptyTaskBindingSummary() {
|
||||
return {
|
||||
totalBindingCount: 0,
|
||||
reservedBindingCount: 0,
|
||||
consumedBindingCount: 0,
|
||||
releasedBindingCount: 0,
|
||||
roleKeys: [],
|
||||
}
|
||||
}
|
||||
|
||||
export async function getTaskBindingSummaryMap(taskIds = []) {
|
||||
const rows = await listTaskInventoryBindingSummariesByTaskIds(taskIds)
|
||||
const output = new Map()
|
||||
|
||||
for (const row of rows) {
|
||||
output.set(Number(row.task_id), {
|
||||
totalBindingCount: Number(row.total_binding_count || 0),
|
||||
reservedBindingCount: Number(row.reserved_binding_count || 0),
|
||||
consumedBindingCount: Number(row.consumed_binding_count || 0),
|
||||
releasedBindingCount: Number(row.released_binding_count || 0),
|
||||
roleKeys: Array.isArray(row.role_keys)
|
||||
? row.role_keys.map((value) => String(value || '').trim()).filter(Boolean)
|
||||
: [],
|
||||
})
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
export function getTaskBindingSummary(summaryMap, taskId) {
|
||||
return summaryMap.get(Number(taskId)) || createEmptyTaskBindingSummary()
|
||||
}
|
||||
|
||||
export function createTaskBindingSummaryFromBindings(bindings = []) {
|
||||
const normalizedBindings = Array.isArray(bindings) ? bindings : []
|
||||
const roleKeys = Array.from(new Set(normalizedBindings
|
||||
.map((binding) => String(binding?.role_key || '').trim())
|
||||
.filter(Boolean)))
|
||||
|
||||
return {
|
||||
totalBindingCount: normalizedBindings.length,
|
||||
reservedBindingCount: normalizedBindings.filter((binding) => String(binding?.binding_status || '') === 'reserved').length,
|
||||
consumedBindingCount: normalizedBindings.filter((binding) => String(binding?.binding_status || '') === 'consumed').length,
|
||||
releasedBindingCount: normalizedBindings.filter((binding) => String(binding?.binding_status || '') === 'released').length,
|
||||
roleKeys,
|
||||
}
|
||||
}
|
||||
|
||||
export function mapAdminTaskInventoryBinding(binding, task, viewerContext = createAdminViewerContext()) {
|
||||
const metadata = safeParseJson(binding.metadata_json)
|
||||
|
||||
return {
|
||||
bindingId: binding.id,
|
||||
inventoryItemId: binding.inventory_item_id,
|
||||
roleKey: String(binding.role_key || '').trim(),
|
||||
quantity: Math.max(1, Number(binding.quantity || 1)),
|
||||
bindingStatus: String(binding.binding_status || '').trim(),
|
||||
inventoryStatus: String(binding.inventory_item_status || '').trim(),
|
||||
skuCode: String(binding.sku_code || '').trim(),
|
||||
batchNo: String(binding.batch_no || '').trim(),
|
||||
credentialType: String(binding.credential_type || 'tencent_code').trim() || 'tencent_code',
|
||||
displayValue: viewerContext.canViewSensitiveTaskData ? String(binding.display_value || '').trim() : '',
|
||||
invalidReason: String(binding.invalid_reason || '').trim(),
|
||||
consumedAt: binding.consumed_at || null,
|
||||
releasedAt: binding.released_at || null,
|
||||
createdAt: binding.created_at,
|
||||
updatedAt: binding.updated_at,
|
||||
metadata: normalizeRecord(metadata),
|
||||
isPrimary: Number(binding.inventory_item_id || 0) === getTaskPrimaryInventoryItemId(task),
|
||||
canRelease: viewerContext.canManageSensitiveInventory && canReleaseTaskInventoryBinding(task, binding),
|
||||
}
|
||||
}
|
||||
|
||||
export function buildOrderBindingSummary(tasks, taskBindingSummaryMap = new Map()) {
|
||||
const normalizedTasks = Array.isArray(tasks) ? tasks : []
|
||||
const totalTaskCount = normalizedTasks.length
|
||||
const taskBindings = normalizedTasks.map((task) => buildTaskBindingState(task))
|
||||
const systemBoundTaskCount = normalizedTasks.filter((task) => isTaskSystemBound(task)).length
|
||||
const completedBindingTaskCount = normalizedTasks.filter((task) => String(task?.task_status || '') === 'redeemed').length
|
||||
const bindingSummaries = normalizedTasks.map((task) => getTaskBindingSummary(taskBindingSummaryMap, task.id))
|
||||
const totalBindingCount = bindingSummaries.reduce((sum, item) => sum + item.totalBindingCount, 0)
|
||||
const reservedBindingCount = bindingSummaries.reduce((sum, item) => sum + item.reservedBindingCount, 0)
|
||||
const consumedBindingCount = bindingSummaries.reduce((sum, item) => sum + item.consumedBindingCount, 0)
|
||||
const releasedBindingCount = bindingSummaries.reduce((sum, item) => sum + item.releasedBindingCount, 0)
|
||||
|
||||
let systemBindingStatus = 'pending_binding'
|
||||
let userBindingStatus = 'not_started'
|
||||
|
||||
if (totalTaskCount === 0) {
|
||||
return {
|
||||
totalTaskCount,
|
||||
systemBoundTaskCount,
|
||||
completedBindingTaskCount,
|
||||
totalBindingCount,
|
||||
reservedBindingCount,
|
||||
consumedBindingCount,
|
||||
releasedBindingCount,
|
||||
systemBindingStatus,
|
||||
userBindingStatus,
|
||||
}
|
||||
}
|
||||
|
||||
if (normalizedTasks.every((task) => String(task.task_status || '') === 'redeemed')) {
|
||||
systemBindingStatus = 'system_bound'
|
||||
userBindingStatus = 'binding_completed'
|
||||
} else if (taskBindings.some((item) => ['binding_in_progress', 'binding_confirmed', 'link_opened'].includes(item.userBindingStatus))) {
|
||||
systemBindingStatus = systemBoundTaskCount > 0 ? 'system_bound' : 'pending_binding'
|
||||
userBindingStatus = 'user_binding'
|
||||
} else if (taskBindings.some((item) => item.userBindingStatus === 'waiting_user_claim')) {
|
||||
systemBindingStatus = systemBoundTaskCount > 0 ? 'system_bound' : 'pending_binding'
|
||||
userBindingStatus = 'waiting_user_claim'
|
||||
} else if (taskBindings.some((item) => item.userBindingStatus === 'binding_exception')) {
|
||||
systemBindingStatus = systemBoundTaskCount > 0 ? 'system_bound' : 'pending_binding'
|
||||
userBindingStatus = 'binding_exception'
|
||||
} else if (systemBoundTaskCount > 0) {
|
||||
systemBindingStatus = 'system_bound'
|
||||
} else if (taskBindings.some((item) => ['manual_review', 'retry_pending', 'waiting_inventory'].includes(item.systemBindingStatus))) {
|
||||
systemBindingStatus = 'binding_exception'
|
||||
}
|
||||
|
||||
return {
|
||||
totalTaskCount,
|
||||
systemBoundTaskCount,
|
||||
completedBindingTaskCount,
|
||||
totalBindingCount,
|
||||
reservedBindingCount,
|
||||
consumedBindingCount,
|
||||
releasedBindingCount,
|
||||
systemBindingStatus,
|
||||
userBindingStatus,
|
||||
}
|
||||
}
|
||||
|
||||
export function buildOrderAgisoAutoDeliverySummary(order, tasks = []) {
|
||||
if (String(order?.provider || '').trim() !== 'agiso' || String(order?.platform || '').trim() !== 'xianyu') {
|
||||
return null
|
||||
}
|
||||
|
||||
const normalizedTasks = Array.isArray(tasks) ? tasks.filter(Boolean) : []
|
||||
const totalTaskCount = normalizedTasks.length
|
||||
const deliveredTaskCount = normalizedTasks.filter((task) => String(task?.delivery_status || '').trim() === 'delivered').length
|
||||
const latest = normalizedTasks.reduce((best, task) => {
|
||||
const autoDelivery = mapAgisoAutoDeliveryContext(parseTaskContext(task).agisoAutoDelivery)
|
||||
|
||||
if (!autoDelivery) {
|
||||
return best
|
||||
}
|
||||
|
||||
const candidate = {
|
||||
...autoDelivery,
|
||||
sourceTaskId: Number(task.id || 0) || null,
|
||||
sourceTaskNo: String(task.task_no || '').trim(),
|
||||
}
|
||||
const candidateTime = Date.parse(String(candidate.updatedAt || task.updated_at || ''))
|
||||
const bestTime = Date.parse(String(best?.updatedAt || ''))
|
||||
|
||||
if (!best || (Number.isFinite(candidateTime) && (!Number.isFinite(bestTime) || candidateTime >= bestTime))) {
|
||||
return candidate
|
||||
}
|
||||
|
||||
return best
|
||||
}, null)
|
||||
|
||||
if (latest) {
|
||||
return {
|
||||
...latest,
|
||||
totalTaskCount,
|
||||
deliveredTaskCount,
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
status: totalTaskCount === 0 ? 'not_started' : deliveredTaskCount >= totalTaskCount ? 'pending' : 'waiting',
|
||||
trigger: '',
|
||||
reason: deliveredTaskCount >= totalTaskCount ? '' : 'waiting_other_tasks',
|
||||
platformOrderId: String(order?.platform_order_id || '').trim(),
|
||||
responseStatus: 0,
|
||||
errorMessage: '',
|
||||
requestId: '',
|
||||
aldsType: null,
|
||||
updatedAt: null,
|
||||
sourceTaskId: null,
|
||||
sourceTaskNo: '',
|
||||
totalTaskCount,
|
||||
deliveredTaskCount,
|
||||
}
|
||||
}
|
||||
|
||||
function canReleaseTaskInventoryBinding(task, binding) {
|
||||
if (!task || !binding) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (String(binding.binding_status || '').trim() !== 'reserved') {
|
||||
return false
|
||||
}
|
||||
|
||||
return !['redeemed', 'expired'].includes(String(task.task_status || '').trim())
|
||||
}
|
||||
|
||||
function buildTaskBindingState(task) {
|
||||
const normalizedStatus = String(task?.task_status || '').trim()
|
||||
|
||||
if (!normalizedStatus) {
|
||||
return {
|
||||
systemBindingStatus: 'pending_binding',
|
||||
userBindingStatus: 'not_started',
|
||||
}
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'pending_payment') {
|
||||
return { systemBindingStatus: 'pending_payment', userBindingStatus: 'not_started' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'paid') {
|
||||
return { systemBindingStatus: 'pending_binding', userBindingStatus: 'not_started' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'waiting_inventory') {
|
||||
return { systemBindingStatus: 'waiting_inventory', userBindingStatus: 'not_started' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'manual_review') {
|
||||
return { systemBindingStatus: 'manual_review', userBindingStatus: 'binding_exception' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'retry_pending') {
|
||||
return { systemBindingStatus: 'retry_pending', userBindingStatus: 'binding_exception' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'closed') {
|
||||
return { systemBindingStatus: 'closed', userBindingStatus: 'closed' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'expired') {
|
||||
return { systemBindingStatus: 'expired', userBindingStatus: 'expired' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'link_generated') {
|
||||
return { systemBindingStatus: 'system_bound', userBindingStatus: 'waiting_user_claim' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'claimed') {
|
||||
return { systemBindingStatus: 'system_bound', userBindingStatus: 'link_opened' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'role_confirmed') {
|
||||
return { systemBindingStatus: 'system_bound', userBindingStatus: 'binding_confirmed' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'redeeming') {
|
||||
return { systemBindingStatus: 'system_bound', userBindingStatus: 'binding_in_progress' }
|
||||
}
|
||||
|
||||
if (normalizedStatus === 'redeemed') {
|
||||
return { systemBindingStatus: 'system_bound', userBindingStatus: 'binding_completed' }
|
||||
}
|
||||
|
||||
if (isTaskSystemBound(task)) {
|
||||
return { systemBindingStatus: 'system_bound', userBindingStatus: 'waiting_user_claim' }
|
||||
}
|
||||
|
||||
return { systemBindingStatus: 'pending_binding', userBindingStatus: 'not_started' }
|
||||
}
|
||||
|
||||
function isTaskSystemBound(task) {
|
||||
return Boolean(task && (getTaskPrimaryInventoryItemId(task) || getTaskPrimaryClaimTokenId(task)))
|
||||
}
|
||||
|
||||
function mapAgisoAutoDeliveryContext(value) {
|
||||
if (!value || typeof value !== 'object') {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
status: String(value.status || '').trim(),
|
||||
trigger: String(value.trigger || '').trim(),
|
||||
reason: String(value.reason || '').trim(),
|
||||
platformOrderId: String(value.platformOrderId || '').trim(),
|
||||
responseStatus: Number(value.responseStatus || 0),
|
||||
errorMessage: String(value.errorMessage || '').trim(),
|
||||
requestId: String(value.requestId || '').trim(),
|
||||
aldsType: Number(value.aldsType || 0) || null,
|
||||
updatedAt: value.updatedAt || null,
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeRecord(value) {
|
||||
return value && typeof value === 'object' && !Array.isArray(value) ? value : {}
|
||||
}
|
||||
|
||||
function maskCode(value) {
|
||||
const text = String(value || '').trim()
|
||||
if (!text) {
|
||||
return ''
|
||||
}
|
||||
if (text.length <= 8) {
|
||||
return `${text.slice(0, 2)}****${text.slice(-2)}`
|
||||
}
|
||||
return `${text.slice(0, 4)}****${text.slice(-4)}`
|
||||
}
|
||||
|
||||
function getTaskRetryCount(task) {
|
||||
return Number(task?.attempt_count || 0)
|
||||
}
|
||||
@@ -28,16 +28,20 @@ import {
|
||||
canViewerConfirmAssistedRole,
|
||||
canViewerRedeemAssistedTask,
|
||||
createAdminViewerContext,
|
||||
getRequiredInventoryItem,
|
||||
getRequiredTask,
|
||||
getTaskPrimaryClaimTokenId,
|
||||
getTaskPrimaryInventoryItemId,
|
||||
isAssistedClaimTask,
|
||||
isManualDispatchTask,
|
||||
mapAdminInventoryListItem,
|
||||
mapTaskActionPayload,
|
||||
parseTaskContext,
|
||||
} from './admin-read-shared-helpers.js'
|
||||
import {
|
||||
getRequiredInventoryItem,
|
||||
mapAdminInventoryListItem,
|
||||
} from './admin-read-helpers.js'
|
||||
import {
|
||||
getRequiredTask,
|
||||
mapTaskActionPayload,
|
||||
} from './admin-task-read-helpers.js'
|
||||
|
||||
/** @typedef {import('../../types/admin-read-inputs.js').AdminEntityIdInput} AdminEntityIdInput */
|
||||
/** @typedef {import('../../types/admin-read-inputs.js').AdminViewerSessionInput} AdminViewerSessionInput */
|
||||
|
||||
Reference in New Issue
Block a user