3D 生成请求落点改为平坦可选字段并复用统一落点预检

- shared-contracts 的 text-to-model / image-to-model 请求用平坦可选 projectId / canvasCompletion / assetFolderId / assetLabel 取代 tagged enum target,删除 Model3dGenerationTarget 及其契约测试。
- 同步 ts-rs 生成绑定:新增四个可选字段并移除 Model3dGenerationTarget.ts 与 barrel 导出。
- api-server 校验层改按「项目资源 / 素材库二选一」校验,缺失、冲突与空白值都返回 400 并点名具体字段。
- 落点预检改用其它付费编辑器生成共用的 preflight_editor_generation_target_and_return,素材库落点不再读整库。
- worker 按平坦字段落库,素材名缺省回落到 MODEL3D_DEFAULT_ASSET_LABEL。
- 定向验证:cargo test -p shared-contracts 与 cargo test -p api-server tripo3d:: 全绿(54 passed)。
This commit is contained in:
2026-09-23 14:02:44 +08:00
parent 48ba8b3133
commit fd48829c24
14 changed files with 431 additions and 216 deletions
@@ -1,16 +0,0 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { EditorCanvasGenerationCompletionPayload } from '../../editor-canvas/EditorCanvasGenerationCompletionPayload';
/**
* 生成结果的落点。两个分支都必须给出定位字段,不存在“都不给就默认落素材库”的口径。
*/
export type Model3dGenerationTarget =
| {
kind: 'projectResource';
projectId: string;
/**
* 画布占位框回填载荷:结果落库后前端据此把新资源放到用户提交时的位置。
*/
canvasCompletion?: EditorCanvasGenerationCompletionPayload | null;
}
| { kind: 'assetLibrary'; folderId: string; label: string };
@@ -1,13 +1,31 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { EditorCanvasGenerationCompletionPayload } from '../../editor-canvas/EditorCanvasGenerationCompletionPayload';
import type { Model3dGenerationSource } from '../common/Model3dGenerationSource';
import type { Model3dGenerationTarget } from '../common/Model3dGenerationTarget';
import type { Model3dImageToModelParams } from './Model3dImageToModelParams';
/**
* image-to-model API 请求:站内图片引用 + provider 生成参数 + 平台字段。
*
* 结果落点与 text-to-model 同形:平坦的可选 `projectId` / `canvasCompletion` /
* `assetFolderId` / `assetLabel`,二选一,不用 tagged enum。
*/
export type Model3dImageToModelRequest = {
source: Model3dGenerationSource;
generation: Model3dImageToModelParams;
target: Model3dGenerationTarget;
/**
* 项目资源落点;与 `assetFolderId` 二选一。
*/
projectId?: string | null;
/**
* 画布占位框回填载荷:结果落库后前端据此把新资源放到用户提交时的位置;只在项目资源落点下生效。
*/
canvasCompletion?: EditorCanvasGenerationCompletionPayload | null;
/**
* 素材库落点;与 `projectId` 二选一。
*/
assetFolderId?: string | null;
/**
* 素材名称;缺省用平台默认名。
*/
assetLabel?: string | null;
};
@@ -2,7 +2,6 @@ export type * from './common/Model3dCompression';
export type * from './common/Model3dExportOrientation';
export type * from './common/Model3dGeneratedArtifact';
export type * from './common/Model3dGenerationSource';
export type * from './common/Model3dGenerationTarget';
export type * from './common/Model3dGenerationTargetRef';
export type * from './common/Model3dGeometryQuality';
export type * from './common/Model3dInputOrientation';
@@ -1,5 +1,5 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { Model3dGenerationTarget } from '../common/Model3dGenerationTarget';
import type { EditorCanvasGenerationCompletionPayload } from '../../editor-canvas/EditorCanvasGenerationCompletionPayload';
import type { Model3dTextToModelParams } from './Model3dTextToModelParams';
/**
@@ -7,8 +7,27 @@ import type { Model3dTextToModelParams } from './Model3dTextToModelParams';
*
* 生成参数单独嵌一层而不是摊平到顶层:serde 的 `deny_unknown_fields` 与 `flatten`
* 不能共存,摊平会让顶层未知字段静默通过。
*
* 结果落点与其它生成接口同形:平坦的可选 `projectId` / `canvasCompletion` /
* `assetFolderId` / `assetLabel`,不用 tagged enum —— 客户端不必为「落项目还是落素材库」
* 多拼一层判别结构。服务端按「二选一」校验:两个都给或都不给都拒绝。
*/
export type Model3dTextToModelRequest = {
generation: Model3dTextToModelParams;
target: Model3dGenerationTarget;
/**
* 项目资源落点;与 `assetFolderId` 二选一。
*/
projectId?: string | null;
/**
* 画布占位框回填载荷:结果落库后前端据此把新资源放到用户提交时的位置;只在项目资源落点下生效。
*/
canvasCompletion?: EditorCanvasGenerationCompletionPayload | null;
/**
* 素材库落点;与 `projectId` 二选一。
*/
assetFolderId?: string | null;
/**
* 素材名称;缺省用平台默认名。
*/
assetLabel?: string | null;
};