XuqmGroup-RNSDK/packages/update/src/releaseSetRequest.ts

29 行
1.1 KiB
TypeScript

import type { InstalledPluginModule } from './releaseSet'
export interface ReleaseSetCheckBody {
appKey: string
targetModuleId: string
platform: 'ANDROID' | 'IOS'
userId?: string
appVersion: string
nativeApiLevel: number
nativeBaselineId: string
installedModules: InstalledPluginModule[]
}
/** 服务端兼容性判断所需的终态请求契约,客户端收到候选后仍执行二次校验。 */
export function createReleaseSetCheckBody(input: ReleaseSetCheckBody): ReleaseSetCheckBody {
const appVersion = input.appVersion.trim()
if (!appVersion) {
throw new Error('[UpdateSDK] Full-app version is required before checking a release set.')
}
if (!Number.isInteger(input.nativeApiLevel) || input.nativeApiLevel < 1) {
throw new Error('[UpdateSDK] Native API level must be positive before checking a release set.')
}
const nativeBaselineId = input.nativeBaselineId.trim()
if (!nativeBaselineId) {
throw new Error('[UpdateSDK] Native baseline is required before checking a plugin release set.')
}
return { ...input, appVersion, nativeBaselineId }
}