后端迁移平台配置聚合服务
This commit is contained in:
+11
-9
@@ -1,5 +1,3 @@
|
||||
// @ts-check
|
||||
|
||||
import { getAgisoShopConfig } from '../../platforms/agiso/shop-config-service.js'
|
||||
import {
|
||||
filterLegacyOrderFulfillmentBindings,
|
||||
@@ -20,8 +18,12 @@ import { listAdminObservedProducts } from './observed-products.js'
|
||||
import { validateAdminFulfillmentBindingConfigs } from './validation.js'
|
||||
import { mapAdminFulfillmentBindingConfigItem } from './domain.js'
|
||||
|
||||
/** @typedef {import('../../../types/admin-write-inputs.js').AdminFulfillmentBindingConfigSaveInput} AdminFulfillmentBindingConfigSaveInput */
|
||||
/** @typedef {import('../../../types/admin-write-inputs.js').AdminFulfillmentBindingLookupInput} AdminFulfillmentBindingLookupInput */
|
||||
import type {
|
||||
AdminFulfillmentBindingConfigSaveInput,
|
||||
AdminFulfillmentBindingLookupInput,
|
||||
} from '../../../types/admin-write-inputs.js'
|
||||
|
||||
type JsonObject = Record<string, any>
|
||||
|
||||
export async function getAdminFulfillmentBindingConfigs() {
|
||||
const bindings = getLegacyOrderFulfillmentBindingConfigs()
|
||||
@@ -33,8 +35,9 @@ export async function getAdminFulfillmentBindingConfigs() {
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {AdminFulfillmentBindingLookupInput} [payload] */
|
||||
export async function lookupAdminFulfillmentBindingOrder(payload = /** @type {AdminFulfillmentBindingLookupInput} */ ({})) {
|
||||
export async function lookupAdminFulfillmentBindingOrder(
|
||||
payload: AdminFulfillmentBindingLookupInput = {},
|
||||
) {
|
||||
const { provider, platform, shopId, platformOrderId } = normalizeFulfillmentLookupPayload(payload)
|
||||
|
||||
const detailResult = await enrichAgisoXianyuTradeOrder({
|
||||
@@ -71,9 +74,8 @@ export async function lookupAdminFulfillmentBindingOrder(payload = /** @type {Ad
|
||||
})
|
||||
}
|
||||
|
||||
/** @param {AdminFulfillmentBindingConfigSaveInput} [payload] */
|
||||
export async function updateAdminFulfillmentBindingConfigs(
|
||||
payload = /** @type {AdminFulfillmentBindingConfigSaveInput} */ ({}),
|
||||
payload: AdminFulfillmentBindingConfigSaveInput = {},
|
||||
) {
|
||||
const bindingsInput = Array.isArray(payload.bindings) ? payload.bindings : []
|
||||
const normalizedBindings = await validateAdminFulfillmentBindingConfigs(bindingsInput, {
|
||||
@@ -89,7 +91,7 @@ export async function updateAdminFulfillmentBindingConfigs(
|
||||
}
|
||||
}
|
||||
|
||||
function assertLegacyBindingConfigsOnly(bindings = []) {
|
||||
function assertLegacyBindingConfigsOnly(bindings: JsonObject[] = []) {
|
||||
if (filterLegacyOrderFulfillmentBindings(bindings).length === bindings.length) {
|
||||
return
|
||||
}
|
||||
+13
-14
@@ -1,5 +1,3 @@
|
||||
// @ts-check
|
||||
|
||||
import {
|
||||
getNotificationConfig,
|
||||
getNotificationConfigFilePath,
|
||||
@@ -18,9 +16,13 @@ import {
|
||||
} from '../../scheduler/scheduler-service.js'
|
||||
import { maskSecret } from './mappers.js'
|
||||
|
||||
/** @typedef {import('../../../types/admin-write-inputs.js').AdminNotificationConfigInput} AdminNotificationConfigInput */
|
||||
/** @typedef {import('../../../types/admin-write-inputs.js').AdminNotificationTestInput} AdminNotificationTestInput */
|
||||
/** @typedef {import('../../../types/admin-write-inputs.js').AdminScheduledJobsConfigInput} AdminScheduledJobsConfigInput */
|
||||
import type {
|
||||
AdminNotificationConfigInput,
|
||||
AdminNotificationTestInput,
|
||||
AdminScheduledJobsConfigInput,
|
||||
} from '../../../types/admin-write-inputs.js'
|
||||
|
||||
type JsonObject = Record<string, any>
|
||||
|
||||
export function getAdminNotificationConfig() {
|
||||
const config = getNotificationConfig()
|
||||
@@ -31,8 +33,7 @@ export function getAdminNotificationConfig() {
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {AdminNotificationConfigInput} [payload] */
|
||||
export function updateAdminNotificationConfig(payload = /** @type {AdminNotificationConfigInput} */ ({})) {
|
||||
export function updateAdminNotificationConfig(payload: AdminNotificationConfigInput = {}) {
|
||||
const saved = saveNotificationConfig(payload)
|
||||
|
||||
return {
|
||||
@@ -41,8 +42,7 @@ export function updateAdminNotificationConfig(payload = /** @type {AdminNotifica
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {AdminNotificationTestInput} [payload] */
|
||||
export async function testAdminNotification(payload = /** @type {AdminNotificationTestInput} */ ({})) {
|
||||
export async function testAdminNotification(payload: AdminNotificationTestInput = {}) {
|
||||
return sendInternalNotification({
|
||||
title: String(payload.title || '订单系统测试通知').trim() || '订单系统测试通知',
|
||||
body: String(payload.body || '这是一条 Bark 内部通知测试。').trim() || '这是一条 Bark 内部通知测试。',
|
||||
@@ -61,8 +61,7 @@ export function getAdminScheduledJobsConfig() {
|
||||
}
|
||||
}
|
||||
|
||||
/** @param {AdminScheduledJobsConfigInput} [payload] */
|
||||
export function updateAdminScheduledJobsConfig(payload = /** @type {AdminScheduledJobsConfigInput} */ ({})) {
|
||||
export function updateAdminScheduledJobsConfig(payload: AdminScheduledJobsConfigInput = {}) {
|
||||
const saved = saveScheduledJobsConfig(payload)
|
||||
reloadScheduledJobs()
|
||||
|
||||
@@ -73,7 +72,7 @@ export function updateAdminScheduledJobsConfig(payload = /** @type {AdminSchedul
|
||||
}
|
||||
}
|
||||
|
||||
export async function runAdminScheduledJobNow(jobId) {
|
||||
export async function runAdminScheduledJobNow(jobId: unknown) {
|
||||
const result = await runScheduledJobNow(jobId)
|
||||
|
||||
return {
|
||||
@@ -82,7 +81,7 @@ export async function runAdminScheduledJobNow(jobId) {
|
||||
}
|
||||
}
|
||||
|
||||
function mapAdminNotificationConfig(config = {}) {
|
||||
function mapAdminNotificationConfig(config: JsonObject = {}) {
|
||||
const bark = config.channels?.bark || {}
|
||||
|
||||
return {
|
||||
@@ -103,7 +102,7 @@ function mapAdminNotificationConfig(config = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
function mapAdminScheduledJobsConfig(config = {}) {
|
||||
function mapAdminScheduledJobsConfig(config: JsonObject = {}) {
|
||||
return {
|
||||
enabled: config.enabled !== false,
|
||||
jobs: (Array.isArray(config.jobs) ? config.jobs : []).map((item) => ({
|
||||
@@ -618,6 +618,16 @@
|
||||
- `npm run typecheck`
|
||||
- `npm run build`
|
||||
- `npm test` 共 139 个用例通过
|
||||
147. 后台平台配置聚合入口、履约绑定服务、通知 / 定时任务服务迁移到 `.ts`:
|
||||
- `src/services/admin/platform-config/service.ts`
|
||||
- `src/services/admin/platform-config/fulfillment-bindings-service.ts`
|
||||
- `src/services/admin/platform-config/notification-service.ts`
|
||||
148. 旧履约绑定读写 / 手动订单查询、通知配置更新、测试通知、定时任务运行入口已进入 TS 编译链路;写入 payload、查询 payload、动态配置 map 与 jobId 补齐类型
|
||||
149. Docker 内验证通过:
|
||||
- `src/services/admin/platform-config/*.test.js` 共 37 个用例通过
|
||||
- `npm run typecheck`
|
||||
- `npm run build`
|
||||
- `npm test` 共 139 个用例通过
|
||||
|
||||
## 下一步建议
|
||||
|
||||
|
||||
Reference in New Issue
Block a user