From f90e114bcbc9850eaa0ee41cc33895f348dff4d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Mon, 21 Sep 2026 12:39:33 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90=E7=9B=AE=E5=BD=95=E5=8C=96?= =?UTF-8?q?=E7=9A=84Tripo=20API=E4=B8=8E=E7=94=BB=E5=B8=83TS=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=20-=20=E7=94=9F=E6=88=90=E6=A8=A1=E5=9E=8B=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E3=80=81=E7=BB=93=E6=9E=9C=E8=90=BD=E7=82=B9=E3=80=81?= =?UTF-8?q?=E4=BA=A7=E7=89=A9=E5=85=83=E6=95=B0=E6=8D=AE=E4=B8=8E=E6=8C=89?= =?UTF-8?q?=E7=AB=AF=E7=82=B9=E7=9A=84=E7=BB=93=E6=9E=9C=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=88=B0=20packages/shared/src/contracts/model3d=20=E5=AD=90?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=20-=20=E6=96=B0=E5=A2=9E=20editor-canvas=20?= =?UTF-8?q?=E7=94=9F=E6=88=90=E7=9B=AE=E5=BD=95=EF=BC=8C=E7=94=BB=E5=B8=83?= =?UTF-8?q?=E5=8D=A0=E4=BD=8D=E8=BD=BD=E8=8D=B7=E4=B8=8D=E5=86=8D=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E6=89=8B=E5=86=99=20TS=20-=20=E6=9B=B4=E6=96=B0=20mod?= =?UTF-8?q?el3d=20=E5=AF=BC=E5=87=BA=E7=B4=A2=E5=BC=95=EF=BC=8C=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E5=B7=B2=E5=88=A0=E9=99=A4=E7=9A=84=E5=8D=A0=E4=BD=8D?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E7=B1=BB=E5=9E=8B=20-=20contracts:model3d:ge?= =?UTF-8?q?nerate=20=E7=94=9F=E6=88=90=E5=90=8E=E8=87=AA=E5=8A=A8=E8=B7=91?= =?UTF-8?q?=20prettier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- ...EditorCanvasGenerationCompletionPayload.ts | 8 ++++ ...ditorCanvasGenerationPlaceholderPayload.ts | 10 +++++ .../model3d/Model3dGenerationResult.ts | 11 ++++++ .../common/Model3dGeneratedArtifact.ts | 16 ++++++++ .../model3d/common/Model3dGenerationSource.ts | 11 ++++++ .../model3d/common/Model3dGenerationTarget.ts | 16 ++++++++ .../common/Model3dGenerationTargetRef.ts | 8 ++++ .../Model3dImageToModelParams.ts | 38 +++++++++++++++++++ .../Model3dImageToModelRequest.ts | 38 +++++-------------- .../Model3dImageToModelResult.ts | 12 ++++++ .../shared/src/contracts/model3d/index.ts | 13 +++++-- .../model3d/text-to-model/Model3dArtifact.ts | 14 ------- .../text-to-model/Model3dGenerationJob.ts | 16 -------- .../text-to-model/Model3dGenerationResult.ts | 8 ---- .../Model3dGenerationSubmission.ts | 12 ------ .../text-to-model/Model3dTextToModelParams.ts | 36 ++++++++++++++++++ .../Model3dTextToModelRequest.ts | 36 +++++------------- .../text-to-model/Model3dTextToModelResult.ts | 12 ++++++ 19 files changed, 207 insertions(+), 110 deletions(-) create mode 100644 packages/shared/src/contracts/editor-canvas/EditorCanvasGenerationCompletionPayload.ts create mode 100644 packages/shared/src/contracts/editor-canvas/EditorCanvasGenerationPlaceholderPayload.ts create mode 100644 packages/shared/src/contracts/model3d/Model3dGenerationResult.ts create mode 100644 packages/shared/src/contracts/model3d/common/Model3dGeneratedArtifact.ts create mode 100644 packages/shared/src/contracts/model3d/common/Model3dGenerationSource.ts create mode 100644 packages/shared/src/contracts/model3d/common/Model3dGenerationTarget.ts create mode 100644 packages/shared/src/contracts/model3d/common/Model3dGenerationTargetRef.ts create mode 100644 packages/shared/src/contracts/model3d/image-to-model/Model3dImageToModelParams.ts create mode 100644 packages/shared/src/contracts/model3d/image-to-model/Model3dImageToModelResult.ts delete mode 100644 packages/shared/src/contracts/model3d/text-to-model/Model3dArtifact.ts delete mode 100644 packages/shared/src/contracts/model3d/text-to-model/Model3dGenerationJob.ts delete mode 100644 packages/shared/src/contracts/model3d/text-to-model/Model3dGenerationResult.ts delete mode 100644 packages/shared/src/contracts/model3d/text-to-model/Model3dGenerationSubmission.ts create mode 100644 packages/shared/src/contracts/model3d/text-to-model/Model3dTextToModelParams.ts create mode 100644 packages/shared/src/contracts/model3d/text-to-model/Model3dTextToModelResult.ts diff --git a/package.json b/package.json index ee9a5e899..1f5b70320 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "admin-web:typecheck": "node scripts/admin-web-build.mjs typecheck", "admin-web:preview": "npm --prefix apps/admin-web run preview --", "spacetime:generate": "node scripts/generate-spacetime-bindings.mjs", - "contracts:model3d:generate": "cargo test --locked -p shared-contracts model3d --manifest-path server-rs/Cargo.toml", + "contracts:model3d:generate": "cargo test --locked -p shared-contracts --manifest-path server-rs/Cargo.toml -- model3d editorcanvas && prettier --write packages/shared/src/contracts/model3d packages/shared/src/contracts/editor-canvas", "spacetime:external-generation:maintain": "node scripts/spacetime-maintain-external-generation-jobs.mjs", "spacetime:editor-image-asset-kind:clean": "node scripts/spacetime-clean-editor-image-asset-kind.mjs", "spacetime:editor-canvas-layout:migrate": "node scripts/spacetime-migrate-editor-canvas-layout.mjs", diff --git a/packages/shared/src/contracts/editor-canvas/EditorCanvasGenerationCompletionPayload.ts b/packages/shared/src/contracts/editor-canvas/EditorCanvasGenerationCompletionPayload.ts new file mode 100644 index 000000000..f625a40ec --- /dev/null +++ b/packages/shared/src/contracts/editor-canvas/EditorCanvasGenerationCompletionPayload.ts @@ -0,0 +1,8 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { EditorCanvasGenerationPlaceholderPayload } from './EditorCanvasGenerationPlaceholderPayload'; + +export type EditorCanvasGenerationCompletionPayload = { + dialogId?: string | null; + title: string; + placeholder: EditorCanvasGenerationPlaceholderPayload; +}; diff --git a/packages/shared/src/contracts/editor-canvas/EditorCanvasGenerationPlaceholderPayload.ts b/packages/shared/src/contracts/editor-canvas/EditorCanvasGenerationPlaceholderPayload.ts new file mode 100644 index 000000000..5d31fce9a --- /dev/null +++ b/packages/shared/src/contracts/editor-canvas/EditorCanvasGenerationPlaceholderPayload.ts @@ -0,0 +1,10 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type EditorCanvasGenerationPlaceholderPayload = { + x: number; + y: number; + width: number; + height: number; + originalWidth: number; + originalHeight: number; +}; diff --git a/packages/shared/src/contracts/model3d/Model3dGenerationResult.ts b/packages/shared/src/contracts/model3d/Model3dGenerationResult.ts new file mode 100644 index 000000000..b6b6a3d64 --- /dev/null +++ b/packages/shared/src/contracts/model3d/Model3dGenerationResult.ts @@ -0,0 +1,11 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Model3dImageToModelResult } from './image-to-model/Model3dImageToModelResult'; +import type { Model3dTextToModelResult } from './text-to-model/Model3dTextToModelResult'; + +/** + * 完成结果按端点严格 tagged enum:每个分支只携带该端点真正会产出的字段, + * 不使用“所有端点共用一份大结构 + 一堆 Option”的宽松形态。 + */ +export type Model3dGenerationResult = + | ({ kind: 'textToModel' } & Model3dTextToModelResult) + | ({ kind: 'imageToModel' } & Model3dImageToModelResult); diff --git a/packages/shared/src/contracts/model3d/common/Model3dGeneratedArtifact.ts b/packages/shared/src/contracts/model3d/common/Model3dGeneratedArtifact.ts new file mode 100644 index 000000000..d28f06be3 --- /dev/null +++ b/packages/shared/src/contracts/model3d/common/Model3dGeneratedArtifact.ts @@ -0,0 +1,16 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * 单个生成产物的对象元数据。 + * + * 只描述服务端已经持久化的正式对象;不带 provider task ID,也不带带签名的临时下载地址。 + */ +export type Model3dGeneratedArtifact = { + objectKey: string; + contentType: string; + /** + * 对象字节数;单体模型产物为几十 MB,远低于 2^53,按 TS number 导出。 + */ + contentLength: number; + sha256: string; +}; diff --git a/packages/shared/src/contracts/model3d/common/Model3dGenerationSource.ts b/packages/shared/src/contracts/model3d/common/Model3dGenerationSource.ts new file mode 100644 index 000000000..ee067ab28 --- /dev/null +++ b/packages/shared/src/contracts/model3d/common/Model3dGenerationSource.ts @@ -0,0 +1,11 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * API 层图片输入:只接受站内的画布资源或素材库对象,二者互斥。 + * + * 不接受裸字符串、远程 URL 与 data URL,因此 provider 需要的图片地址由服务端 + * 按分支校验归属后解析,客户端无法绕过归属校验直接给 provider 传地址。 + */ +export type Model3dGenerationSource = + | { kind: 'resource'; resourceId: string } + | { kind: 'asset'; assetId: string }; diff --git a/packages/shared/src/contracts/model3d/common/Model3dGenerationTarget.ts b/packages/shared/src/contracts/model3d/common/Model3dGenerationTarget.ts new file mode 100644 index 000000000..4dc7db337 --- /dev/null +++ b/packages/shared/src/contracts/model3d/common/Model3dGenerationTarget.ts @@ -0,0 +1,16 @@ +// 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 }; diff --git a/packages/shared/src/contracts/model3d/common/Model3dGenerationTargetRef.ts b/packages/shared/src/contracts/model3d/common/Model3dGenerationTargetRef.ts new file mode 100644 index 000000000..21c0a11f0 --- /dev/null +++ b/packages/shared/src/contracts/model3d/common/Model3dGenerationTargetRef.ts @@ -0,0 +1,8 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * 结果落点引用:与请求 `target` 同分支,但给的是已创建资源 / 素材的正式 ID。 + */ +export type Model3dGenerationTargetRef = + | { kind: 'projectResource'; resourceId: string } + | { kind: 'assetLibrary'; assetId: string }; diff --git a/packages/shared/src/contracts/model3d/image-to-model/Model3dImageToModelParams.ts b/packages/shared/src/contracts/model3d/image-to-model/Model3dImageToModelParams.ts new file mode 100644 index 000000000..031f12a70 --- /dev/null +++ b/packages/shared/src/contracts/model3d/image-to-model/Model3dImageToModelParams.ts @@ -0,0 +1,38 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Model3dCompression } from '../common/Model3dCompression'; +import type { Model3dExportOrientation } from '../common/Model3dExportOrientation'; +import type { Model3dGeometryQuality } from '../common/Model3dGeometryQuality'; +import type { Model3dInputOrientation } from '../common/Model3dInputOrientation'; +import type { Model3dModelVersion } from '../common/Model3dModelVersion'; +import type { Model3dTextureAlignment } from '../common/Model3dTextureAlignment'; +import type { Model3dTextureQuality } from '../common/Model3dTextureQuality'; +import type { Model3dTextureVersion } from '../common/Model3dTextureVersion'; + +/** + * image-to-model 的 provider 生成参数。 + * + * 图片本体不在 provider 参数里:客户端只能给 `Model3dGenerationSource`, + * 服务端解析归属后把 provider 需要的地址注入调用,见 `api-server::tripo3d`。 + */ +export type Model3dImageToModelParams = { + model: Model3dModelVersion; + enableImageAutofix?: boolean | null; + modelSeed?: number | null; + textureSeed?: number | null; + texture?: boolean | null; + pbr?: boolean | null; + textureQuality?: Model3dTextureQuality | null; + textureVersion?: Model3dTextureVersion | null; + delight?: boolean | null; + textureAlignment?: Model3dTextureAlignment | null; + geometryQuality?: Model3dGeometryQuality | null; + faceLimit?: number | null; + autoSize?: boolean | null; + orientation?: Model3dInputOrientation | null; + quad?: boolean | null; + smartLowPoly?: boolean | null; + generateParts?: boolean | null; + compress?: Model3dCompression | null; + exportUv?: boolean | null; + exportOrientation?: Model3dExportOrientation | null; +}; diff --git a/packages/shared/src/contracts/model3d/image-to-model/Model3dImageToModelRequest.ts b/packages/shared/src/contracts/model3d/image-to-model/Model3dImageToModelRequest.ts index 94fb476ee..85b08dea6 100644 --- a/packages/shared/src/contracts/model3d/image-to-model/Model3dImageToModelRequest.ts +++ b/packages/shared/src/contracts/model3d/image-to-model/Model3dImageToModelRequest.ts @@ -1,33 +1,13 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { Model3dCompression } from '../common/Model3dCompression'; -import type { Model3dExportOrientation } from '../common/Model3dExportOrientation'; -import type { Model3dGeometryQuality } from '../common/Model3dGeometryQuality'; -import type { Model3dInputOrientation } from '../common/Model3dInputOrientation'; -import type { Model3dModelVersion } from '../common/Model3dModelVersion'; -import type { Model3dTextureAlignment } from '../common/Model3dTextureAlignment'; -import type { Model3dTextureQuality } from '../common/Model3dTextureQuality'; -import type { Model3dTextureVersion } from '../common/Model3dTextureVersion'; +import type { Model3dGenerationSource } from '../common/Model3dGenerationSource'; +import type { Model3dGenerationTarget } from '../common/Model3dGenerationTarget'; +import type { Model3dImageToModelParams } from './Model3dImageToModelParams'; +/** + * image-to-model API 请求:站内图片引用 + provider 生成参数 + 平台字段。 + */ export type Model3dImageToModelRequest = { - input: string; - model: Model3dModelVersion; - enableImageAutofix?: boolean | null; - modelSeed?: number | null; - textureSeed?: number | null; - texture?: boolean | null; - pbr?: boolean | null; - textureQuality?: Model3dTextureQuality | null; - textureVersion?: Model3dTextureVersion | null; - delight?: boolean | null; - textureAlignment?: Model3dTextureAlignment | null; - geometryQuality?: Model3dGeometryQuality | null; - faceLimit?: number | null; - autoSize?: boolean | null; - orientation?: Model3dInputOrientation | null; - quad?: boolean | null; - smartLowPoly?: boolean | null; - generateParts?: boolean | null; - compress?: Model3dCompression | null; - exportUv?: boolean | null; - exportOrientation?: Model3dExportOrientation | null; + source: Model3dGenerationSource; + generation: Model3dImageToModelParams; + target: Model3dGenerationTarget; }; diff --git a/packages/shared/src/contracts/model3d/image-to-model/Model3dImageToModelResult.ts b/packages/shared/src/contracts/model3d/image-to-model/Model3dImageToModelResult.ts new file mode 100644 index 000000000..2f710bad1 --- /dev/null +++ b/packages/shared/src/contracts/model3d/image-to-model/Model3dImageToModelResult.ts @@ -0,0 +1,12 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Model3dGeneratedArtifact } from '../common/Model3dGeneratedArtifact'; +import type { Model3dGenerationTargetRef } from '../common/Model3dGenerationTargetRef'; + +/** + * image-to-model 的完成结果:只包含正式资源引用与已持久化产物。 + */ +export type Model3dImageToModelResult = { + target: Model3dGenerationTargetRef; + model: Model3dGeneratedArtifact; + preview: Model3dGeneratedArtifact; +}; diff --git a/packages/shared/src/contracts/model3d/index.ts b/packages/shared/src/contracts/model3d/index.ts index 0c042c42d..dd4239b93 100644 --- a/packages/shared/src/contracts/model3d/index.ts +++ b/packages/shared/src/contracts/model3d/index.ts @@ -1,5 +1,9 @@ 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'; export type * from './common/Model3dModelVersion'; @@ -8,11 +12,12 @@ export type * from './common/Model3dTaskStatus'; export type * from './common/Model3dTextureAlignment'; export type * from './common/Model3dTextureQuality'; export type * from './common/Model3dTextureVersion'; +export type * from './image-to-model/Model3dImageToModelParams'; export type * from './image-to-model/Model3dImageToModelRequest'; +export type * from './image-to-model/Model3dImageToModelResult'; +export type * from './Model3dGenerationResult'; export type * from './multiview-to-model/Model3dMultiviewInputs'; export type * from './multiview-to-model/Model3dMultiviewToModelRequest'; -export type * from './text-to-model/Model3dArtifact'; -export type * from './text-to-model/Model3dGenerationJob'; -export type * from './text-to-model/Model3dGenerationResult'; -export type * from './text-to-model/Model3dGenerationSubmission'; +export type * from './text-to-model/Model3dTextToModelParams'; export type * from './text-to-model/Model3dTextToModelRequest'; +export type * from './text-to-model/Model3dTextToModelResult'; diff --git a/packages/shared/src/contracts/model3d/text-to-model/Model3dArtifact.ts b/packages/shared/src/contracts/model3d/text-to-model/Model3dArtifact.ts deleted file mode 100644 index 041d131d0..000000000 --- a/packages/shared/src/contracts/model3d/text-to-model/Model3dArtifact.ts +++ /dev/null @@ -1,14 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { Model3dOutputFormat } from '../common/Model3dOutputFormat'; - -export type Model3dArtifact = { - resourceId: string; - format: Model3dOutputFormat; - contentType: string; - /** - * 产物字节数,当前单模型产物为几十 MB,远低于 2^53,按 TS number 导出。 - */ - sizeBytes: number; - sha256: string; - previewResourceId?: string | null; -}; diff --git a/packages/shared/src/contracts/model3d/text-to-model/Model3dGenerationJob.ts b/packages/shared/src/contracts/model3d/text-to-model/Model3dGenerationJob.ts deleted file mode 100644 index 9c5298c71..000000000 --- a/packages/shared/src/contracts/model3d/text-to-model/Model3dGenerationJob.ts +++ /dev/null @@ -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 { Model3dTaskStatus } from '../common/Model3dTaskStatus'; -import type { Model3dGenerationResult } from './Model3dGenerationResult'; - -export type Model3dGenerationJob = { - operationId: string; - status: Model3dTaskStatus; - phase: string; - progress: number; - error?: string | null; - result?: Model3dGenerationResult | null; - /** - * 更新时间(Unix 微秒);2^53 微秒约到公元 2255 年,按 TS number 导出即可精确表示。 - */ - updatedAtMicros: number; -}; diff --git a/packages/shared/src/contracts/model3d/text-to-model/Model3dGenerationResult.ts b/packages/shared/src/contracts/model3d/text-to-model/Model3dGenerationResult.ts deleted file mode 100644 index 0a48fbb24..000000000 --- a/packages/shared/src/contracts/model3d/text-to-model/Model3dGenerationResult.ts +++ /dev/null @@ -1,8 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { Model3dArtifact } from './Model3dArtifact'; - -export type Model3dGenerationResult = { - resourceId: string; - assetId: string; - artifacts: Array; -}; diff --git a/packages/shared/src/contracts/model3d/text-to-model/Model3dGenerationSubmission.ts b/packages/shared/src/contracts/model3d/text-to-model/Model3dGenerationSubmission.ts deleted file mode 100644 index 75f27282d..000000000 --- a/packages/shared/src/contracts/model3d/text-to-model/Model3dGenerationSubmission.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { Model3dTaskStatus } from '../common/Model3dTaskStatus'; - -export type Model3dGenerationSubmission = { - operationId: string; - status: Model3dTaskStatus; - statusUrl: string; - /** - * 轮询间隔(毫秒),量级为分钟级,远低于 2^53,按 TS number 导出。 - */ - pollAfterMs: number; -}; diff --git a/packages/shared/src/contracts/model3d/text-to-model/Model3dTextToModelParams.ts b/packages/shared/src/contracts/model3d/text-to-model/Model3dTextToModelParams.ts new file mode 100644 index 000000000..e8520db02 --- /dev/null +++ b/packages/shared/src/contracts/model3d/text-to-model/Model3dTextToModelParams.ts @@ -0,0 +1,36 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Model3dCompression } from '../common/Model3dCompression'; +import type { Model3dExportOrientation } from '../common/Model3dExportOrientation'; +import type { Model3dGeometryQuality } from '../common/Model3dGeometryQuality'; +import type { Model3dModelVersion } from '../common/Model3dModelVersion'; +import type { Model3dTextureQuality } from '../common/Model3dTextureQuality'; +import type { Model3dTextureVersion } from '../common/Model3dTextureVersion'; + +/** + * text-to-model 的 provider 生成参数。 + * + * 这里保持与 provider 一致的宽松形态(未提供的参数由 provider 取默认值), + * 平台侧的必填口径与组合校验在调用 provider 之前完成,见 `api-server::tripo3d::validation`。 + */ +export type Model3dTextToModelParams = { + prompt: string; + model: Model3dModelVersion; + negativePrompt?: string | null; + imageSeed?: number | null; + modelSeed?: number | null; + textureSeed?: number | null; + texture?: boolean | null; + pbr?: boolean | null; + textureQuality?: Model3dTextureQuality | null; + textureVersion?: Model3dTextureVersion | null; + delight?: boolean | null; + geometryQuality?: Model3dGeometryQuality | null; + faceLimit?: number | null; + autoSize?: boolean | null; + quad?: boolean | null; + smartLowPoly?: boolean | null; + generateParts?: boolean | null; + compress?: Model3dCompression | null; + exportUv?: boolean | null; + exportOrientation?: Model3dExportOrientation | null; +}; diff --git a/packages/shared/src/contracts/model3d/text-to-model/Model3dTextToModelRequest.ts b/packages/shared/src/contracts/model3d/text-to-model/Model3dTextToModelRequest.ts index 310d05e7f..880c7e39c 100644 --- a/packages/shared/src/contracts/model3d/text-to-model/Model3dTextToModelRequest.ts +++ b/packages/shared/src/contracts/model3d/text-to-model/Model3dTextToModelRequest.ts @@ -1,30 +1,14 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { Model3dCompression } from '../common/Model3dCompression'; -import type { Model3dExportOrientation } from '../common/Model3dExportOrientation'; -import type { Model3dGeometryQuality } from '../common/Model3dGeometryQuality'; -import type { Model3dModelVersion } from '../common/Model3dModelVersion'; -import type { Model3dTextureQuality } from '../common/Model3dTextureQuality'; -import type { Model3dTextureVersion } from '../common/Model3dTextureVersion'; +import type { Model3dGenerationTarget } from '../common/Model3dGenerationTarget'; +import type { Model3dTextToModelParams } from './Model3dTextToModelParams'; +/** + * text-to-model API 请求:provider 生成参数 + 平台字段。 + * + * 生成参数单独嵌一层而不是摊平到顶层:serde 的 `deny_unknown_fields` 与 `flatten` + * 不能共存,摊平会让顶层未知字段静默通过。 + */ export type Model3dTextToModelRequest = { - prompt: string; - model: Model3dModelVersion; - negativePrompt?: string | null; - imageSeed?: number | null; - modelSeed?: number | null; - textureSeed?: number | null; - texture?: boolean | null; - pbr?: boolean | null; - textureQuality?: Model3dTextureQuality | null; - textureVersion?: Model3dTextureVersion | null; - delight?: boolean | null; - geometryQuality?: Model3dGeometryQuality | null; - faceLimit?: number | null; - autoSize?: boolean | null; - quad?: boolean | null; - smartLowPoly?: boolean | null; - generateParts?: boolean | null; - compress?: Model3dCompression | null; - exportUv?: boolean | null; - exportOrientation?: Model3dExportOrientation | null; + generation: Model3dTextToModelParams; + target: Model3dGenerationTarget; }; diff --git a/packages/shared/src/contracts/model3d/text-to-model/Model3dTextToModelResult.ts b/packages/shared/src/contracts/model3d/text-to-model/Model3dTextToModelResult.ts new file mode 100644 index 000000000..cdf3f98b1 --- /dev/null +++ b/packages/shared/src/contracts/model3d/text-to-model/Model3dTextToModelResult.ts @@ -0,0 +1,12 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Model3dGeneratedArtifact } from '../common/Model3dGeneratedArtifact'; +import type { Model3dGenerationTargetRef } from '../common/Model3dGenerationTargetRef'; + +/** + * text-to-model 的完成结果:只包含正式资源引用与已持久化产物。 + */ +export type Model3dTextToModelResult = { + target: Model3dGenerationTargetRef; + model: Model3dGeneratedArtifact; + preview: Model3dGeneratedArtifact; +};