生成目录化的Tripo API与画布TS绑定
- 生成模型输入、结果落点、产物元数据与按端点的结果类型到 packages/shared/src/contracts/model3d 子目录 - 新增 editor-canvas 生成目录,画布占位载荷不再依赖手写 TS - 更新 model3d 导出索引,移除已删除的占位作业类型 - contracts:model3d:generate 生成后自动跑 prettier
This commit is contained in:
+1
-1
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
+10
@@ -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;
|
||||
};
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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 };
|
||||
@@ -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 };
|
||||
@@ -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 };
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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<Model3dArtifact>;
|
||||
};
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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;
|
||||
};
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user