后端迁移平台配置聚合服务
This commit is contained in:
+11
-9
@@ -1,5 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
import { getAgisoShopConfig } from '../../platforms/agiso/shop-config-service.js'
|
import { getAgisoShopConfig } from '../../platforms/agiso/shop-config-service.js'
|
||||||
import {
|
import {
|
||||||
filterLegacyOrderFulfillmentBindings,
|
filterLegacyOrderFulfillmentBindings,
|
||||||
@@ -20,8 +18,12 @@ import { listAdminObservedProducts } from './observed-products.js'
|
|||||||
import { validateAdminFulfillmentBindingConfigs } from './validation.js'
|
import { validateAdminFulfillmentBindingConfigs } from './validation.js'
|
||||||
import { mapAdminFulfillmentBindingConfigItem } from './domain.js'
|
import { mapAdminFulfillmentBindingConfigItem } from './domain.js'
|
||||||
|
|
||||||
/** @typedef {import('../../../types/admin-write-inputs.js').AdminFulfillmentBindingConfigSaveInput} AdminFulfillmentBindingConfigSaveInput */
|
import type {
|
||||||
/** @typedef {import('../../../types/admin-write-inputs.js').AdminFulfillmentBindingLookupInput} AdminFulfillmentBindingLookupInput */
|
AdminFulfillmentBindingConfigSaveInput,
|
||||||
|
AdminFulfillmentBindingLookupInput,
|
||||||
|
} from '../../../types/admin-write-inputs.js'
|
||||||
|
|
||||||
|
type JsonObject = Record<string, any>
|
||||||
|
|
||||||
export async function getAdminFulfillmentBindingConfigs() {
|
export async function getAdminFulfillmentBindingConfigs() {
|
||||||
const bindings = getLegacyOrderFulfillmentBindingConfigs()
|
const bindings = getLegacyOrderFulfillmentBindingConfigs()
|
||||||
@@ -33,8 +35,9 @@ export async function getAdminFulfillmentBindingConfigs() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {AdminFulfillmentBindingLookupInput} [payload] */
|
export async function lookupAdminFulfillmentBindingOrder(
|
||||||
export async function lookupAdminFulfillmentBindingOrder(payload = /** @type {AdminFulfillmentBindingLookupInput} */ ({})) {
|
payload: AdminFulfillmentBindingLookupInput = {},
|
||||||
|
) {
|
||||||
const { provider, platform, shopId, platformOrderId } = normalizeFulfillmentLookupPayload(payload)
|
const { provider, platform, shopId, platformOrderId } = normalizeFulfillmentLookupPayload(payload)
|
||||||
|
|
||||||
const detailResult = await enrichAgisoXianyuTradeOrder({
|
const detailResult = await enrichAgisoXianyuTradeOrder({
|
||||||
@@ -71,9 +74,8 @@ export async function lookupAdminFulfillmentBindingOrder(payload = /** @type {Ad
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {AdminFulfillmentBindingConfigSaveInput} [payload] */
|
|
||||||
export async function updateAdminFulfillmentBindingConfigs(
|
export async function updateAdminFulfillmentBindingConfigs(
|
||||||
payload = /** @type {AdminFulfillmentBindingConfigSaveInput} */ ({}),
|
payload: AdminFulfillmentBindingConfigSaveInput = {},
|
||||||
) {
|
) {
|
||||||
const bindingsInput = Array.isArray(payload.bindings) ? payload.bindings : []
|
const bindingsInput = Array.isArray(payload.bindings) ? payload.bindings : []
|
||||||
const normalizedBindings = await validateAdminFulfillmentBindingConfigs(bindingsInput, {
|
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) {
|
if (filterLegacyOrderFulfillmentBindings(bindings).length === bindings.length) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
+13
-14
@@ -1,5 +1,3 @@
|
|||||||
// @ts-check
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getNotificationConfig,
|
getNotificationConfig,
|
||||||
getNotificationConfigFilePath,
|
getNotificationConfigFilePath,
|
||||||
@@ -18,9 +16,13 @@ import {
|
|||||||
} from '../../scheduler/scheduler-service.js'
|
} from '../../scheduler/scheduler-service.js'
|
||||||
import { maskSecret } from './mappers.js'
|
import { maskSecret } from './mappers.js'
|
||||||
|
|
||||||
/** @typedef {import('../../../types/admin-write-inputs.js').AdminNotificationConfigInput} AdminNotificationConfigInput */
|
import type {
|
||||||
/** @typedef {import('../../../types/admin-write-inputs.js').AdminNotificationTestInput} AdminNotificationTestInput */
|
AdminNotificationConfigInput,
|
||||||
/** @typedef {import('../../../types/admin-write-inputs.js').AdminScheduledJobsConfigInput} AdminScheduledJobsConfigInput */
|
AdminNotificationTestInput,
|
||||||
|
AdminScheduledJobsConfigInput,
|
||||||
|
} from '../../../types/admin-write-inputs.js'
|
||||||
|
|
||||||
|
type JsonObject = Record<string, any>
|
||||||
|
|
||||||
export function getAdminNotificationConfig() {
|
export function getAdminNotificationConfig() {
|
||||||
const config = getNotificationConfig()
|
const config = getNotificationConfig()
|
||||||
@@ -31,8 +33,7 @@ export function getAdminNotificationConfig() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {AdminNotificationConfigInput} [payload] */
|
export function updateAdminNotificationConfig(payload: AdminNotificationConfigInput = {}) {
|
||||||
export function updateAdminNotificationConfig(payload = /** @type {AdminNotificationConfigInput} */ ({})) {
|
|
||||||
const saved = saveNotificationConfig(payload)
|
const saved = saveNotificationConfig(payload)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -41,8 +42,7 @@ export function updateAdminNotificationConfig(payload = /** @type {AdminNotifica
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {AdminNotificationTestInput} [payload] */
|
export async function testAdminNotification(payload: AdminNotificationTestInput = {}) {
|
||||||
export async function testAdminNotification(payload = /** @type {AdminNotificationTestInput} */ ({})) {
|
|
||||||
return sendInternalNotification({
|
return sendInternalNotification({
|
||||||
title: String(payload.title || '订单系统测试通知').trim() || '订单系统测试通知',
|
title: String(payload.title || '订单系统测试通知').trim() || '订单系统测试通知',
|
||||||
body: String(payload.body || '这是一条 Bark 内部通知测试。').trim() || '这是一条 Bark 内部通知测试。',
|
body: String(payload.body || '这是一条 Bark 内部通知测试。').trim() || '这是一条 Bark 内部通知测试。',
|
||||||
@@ -61,8 +61,7 @@ export function getAdminScheduledJobsConfig() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param {AdminScheduledJobsConfigInput} [payload] */
|
export function updateAdminScheduledJobsConfig(payload: AdminScheduledJobsConfigInput = {}) {
|
||||||
export function updateAdminScheduledJobsConfig(payload = /** @type {AdminScheduledJobsConfigInput} */ ({})) {
|
|
||||||
const saved = saveScheduledJobsConfig(payload)
|
const saved = saveScheduledJobsConfig(payload)
|
||||||
reloadScheduledJobs()
|
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)
|
const result = await runScheduledJobNow(jobId)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -82,7 +81,7 @@ export async function runAdminScheduledJobNow(jobId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapAdminNotificationConfig(config = {}) {
|
function mapAdminNotificationConfig(config: JsonObject = {}) {
|
||||||
const bark = config.channels?.bark || {}
|
const bark = config.channels?.bark || {}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -103,7 +102,7 @@ function mapAdminNotificationConfig(config = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapAdminScheduledJobsConfig(config = {}) {
|
function mapAdminScheduledJobsConfig(config: JsonObject = {}) {
|
||||||
return {
|
return {
|
||||||
enabled: config.enabled !== false,
|
enabled: config.enabled !== false,
|
||||||
jobs: (Array.isArray(config.jobs) ? config.jobs : []).map((item) => ({
|
jobs: (Array.isArray(config.jobs) ? config.jobs : []).map((item) => ({
|
||||||
@@ -618,6 +618,16 @@
|
|||||||
- `npm run typecheck`
|
- `npm run typecheck`
|
||||||
- `npm run build`
|
- `npm run build`
|
||||||
- `npm test` 共 139 个用例通过
|
- `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