mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-20 02:37:35 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49ef48a74a | ||
|
|
a680fccb12 | ||
|
|
e67552d8bd | ||
|
|
8080acfb2e | ||
|
|
dbd30a815f | ||
|
|
442568de00 | ||
|
|
d15fc5c6be | ||
|
|
aa6d5ed626 | ||
|
|
283d28bed9 | ||
|
|
315cacd474 | ||
|
|
44ab1e7023 | ||
|
|
beef4e9963 | ||
|
|
990f68fb3b | ||
|
|
ee4933a4f8 | ||
|
|
c91867b8eb | ||
|
|
8608ee027a | ||
|
|
394ddc8db4 | ||
|
|
83455aeaea | ||
|
|
707c091c9b | ||
|
|
d3f5892dd2 | ||
|
|
70b6c33204 | ||
|
|
624a3a6a54 | ||
|
|
03aea2cb36 |
@@ -90,7 +90,8 @@ Add any additional context, caveats, or follow-up work.
|
||||
- `bun run format`
|
||||
- `bun run typecheck`
|
||||
- `bun run test`
|
||||
- `bun run test:e2e`
|
||||
- `bun run test:e2e:app`
|
||||
- `bun run test:e2e:webui`
|
||||
- `bun run test:e2e:workflow`
|
||||
|
||||
- **Backend Testing Mandate**: Every backend feature, service method, workflow, and activity MUST be accompanied by comprehensive tests. Logic-heavy code without corresponding test coverage is considered incomplete.
|
||||
@@ -285,7 +286,7 @@ describe('Team API', () => {
|
||||
### Web App E2E Tests
|
||||
|
||||
- Located in `apps/web/e2e/**/*.spec.ts`, organized by domain under `tests/<domain>/` (e.g. `auth`, `project`).
|
||||
- Run via `bun run test:e2e`.
|
||||
- Run via `bun run test:e2e:app`.
|
||||
- **Fixtures**: Use the `owner`, `project`, and `file` fixtures for setup — they seed data through API calls/DB (no slow UI setup). You can add more fixtures if necessary.
|
||||
- **Documentation**: Every test case MUST be documented in [`apps/web/e2e/README.md`](apps/web/e2e/README.md). Add or update the corresponding entry in the README whenever you add, rename, or remove a spec.
|
||||
|
||||
@@ -321,7 +322,8 @@ We use `prisma-json-types-generator` to enforce strict type-safety for Prisma `J
|
||||
|
||||
- Development: Use `bun --bun run prisma migrate dev` to create and apply migrations during development.
|
||||
- Production: Use `bun --bun run prisma migrate deploy` to apply pending migrations in production environments.
|
||||
- **No Manual Migration Creation**: Never create migration SQL files or directories manually by hand. Always use Prisma CLI commands (e.g. `bun --bun run prisma migrate dev --create-only` to generate a migration template, or `bun --bun run prisma migrate dev`) so Prisma correctly tracks migration metadata and checksums.
|
||||
- **No Manual DDL Creation**: Never hand-write **schema (DDL) migration** files or directories. Always generate them with Prisma CLI (`bun --bun run prisma migrate dev --create-only` to create a template, then edit it if needed, or `bun --bun run prisma migrate dev` to apply) so Prisma correctly tracks migration metadata and checksums.
|
||||
- **Data Migrations Are Allowed**: Pure **data migration** SQL (no schema change) may be written by hand, but it MUST live inside a migration generated via `bun --bun run prisma migrate dev --create-only` so it is tracked and applied automatically.
|
||||
- **No Automatic Dev DB Reset**: Do not run `prisma migrate reset --force` or commands that force-reset the database automatically. If migrations become out of sync or a reset is required, stop executing, report the situation to the user, and present suggested manual cleanup/reset steps for the user to execute.
|
||||
|
||||
### Commands
|
||||
|
||||
@@ -24,6 +24,9 @@ Shumai is an open-source Frame.io alternative built for creative teams to collab
|
||||
* **Granular Access Control**: Manage workspace permissions with team-level and project-level role-based access control.
|
||||
* **Distributed Transcoding via Temporal**: Offload resource-intensive video transcoding to a background worker pool orchestrated by Temporal.
|
||||
* **Custom Asset Metadata**: Define dynamic metadata fields tailored to your production pipeline.
|
||||
* **Share Link Watermarking**: Protect shared media with customizable text and image watermarks, and save watermark as reusable templates.
|
||||
* **Wide File Format Support**: Preview common creative file formats, including images (with PSD support), videos, audio, and documents, while allowing any file type to be uploaded and stored.
|
||||
* **Office & Document PDF Proxying via Gotenberg**: Convert Word, PowerPoint, Excel, Markdown, HTML, and CSV documents to high-quality PDF proxies for in-browser previewing using [Gotenberg](https://docs.shumai.one/using-shumai/gotenberg).
|
||||
|
||||
But Shumai goes beyond being a Frame.io alternative. With modern models like GPT-Image-2 and Seedance 2.5, AI can already handle a surprising amount of creative work. That means you can create or update videos and images from a simple prompt without having to jump back into Photoshop, Premiere or Houdini. That is why Shumai includes a powerful agent system:
|
||||
|
||||
@@ -43,7 +46,7 @@ https://github.com/user-attachments/assets/1186067a-72c0-41b9-836f-987438f2332a
|
||||
|
||||
|
||||
> [!NOTE]
|
||||
> **Media Processing & Storage:** When uploading media, Shumai always preserves and stores your original raw file. Note that the file size shown in the system represents the original file size and does not include the size of any transcoded files. For all media types (both images and videos), Shumai creates a 480p WebP poster image to serve as the preview in the file list view. Additionally:
|
||||
> **Media Processing & Storage:** When uploading media, Shumai always preserves and stores your original raw file. Note that the file size shown in the system represents the original file size and does not include the size of any transcoded files. For all media types (both images and videos), Shumai creates a 300p WebP poster image to serve as the preview in the file list view. Additionally:
|
||||
> * **For Images:** Shumai generates a high-quality WebP proxy at the exact same resolution as your original file for optimized viewing.
|
||||
> * **For Videos:** It generates at least one proxy video (depending on your transcoding settings), alongside a sprite image and a small preview video (capped at 1600 frames) to enable fast timeline scrubbing and lightning-quick previews.
|
||||
|
||||
|
||||
+4
-1
@@ -25,6 +25,9 @@ Shumai 是一个开源的 Frame.io 替代方案,专为创意团队打造,让
|
||||
* **细粒度权限控制**:支持按团队、项目设置角色权限,方便管理不同成员的访问范围。
|
||||
* **基于 Temporal 的分布式转码**:把吃资源的视频转码任务交给后台 worker 池处理,由 Temporal 统一调度。
|
||||
* **自定义素材元数据**:可以按你的制作流程,自由定义动态元数据字段。
|
||||
* **分享链接水印**:通过可自定义的文字和图片水印保护共享媒体,并将水印配置保存为模板以便重复使用。
|
||||
* **丰富的文件格式支持**:支持预览常见创意文件格式,包括图片(支持 PSD)、视频、音频和文档,同时可上传和存储任意类型的文件。
|
||||
* **基于 Gotenberg 的文档 PDF 转码代理**:通过集成 [Gotenberg](https://docs.shumai.one/using-shumai/gotenberg) 支持将 Word、PowerPoint、Excel、Markdown、HTML 和 CSV 文档高质量转换为 PDF 代理文件进行在线预览。
|
||||
|
||||
但 Shumai 不仅仅只满足于 Frame.io 的开源替代。随着 GPT-Image-2、Seedance 2.5 这类强大模型的问世,AI已经生成产品级的图片/视频。很多时候,你只要给一句提示词,就能直接生成或修改图片和视频,而不用再打开 Photoshop、Premiere 或者 Houdini。也正因为这样,Shumai 才把 AI Agent 做成了核心能力:
|
||||
|
||||
@@ -40,7 +43,7 @@ Shumai 是一个开源的 Frame.io 替代方案,专为创意团队打造,让
|
||||
https://github.com/user-attachments/assets/1186067a-72c0-41b9-836f-987438f2332a
|
||||
|
||||
> [!NOTE]
|
||||
> **媒体处理与存储机制:** 上传媒体文件后,Shumai 始终会保留并存储原始文件。请注意,系统中显示的文件大小为原始文件的大小,不包含转码后生成的代理文件大小。无论图片还是视频,都会额外生成一张 480p 的 WebP 封面图,作为文件列表中的预览图。此外:
|
||||
> **媒体处理与存储机制:** 上传媒体文件后,Shumai 始终会保留并存储原始文件。请注意,系统中显示的文件大小为原始文件的大小,不包含转码后生成的代理文件大小。无论图片还是视频,都会额外生成一张 300p 的 WebP 封面图,作为文件列表中的预览图。此外:
|
||||
>
|
||||
> * **图片:** 会生成一份与原图分辨率完全一致的高质量 WebP 转码版本,在保证画质的同时提升浏览性能。
|
||||
> * **视频:** 会根据转码配置生成至少一个代理视频,同时生成雪碧图(Sprite)和一段最长 1600 帧的低分辨率转码视频,用于实现快速拖动时间轴和即时视频预览。
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/agent-app",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.5",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"bin": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/cli",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.5",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"bin": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/transcode-app",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.5",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"bin": {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
Fullstack end-to-end tests for the Shumai web app. They run against a real backend
|
||||
(pgvector container + local S3 storage) served on `http://localhost:5200` and are
|
||||
executed with Playwright via `bun run test:e2e`.
|
||||
executed with Playwright via `bun run test:e2e:app`.
|
||||
|
||||
## Structure
|
||||
|
||||
@@ -68,7 +68,7 @@ apps/web/e2e/
|
||||
| Test | File |
|
||||
|---|---|
|
||||
| Owner creates a project with a cover image | `tests/project/create-project.spec.ts` |
|
||||
| Owner uploads a file via the "Upload File" context menu action | `tests/project/upload-file.spec.ts` |
|
||||
| Owner uploads a file or an unsupported file via the "Upload File" context menu action | `tests/project/upload-file.spec.ts` |
|
||||
| Owner deletes a file, finds it in recently deleted, and restores it | `tests/project/delete-restore.spec.ts` |
|
||||
| Owner creates a share link from a file context menu and lands on the share page | `tests/project/create-share-link.spec.ts` |
|
||||
| Owner protects a share with a password; guests must enter it to view | `tests/project/share-password.spec.ts` |
|
||||
@@ -84,6 +84,8 @@ apps/web/e2e/
|
||||
| Owner searches the file list by Chinese, Japanese, and Korean name keywords | `tests/project/search-file-list.spec.ts` |
|
||||
| Owner searches the file list with a keyword and a filter condition | `tests/project/search-file-list.spec.ts` |
|
||||
| Owner saves a search result as a collection | `tests/project/save-search-collection.spec.ts` |
|
||||
| Image share with watermark + download disabled: no download buttons on public list/detail pages, watermarked proxy served, download-url rejected | `tests/project/share-watermark-no-download.spec.ts` |
|
||||
| Video share with watermark + download disabled: no download buttons on public list/detail pages, watermarked proxy served, download-url rejected | `tests/project/share-watermark-no-download.spec.ts` |
|
||||
|
||||
### file
|
||||
| Test | File |
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { APIRequestContext, Locator, Page } from '@playwright/test'
|
||||
interface CreateShareResponse {
|
||||
id?: string
|
||||
name?: string
|
||||
rootFolderId?: string
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -23,7 +24,7 @@ export async function apiCreateShare(
|
||||
request: APIRequestContext,
|
||||
projectId: string,
|
||||
name: string,
|
||||
): Promise<{ id: string; name: string }> {
|
||||
): Promise<{ id: string; name: string; rootFolderId: string }> {
|
||||
const res = await request.post(`/api/projects/${projectId}/shares`, {
|
||||
data: { name },
|
||||
})
|
||||
@@ -31,10 +32,10 @@ export async function apiCreateShare(
|
||||
throw new Error(`Create share API failed (${res.status()}): ${await res.text()}`)
|
||||
}
|
||||
const body = (await res.json()) as CreateShareResponse
|
||||
if (!body.id || !body.name) {
|
||||
if (!body.id || !body.name || !body.rootFolderId) {
|
||||
throw new Error(`Create share returned an unexpected response: ${JSON.stringify(body)}`)
|
||||
}
|
||||
return { id: body.id, name: body.name }
|
||||
return { id: body.id, name: body.name, rootFolderId: body.rootFolderId }
|
||||
}
|
||||
|
||||
/** Adds assets to a share link through the API. */
|
||||
@@ -51,6 +52,66 @@ export async function apiAddAssetsToShare(
|
||||
}
|
||||
}
|
||||
|
||||
/** Updates share link settings (e.g. `allowDownload`) through the API. */
|
||||
export async function apiUpdateShare(
|
||||
request: APIRequestContext,
|
||||
shareId: string,
|
||||
patch: { allowDownload?: boolean },
|
||||
): Promise<void> {
|
||||
const res = await request.put(`/api/shares/${shareId}`, { data: patch })
|
||||
if (!res.ok()) {
|
||||
throw new Error(`Update share API failed (${res.status()}): ${await res.text()}`)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables a text watermark on the share link through the API. Uses the same
|
||||
* default block shape the watermark editor produces (a "CONFIDENTIAL" text
|
||||
* block), so the transcode workflow runs against a realistic config.
|
||||
*/
|
||||
export async function apiEnableShareWatermark(
|
||||
request: APIRequestContext,
|
||||
shareId: string,
|
||||
): Promise<void> {
|
||||
const res = await request.put(`/api/shares/${shareId}/watermark`, {
|
||||
data: {
|
||||
enabled: true,
|
||||
config: {
|
||||
blocks: [
|
||||
{
|
||||
id: `wm-${Date.now()}`,
|
||||
type: 'text',
|
||||
text: 'CONFIDENTIAL',
|
||||
x: 0.5,
|
||||
y: 0.5,
|
||||
// size is a fraction (0..1) of the canvas width
|
||||
size: 0.05,
|
||||
color: '#999999',
|
||||
opacity: 0.5,
|
||||
rotation: -30,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
if (!res.ok()) {
|
||||
throw new Error(`Enable share watermark API failed (${res.status()}): ${await res.text()}`)
|
||||
}
|
||||
}
|
||||
|
||||
/** Requests a public download URL. Returns status + body for assertions. */
|
||||
export async function apiPublicDownloadUrl(
|
||||
request: APIRequestContext,
|
||||
shareId: string,
|
||||
fileId: string,
|
||||
key: string,
|
||||
): Promise<{ status: number; body: unknown }> {
|
||||
const res = await request.post(`/api/shares/${shareId}/files/${fileId}/download-url`, {
|
||||
data: { key },
|
||||
})
|
||||
return { status: res.status(), body: await res.json().catch(() => null) }
|
||||
}
|
||||
|
||||
/** Uploads a file asset through the official API upload task endpoints. */
|
||||
export async function apiUploadFile(
|
||||
request: APIRequestContext,
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
import { expect, test } from '../../fixtures'
|
||||
import {
|
||||
apiAddAssetsToShare,
|
||||
apiCreateShare,
|
||||
apiEnableShareWatermark,
|
||||
apiPublicDownloadUrl,
|
||||
apiUpdateShare,
|
||||
fileCard,
|
||||
} from '../../helpers/files'
|
||||
|
||||
/**
|
||||
* The watermarked + download-disabled combination is frequently used together:
|
||||
* guests can preview the content but never download it, and any previewed proxy
|
||||
* carries a watermark. This covers both watermarkable media types (image and
|
||||
* video) and asserts, per type:
|
||||
* - the public share list page exposes no download affordance,
|
||||
* - the public share file detail page exposes no download affordance,
|
||||
* - the proxy loaded in the detail page is the watermarked version, and
|
||||
* - the download-url endpoint rejects guest download attempts with 403.
|
||||
*/
|
||||
for (const mediaType of ['image', 'video'] as const) {
|
||||
// NOTE: `test.use` must be scoped per describe block — a bare `test.use`
|
||||
// inside a `for` loop leaks the last iteration's value to every test.
|
||||
test.describe(`${mediaType} share`, () => {
|
||||
test.use({ fileOptions: { mediaType } })
|
||||
|
||||
// Transcoding (original + watermark) happens through the local workflow
|
||||
// executor, so this test needs a much larger budget than the 60s default.
|
||||
test.setTimeout(300_000)
|
||||
|
||||
test('with watermark + download disabled: no download buttons, watermarked proxy', async ({
|
||||
file,
|
||||
browser,
|
||||
prisma,
|
||||
}) => {
|
||||
const { context, projectId, fileName, fileId } = file
|
||||
|
||||
// The watermark transcode re-encodes from the existing transcode slots, so
|
||||
// the original transcode must finish first.
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const asset = await prisma.asset.findUnique({ where: { id: fileId } })
|
||||
return asset?.status
|
||||
},
|
||||
{ timeout: 60_000 },
|
||||
)
|
||||
.toBe('processed')
|
||||
|
||||
// Seed the share through the API (setup, not the flow under test)
|
||||
const share = await apiCreateShare(context.request, projectId, 'Watermarked Share')
|
||||
await apiAddAssetsToShare(context.request, share.id, [fileId])
|
||||
await apiUpdateShare(context.request, share.id, { allowDownload: false })
|
||||
await apiEnableShareWatermark(context.request, share.id)
|
||||
|
||||
// Wait for the watermark transcode to complete and the share to be ready
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const link = await prisma.shareLink.findUnique({ where: { id: share.id } })
|
||||
return link?.watermarkStatus
|
||||
},
|
||||
{ timeout: 120_000 },
|
||||
)
|
||||
.toBe('ready')
|
||||
|
||||
const saved = await prisma.shareLink.findUnique({ where: { id: share.id } })
|
||||
expect(saved?.allowDownload).toBe(false)
|
||||
expect(saved?.watermarkConfigId).not.toBeNull()
|
||||
|
||||
// The share root contains a symlink pointing at the real asset; the public
|
||||
// detail page navigates with the symlink id (mirrors the real double-click flow).
|
||||
const symlink = await prisma.asset.findFirst({
|
||||
where: { parentId: share.rootFolderId, targetId: fileId },
|
||||
})
|
||||
expect(symlink).not.toBeNull()
|
||||
|
||||
// Original (unwatermarked) transcode keys, to prove they are never served
|
||||
const asset = await prisma.asset.findUnique({ where: { id: fileId } })
|
||||
const media = asset?.media as {
|
||||
imageTranscodes?: Array<{ key: string }>
|
||||
videoTranscodes?: Array<{ key: string }>
|
||||
original?: { key: string } | null
|
||||
} | null
|
||||
const originalKeys =
|
||||
(mediaType === 'image' ? media?.imageTranscodes : media?.videoTranscodes)?.map(
|
||||
(t) => t.key,
|
||||
) ?? []
|
||||
|
||||
const guestContext = await browser.newContext()
|
||||
const guestPage = await guestContext.newPage()
|
||||
try {
|
||||
// ---------------- Public share list page ----------------
|
||||
await guestPage.goto(`/share/${share.id}`)
|
||||
await expect(fileCard(guestPage, fileName)).toBeVisible()
|
||||
|
||||
// Card context menu: no Download item
|
||||
const card = fileCard(guestPage, fileName)
|
||||
const kebab = card.locator('button', {
|
||||
has: guestPage.locator('svg.lucide-ellipsis'),
|
||||
})
|
||||
await kebab.click()
|
||||
await expect(guestPage.locator('[data-radix-menu-content]').first()).toBeAttached()
|
||||
await expect(guestPage.getByRole('menuitem', { name: 'Download' })).toHaveCount(0)
|
||||
await guestPage.keyboard.press('Escape')
|
||||
// Wait for the Radix menu to fully unmount before interacting again:
|
||||
// while its exit animation is running its dismiss layer can intercept
|
||||
// the outside pointerdown and swallow the next click.
|
||||
await guestPage
|
||||
.waitForFunction(() => !document.querySelector('[data-radix-menu-content]'), null, {
|
||||
timeout: 10_000,
|
||||
})
|
||||
.catch(() => {})
|
||||
|
||||
// Selection bar: selecting the file must not surface a Download button.
|
||||
// Click the card checkbox (selects directly) instead of the card body:
|
||||
// the preview area (video sprite scrubber) re-renders on hover and can
|
||||
// race with a body click.
|
||||
const checkbox = card.getByRole('checkbox')
|
||||
await checkbox.click()
|
||||
await expect(guestPage.getByText(/1 file selected/)).toBeVisible()
|
||||
await expect(guestPage.getByRole('button', { name: 'Download' })).toHaveCount(0)
|
||||
|
||||
// ---------------- Public share file detail page ----------------
|
||||
// Capture every network request so we can prove the loaded proxy is the
|
||||
// watermarked one and no original transcode key is ever requested.
|
||||
const watermarkedRequests: string[] = []
|
||||
const allRequests: string[] = []
|
||||
guestPage.on('request', (req) => {
|
||||
const url = req.url()
|
||||
allRequests.push(url)
|
||||
if (url.includes('-watermark-')) watermarkedRequests.push(url)
|
||||
})
|
||||
|
||||
const detailFileId = symlink!.id
|
||||
await guestPage.goto(`/share/${share.id}/files/${detailFileId}`)
|
||||
|
||||
// The viewer (image canvas / video element) renders the proxy
|
||||
if (mediaType === 'image') {
|
||||
await expect(guestPage.locator('canvas').first()).toBeVisible({ timeout: 30_000 })
|
||||
} else {
|
||||
await expect(guestPage.locator('video').first()).toBeVisible({ timeout: 30_000 })
|
||||
}
|
||||
|
||||
// The proxy actually loaded is the watermarked version, and no original
|
||||
// (unwatermarked) transcode key was requested
|
||||
await expect.poll(() => watermarkedRequests.length, { timeout: 30_000 }).toBeGreaterThan(0)
|
||||
const leaked = allRequests.filter((url) => originalKeys.some((key) => url.includes(key)))
|
||||
expect(leaked).toEqual([])
|
||||
|
||||
// No download affordance in the viewer control bar
|
||||
await expect(guestPage.getByTitle('Download')).toHaveCount(0)
|
||||
await expect(guestPage.getByTitle('Download original image')).toHaveCount(0)
|
||||
await expect(guestPage.getByRole('button', { name: 'Download' })).toHaveCount(0)
|
||||
|
||||
// Top-nav file dropdown: no Download item (video: also no resolution submenu)
|
||||
await guestPage.getByRole('button', { name: new RegExp(fileName) }).click()
|
||||
await expect(guestPage.locator('[data-radix-menu-content]').first()).toBeAttached()
|
||||
await expect(guestPage.getByRole('menuitem', { name: 'Download' })).toHaveCount(0)
|
||||
if (mediaType === 'video') {
|
||||
await expect(
|
||||
guestPage.locator('[data-radix-menu-content]').getByText('Original', { exact: true }),
|
||||
).toHaveCount(0)
|
||||
await expect(
|
||||
guestPage.locator('[data-radix-menu-content]').getByText('MP4', { exact: true }),
|
||||
).toHaveCount(0)
|
||||
}
|
||||
|
||||
// ---------------- Backend enforcement ----------------
|
||||
// Guests cannot obtain a download URL even when they know the storage key
|
||||
const originalKey = originalKeys[0] || media?.original?.key || ''
|
||||
const download = await apiPublicDownloadUrl(
|
||||
guestContext.request,
|
||||
share.id,
|
||||
detailFileId,
|
||||
originalKey,
|
||||
)
|
||||
expect(download.status).toBe(403)
|
||||
} finally {
|
||||
await guestContext.close()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -47,3 +47,39 @@ test('owner uploads a file via the "Upload File" context menu action', async ({
|
||||
const projectRow = await prisma.project.findUnique({ where: { id: projectId } })
|
||||
expect(asset!.parentId).toBe(projectRow?.rootFolderId)
|
||||
})
|
||||
|
||||
test('owner uploads an unsupported file via context menu action', async ({ project, prisma }) => {
|
||||
const { page, projectId } = project
|
||||
const fileName = `e2e-upload-${Date.now()}.bin`
|
||||
const binBuffer = Buffer.from([0x00, 0x01, 0x02, 0x03])
|
||||
|
||||
await page.goto(`/projects/${projectId}`)
|
||||
await expect(page.getByText('This folder is empty')).toBeVisible()
|
||||
|
||||
await page.getByText('This folder is empty').click({ button: 'right' })
|
||||
const [fileChooser] = await Promise.all([
|
||||
page.waitForEvent('filechooser'),
|
||||
page.getByRole('menuitem', { name: 'Upload File' }).click(),
|
||||
])
|
||||
await fileChooser.setFiles({
|
||||
name: fileName,
|
||||
mimeType: 'application/octet-stream',
|
||||
buffer: binBuffer,
|
||||
})
|
||||
|
||||
const card = fileCard(page, fileName)
|
||||
await expect(card).toBeVisible()
|
||||
|
||||
await expect
|
||||
.poll(
|
||||
async () => {
|
||||
const asset = await prisma.asset.findFirst({ where: { name: fileName } })
|
||||
return asset?.status
|
||||
},
|
||||
{ timeout: 30_000 },
|
||||
)
|
||||
.toBe('processed')
|
||||
|
||||
// Verify that the file card shows the generic file icon and is not stuck in uploading state
|
||||
await expect(card.locator('svg.lucide-file')).toBeVisible({ timeout: 10_000 })
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/web-app",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.5",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
|
||||
+2
-1
@@ -34,7 +34,8 @@
|
||||
"using-shumai/notifications",
|
||||
"using-shumai/metadata",
|
||||
"using-shumai/collections",
|
||||
"using-shumai/share-links"
|
||||
"using-shumai/share-links",
|
||||
"using-shumai/gotenberg"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 82 KiB |
@@ -0,0 +1,82 @@
|
||||
---
|
||||
title: Document PDF Conversion with Gotenberg
|
||||
description: Convert Office documents, HTML, Markdown, CSV, and TXT files into high-fidelity PDF proxies for in-browser previewing.
|
||||
---
|
||||
|
||||
Office documents, HTML pages, Markdown files, spreadsheets, and plain-text files cannot be rendered natively in web browsers. Shumai uses [Gotenberg](https://gotenberg.dev), an open-source, Docker powered conversion API — to turn these files into PDF proxy assets for seamless in-browser previewing.
|
||||
|
||||
Gotenberg performs the conversion using:
|
||||
|
||||
- **LibreOffice** for Office documents, spreadsheets, and plain text.
|
||||
- **Headless Chromium** for HTML and Markdown files.
|
||||
|
||||
---
|
||||
|
||||
## Supported File Types
|
||||
|
||||
When Gotenberg is configured, Shumai automatically generates a PDF proxy for the following uploads:
|
||||
|
||||
| Category | Extensions | Converter |
|
||||
| ------------------ | ---------------------- | ----------- |
|
||||
| Word | `.doc`, `.docx` | LibreOffice |
|
||||
| Excel | `.xls`, `.xlsx` | LibreOffice |
|
||||
| PowerPoint | `.ppt`, `.pptx` | LibreOffice |
|
||||
| OpenDocument | `.odt`, `.ods`, `.odp` | LibreOffice |
|
||||
| Rich Text | `.rtf` | LibreOffice |
|
||||
| HTML | `.html`, `.htm` | Chromium |
|
||||
| Markdown | `.md`, `.markdown` | Chromium |
|
||||
| Spreadsheets / CSV | `.csv` | LibreOffice |
|
||||
| Plain text | `.txt` | LibreOffice |
|
||||
|
||||
---
|
||||
|
||||
## Configuration
|
||||
|
||||
Gotenberg support is opt-in and controlled by the following environment variables on the machine running the transcode workers:
|
||||
|
||||
| Variable | Required | Description |
|
||||
| ------------------------------- | --------------- | ---------------------------------------------------------------- |
|
||||
| `GOTENBERG_URL` | Yes (to enable) | Base URL of the Gotenberg service, e.g. `http://gotenberg:3000`. |
|
||||
| `GOTENBERG_BASIC_AUTH_USERNAME` | No | Username when Basic Authentication is enabled on Gotenberg. |
|
||||
| `GOTENBERG_BASIC_AUTH_PASSWORD` | No | Password when Basic Authentication is enabled on Gotenberg. |
|
||||
|
||||
### Docker Quickstart
|
||||
|
||||
You can start a Gotenberg container with a single command:
|
||||
|
||||
```bash
|
||||
docker run -d --name gotenberg -p 3000:3000 gotenberg/gotenberg:8
|
||||
```
|
||||
|
||||
If you wish to enable Basic Authentication:
|
||||
|
||||
```bash
|
||||
docker run -d --name gotenberg -p 3000:3000 gotenberg/gotenberg:8 gotenberg --gotenberg-basic-auth-username=admin --gotenberg-basic-auth-password=secret
|
||||
```
|
||||
|
||||
### Docker Compose Setup
|
||||
|
||||
Add a Gotenberg service to your `docker-compose.yaml`:
|
||||
|
||||
```yaml
|
||||
gotenberg:
|
||||
image: gotenberg/gotenberg:8
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- '3000:3000'
|
||||
```
|
||||
|
||||
Then point Shumai at it:
|
||||
|
||||
```bash
|
||||
GOTENBERG_URL=http://localhost:3000
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Behavior Without Gotenberg
|
||||
|
||||
If Gotenberg is not configured or unreachable, Shumai degrades gracefully:
|
||||
|
||||
- **Office documents and HTML**: the upload completes as `processed` without a PDF proxy.
|
||||
- **CSV, Markdown, and TXT**: a lightweight built-in PDF generator produces the proxy instead, with reduced fidelity.
|
||||
@@ -14,6 +14,8 @@ Shumai allows you to collaborate with external stakeholders who do not have acco
|
||||
3. Configure the share link in the right sidebar. You can:
|
||||
- Add password protection
|
||||
- Set an expiration date
|
||||
- Allow or disallow downloads
|
||||
- Add a watermark to previews
|
||||
- Configure which metadata fields are visible to recipients
|
||||
4. Click **Copy Link** at the bottom of the sidebar, then send the link to your client or stakeholder.
|
||||
|
||||
@@ -41,6 +43,30 @@ Set an optional date and time after which the link becomes inactive. Once the da
|
||||
|
||||
Secure sensitive work by adding a password. External users visiting the link will be prompted to enter the correct password before they can view the assets.
|
||||
|
||||
### Allow Download
|
||||
|
||||
Control whether visitors can download the shared files. When **Allow download** is turned off:
|
||||
|
||||
- All download buttons are hidden on the public share page (file cards, selection bar, viewer control bars, and the top navigation).
|
||||
|
||||
Guests can still preview the files; only downloading is blocked. This is often combined with a watermark so previews remain viewable but protected.
|
||||
|
||||
### Watermark
|
||||
|
||||
Overlay a watermark (e.g. a "CONFIDENTIAL" text label or a logo image) on every preview shown through the share link. Open the watermark editor, arrange the blocks, and save.
|
||||
|
||||
Watermarking is **lazy and per-share-link** to keep storage costs low:
|
||||
|
||||
- The watermark transcode is only triggered when you **enable the watermark on a share link** — Shumai does **not** pre-generate watermark copies for every file in your workspace.
|
||||
- All video and image assets already in the share are transcoded at that moment (the sidebar shows a _processing_ status until it finishes).
|
||||
- Files and folders **added to the share link later are automatically transcoded too**, so the watermark always covers the full share without any manual steps.
|
||||
- Since watermark copies are only produced for assets that are actually shared through a watermarked link, files that are never shared (or shared through non-watermarked links) never consume extra storage for watermark proxies. This can save a very large amount of storage on big libraries.
|
||||
|
||||
Notes:
|
||||
|
||||
- Only **video and image** proxies are watermarked; other media types (PDF, audio, ...) are not affected.
|
||||
- While the watermark is still processing, previews are hidden rather than exposing the original, unwatermarked proxy.
|
||||
|
||||
### Default Sort Order
|
||||
|
||||
Set a default sorting rule for the shared page (e.g. sorting by name or version) to ensure the client views the files in the intended order.
|
||||
|
||||
+3
-4
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "shumai",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.5",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"repository": {
|
||||
@@ -18,11 +18,10 @@
|
||||
"typecheck": "tsc --noEmit",
|
||||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||
"test": "bun --bun vitest run",
|
||||
"test:e2e": "playwright test --project=harness-chromium --project=app-chromium",
|
||||
"test:e2e:app": "playwright test --project=app-chromium",
|
||||
"test:e2e:webui": "E2E_SKIP_APP_SERVER=true playwright test --project=harness-chromium",
|
||||
"test:e2e:all": "playwright test",
|
||||
"test:e2e:workflow": "bun --bun vitest run -c packages/e2e/vitest.config.ts",
|
||||
"test:e2e:ui": "playwright test --ui --project=harness-chromium --project=app-chromium",
|
||||
"test:e2e:report": "playwright show-report",
|
||||
"test:e2e:install": "playwright install --with-deps",
|
||||
"harness:dev": "bun run packages/webui/e2e/harness/serve.ts",
|
||||
"format": "prettier --write .",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/agent",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.5",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -96,7 +96,7 @@ shumai has its own cloud file system. If a user asks you to perform file system
|
||||
|
||||
If you need to create files in the local filesystem (for example, a temporary file for uploading), only the '.pi' folder in the current directory has write permissions. Do NOT attempt to create files in any other directories.
|
||||
|
||||
When creating a file or version, first use 'list_autofill_fields' to inspect the project's AI-autofillable metadata fields. If relevant metadata depends on information unavailable from the file content (for example, the AI model or tool used to generate it), include a brief context hint (maximum 50 words) in the 'context' field of 'create_file' or 'create_version' tool.`
|
||||
When creating a file or version, first use 'list_autofill_fields' to inspect the project's AI-autofillable metadata fields. If relevant metadata depends on information unavailable from the file content (for example, the AI model or prompt used to generate the asset), include a context in the 'context' field of 'create_file' or 'create_version'. Keep the context short and only include information relevant to those fields.`
|
||||
|
||||
if (agent.soul) {
|
||||
systemPrompt = `${systemPrompt}\n\nAgent Personality and Core Instructions:\n${agent.soul}`
|
||||
|
||||
@@ -33,9 +33,10 @@ const createFileSchema = Type.Object({
|
||||
context: Type.Optional(
|
||||
Type.String({
|
||||
description:
|
||||
'Optional short context about this file and how it was generated (max 50 words, e.g. "Generated using gemini"). ' +
|
||||
'Passed to the AI metadata autofill workflow to fill fields that cannot be determined from file content alone. ' +
|
||||
'Check autofillable fields with list_autofill_fields first.',
|
||||
'Optional context passed to the AI metadata autofill workflow for fields that cannot be inferred from file content alone ' +
|
||||
'(e.g. the model or prompt used to generate the asset). ' +
|
||||
'Use list_autofill_fields first to check which fields can be autofilled. ' +
|
||||
'Keep the context short and only include information relevant to those fields.',
|
||||
}),
|
||||
),
|
||||
})
|
||||
|
||||
@@ -20,9 +20,10 @@ const createVersionSchema = Type.Object({
|
||||
context: Type.Optional(
|
||||
Type.String({
|
||||
description:
|
||||
'Optional short context about this version and how it was generated (max 50 words, e.g. "Generated using gemini"). ' +
|
||||
'Passed to the AI metadata autofill workflow to fill fields that cannot be determined from file content alone. ' +
|
||||
'Check autofillable fields with list_autofill_fields first.',
|
||||
'Optional context passed to the AI metadata autofill workflow for fields that cannot be inferred from file content alone ' +
|
||||
'(e.g. the model or prompt used to generate the asset). ' +
|
||||
'Use list_autofill_fields first to check which fields can be autofilled. ' +
|
||||
'Keep the context short and only include information relevant to those fields.',
|
||||
}),
|
||||
),
|
||||
})
|
||||
|
||||
@@ -17,7 +17,7 @@ export function createListAutofillFieldsTool(
|
||||
label: 'List Autofill Fields',
|
||||
description:
|
||||
'List the AI-autofillable metadata fields defined for the project of a parent folder, including their types and available options. ' +
|
||||
'Use this before creating a file or version so you can pass relevant context (e.g. generation source) to create_file/create_version.',
|
||||
'Use this before creating a file or version so you can pass relevant context (e.g. the model or prompt used to generate the asset) to create_file/create_version.',
|
||||
parameters: listAutofillFieldsSchema,
|
||||
execute: async (_toolCallId, params) => {
|
||||
const result = await executeAgentToolWorkflow({
|
||||
|
||||
@@ -186,7 +186,7 @@ describe('Agent Embedding Workflow', () => {
|
||||
mediaType: 'image/png',
|
||||
storageKey: { key: 'test.png' },
|
||||
media: {
|
||||
imageTranscodes: [{ key: 'test-transcoded.webp', isRaw: false, format: 'webp' }],
|
||||
imageTranscodes: [{ key: 'test-transcoded.webp', format: 'webp' }],
|
||||
},
|
||||
},
|
||||
chunkDuration: 60.0,
|
||||
@@ -220,7 +220,7 @@ describe('Agent Embedding Workflow', () => {
|
||||
storageKey: { key: 'test.mp4' },
|
||||
media: {
|
||||
duration: 150.0,
|
||||
videoTranscodes: [{ key: 'test-transcoded.mp4', isRaw: false }],
|
||||
videoTranscodes: [{ key: 'test-transcoded.mp4' }],
|
||||
},
|
||||
},
|
||||
chunkDuration: 60.0,
|
||||
|
||||
@@ -91,20 +91,14 @@ export async function agentEmbeddingMedia(task: WorkflowTask): Promise<void> {
|
||||
const media = asset.media as any
|
||||
if (isVideo) {
|
||||
if (media.videoTranscodes && media.videoTranscodes.length > 0) {
|
||||
// Find first non-raw transcode or fallback to first transcode
|
||||
const transcode =
|
||||
media.videoTranscodes.find((t: PrismaJson.VideoTranscode) => !t.isRaw) ||
|
||||
media.videoTranscodes[0]
|
||||
const transcode = media.videoTranscodes[0] as PrismaJson.VideoTranscode
|
||||
if (transcode?.key) {
|
||||
embeddingKey = transcode.key
|
||||
}
|
||||
}
|
||||
} else if (isImage) {
|
||||
if (media.imageTranscodes && media.imageTranscodes.length > 0) {
|
||||
// Find first non-raw transcode or fallback to first transcode
|
||||
const transcode =
|
||||
media.imageTranscodes.find((t: PrismaJson.ImageTranscode) => !t.isRaw) ||
|
||||
media.imageTranscodes[0]
|
||||
const transcode = media.imageTranscodes[0] as PrismaJson.ImageTranscode
|
||||
if (transcode?.key) {
|
||||
embeddingKey = transcode.key
|
||||
if (transcode.format) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/api",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.5",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -351,7 +351,8 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
contentType,
|
||||
)
|
||||
|
||||
return c.json({ key })
|
||||
const url = await s3Service.presign(process.env.S3_BUCKET || 'shumai', key, 'GET')
|
||||
return c.json({ key, url })
|
||||
})
|
||||
.post('/files/download-links', zValidator('json', getDownloadLinksRequestSchema), async (c) => {
|
||||
const user = c.get('user')
|
||||
|
||||
@@ -19,6 +19,7 @@ import publicShareRoute from './public-share'
|
||||
import s3Route from './s3'
|
||||
import shareRoute from './share'
|
||||
import skillRoute from './skill'
|
||||
import watermarkTemplateRoute from './watermark-template'
|
||||
import teamRoute from './team'
|
||||
import uploadRoute, { localUploadRoute } from './upload'
|
||||
import versionStackRoute from './versionStack'
|
||||
@@ -60,6 +61,7 @@ const apiRoute = new Hono<{ Variables: { user: User } }>()
|
||||
.route('/', uploadRoute)
|
||||
.route('/', shareRoute)
|
||||
.route('/', skillRoute)
|
||||
.route('/', watermarkTemplateRoute)
|
||||
|
||||
app.route('/files', s3Route)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import type { Context } from 'hono'
|
||||
import { zValidator } from '@hono/zod-validator'
|
||||
import { shareService } from '@shumai/core/src/share/share'
|
||||
import { assetService } from '@shumai/core/src/asset/asset'
|
||||
import { watermarkService } from '@shumai/core/src/watermark/watermark'
|
||||
import { paginationParamsSchema } from '@shumai/dtos'
|
||||
import { z } from 'zod'
|
||||
import { metadataService } from '@shumai/core/src/metadata/metadata'
|
||||
@@ -18,7 +19,65 @@ import {
|
||||
ShareLinkDisabledError,
|
||||
ShareLinkExpiredError,
|
||||
ShareLinkPasswordInvalidError,
|
||||
ShareLinkDownloadDisabledError,
|
||||
} from '@shumai/core/src/share/errors'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import type { AssetInfo } from '@shumai/dtos'
|
||||
|
||||
/**
|
||||
* Replaces the served media entries with the watermarked proxy entries produced
|
||||
* by the watermark transcode activity. When no completed watermark proxy exists
|
||||
* yet (still transcoding, or failed), the video/image transcode slots are emptied
|
||||
* so original, unwatermarked proxies are never exposed on the public share.
|
||||
*
|
||||
* Only video/image assets are subject to watermark protection; other media types
|
||||
* (pdf, audio, ...) never receive watermark transcodes and pass through untouched.
|
||||
* `original`, `thumbnail` and `videoPreview` are intentionally left untouched here.
|
||||
* S3 GET URLs are generated for all watermarked proxies.
|
||||
*/
|
||||
async function applyWatermarkToAssetMedia(
|
||||
asset: AssetInfo,
|
||||
watermarkMedia: PrismaJson.MediaInfo | null,
|
||||
): Promise<AssetInfo> {
|
||||
if (!asset.media) return asset
|
||||
if (asset.proxyType !== 'video' && asset.proxyType !== 'image') return asset
|
||||
|
||||
const updatedMedia = { ...asset.media }
|
||||
const bucket = process.env.S3_BUCKET || 'shumai'
|
||||
|
||||
updatedMedia.videoTranscodes =
|
||||
watermarkMedia?.videoTranscodes && watermarkMedia.videoTranscodes.length > 0
|
||||
? await Promise.all(
|
||||
watermarkMedia.videoTranscodes.map(async (vt) => ({
|
||||
id: vt.key ?? '',
|
||||
url: vt.key ? await s3Service.presign(bucket, vt.key, 'GET') : '',
|
||||
key: vt.key ?? '',
|
||||
width: vt.width ?? 0,
|
||||
height: vt.height ?? 0,
|
||||
size: 0,
|
||||
})),
|
||||
)
|
||||
: []
|
||||
|
||||
updatedMedia.imageTranscodes =
|
||||
watermarkMedia?.imageTranscodes && watermarkMedia.imageTranscodes.length > 0
|
||||
? await Promise.all(
|
||||
watermarkMedia.imageTranscodes.map(async (it) => ({
|
||||
id: it.key ?? '',
|
||||
url: it.key ? await s3Service.presign(bucket, it.key, 'GET') : '',
|
||||
key: it.key ?? '',
|
||||
width: it.width ?? 0,
|
||||
height: it.height ?? 0,
|
||||
size: 0,
|
||||
})),
|
||||
)
|
||||
: []
|
||||
|
||||
return {
|
||||
...asset,
|
||||
media: updatedMedia,
|
||||
}
|
||||
}
|
||||
|
||||
const app = new Hono()
|
||||
|
||||
@@ -46,6 +105,10 @@ export function handlePublicShareError(c: Context, err: unknown) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
return c.json({ error: msg }, 403)
|
||||
}
|
||||
if (err instanceof ShareLinkDownloadDisabledError) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
return c.json({ error: msg }, 403)
|
||||
}
|
||||
if (err instanceof ShareLinkNotFoundError) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
return c.json({ error: msg }, 404)
|
||||
@@ -70,6 +133,7 @@ const route = app
|
||||
name: shareLink.name,
|
||||
expireAt: shareLink.expireAt,
|
||||
isDisabled: shareLink.isDisabled,
|
||||
allowDownload: shareLink.allowDownload,
|
||||
isExpired: shareLink.isExpired,
|
||||
hasPassword: shareLink.hasPassword,
|
||||
rootFolderId: shareLink.rootFolderId,
|
||||
@@ -129,6 +193,24 @@ const route = app
|
||||
order,
|
||||
})
|
||||
|
||||
if (shareLink.watermarkConfigId && res.data.length > 0) {
|
||||
// Resolve symlink targets once and reuse for the media lookup, so each
|
||||
// item costs a single query instead of two.
|
||||
const targetIds = await Promise.all(
|
||||
res.data.map((item) => assetService.resolveTargetAssetId(item.id)),
|
||||
)
|
||||
const wfMap = await watermarkService.getCompletedWatermarkMediaMap(
|
||||
targetIds,
|
||||
shareLink.watermarkConfigId,
|
||||
)
|
||||
|
||||
res.data = await Promise.all(
|
||||
res.data.map(async (item, index) =>
|
||||
applyWatermarkToAssetMedia(item, wfMap.get(targetIds[index]) ?? null),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
return c.json(res)
|
||||
} catch (err) {
|
||||
return handlePublicShareError(c, err)
|
||||
@@ -140,9 +222,24 @@ const route = app
|
||||
const password = c.req.header('x-share-password')
|
||||
|
||||
try {
|
||||
await shareService.verifyPublicAccess(fileId, password)
|
||||
const shareLink = await shareService.verifyPublicAccess(fileId, password)
|
||||
|
||||
let asset = await assetService.getAsset({ assetId: fileId })
|
||||
|
||||
// Only video/image assets are subject to watermark protection; skip the
|
||||
// watermark lookup entirely for other media types (pdf, audio, ...).
|
||||
if (
|
||||
shareLink.watermarkConfigId &&
|
||||
(asset.proxyType === 'video' || asset.proxyType === 'image')
|
||||
) {
|
||||
const targetAssetId = await assetService.resolveTargetAssetId(fileId)
|
||||
const wfMap = await watermarkService.getCompletedWatermarkMediaMap(
|
||||
[targetAssetId],
|
||||
shareLink.watermarkConfigId,
|
||||
)
|
||||
asset = await applyWatermarkToAssetMedia(asset, wfMap.get(targetAssetId) ?? null)
|
||||
}
|
||||
|
||||
const asset = await assetService.getAsset({ assetId: fileId })
|
||||
return c.json(asset)
|
||||
} catch (err) {
|
||||
return handlePublicShareError(c, err)
|
||||
@@ -157,7 +254,11 @@ const route = app
|
||||
const { key } = c.req.valid('json')
|
||||
|
||||
try {
|
||||
await shareService.verifyPublicAccess(fileId, password)
|
||||
const shareLink = await shareService.verifyPublicAccess(fileId, password)
|
||||
|
||||
if (!shareLink.allowDownload) {
|
||||
throw new ShareLinkDownloadDisabledError('Download is disabled for this share link')
|
||||
}
|
||||
|
||||
if (!key.startsWith('files/')) {
|
||||
return c.json({ error: 'Invalid key' }, 400)
|
||||
|
||||
@@ -39,7 +39,7 @@ describe('S3 API', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('GET /files/* sets Content-Disposition: attachment only when download=1 query param is present', async () => {
|
||||
it('GET /files/* sets Content-Disposition with filename when download=1 & filename query params are present', async () => {
|
||||
// We need to capture the onFound callback from serveStatic options
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let onFoundCallback: ((path: string, c: any) => void) | undefined
|
||||
@@ -54,19 +54,36 @@ describe('S3 API', () => {
|
||||
const { default: route } = await import('./s3')
|
||||
const app = new Hono().route('/files', route)
|
||||
|
||||
await app.request('/files/b1/test.webp?download=1')
|
||||
await app.request('/files/b1/test.webp?download=1&filename=foo.png')
|
||||
|
||||
expect(onFoundCallback).toBeDefined()
|
||||
|
||||
// Test with download=1
|
||||
// Test with download=1 and filename
|
||||
const mockContextWithDownload = {
|
||||
req: { query: (key: string) => (key === 'download' ? '1' : undefined) },
|
||||
req: {
|
||||
query: (key: string) =>
|
||||
key === 'download' ? '1' : key === 'filename' ? 'foo.png' : undefined,
|
||||
},
|
||||
header: vi.fn(),
|
||||
}
|
||||
|
||||
if (onFoundCallback) {
|
||||
onFoundCallback('/files/b1/test.webp', mockContextWithDownload)
|
||||
expect(mockContextWithDownload.header).toHaveBeenCalledWith(
|
||||
'Content-Disposition',
|
||||
'attachment; filename="foo.png"; filename*=UTF-8\'\'foo.png',
|
||||
)
|
||||
}
|
||||
|
||||
// Test with download=1 but no filename
|
||||
const mockContextDownloadNoFilename = {
|
||||
req: { query: (key: string) => (key === 'download' ? '1' : undefined) },
|
||||
header: vi.fn(),
|
||||
}
|
||||
|
||||
if (onFoundCallback) {
|
||||
onFoundCallback('/files/b1/test.webp', mockContextDownloadNoFilename)
|
||||
expect(mockContextDownloadNoFilename.header).toHaveBeenCalledWith(
|
||||
'Content-Disposition',
|
||||
'attachment',
|
||||
)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Hono } from 'hono'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { buildContentDisposition, s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { serveStatic } from 'hono/bun'
|
||||
|
||||
const route = new Hono()
|
||||
@@ -10,7 +10,7 @@ const route = new Hono()
|
||||
rewriteRequestPath: (path) => path.replace(/^\/files\//, ''),
|
||||
onFound: (_path, c) => {
|
||||
if (c.req.query('download') === '1') {
|
||||
c.header('Content-Disposition', 'attachment')
|
||||
c.header('Content-Disposition', buildContentDisposition(c.req.query('filename')))
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -9,6 +9,8 @@ import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/a
|
||||
import { ShareLinkPasswordInvalidError, ShareLinkExpiredError } from '@shumai/core/src/share/errors'
|
||||
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
import { watermarkService } from '@shumai/core/src/watermark/watermark'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
|
||||
vi.mock('./middleware/auth', () => ({
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@@ -47,6 +49,35 @@ vi.mock('@shumai/core/src/project/project', () => ({
|
||||
},
|
||||
}))
|
||||
|
||||
function watermarkMediaInfo(overrides: Partial<PrismaJson.MediaInfo> = {}): PrismaJson.MediaInfo {
|
||||
return {
|
||||
duration: 1,
|
||||
filesize: 100,
|
||||
frames: 30,
|
||||
proxyType: 'video',
|
||||
imageTranscodes: [],
|
||||
videoTranscodes: [],
|
||||
finishedAt: new Date().toISOString(),
|
||||
metadata: {
|
||||
originalHeight: 360,
|
||||
originalWidth: 640,
|
||||
hasAudio: false,
|
||||
duration: 1,
|
||||
bitRate: 0,
|
||||
frameRate: 30,
|
||||
totalFrames: 30,
|
||||
startTimecode: '00:00:00:00',
|
||||
format: {},
|
||||
},
|
||||
original: {
|
||||
key: 'files/orig.mp4',
|
||||
filesizeInBytes: 100,
|
||||
codec: '',
|
||||
},
|
||||
...overrides,
|
||||
}
|
||||
}
|
||||
|
||||
describe('Share API', () => {
|
||||
const app = new Hono()
|
||||
.route('/', publicShareRoute)
|
||||
@@ -65,6 +96,7 @@ describe('Share API', () => {
|
||||
id: 'share1',
|
||||
name: 'Public Share',
|
||||
isDisabled: false,
|
||||
allowDownload: false,
|
||||
isExpired: false,
|
||||
hasPassword: true,
|
||||
rootFolderId: 'folder1',
|
||||
@@ -88,6 +120,7 @@ describe('Share API', () => {
|
||||
const body = await res.json()
|
||||
expect(body.name).toBe('Public Share')
|
||||
expect(body.hasPassword).toBe(true)
|
||||
expect(body.allowDownload).toBe(false)
|
||||
expect(shareService.verifyPublicAccess).toHaveBeenCalledWith('folder1', 'pass')
|
||||
})
|
||||
|
||||
@@ -96,6 +129,7 @@ describe('Share API', () => {
|
||||
id: 'share1',
|
||||
name: 'Public Share',
|
||||
isDisabled: false,
|
||||
allowDownload: false,
|
||||
isExpired: false,
|
||||
hasPassword: true,
|
||||
rootFolderId: 'folder1',
|
||||
@@ -122,6 +156,7 @@ describe('Share API', () => {
|
||||
id: 'share1',
|
||||
name: 'Public Share',
|
||||
isDisabled: false,
|
||||
allowDownload: false,
|
||||
isExpired: false,
|
||||
hasPassword: true,
|
||||
rootFolderId: 'folder1',
|
||||
@@ -149,6 +184,7 @@ describe('Share API', () => {
|
||||
id: 'share1',
|
||||
name: 'My Share',
|
||||
isDisabled: false,
|
||||
allowDownload: false,
|
||||
rootFolderId: 'folder1',
|
||||
projectId: 'project1',
|
||||
password: null,
|
||||
@@ -180,6 +216,291 @@ describe('Share API', () => {
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
test('applies per-file watermark proxies when watermark enabled', async () => {
|
||||
vi.spyOn(shareService, 'verifyPublicAccess').mockResolvedValue({
|
||||
id: 'share1',
|
||||
name: 'My Share',
|
||||
isDisabled: false,
|
||||
allowDownload: false,
|
||||
rootFolderId: 'folder1',
|
||||
projectId: 'project1',
|
||||
password: null,
|
||||
expireAt: null,
|
||||
watermarkConfigId: 'cfg1',
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any)
|
||||
vi.spyOn(assetService, 'listChildren').mockResolvedValue({
|
||||
data: [
|
||||
{
|
||||
id: 'video-ready',
|
||||
name: 'a.mp4',
|
||||
sizeByte: 1,
|
||||
fileCount: 0,
|
||||
type: 'file',
|
||||
status: 'processed',
|
||||
proxyType: 'video',
|
||||
media: {
|
||||
proxyType: 'video',
|
||||
videoTranscodes: [
|
||||
{
|
||||
id: 'orig',
|
||||
url: 'u',
|
||||
key: 'files/orig.mp4',
|
||||
width: 640,
|
||||
height: 360,
|
||||
size: 1,
|
||||
},
|
||||
],
|
||||
imageTranscodes: [],
|
||||
original: { key: 'files/orig.mp4' },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'video-pending',
|
||||
name: 'b.mp4',
|
||||
sizeByte: 1,
|
||||
fileCount: 0,
|
||||
type: 'file',
|
||||
status: 'processed',
|
||||
proxyType: 'video',
|
||||
media: {
|
||||
proxyType: 'video',
|
||||
videoTranscodes: [
|
||||
{
|
||||
id: 'orig',
|
||||
url: 'u',
|
||||
key: 'files/orig.mp4',
|
||||
width: 640,
|
||||
height: 360,
|
||||
size: 1,
|
||||
},
|
||||
],
|
||||
imageTranscodes: [],
|
||||
original: { key: 'files/orig.mp4' },
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'doc',
|
||||
name: 'c.pdf',
|
||||
sizeByte: 1,
|
||||
fileCount: 0,
|
||||
type: 'file',
|
||||
status: 'processed',
|
||||
proxyType: 'pdf',
|
||||
media: {
|
||||
proxyType: 'pdf',
|
||||
pdfTranscode: { url: 'u', key: 'files/doc.pdf' },
|
||||
videoTranscodes: [],
|
||||
imageTranscodes: [],
|
||||
original: { key: 'files/doc.pdf' },
|
||||
},
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
] as any,
|
||||
pageInfo: { total: 3, cursor: undefined },
|
||||
})
|
||||
vi.spyOn(assetService, 'resolveTargetAssetId').mockImplementation(async (id) => id)
|
||||
vi.spyOn(s3Service, 'presign').mockResolvedValue('http://s3/presigned')
|
||||
vi.spyOn(watermarkService, 'getCompletedWatermarkMediaMap').mockResolvedValue(
|
||||
new Map([
|
||||
[
|
||||
'video-ready',
|
||||
watermarkMediaInfo({
|
||||
videoTranscodes: [{ key: 'files/wm-a.mp4', width: 640, height: 360 }],
|
||||
}),
|
||||
],
|
||||
]),
|
||||
)
|
||||
|
||||
const res = await app.request('/shares/share1/folders/folder1/children?assetType=file', {
|
||||
method: 'GET',
|
||||
headers: { 'x-share-password': 'pass' },
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
const body = await res.json()
|
||||
// Ready item → watermarked proxy
|
||||
expect(body.data[0].media.videoTranscodes).toEqual([
|
||||
{
|
||||
id: 'files/wm-a.mp4',
|
||||
url: 'http://s3/presigned',
|
||||
key: 'files/wm-a.mp4',
|
||||
width: 640,
|
||||
height: 360,
|
||||
size: 0,
|
||||
},
|
||||
])
|
||||
// Pending item → original transcodes emptied
|
||||
expect(body.data[1].media.videoTranscodes).toEqual([])
|
||||
expect(body.data[1].media.imageTranscodes).toEqual([])
|
||||
// Non-media item → untouched
|
||||
expect(body.data[2].media.pdfTranscode).toEqual({ url: 'u', key: 'files/doc.pdf' })
|
||||
})
|
||||
})
|
||||
|
||||
describe('GET /shares/:shareId/files/:fileId', () => {
|
||||
const shareLinkWithWatermark = {
|
||||
id: 'share1',
|
||||
name: 'My Share',
|
||||
isDisabled: false,
|
||||
allowDownload: false,
|
||||
rootFolderId: 'folder1',
|
||||
projectId: 'project1',
|
||||
password: null,
|
||||
expireAt: null,
|
||||
watermarkConfigId: 'cfg1',
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any
|
||||
|
||||
const videoAsset = {
|
||||
id: 'file1',
|
||||
name: 'video.mp4',
|
||||
sizeByte: 1024,
|
||||
fileCount: 0,
|
||||
type: 'file',
|
||||
status: 'processed',
|
||||
proxyType: 'video',
|
||||
media: {
|
||||
proxyType: 'video',
|
||||
videoTranscodes: [
|
||||
{
|
||||
id: 'orig-360p',
|
||||
url: 'http://s3/original-360p',
|
||||
key: 'files/original-360p.mp4',
|
||||
width: 640,
|
||||
height: 360,
|
||||
size: 100,
|
||||
},
|
||||
],
|
||||
imageTranscodes: [],
|
||||
original: { key: 'files/original.mp4' },
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any
|
||||
|
||||
beforeEach(() => {
|
||||
vi.spyOn(assetService, 'getAsset').mockResolvedValue(videoAsset)
|
||||
vi.spyOn(assetService, 'resolveTargetAssetId').mockResolvedValue('file1')
|
||||
vi.spyOn(s3Service, 'presign').mockResolvedValue('http://s3/presigned')
|
||||
})
|
||||
|
||||
test('serves watermarked transcodes when watermark enabled and completed', async () => {
|
||||
vi.spyOn(shareService, 'verifyPublicAccess').mockResolvedValue(shareLinkWithWatermark)
|
||||
vi.spyOn(watermarkService, 'getCompletedWatermarkMediaMap').mockResolvedValue(
|
||||
new Map([
|
||||
[
|
||||
'file1',
|
||||
watermarkMediaInfo({
|
||||
videoTranscodes: [{ key: 'files/watermarked-360p.mp4', width: 640, height: 360 }],
|
||||
}),
|
||||
],
|
||||
]),
|
||||
)
|
||||
|
||||
const res = await app.request('/shares/share1/files/file1', {
|
||||
method: 'GET',
|
||||
headers: { 'x-share-password': 'pass' },
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
const body = await res.json()
|
||||
expect(body.media.videoTranscodes).toEqual([
|
||||
{
|
||||
id: 'files/watermarked-360p.mp4',
|
||||
url: 'http://s3/presigned',
|
||||
key: 'files/watermarked-360p.mp4',
|
||||
width: 640,
|
||||
height: 360,
|
||||
size: 0,
|
||||
},
|
||||
])
|
||||
expect(body.media.imageTranscodes).toEqual([])
|
||||
})
|
||||
|
||||
test('serves empty transcode arrays while watermark transcoding is in flight', async () => {
|
||||
vi.spyOn(shareService, 'verifyPublicAccess').mockResolvedValue(shareLinkWithWatermark)
|
||||
vi.spyOn(watermarkService, 'getCompletedWatermarkMediaMap').mockResolvedValue(new Map())
|
||||
|
||||
const res = await app.request('/shares/share1/files/file1', {
|
||||
method: 'GET',
|
||||
headers: { 'x-share-password': 'pass' },
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
const body = await res.json()
|
||||
expect(body.media.videoTranscodes).toEqual([])
|
||||
expect(body.media.imageTranscodes).toEqual([])
|
||||
})
|
||||
|
||||
test('leaves non-video/image media untouched when watermark enabled', async () => {
|
||||
vi.spyOn(shareService, 'verifyPublicAccess').mockResolvedValue(shareLinkWithWatermark)
|
||||
vi.spyOn(assetService, 'getAsset').mockResolvedValue({
|
||||
id: 'file1',
|
||||
name: 'doc.pdf',
|
||||
sizeByte: 1024,
|
||||
fileCount: 0,
|
||||
type: 'file',
|
||||
status: 'processed',
|
||||
proxyType: 'pdf',
|
||||
media: {
|
||||
proxyType: 'pdf',
|
||||
pdfTranscode: { url: 'http://s3/doc', key: 'files/doc.pdf' },
|
||||
videoTranscodes: [],
|
||||
imageTranscodes: [],
|
||||
original: { key: 'files/doc.pdf' },
|
||||
},
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any)
|
||||
const resolveSpy = vi.spyOn(assetService, 'resolveTargetAssetId')
|
||||
const wfSpy = vi.spyOn(watermarkService, 'getCompletedWatermarkMediaMap')
|
||||
|
||||
const res = await app.request('/shares/share1/files/file1', {
|
||||
method: 'GET',
|
||||
headers: { 'x-share-password': 'pass' },
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
const body = await res.json()
|
||||
expect(body.media.pdfTranscode).toEqual({ url: 'http://s3/doc', key: 'files/doc.pdf' })
|
||||
expect(resolveSpy).not.toHaveBeenCalled()
|
||||
expect(wfSpy).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test('serves original media unchanged when watermark disabled', async () => {
|
||||
vi.spyOn(shareService, 'verifyPublicAccess').mockResolvedValue({
|
||||
id: 'share1',
|
||||
name: 'My Share',
|
||||
isDisabled: false,
|
||||
allowDownload: false,
|
||||
rootFolderId: 'folder1',
|
||||
projectId: 'project1',
|
||||
password: null,
|
||||
expireAt: null,
|
||||
watermarkConfigId: null,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any)
|
||||
const wfSpy = vi.spyOn(watermarkService, 'getCompletedWatermarkMediaMap')
|
||||
|
||||
const res = await app.request('/shares/share1/files/file1', {
|
||||
method: 'GET',
|
||||
headers: { 'x-share-password': 'pass' },
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
const body = await res.json()
|
||||
expect(body.media.videoTranscodes).toEqual([
|
||||
{
|
||||
id: 'orig-360p',
|
||||
url: 'http://s3/original-360p',
|
||||
key: 'files/original-360p.mp4',
|
||||
width: 640,
|
||||
height: 360,
|
||||
size: 100,
|
||||
},
|
||||
])
|
||||
expect(wfSpy).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
// Protected Routes
|
||||
@@ -189,6 +510,7 @@ describe('Share API', () => {
|
||||
id: 'share1',
|
||||
name: 'test-share',
|
||||
isDisabled: false,
|
||||
allowDownload: false,
|
||||
rootFolderId: 'root1',
|
||||
projectId: 'project1',
|
||||
isExpired: false,
|
||||
@@ -226,6 +548,34 @@ describe('Share API', () => {
|
||||
itemId: 'share1',
|
||||
})
|
||||
})
|
||||
|
||||
test('Passes allowDownload to service', async () => {
|
||||
vi.spyOn(shareService, 'createShareLink').mockResolvedValue({
|
||||
id: 'share1',
|
||||
name: 'test-share',
|
||||
isDisabled: false,
|
||||
allowDownload: false,
|
||||
rootFolderId: 'root1',
|
||||
projectId: 'project1',
|
||||
isExpired: false,
|
||||
hasPassword: false,
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
})
|
||||
|
||||
const res = await app.request('/projects/project1/shares', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ name: 'My Share', allowDownload: false }),
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(shareService.createShareLink).toHaveBeenCalledWith(
|
||||
'project1',
|
||||
{ name: 'My Share', allowDownload: false },
|
||||
'user1',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('GET /projects/:projectId/shares', () => {
|
||||
@@ -261,6 +611,7 @@ describe('Share API', () => {
|
||||
id: 'share1',
|
||||
name: 'test-share',
|
||||
isDisabled: false,
|
||||
allowDownload: false,
|
||||
rootFolderId: 'root1',
|
||||
projectId: 'project1',
|
||||
isExpired: false,
|
||||
@@ -291,6 +642,7 @@ describe('Share API', () => {
|
||||
id: 'share1',
|
||||
name: 'test-share',
|
||||
isDisabled: false,
|
||||
allowDownload: false,
|
||||
rootFolderId: 'root1',
|
||||
projectId: 'project1',
|
||||
isExpired: false,
|
||||
@@ -326,4 +678,147 @@ describe('Share API', () => {
|
||||
expect(shareService.addAssetToShare).toHaveBeenCalledWith('share1', { assetIds: ['asset1'] })
|
||||
})
|
||||
})
|
||||
|
||||
describe('Watermark API', () => {
|
||||
test('PUT /shares/:shareId/watermark success', async () => {
|
||||
const { watermarkService } = await import('@shumai/core/src/watermark/watermark')
|
||||
vi.spyOn(watermarkService, 'updateShareLinkWatermark').mockResolvedValue({
|
||||
id: 'share1',
|
||||
name: 'test-share',
|
||||
isDisabled: false,
|
||||
allowDownload: false,
|
||||
rootFolderId: 'root1',
|
||||
projectId: 'project1',
|
||||
isExpired: false,
|
||||
hasPassword: false,
|
||||
watermarkStatus: 'processing',
|
||||
watermarkConfigId: 'cfg1',
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
})
|
||||
|
||||
const res = await app.request('/shares/share1/watermark', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
enabled: true,
|
||||
config: {
|
||||
blocks: [
|
||||
{
|
||||
id: 'b1',
|
||||
type: 'text',
|
||||
x: 0.5,
|
||||
y: 0.5,
|
||||
opacity: 0.5,
|
||||
rotation: 0,
|
||||
text: 'TEST',
|
||||
size: 0.1,
|
||||
color: '#FFF',
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
const body = await res.json()
|
||||
expect(body.watermarkStatus).toBe('processing')
|
||||
})
|
||||
|
||||
test('PUT /shares/:shareId/watermark conflict 409', async () => {
|
||||
const { watermarkService } = await import('@shumai/core/src/watermark/watermark')
|
||||
const { ShareLinkWatermarkProcessingError } = await import('@shumai/core/src/share/errors')
|
||||
vi.spyOn(watermarkService, 'updateShareLinkWatermark').mockRejectedValue(
|
||||
new ShareLinkWatermarkProcessingError(),
|
||||
)
|
||||
|
||||
const res = await app.request('/shares/share1/watermark', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ enabled: false }),
|
||||
})
|
||||
|
||||
expect(res.status).toBe(409)
|
||||
const body = await res.json()
|
||||
expect(body.error).toBe('Watermark transcoding is currently in progress')
|
||||
})
|
||||
|
||||
test('PUT /shares/:shareId/watermark without config when enabled returns 400', async () => {
|
||||
const res = await app.request('/shares/share1/watermark', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ enabled: true }),
|
||||
})
|
||||
|
||||
expect(res.status).toBe(400)
|
||||
})
|
||||
|
||||
test('GET /shares/:shareId/watermark success', async () => {
|
||||
const { watermarkService } = await import('@shumai/core/src/watermark/watermark')
|
||||
vi.spyOn(watermarkService, 'getShareLinkWatermark').mockResolvedValue({
|
||||
watermarkStatus: 'ready',
|
||||
watermarkConfig: {
|
||||
id: 'cfg1',
|
||||
config: { blocks: [] },
|
||||
hash: 'h1',
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
},
|
||||
})
|
||||
|
||||
const res = await app.request('/shares/share1/watermark', {
|
||||
method: 'GET',
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
const body = await res.json()
|
||||
expect(body.watermarkStatus).toBe('ready')
|
||||
expect(body.watermarkConfig.hash).toBe('h1')
|
||||
})
|
||||
})
|
||||
|
||||
describe('POST /shares/:shareId/files/:fileId/download-url', () => {
|
||||
test('Success for symlink asset in share', async () => {
|
||||
vi.spyOn(shareService, 'verifyPublicAccess').mockResolvedValue({
|
||||
allowDownload: true,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any)
|
||||
vi.spyOn(assetService, 'getDownloadUrl').mockResolvedValue('https://s3.example.com/download')
|
||||
|
||||
const res = await app.request('/shares/share1/files/symlink1/download-url', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ key: 'files/target1/fly.png' }),
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
const body = await res.json()
|
||||
expect(body.url).toBe('https://s3.example.com/download')
|
||||
expect(shareService.verifyPublicAccess).toHaveBeenCalledWith('symlink1', undefined)
|
||||
expect(assetService.getDownloadUrl).toHaveBeenCalledWith('symlink1', 'files/target1/fly.png')
|
||||
})
|
||||
|
||||
test('Rejects when allowDownload is disabled', async () => {
|
||||
vi.spyOn(shareService, 'verifyPublicAccess').mockResolvedValue({
|
||||
id: 'share1',
|
||||
name: 'No Download',
|
||||
allowDownload: false,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any)
|
||||
const getDownloadUrlSpy = vi
|
||||
.spyOn(assetService, 'getDownloadUrl')
|
||||
.mockResolvedValue('https://s3.example.com/download')
|
||||
|
||||
const res = await app.request('/shares/share1/files/symlink1/download-url', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ key: 'files/target1/fly.png' }),
|
||||
})
|
||||
|
||||
expect(res.status).toBe(403)
|
||||
const body = await res.json()
|
||||
expect(body.error).toBe('Download is disabled for this share link')
|
||||
expect(getDownloadUrlSpy).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -8,10 +8,16 @@ import {
|
||||
updateShareLinkRequestSchema,
|
||||
listShareLinksRequestSchema,
|
||||
addAssetToShareRequestSchema,
|
||||
updateShareLinkWatermarkRequestSchema,
|
||||
AuditAction,
|
||||
} from '@shumai/dtos'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
import { watermarkService } from '@shumai/core/src/watermark/watermark'
|
||||
import {
|
||||
ShareLinkNotFoundError,
|
||||
ShareLinkWatermarkProcessingError,
|
||||
} from '@shumai/core/src/share/errors'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -183,5 +189,52 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
await shareService.removeAssetFromShare(shareId, assetId)
|
||||
return c.body(null, 204)
|
||||
})
|
||||
.put(
|
||||
'/shares/:shareId/watermark',
|
||||
zValidator('json', updateShareLinkWatermarkRequestSchema),
|
||||
async (c) => {
|
||||
const shareId = c.req.param('shareId')
|
||||
const user = c.get('user')
|
||||
const req = c.req.valid('json')
|
||||
|
||||
await authzService.hasPermission({
|
||||
user,
|
||||
permission: Permission.Edit,
|
||||
type: ResourceType.Share,
|
||||
id: shareId,
|
||||
})
|
||||
|
||||
try {
|
||||
const updated = await watermarkService.updateShareLinkWatermark(
|
||||
shareId,
|
||||
req.enabled,
|
||||
req.config,
|
||||
)
|
||||
return c.json(updated)
|
||||
} catch (err) {
|
||||
if (err instanceof ShareLinkWatermarkProcessingError) {
|
||||
return c.json({ error: err.message }, 409)
|
||||
}
|
||||
if (err instanceof ShareLinkNotFoundError) {
|
||||
return c.json({ error: err.message }, 404)
|
||||
}
|
||||
throw err
|
||||
}
|
||||
},
|
||||
)
|
||||
.get('/shares/:shareId/watermark', async (c) => {
|
||||
const shareId = c.req.param('shareId')
|
||||
const user = c.get('user')
|
||||
|
||||
await authzService.hasPermission({
|
||||
user,
|
||||
permission: Permission.Read,
|
||||
type: ResourceType.Share,
|
||||
id: shareId,
|
||||
})
|
||||
|
||||
const res = await watermarkService.getShareLinkWatermark(shareId)
|
||||
return c.json(res)
|
||||
})
|
||||
|
||||
export default route
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
import { describe, expect, test, vi, beforeEach } from 'vitest'
|
||||
import { Hono } from 'hono'
|
||||
import watermarkTemplateRoute from './watermark-template'
|
||||
import { authMiddleware } from './middleware/auth'
|
||||
import { authzService } from '@shumai/core/src/authz/authz'
|
||||
import { watermarkService } from '@shumai/core/src/watermark/watermark'
|
||||
import { teamService } from '@shumai/core/src/team/team'
|
||||
|
||||
vi.mock('./middleware/auth', () => ({
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
authMiddleware: async (c: any, next: any) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
c.set('user', { id: 'user1', name: 'Test User' } as any)
|
||||
await next()
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('@shumai/core/src/authz/authz', () => ({
|
||||
authzService: {
|
||||
hasPermission: vi.fn().mockResolvedValue(undefined),
|
||||
},
|
||||
Permission: {
|
||||
Read: 'Read',
|
||||
Edit: 'Edit',
|
||||
Admin: 'Admin',
|
||||
},
|
||||
ResourceType: {
|
||||
Team: 'team',
|
||||
},
|
||||
}))
|
||||
|
||||
describe('Watermark Template API', () => {
|
||||
const app = new Hono().use('*', authMiddleware).route('/', watermarkTemplateRoute)
|
||||
|
||||
beforeEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
vi.mocked(authzService.hasPermission).mockResolvedValue(undefined)
|
||||
})
|
||||
|
||||
test('GET /watermark-templates', async () => {
|
||||
vi.spyOn(watermarkService, 'listTemplates').mockResolvedValue([
|
||||
{
|
||||
id: 'tpl1',
|
||||
name: 'Preset 1',
|
||||
config: { blocks: [] },
|
||||
teamId: 't1',
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
},
|
||||
])
|
||||
|
||||
const res = await app.request('/watermark-templates?teamId=t1', {
|
||||
method: 'GET',
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
const body = await res.json()
|
||||
expect(body).toHaveLength(1)
|
||||
expect(body[0].name).toBe('Preset 1')
|
||||
})
|
||||
|
||||
test("GET /watermark-templates without teamId scopes to the caller's teams", async () => {
|
||||
vi.spyOn(teamService, 'getUserTeams').mockResolvedValue({
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
data: [{ id: 't1', name: 'My Team' }] as any,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
pageInfo: {} as any,
|
||||
})
|
||||
vi.spyOn(watermarkService, 'listTemplates').mockResolvedValue([])
|
||||
|
||||
const res = await app.request('/watermark-templates', {
|
||||
method: 'GET',
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(watermarkService.listTemplates).toHaveBeenCalledWith(['t1'])
|
||||
})
|
||||
|
||||
test('POST /watermark-templates', async () => {
|
||||
vi.spyOn(teamService, 'getUserTeams').mockResolvedValue({
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
data: [{ id: 't1', name: 'My Team' }] as any,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
pageInfo: {} as any,
|
||||
})
|
||||
vi.spyOn(watermarkService, 'createTemplate').mockResolvedValue({
|
||||
id: 'tpl1',
|
||||
name: 'New Preset',
|
||||
config: { blocks: [] },
|
||||
teamId: 't1',
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
})
|
||||
|
||||
const res = await app.request('/watermark-templates', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
name: 'New Preset',
|
||||
config: { blocks: [] },
|
||||
}),
|
||||
})
|
||||
|
||||
expect(res.status).toBe(201)
|
||||
const body = await res.json()
|
||||
expect(body.name).toBe('New Preset')
|
||||
})
|
||||
|
||||
test('DELETE /watermark-templates/:templateId', async () => {
|
||||
vi.spyOn(watermarkService, 'getTemplate').mockResolvedValue({
|
||||
id: 'tpl1',
|
||||
name: 'New Preset',
|
||||
config: { blocks: [] },
|
||||
teamId: 't1',
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
})
|
||||
vi.spyOn(watermarkService, 'deleteTemplate').mockResolvedValue(undefined)
|
||||
|
||||
const res = await app.request('/watermark-templates/tpl1', {
|
||||
method: 'DELETE',
|
||||
})
|
||||
|
||||
expect(res.status).toBe(204)
|
||||
expect(watermarkService.deleteTemplate).toHaveBeenCalledWith('tpl1')
|
||||
})
|
||||
|
||||
test('DELETE /watermark-templates/:templateId on a teamless template returns 403', async () => {
|
||||
vi.spyOn(watermarkService, 'getTemplate').mockResolvedValue({
|
||||
id: 'tpl-global',
|
||||
name: 'Platform Preset',
|
||||
config: { blocks: [] },
|
||||
teamId: null,
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
})
|
||||
vi.spyOn(watermarkService, 'deleteTemplate').mockResolvedValue(undefined)
|
||||
|
||||
const res = await app.request('/watermark-templates/tpl-global', {
|
||||
method: 'DELETE',
|
||||
})
|
||||
|
||||
expect(res.status).toBe(403)
|
||||
expect(watermarkService.deleteTemplate).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,145 @@
|
||||
import { Hono } from 'hono'
|
||||
import { zValidator } from '@hono/zod-validator'
|
||||
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
||||
import { teamService } from '@shumai/core/src/team/team'
|
||||
import { watermarkService } from '@shumai/core/src/watermark/watermark'
|
||||
import {
|
||||
createWatermarkTemplateRequestSchema,
|
||||
updateWatermarkTemplateRequestSchema,
|
||||
} from '@shumai/dtos'
|
||||
import { z } from 'zod'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
const listTemplatesQuerySchema = z.object({
|
||||
teamId: z.string().optional(),
|
||||
})
|
||||
|
||||
const route = new Hono<{ Variables: { user: User } }>()
|
||||
.get('/watermark-templates', zValidator('query', listTemplatesQuerySchema), async (c) => {
|
||||
const user = c.get('user')
|
||||
const { teamId } = c.req.valid('query')
|
||||
|
||||
let teamIds: string[]
|
||||
if (teamId) {
|
||||
await authzService.hasPermission({
|
||||
user,
|
||||
permission: Permission.Read,
|
||||
type: ResourceType.Team,
|
||||
id: teamId,
|
||||
})
|
||||
teamIds = [teamId]
|
||||
} else {
|
||||
// No teamId: scope to the caller's own teams so templates are never
|
||||
// leaked across tenants.
|
||||
const userTeams = await teamService.getUserTeams({
|
||||
userId: user.id,
|
||||
pagination: { first: 20 },
|
||||
})
|
||||
teamIds = userTeams.data.map((t) => t.id)
|
||||
}
|
||||
|
||||
const templates = await watermarkService.listTemplates(teamIds)
|
||||
return c.json(templates)
|
||||
})
|
||||
.get('/watermark-templates/:templateId', async (c) => {
|
||||
const templateId = c.req.param('templateId')
|
||||
const template = await watermarkService.getTemplate(templateId)
|
||||
|
||||
if (template.teamId) {
|
||||
const user = c.get('user')
|
||||
await authzService.hasPermission({
|
||||
user,
|
||||
permission: Permission.Read,
|
||||
type: ResourceType.Team,
|
||||
id: template.teamId,
|
||||
})
|
||||
}
|
||||
// Teamless templates are shared platform defaults: readable by any
|
||||
// authenticated user, but not writable (enforced on PUT/DELETE).
|
||||
|
||||
return c.json(template)
|
||||
})
|
||||
.post(
|
||||
'/watermark-templates',
|
||||
zValidator('json', createWatermarkTemplateRequestSchema),
|
||||
async (c) => {
|
||||
const user = c.get('user')
|
||||
const req = c.req.valid('json')
|
||||
|
||||
let teamId: string | null
|
||||
if (req.teamId) {
|
||||
await authzService.hasPermission({
|
||||
user,
|
||||
permission: Permission.Edit,
|
||||
type: ResourceType.Team,
|
||||
id: req.teamId,
|
||||
})
|
||||
teamId = req.teamId
|
||||
} else {
|
||||
const userTeams = await teamService.getUserTeams({
|
||||
userId: user.id,
|
||||
pagination: { first: 20 },
|
||||
})
|
||||
teamId = userTeams.data[0]?.id || null
|
||||
if (!teamId) {
|
||||
return c.json({ error: 'A team is required to create a watermark template' }, 400)
|
||||
}
|
||||
await authzService.hasPermission({
|
||||
user,
|
||||
permission: Permission.Edit,
|
||||
type: ResourceType.Team,
|
||||
id: teamId,
|
||||
})
|
||||
}
|
||||
|
||||
const template = await watermarkService.createTemplate(teamId, req.name, req.config)
|
||||
return c.json(template, 201)
|
||||
},
|
||||
)
|
||||
.put(
|
||||
'/watermark-templates/:templateId',
|
||||
zValidator('json', updateWatermarkTemplateRequestSchema),
|
||||
async (c) => {
|
||||
const templateId = c.req.param('templateId')
|
||||
const user = c.get('user')
|
||||
const req = c.req.valid('json')
|
||||
|
||||
const existing = await watermarkService.getTemplate(templateId)
|
||||
if (existing.teamId) {
|
||||
await authzService.hasPermission({
|
||||
user,
|
||||
permission: Permission.Edit,
|
||||
type: ResourceType.Team,
|
||||
id: existing.teamId,
|
||||
})
|
||||
} else {
|
||||
return c.json({ error: 'Platform templates are read-only' }, 403)
|
||||
}
|
||||
|
||||
const updated = await watermarkService.updateTemplate(templateId, req.name, req.config)
|
||||
return c.json(updated)
|
||||
},
|
||||
)
|
||||
.delete('/watermark-templates/:templateId', async (c) => {
|
||||
const templateId = c.req.param('templateId')
|
||||
const user = c.get('user')
|
||||
|
||||
const existing = await watermarkService.getTemplate(templateId)
|
||||
if (existing.teamId) {
|
||||
await authzService.hasPermission({
|
||||
user,
|
||||
permission: Permission.Edit,
|
||||
type: ResourceType.Team,
|
||||
id: existing.teamId,
|
||||
})
|
||||
} else {
|
||||
return c.json({ error: 'Platform templates are read-only' }, 403)
|
||||
}
|
||||
|
||||
await watermarkService.deleteTemplate(templateId)
|
||||
return c.body(null, 204)
|
||||
})
|
||||
|
||||
export default route
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/core",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.5",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -4,6 +4,7 @@ import { setupTestDbHooks } from '@shumai/db/test'
|
||||
import { HTTPException } from 'hono/http-exception'
|
||||
|
||||
import { AssetType, AssetStatus, Prisma } from '@shumai/db'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { AssetService } from './asset'
|
||||
|
||||
vi.mock('@shumai/core/src/s3/s3', () => ({
|
||||
@@ -2229,6 +2230,18 @@ describe('AssetService — natural sort by name', () => {
|
||||
for (const item of result) {
|
||||
expect(item.url).toBe('http://mock-s3-url')
|
||||
}
|
||||
|
||||
// Renamed file names must be passed to presign so the download
|
||||
// Content-Disposition header uses the asset name, not the storage key
|
||||
for (const name of ['file1.txt', 'file2.txt', 'version2.txt']) {
|
||||
expect(s3Service.presign).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
expect.any(String),
|
||||
'GET',
|
||||
true,
|
||||
name,
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it('resolves top-level symlinks to their targets when passed as direct starting IDs', async () => {
|
||||
@@ -2539,6 +2552,40 @@ describe('AssetService — natural sort by name', () => {
|
||||
)
|
||||
|
||||
expect(url).toBe('http://mock-s3-url')
|
||||
expect(s3Service.presign).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
'files/01TESTULID000000000000000/test-720p.mp4',
|
||||
'GET',
|
||||
true,
|
||||
'test.mp4',
|
||||
)
|
||||
})
|
||||
|
||||
it('should use the renamed asset name as the download filename', async () => {
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'foo.png',
|
||||
type: AssetType.file,
|
||||
status: AssetStatus.uploaded,
|
||||
storageKey: {
|
||||
create: { key: 'files/01RENAMEDULID0000000000000/test.png' },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const url = await assetService.getDownloadUrl(
|
||||
asset.id,
|
||||
'files/01RENAMEDULID0000000000000/test.png',
|
||||
)
|
||||
|
||||
expect(url).toBe('http://mock-s3-url')
|
||||
expect(s3Service.presign).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
'files/01RENAMEDULID0000000000000/test.png',
|
||||
'GET',
|
||||
true,
|
||||
'foo.png',
|
||||
)
|
||||
})
|
||||
|
||||
it('should return a presigned download URL for the original key', async () => {
|
||||
@@ -2617,6 +2664,35 @@ describe('AssetService — natural sort by name', () => {
|
||||
assetService.getDownloadUrl(asset.id, 'files/01TESTULID000000000000000/test.mp4'),
|
||||
).rejects.toThrow('Asset not found or has no storage key')
|
||||
})
|
||||
|
||||
it('should return a presigned download URL when given a symlink asset ID', async () => {
|
||||
const realAsset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'fly.png',
|
||||
type: AssetType.file,
|
||||
status: AssetStatus.uploaded,
|
||||
storageKey: {
|
||||
create: { key: 'files/01KZ8VH3QHKQCSQDC5JPXCYT0R/fly.png' },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const symlinkAsset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'fly.png',
|
||||
type: AssetType.symlink,
|
||||
status: AssetStatus.uploaded,
|
||||
targetId: realAsset.id,
|
||||
},
|
||||
})
|
||||
|
||||
const url = await assetService.getDownloadUrl(
|
||||
symlinkAsset.id,
|
||||
'files/01KZ8VH3QHKQCSQDC5JPXCYT0R/fly.png',
|
||||
)
|
||||
|
||||
expect(url).toBe('http://mock-s3-url')
|
||||
})
|
||||
})
|
||||
|
||||
describe('resolveLatestVersionId', () => {
|
||||
|
||||
@@ -22,6 +22,7 @@ import { HTTPException } from 'hono/http-exception'
|
||||
import { logger } from '@shumai/core/src/logger'
|
||||
import { PaginatedData, paginateQuery, PaginationParams } from '@shumai/core/src/pagination'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { watermarkService } from '@shumai/core/src/watermark/watermark'
|
||||
import { generateKeyBetween } from 'jittered-fractional-indexing'
|
||||
import { getAvatarUrl } from '@shumai/core/src/user/avatar'
|
||||
|
||||
@@ -852,13 +853,6 @@ export class AssetService {
|
||||
t.url = await s3Service.presign(process.env.S3_BUCKET || 'shumai', t.key, 'GET')
|
||||
}
|
||||
}
|
||||
if (info.media.original?.key) {
|
||||
info.media.original.downloadUrl = await s3Service.presign(
|
||||
process.env.S3_BUCKET || 'shumai',
|
||||
info.media.original.key,
|
||||
'GET',
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return info
|
||||
@@ -1104,6 +1098,7 @@ export class AssetService {
|
||||
await this.expireTrashedAssets()
|
||||
await this.purgePendingAssets()
|
||||
await this.purgeUnreferencedStorageKeys()
|
||||
await watermarkService.purgeOrphanWatermarkConfigs()
|
||||
} catch (e: unknown) {
|
||||
console.error('Error in asset cleanup job:', e)
|
||||
}
|
||||
@@ -1730,7 +1725,6 @@ export class AssetService {
|
||||
}
|
||||
media.original = {
|
||||
key,
|
||||
downloadUrl: await s3Service.presign(process.env.S3_BUCKET || 'shumai', key, 'GET'),
|
||||
filesizeInBytes: Number(latestVersion.sizeByte),
|
||||
codec: '',
|
||||
}
|
||||
@@ -1972,7 +1966,13 @@ export class AssetService {
|
||||
const key = file.storageKeyId ? storageKeyMap.get(file.storageKeyId) : null
|
||||
if (!key) return null
|
||||
|
||||
const url = await s3Service.presign(process.env.S3_BUCKET || 'shumai', key, 'GET', true)
|
||||
const url = await s3Service.presign(
|
||||
process.env.S3_BUCKET || 'shumai',
|
||||
key,
|
||||
'GET',
|
||||
true,
|
||||
file.name,
|
||||
)
|
||||
|
||||
return {
|
||||
id: file.id,
|
||||
@@ -1991,23 +1991,50 @@ export class AssetService {
|
||||
* that belong to an asset they have access to.
|
||||
*/
|
||||
async getDownloadUrl(assetId: string, key: string): Promise<string> {
|
||||
const targetAssetId = await this.resolveLatestVersionId(assetId)
|
||||
const asset = await this.prismaClient.asset.findUnique({
|
||||
where: { id: assetId },
|
||||
select: { storageKey: { select: { key: true } } },
|
||||
where: { id: targetAssetId },
|
||||
select: { id: true, name: true, parentId: true, storageKey: { select: { key: true } } },
|
||||
})
|
||||
|
||||
if (!asset?.storageKey?.key) {
|
||||
throw new Error('Asset not found or has no storage key')
|
||||
}
|
||||
|
||||
// Verify the requested key shares the same parent directory as the asset's storage key
|
||||
const storageKey = asset.storageKey.key
|
||||
const assetDir = storageKey.substring(0, storageKey.lastIndexOf('/') + 1)
|
||||
if (key.includes('..') || !key.startsWith(assetDir)) {
|
||||
if (key.includes('..')) {
|
||||
throw new Error('Key does not belong to this asset')
|
||||
}
|
||||
|
||||
return s3Service.presign(process.env.S3_BUCKET || 'shumai', key, 'GET', true)
|
||||
let storageKey = asset.storageKey.key
|
||||
let assetDir = storageKey.substring(0, storageKey.lastIndexOf('/') + 1)
|
||||
|
||||
if (!key.startsWith(assetDir) && asset.parentId) {
|
||||
// Check if requested key belongs to another version in the same version stack
|
||||
const sibling = await this.prismaClient.asset.findFirst({
|
||||
where: {
|
||||
parentId: asset.parentId,
|
||||
isDeleted: false,
|
||||
storageKey: { key: { startsWith: key.substring(0, key.lastIndexOf('/') + 1) } },
|
||||
},
|
||||
select: { storageKey: { select: { key: true } } },
|
||||
})
|
||||
if (sibling?.storageKey?.key) {
|
||||
storageKey = sibling.storageKey.key
|
||||
assetDir = storageKey.substring(0, storageKey.lastIndexOf('/') + 1)
|
||||
}
|
||||
}
|
||||
|
||||
if (!key.startsWith(assetDir)) {
|
||||
throw new Error('Key does not belong to this asset')
|
||||
}
|
||||
|
||||
return s3Service.presign(
|
||||
process.env.S3_BUCKET || 'shumai',
|
||||
key,
|
||||
'GET',
|
||||
true,
|
||||
asset.name ?? undefined,
|
||||
)
|
||||
}
|
||||
|
||||
private async toPreviewInfo(asset: Asset | AssetWithIncludes): Promise<PreviewInfo | null> {
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import * as os from 'os'
|
||||
import { GotenbergService } from './gotenberg'
|
||||
|
||||
describe('GotenbergService', () => {
|
||||
const originalEnv = process.env
|
||||
let tmpDir: string
|
||||
let testFilePath: string
|
||||
|
||||
beforeEach(() => {
|
||||
process.env = { ...originalEnv }
|
||||
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gotenberg-test-'))
|
||||
testFilePath = path.join(tmpDir, 'test.docx')
|
||||
fs.writeFileSync(testFilePath, 'fake docx content')
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
process.env = originalEnv
|
||||
fs.rmSync(tmpDir, { recursive: true, force: true })
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
describe('isAvailable', () => {
|
||||
it('should return false if GOTENBERG_URL is not set', async () => {
|
||||
delete process.env.GOTENBERG_URL
|
||||
const service = new GotenbergService()
|
||||
expect(await service.isAvailable()).toBe(false)
|
||||
})
|
||||
|
||||
it('should return false if GOTENBERG_URL is empty', async () => {
|
||||
process.env.GOTENBERG_URL = ' '
|
||||
const service = new GotenbergService()
|
||||
expect(await service.isAvailable()).toBe(false)
|
||||
})
|
||||
|
||||
it('should return true when health check returns 200 OK', async () => {
|
||||
process.env.GOTENBERG_URL = 'http://gotenberg:3000'
|
||||
const fetchSpy = vi.spyOn(globalThis, 'fetch').mockResolvedValue({
|
||||
ok: true,
|
||||
status: 200,
|
||||
} as Response)
|
||||
|
||||
const service = new GotenbergService()
|
||||
const available = await service.isAvailable()
|
||||
|
||||
expect(available).toBe(true)
|
||||
expect(fetchSpy).toHaveBeenCalledWith(
|
||||
'http://gotenberg:3000/health',
|
||||
expect.objectContaining({
|
||||
method: 'GET',
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('should include Basic Auth header if username and password are provided', async () => {
|
||||
process.env.GOTENBERG_URL = 'http://gotenberg:3000'
|
||||
process.env.GOTENBERG_BASIC_AUTH_USERNAME = 'user'
|
||||
process.env.GOTENBERG_BASIC_AUTH_PASSWORD = 'pass'
|
||||
|
||||
const fetchSpy = vi.spyOn(globalThis, 'fetch').mockResolvedValue({
|
||||
ok: true,
|
||||
status: 200,
|
||||
} as Response)
|
||||
|
||||
const service = new GotenbergService()
|
||||
await service.isAvailable()
|
||||
|
||||
const expectedBasic = Buffer.from('user:pass').toString('base64')
|
||||
expect(fetchSpy).toHaveBeenCalledWith(
|
||||
'http://gotenberg:3000/health',
|
||||
expect.objectContaining({
|
||||
headers: {
|
||||
Authorization: `Basic ${expectedBasic}`,
|
||||
},
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('should return false when fetch fails', async () => {
|
||||
process.env.GOTENBERG_URL = 'http://gotenberg:3000'
|
||||
vi.spyOn(globalThis, 'fetch').mockRejectedValue(new Error('Network error'))
|
||||
|
||||
const service = new GotenbergService()
|
||||
expect(await service.isAvailable()).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('convertDocumentToPdf', () => {
|
||||
it('should throw error if GOTENBERG_URL is not set', async () => {
|
||||
delete process.env.GOTENBERG_URL
|
||||
const service = new GotenbergService()
|
||||
await expect(service.convertDocumentToPdf(testFilePath, 'test.docx')).rejects.toThrow(
|
||||
'Gotenberg URL is not configured',
|
||||
)
|
||||
})
|
||||
|
||||
it('should call libreoffice convert endpoint and return buffer', async () => {
|
||||
process.env.GOTENBERG_URL = 'http://gotenberg:3000/'
|
||||
const mockPdfBuffer = Buffer.from('%PDF-1.7 mock output')
|
||||
const fetchSpy = vi.spyOn(globalThis, 'fetch').mockResolvedValue({
|
||||
ok: true,
|
||||
status: 200,
|
||||
arrayBuffer: async () => mockPdfBuffer.buffer,
|
||||
} as unknown as Response)
|
||||
|
||||
const service = new GotenbergService()
|
||||
const result = await service.convertDocumentToPdf(testFilePath, 'test.docx', {
|
||||
landscape: true,
|
||||
})
|
||||
|
||||
expect(result).toBeDefined()
|
||||
expect(result.toString()).toContain('%PDF-1.7')
|
||||
|
||||
expect(fetchSpy).toHaveBeenCalledWith(
|
||||
'http://gotenberg:3000/forms/libreoffice/convert',
|
||||
expect.objectContaining({
|
||||
method: 'POST',
|
||||
body: expect.any(FormData),
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('should throw error if gotenberg returns non-200', async () => {
|
||||
process.env.GOTENBERG_URL = 'http://gotenberg:3000'
|
||||
vi.spyOn(globalThis, 'fetch').mockResolvedValue({
|
||||
ok: false,
|
||||
status: 500,
|
||||
statusText: 'Internal Server Error',
|
||||
text: async () => 'Conversion failed',
|
||||
} as unknown as Response)
|
||||
|
||||
const service = new GotenbergService()
|
||||
await expect(service.convertDocumentToPdf(testFilePath, 'test.docx')).rejects.toThrow(
|
||||
'Gotenberg conversion failed with status 500: Conversion failed',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('convertHtmlToPdf', () => {
|
||||
it('should call chromium html convert endpoint and return buffer', async () => {
|
||||
process.env.GOTENBERG_URL = 'http://gotenberg:3000'
|
||||
const mockPdfBuffer = Buffer.from('%PDF-1.4 html output')
|
||||
const fetchSpy = vi.spyOn(globalThis, 'fetch').mockResolvedValue({
|
||||
ok: true,
|
||||
status: 200,
|
||||
arrayBuffer: async () => mockPdfBuffer.buffer,
|
||||
} as unknown as Response)
|
||||
|
||||
const htmlPath = path.join(tmpDir, 'test.html')
|
||||
fs.writeFileSync(htmlPath, '<h1>Hello</h1>')
|
||||
|
||||
const service = new GotenbergService()
|
||||
const result = await service.convertHtmlToPdf(htmlPath, 'test.html')
|
||||
|
||||
expect(result).toBeDefined()
|
||||
expect(fetchSpy).toHaveBeenCalledWith(
|
||||
'http://gotenberg:3000/forms/chromium/convert/html',
|
||||
expect.objectContaining({
|
||||
method: 'POST',
|
||||
}),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('convertMarkdownToPdf', () => {
|
||||
it('should call chromium markdown convert endpoint with index.html wrapper and return buffer', async () => {
|
||||
process.env.GOTENBERG_URL = 'http://gotenberg:3000'
|
||||
const mockPdfBuffer = Buffer.from('%PDF-1.4 markdown output')
|
||||
const fetchSpy = vi.spyOn(globalThis, 'fetch').mockResolvedValue({
|
||||
ok: true,
|
||||
status: 200,
|
||||
arrayBuffer: async () => mockPdfBuffer.buffer,
|
||||
} as unknown as Response)
|
||||
|
||||
const mdPath = path.join(tmpDir, 'test.md')
|
||||
fs.writeFileSync(mdPath, '# Hello Gotenberg')
|
||||
|
||||
const service = new GotenbergService()
|
||||
const result = await service.convertMarkdownToPdf(mdPath, 'test.md')
|
||||
|
||||
expect(result).toBeDefined()
|
||||
expect(fetchSpy).toHaveBeenCalledWith(
|
||||
'http://gotenberg:3000/forms/chromium/convert/markdown',
|
||||
expect.objectContaining({
|
||||
method: 'POST',
|
||||
body: expect.any(FormData),
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('should rename non-.md filenames like README.markdown to file.md for Gotenberg endpoint compatibility', async () => {
|
||||
process.env.GOTENBERG_URL = 'http://gotenberg:3000'
|
||||
const mockPdfBuffer = Buffer.from('%PDF-1.4 markdown output')
|
||||
let capturedFormData: FormData | null = null
|
||||
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(async (_url, options) => {
|
||||
capturedFormData = options?.body as FormData
|
||||
return {
|
||||
ok: true,
|
||||
status: 200,
|
||||
arrayBuffer: async () => mockPdfBuffer.buffer,
|
||||
} as unknown as Response
|
||||
})
|
||||
|
||||
const mdPath = path.join(tmpDir, 'README.markdown')
|
||||
fs.writeFileSync(mdPath, '# Hello Gotenberg')
|
||||
|
||||
const service = new GotenbergService()
|
||||
await service.convertMarkdownToPdf(mdPath, 'README.markdown')
|
||||
|
||||
expect(capturedFormData).not.toBeNull()
|
||||
const indexBlob = (capturedFormData as unknown as FormData).get('files') as File
|
||||
const indexHtmlText = await indexBlob.text()
|
||||
expect(indexHtmlText).toContain('{{ toHTML "file.md" }}')
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,178 @@
|
||||
import * as fs from 'fs'
|
||||
|
||||
export interface GotenbergConvertOptions {
|
||||
landscape?: boolean
|
||||
}
|
||||
|
||||
export class GotenbergService {
|
||||
private getUrl(): string | undefined {
|
||||
const url = process.env.GOTENBERG_URL?.trim()
|
||||
return url ? url.replace(/\/+$/, '') : undefined
|
||||
}
|
||||
|
||||
private getAuthHeader(): string | undefined {
|
||||
const username = process.env.GOTENBERG_BASIC_AUTH_USERNAME
|
||||
const password = process.env.GOTENBERG_BASIC_AUTH_PASSWORD
|
||||
|
||||
if (username && password) {
|
||||
const credentials = Buffer.from(`${username}:${password}`).toString('base64')
|
||||
return `Basic ${credentials}`
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
async isAvailable(): Promise<boolean> {
|
||||
const baseUrl = this.getUrl()
|
||||
if (!baseUrl) {
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
const headers: Record<string, string> = {}
|
||||
const authHeader = this.getAuthHeader()
|
||||
if (authHeader) {
|
||||
headers['Authorization'] = authHeader
|
||||
}
|
||||
|
||||
const response = await fetch(`${baseUrl}/health`, {
|
||||
method: 'GET',
|
||||
headers,
|
||||
signal: AbortSignal.timeout(3000),
|
||||
})
|
||||
|
||||
return response.ok
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
async convertDocumentToPdf(
|
||||
filePath: string,
|
||||
filename: string,
|
||||
options: GotenbergConvertOptions = {},
|
||||
): Promise<Buffer> {
|
||||
const baseUrl = this.getUrl()
|
||||
if (!baseUrl) {
|
||||
throw new Error('Gotenberg URL is not configured.')
|
||||
}
|
||||
|
||||
const fileBytes = fs.readFileSync(filePath)
|
||||
const formData = new FormData()
|
||||
formData.append('files', new Blob([fileBytes]), filename)
|
||||
|
||||
if (options.landscape) {
|
||||
formData.append('landscape', 'true')
|
||||
}
|
||||
|
||||
const headers: Record<string, string> = {}
|
||||
const authHeader = this.getAuthHeader()
|
||||
if (authHeader) {
|
||||
headers['Authorization'] = authHeader
|
||||
}
|
||||
|
||||
const response = await fetch(`${baseUrl}/forms/libreoffice/convert`, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: formData,
|
||||
signal: AbortSignal.timeout(60000),
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text().catch(() => '')
|
||||
throw new Error(
|
||||
`Gotenberg conversion failed with status ${response.status}: ${errorText || response.statusText}`,
|
||||
)
|
||||
}
|
||||
|
||||
const arrayBuffer = await response.arrayBuffer()
|
||||
return Buffer.from(arrayBuffer)
|
||||
}
|
||||
|
||||
async convertHtmlToPdf(filePath: string, filename: string): Promise<Buffer> {
|
||||
const baseUrl = this.getUrl()
|
||||
if (!baseUrl) {
|
||||
throw new Error('Gotenberg URL is not configured.')
|
||||
}
|
||||
|
||||
const fileBytes = fs.readFileSync(filePath)
|
||||
const formData = new FormData()
|
||||
const targetFilename =
|
||||
filename.toLowerCase().endsWith('.html') || filename.toLowerCase().endsWith('.htm')
|
||||
? filename
|
||||
: 'index.html'
|
||||
formData.append('files', new Blob([fileBytes]), targetFilename)
|
||||
|
||||
const headers: Record<string, string> = {}
|
||||
const authHeader = this.getAuthHeader()
|
||||
if (authHeader) {
|
||||
headers['Authorization'] = authHeader
|
||||
}
|
||||
|
||||
const response = await fetch(`${baseUrl}/forms/chromium/convert/html`, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: formData,
|
||||
signal: AbortSignal.timeout(60000),
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text().catch(() => '')
|
||||
throw new Error(
|
||||
`Gotenberg HTML conversion failed with status ${response.status}: ${errorText || response.statusText}`,
|
||||
)
|
||||
}
|
||||
|
||||
const arrayBuffer = await response.arrayBuffer()
|
||||
return Buffer.from(arrayBuffer)
|
||||
}
|
||||
|
||||
async convertMarkdownToPdf(filePath: string, filename: string): Promise<Buffer> {
|
||||
const baseUrl = this.getUrl()
|
||||
if (!baseUrl) {
|
||||
throw new Error('Gotenberg URL is not configured.')
|
||||
}
|
||||
|
||||
const mdFilename = filename.toLowerCase().endsWith('.md') ? filename : 'file.md'
|
||||
|
||||
const htmlTemplate = `<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>PDF</title>
|
||||
</head>
|
||||
<body>
|
||||
{{ toHTML "${mdFilename}" }}
|
||||
</body>
|
||||
</html>`
|
||||
|
||||
const fileBytes = fs.readFileSync(filePath)
|
||||
const formData = new FormData()
|
||||
formData.append('files', new Blob([htmlTemplate], { type: 'text/html' }), 'index.html')
|
||||
formData.append('files', new Blob([fileBytes]), mdFilename)
|
||||
|
||||
const headers: Record<string, string> = {}
|
||||
const authHeader = this.getAuthHeader()
|
||||
if (authHeader) {
|
||||
headers['Authorization'] = authHeader
|
||||
}
|
||||
|
||||
const response = await fetch(`${baseUrl}/forms/chromium/convert/markdown`, {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: formData,
|
||||
signal: AbortSignal.timeout(60000),
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text().catch(() => '')
|
||||
throw new Error(
|
||||
`Gotenberg Markdown conversion failed with status ${response.status}: ${errorText || response.statusText}`,
|
||||
)
|
||||
}
|
||||
|
||||
const arrayBuffer = await response.arrayBuffer()
|
||||
return Buffer.from(arrayBuffer)
|
||||
}
|
||||
}
|
||||
|
||||
export const gotenbergService = new GotenbergService()
|
||||
@@ -23,3 +23,5 @@ export * from './hyrumtoken'
|
||||
export * from './pagination'
|
||||
export * from './chat/chat'
|
||||
export * from './ai-usage/ai-usage'
|
||||
export * from './watermark/watermark'
|
||||
export * from './gotenberg/gotenberg'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import { LocalStorageService, S3StorageService } from './s3'
|
||||
import { buildContentDisposition, LocalStorageService, S3StorageService } from './s3'
|
||||
|
||||
// Mock Bun S3Client
|
||||
const s3ClientConstructorSpy = vi.fn()
|
||||
@@ -140,6 +140,32 @@ describe('S3Service implementations', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('should set contentDisposition with the filename when download filename is provided', async () => {
|
||||
const s3 = new S3StorageService('http://localhost:9000', 'key', 'secret', 'test-bucket')
|
||||
await s3.presign('bucket', 'key', 'GET', true, 'foo.png')
|
||||
|
||||
expect(s3PresignSpy).toHaveBeenCalledWith(
|
||||
'key',
|
||||
expect.objectContaining({
|
||||
contentDisposition: 'attachment; filename="foo.png"; filename*=UTF-8\'\'foo.png',
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('should include an RFC 5987 filename* for non-ASCII filenames', async () => {
|
||||
const s3 = new S3StorageService('http://localhost:9000', 'key', 'secret', 'test-bucket')
|
||||
await s3.presign('bucket', 'key', 'GET', true, '报告.png')
|
||||
|
||||
expect(s3PresignSpy).toHaveBeenCalledWith(
|
||||
'key',
|
||||
expect.objectContaining({
|
||||
// Non-ASCII names are conveyed only via filename* (percent-encoded),
|
||||
// keeping the header value pure ASCII (RFC 7230).
|
||||
contentDisposition: "attachment; filename*=UTF-8''%E6%8A%A5%E5%91%8A.png",
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('should not cache download presign URLs', async () => {
|
||||
const s3 = new S3StorageService('http://localhost:9000', 'key', 'secret', 'test-bucket')
|
||||
|
||||
@@ -248,6 +274,18 @@ describe('S3Service implementations', () => {
|
||||
expect(url).toBe('http://localhost:3000/files/my-bucket/dir/file.txt?download=1')
|
||||
})
|
||||
|
||||
it('should include an encoded filename in the local download URL', async () => {
|
||||
const url = await localS3.presign('my-bucket', 'dir/file.txt', 'GET', true, 'foo bar.png')
|
||||
expect(url).toBe(
|
||||
'http://localhost:3000/files/my-bucket/dir/file.txt?download=1&filename=foo%20bar.png',
|
||||
)
|
||||
})
|
||||
|
||||
it('should not append a filename param when none is provided', async () => {
|
||||
const url = await localS3.presign('my-bucket', 'dir/file.txt', 'GET', true)
|
||||
expect(url).not.toContain('filename=')
|
||||
})
|
||||
|
||||
it('should throw an error for unsupported presign methods', async () => {
|
||||
await expect(localS3.presign('b', 'k', 'POST')).rejects.toThrow()
|
||||
})
|
||||
@@ -287,4 +325,46 @@ describe('S3Service implementations', () => {
|
||||
expect(url).not.toContain('4567')
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildContentDisposition', () => {
|
||||
it('returns plain attachment when no filename is provided', () => {
|
||||
expect(buildContentDisposition()).toBe('attachment')
|
||||
expect(buildContentDisposition('')).toBe('attachment')
|
||||
expect(buildContentDisposition(null)).toBe('attachment')
|
||||
})
|
||||
|
||||
it('builds a disposition with quoted filename and RFC 5987 filename*', () => {
|
||||
expect(buildContentDisposition('foo.png')).toBe(
|
||||
'attachment; filename="foo.png"; filename*=UTF-8\'\'foo.png',
|
||||
)
|
||||
})
|
||||
|
||||
it('strips control characters and quotes to prevent header injection', () => {
|
||||
expect(buildContentDisposition('a\r\nb"c\\d')).toBe(
|
||||
'attachment; filename="abcd"; filename*=UTF-8\'\'abcd',
|
||||
)
|
||||
})
|
||||
|
||||
it('percent-encodes reserved RFC 5987 characters', () => {
|
||||
expect(buildContentDisposition("it's (final).png")).toBe(
|
||||
"attachment; filename=\"it's (final).png\"; filename*=UTF-8''it%27s%20%28final%29.png",
|
||||
)
|
||||
})
|
||||
|
||||
it('percent-encodes the * character in filename*', () => {
|
||||
expect(buildContentDisposition('foo*bar.png')).toBe(
|
||||
'attachment; filename="foo*bar.png"; filename*=UTF-8\'\'foo%2Abar.png',
|
||||
)
|
||||
})
|
||||
|
||||
it('omits the quoted filename fallback for non-ASCII names to keep the header ASCII', () => {
|
||||
expect(buildContentDisposition('幻境边界.pptx')).toBe(
|
||||
"attachment; filename*=UTF-8''%E5%B9%BB%E5%A2%83%E8%BE%B9%E7%95%8C.pptx",
|
||||
)
|
||||
// The whole header value must remain pure ASCII so Bun/Node Headers accept it
|
||||
expect(
|
||||
[...buildContentDisposition('幻境边界.pptx')].every((ch) => ch.charCodeAt(0) <= 0x7f),
|
||||
).toBe(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -27,6 +27,38 @@ export function verifyLocalUrlSignature(bucket: string, key: string, signature:
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Content-Disposition header value for downloads.
|
||||
* - Falls back to plain `attachment` when no filename is provided.
|
||||
* - Strips control characters (CR/LF header injection), quotes, and backslashes.
|
||||
* - Header values must be ASCII (RFC 7230): non-ASCII names are conveyed only
|
||||
* via the percent-encoded RFC 5987 `filename*` parameter; the quoted
|
||||
* `filename="..."` fallback is included only when the name is pure ASCII.
|
||||
*/
|
||||
export function buildContentDisposition(filename?: string | null): string {
|
||||
if (!filename) return 'attachment'
|
||||
// Strip C0 control characters (incl. CR/LF header injection) and DEL, then
|
||||
// quotes/backslashes which would break the quoted-string form.
|
||||
const sanitized = [...filename]
|
||||
.filter((ch) => {
|
||||
const code = ch.charCodeAt(0)
|
||||
return code > 0x1f && code !== 0x7f && ch !== '"' && ch !== '\\'
|
||||
})
|
||||
.join('')
|
||||
.trim()
|
||||
if (!sanitized) return 'attachment'
|
||||
// RFC 5987 attr-char excludes ' ( ) * — percent-encode them explicitly
|
||||
const encoded = encodeURIComponent(sanitized).replace(
|
||||
/['()*]/g,
|
||||
(c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`,
|
||||
)
|
||||
const isAscii = [...sanitized].every((ch) => ch.charCodeAt(0) <= 0x7f)
|
||||
if (!isAscii) {
|
||||
return `attachment; filename*=UTF-8''${encoded}`
|
||||
}
|
||||
return `attachment; filename="${sanitized}"; filename*=UTF-8''${encoded}`
|
||||
}
|
||||
|
||||
export interface S3Object {
|
||||
buffer: Buffer
|
||||
contentType: string
|
||||
@@ -55,7 +87,13 @@ export interface S3Service {
|
||||
listObjects: (bucket: string, prefix: string) => Promise<string[]>
|
||||
uploadFile: (filePath: string, contentType: string) => Promise<string>
|
||||
uploadFileToKey: (filePath: string, key: string, contentType: string) => Promise<void>
|
||||
presign: (bucket: string, key: string, method: string, download?: boolean) => Promise<string>
|
||||
presign: (
|
||||
bucket: string,
|
||||
key: string,
|
||||
method: string,
|
||||
download?: boolean,
|
||||
filename?: string,
|
||||
) => Promise<string>
|
||||
}
|
||||
|
||||
export class S3StorageService implements S3Service {
|
||||
@@ -214,7 +252,13 @@ export class S3StorageService implements S3Service {
|
||||
})
|
||||
}
|
||||
|
||||
async presign(bucket: string, key: string, method: string, download?: boolean): Promise<string> {
|
||||
async presign(
|
||||
bucket: string,
|
||||
key: string,
|
||||
method: string,
|
||||
download?: boolean,
|
||||
filename?: string,
|
||||
): Promise<string> {
|
||||
const expireHours = parseInt(process.env.PRESIGNED_URL_EXPIRES_IN || '5', 10)
|
||||
const expiresInSeconds = expireHours * 3600
|
||||
// Cache time is 2/3 of expire time, rounded to minute
|
||||
@@ -237,7 +281,7 @@ export class S3StorageService implements S3Service {
|
||||
}
|
||||
|
||||
if (download) {
|
||||
options.contentDisposition = 'attachment'
|
||||
options.contentDisposition = buildContentDisposition(filename)
|
||||
}
|
||||
|
||||
const url = this.client.presign(key, options)
|
||||
@@ -461,7 +505,13 @@ export class LocalStorageService implements S3Service {
|
||||
await fs.promises.copyFile(filePath, destPath)
|
||||
}
|
||||
|
||||
async presign(bucket: string, key: string, method: string, download?: boolean): Promise<string> {
|
||||
async presign(
|
||||
bucket: string,
|
||||
key: string,
|
||||
method: string,
|
||||
download?: boolean,
|
||||
filename?: string,
|
||||
): Promise<string> {
|
||||
if (method !== 'GET' && method !== 'PUT') {
|
||||
throw new Error(`Invalid method: ${method}`)
|
||||
}
|
||||
@@ -471,6 +521,9 @@ export class LocalStorageService implements S3Service {
|
||||
let url = `${this.endpoint}/files/${bucket}/${key}`
|
||||
if (download) {
|
||||
url += '?download=1'
|
||||
if (filename) {
|
||||
url += `&filename=${encodeURIComponent(filename)}`
|
||||
}
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
||||
@@ -29,3 +29,19 @@ export class ShareLinkPasswordInvalidError extends Error {
|
||||
Object.setPrototypeOf(this, ShareLinkPasswordInvalidError.prototype)
|
||||
}
|
||||
}
|
||||
|
||||
export class ShareLinkDownloadDisabledError extends Error {
|
||||
constructor(message: string) {
|
||||
super(message)
|
||||
this.name = 'ShareLinkDownloadDisabledError'
|
||||
Object.setPrototypeOf(this, ShareLinkDownloadDisabledError.prototype)
|
||||
}
|
||||
}
|
||||
|
||||
export class ShareLinkWatermarkProcessingError extends Error {
|
||||
constructor(message = 'Watermark transcoding is currently in progress') {
|
||||
super(message)
|
||||
this.name = 'ShareLinkWatermarkProcessingError'
|
||||
Object.setPrototypeOf(this, ShareLinkWatermarkProcessingError.prototype)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ describe('ShareService', () => {
|
||||
})
|
||||
|
||||
expect(shareLink.name).toBe('Public Share')
|
||||
expect(shareLink.allowDownload).toBe(true)
|
||||
expect(shareLink.rootFolderId).toBeDefined()
|
||||
|
||||
const asset = await prisma.asset.findUnique({
|
||||
@@ -62,6 +63,18 @@ describe('ShareService', () => {
|
||||
expect(asset?.projectId).toBe(projectId)
|
||||
})
|
||||
|
||||
it('creates a share link with allowDownload disabled', async () => {
|
||||
const shareLink = await shareService.createShareLink(projectId, {
|
||||
name: 'No Download Share',
|
||||
allowDownload: false,
|
||||
})
|
||||
|
||||
expect(shareLink.allowDownload).toBe(false)
|
||||
|
||||
const fetched = await shareService.getShareLink(shareLink.id)
|
||||
expect(fetched.allowDownload).toBe(false)
|
||||
})
|
||||
|
||||
it('adds multiple assets to share and handles duplicates', async () => {
|
||||
// Create real assets
|
||||
const file1 = await prisma.asset.create({
|
||||
@@ -244,6 +257,17 @@ describe('ShareService', () => {
|
||||
expect(rootAsset?.name).toBe('New Name')
|
||||
})
|
||||
|
||||
it('updates allowDownload on a share link', async () => {
|
||||
const shareLink = await shareService.createShareLink(projectId, { name: 'Toggle Share' })
|
||||
expect(shareLink.allowDownload).toBe(true)
|
||||
|
||||
const disabled = await shareService.updateShareLink(shareLink.id, { allowDownload: false })
|
||||
expect(disabled.allowDownload).toBe(false)
|
||||
|
||||
const reEnabled = await shareService.updateShareLink(shareLink.id, { allowDownload: true })
|
||||
expect(reEnabled.allowDownload).toBe(true)
|
||||
})
|
||||
|
||||
it('deletes a share link', async () => {
|
||||
const shareLink = await shareService.createShareLink(projectId, { name: 'To Delete' })
|
||||
await shareService.deleteShareLink(shareLink.id)
|
||||
|
||||
@@ -6,9 +6,11 @@ import {
|
||||
UpdateShareLinkRequest,
|
||||
ListShareLinksRequest,
|
||||
AddAssetToShareRequest,
|
||||
WatermarkConfigSpec,
|
||||
} from '@shumai/dtos'
|
||||
import { PaginatedData, paginateQuery } from '@shumai/core/src/pagination'
|
||||
import { getAvatarUrl } from '@shumai/core/src/user/avatar'
|
||||
import { watermarkService } from '@shumai/core/src/watermark/watermark'
|
||||
import {
|
||||
ShareLinkNotFoundError,
|
||||
ShareLinkDisabledError,
|
||||
@@ -63,6 +65,7 @@ export class ShareService {
|
||||
expireAt: req.expireAt ? new Date(req.expireAt) : null,
|
||||
password: req.password,
|
||||
isDisabled: req.isDisabled ?? false,
|
||||
allowDownload: req.allowDownload ?? true,
|
||||
defaultSortOrder: req.defaultSortOrder,
|
||||
viewMode: req.viewMode,
|
||||
projectId: projectId,
|
||||
@@ -90,6 +93,7 @@ export class ShareService {
|
||||
req.expireAt !== undefined ? (req.expireAt ? new Date(req.expireAt) : null) : undefined,
|
||||
password: req.password,
|
||||
isDisabled: req.isDisabled,
|
||||
allowDownload: req.allowDownload,
|
||||
defaultSortOrder: req.defaultSortOrder,
|
||||
viewMode: req.viewMode,
|
||||
fieldVisibility: (req.fieldVisibility as PrismaJson.ShareLinkFieldVisibility) ?? undefined,
|
||||
@@ -144,13 +148,16 @@ export class ShareService {
|
||||
)
|
||||
}
|
||||
|
||||
async getShareLink(shareLinkId: string): Promise<ShareLinkInfo> {
|
||||
const shareLink = await prisma.shareLink.findUnique({
|
||||
async getShareLink(
|
||||
shareLinkId: string,
|
||||
client: Prisma.TransactionClient | typeof prisma = prisma,
|
||||
): Promise<ShareLinkInfo> {
|
||||
const shareLink = await client.shareLink.findUnique({
|
||||
where: { id: shareLinkId },
|
||||
include: { creator: true },
|
||||
})
|
||||
if (!shareLink) throw new ShareLinkNotFoundError('Share link not found')
|
||||
return await this.toShareLinkInfo(shareLink)
|
||||
return await this.toShareLinkInfo(shareLink, client)
|
||||
}
|
||||
|
||||
async addAssetToShare(shareLinkId: string, req: AddAssetToShareRequest): Promise<number> {
|
||||
@@ -202,6 +209,17 @@ export class ShareService {
|
||||
})
|
||||
})
|
||||
|
||||
if (shareLink.watermarkConfigId) {
|
||||
await prisma.shareLink.update({
|
||||
where: { id: shareLinkId },
|
||||
data: { watermarkStatus: 'processing' },
|
||||
})
|
||||
await watermarkService.triggerWatermarkTranscodeForShareLink(
|
||||
shareLinkId,
|
||||
shareLink.watermarkConfigId,
|
||||
)
|
||||
}
|
||||
|
||||
return idsToAdd.length
|
||||
}
|
||||
|
||||
@@ -297,23 +315,43 @@ export class ShareService {
|
||||
return shareLink
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
private async toShareLinkInfo(l: any): Promise<ShareLinkInfo> {
|
||||
private async toShareLinkInfo(
|
||||
l: Prisma.ShareLinkGetPayload<{ include: { creator: true } }>,
|
||||
client: Prisma.TransactionClient | typeof prisma = prisma,
|
||||
): Promise<ShareLinkInfo> {
|
||||
const isExpired = l.expireAt ? new Date(l.expireAt) < new Date() : false
|
||||
const avatarUrl = l.creator ? await getAvatarUrl(l.creator.image) : undefined
|
||||
let watermarkConfig: Prisma.WatermarkConfigGetPayload<Record<string, never>> | null = null
|
||||
if (l.watermarkConfigId) {
|
||||
watermarkConfig = await client.watermarkConfig.findUnique({
|
||||
where: { id: l.watermarkConfigId },
|
||||
})
|
||||
}
|
||||
return {
|
||||
id: l.id,
|
||||
name: l.name,
|
||||
expireAt: l.expireAt?.toISOString(),
|
||||
isDisabled: l.isDisabled,
|
||||
allowDownload: l.allowDownload,
|
||||
hasPassword: !!l.password,
|
||||
password: l.password,
|
||||
defaultSortOrder: l.defaultSortOrder,
|
||||
viewMode: l.viewMode,
|
||||
defaultSortOrder: l.defaultSortOrder ?? undefined,
|
||||
viewMode: l.viewMode ?? undefined,
|
||||
fieldVisibility: l.fieldVisibility as Record<string, boolean> | undefined,
|
||||
rootFolderId: l.rootFolderId,
|
||||
projectId: l.projectId,
|
||||
isExpired,
|
||||
watermarkConfigId: l.watermarkConfigId,
|
||||
watermarkStatus: l.watermarkStatus || 'disabled',
|
||||
watermarkConfig: watermarkConfig
|
||||
? {
|
||||
id: watermarkConfig.id,
|
||||
config: await watermarkService.enrichWatermarkConfigWithPresignedUrls(
|
||||
watermarkConfig.config as WatermarkConfigSpec,
|
||||
),
|
||||
hash: watermarkConfig.hash,
|
||||
}
|
||||
: null,
|
||||
createdAt: l.createdAt.toISOString(),
|
||||
updatedAt: l.updatedAt.toISOString(),
|
||||
creator: l.creator ? { id: l.creator.id, name: l.creator.name, image: avatarUrl } : null,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
||||
import { transcodeService } from './transcode'
|
||||
import { transcodeService, calculatePreviewDimensions } from './transcode'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import * as path from 'path'
|
||||
import * as child_process from 'child_process'
|
||||
@@ -28,6 +28,7 @@ vi.mock('sharp', () => {
|
||||
toColorspace: vi.fn().mockReturnThis(),
|
||||
webp: vi.fn().mockReturnThis(),
|
||||
composite: vi.fn().mockReturnThis(),
|
||||
png: vi.fn().mockReturnThis(),
|
||||
toBuffer: vi.fn().mockResolvedValue(Buffer.from('fake-webp-buffer')),
|
||||
toFile: vi.fn().mockImplementation(async (filePath: string) => {
|
||||
fs.writeFileSync(filePath, 'fake-webp-data')
|
||||
@@ -184,18 +185,100 @@ describe('TranscodeService', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('should use sharp for image transcoding with sRGB conversion', async () => {
|
||||
it('should use sharp for image transcoding with sRGB conversion (production 300p spec)', async () => {
|
||||
const outputFile = path.join(tempDir, 'output.webp')
|
||||
await transcodeService.transcodeImage('input.png', outputFile, 480, 80)
|
||||
await transcodeService.transcodeImage('input.png', outputFile, 300, 80, { isPreview: true })
|
||||
|
||||
expect(sharp).toHaveBeenCalledWith('input.png', { limitInputPixels: false })
|
||||
const mockSharp = vi.mocked(sharp).mock.results[0].value
|
||||
expect(mockSharp.toColorspace).toHaveBeenCalledWith('srgb')
|
||||
expect(mockSharp.resize).toHaveBeenCalledWith(480, 7680, expect.any(Object))
|
||||
expect(mockSharp.resize).toHaveBeenCalledWith(400, 300, expect.any(Object))
|
||||
expect(mockSharp.webp).toHaveBeenCalledWith({ quality: 80 })
|
||||
expect(mockSharp.toFile).toHaveBeenCalledWith(outputFile)
|
||||
})
|
||||
|
||||
it('should support legacy 480 width fallback shim', async () => {
|
||||
const outputFile = path.join(tempDir, 'output_legacy.webp')
|
||||
await transcodeService.transcodeImage('input.png', outputFile, 480, 80)
|
||||
|
||||
const mockSharp = vi.mocked(sharp).mock.results[vi.mocked(sharp).mock.results.length - 1].value
|
||||
expect(mockSharp.resize).toHaveBeenCalledWith(400, 300, expect.any(Object))
|
||||
})
|
||||
|
||||
it('should handle preview and full-res proxy dimension calculations correctly', async () => {
|
||||
const outputFile = path.join(tempDir, 'out.webp')
|
||||
|
||||
// 16:9 source (1920x1080) in preview mode -> 533x300
|
||||
const mockSharp169 = {
|
||||
resize: vi.fn().mockReturnThis(),
|
||||
toColorspace: vi.fn().mockReturnThis(),
|
||||
webp: vi.fn().mockReturnThis(),
|
||||
toFile: vi.fn().mockResolvedValue({}),
|
||||
metadata: vi.fn().mockResolvedValue({ width: 1920, height: 1080 }),
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
vi.mocked(sharp).mockReturnValueOnce(mockSharp169 as any)
|
||||
await transcodeService.transcodeImage('169.png', outputFile, 300, 80, { isPreview: true })
|
||||
expect(mockSharp169.resize).toHaveBeenCalledWith(533, 300, expect.any(Object))
|
||||
|
||||
// Small image (200x150) in preview mode -> 200x150
|
||||
const mockSharpSmall = {
|
||||
resize: vi.fn().mockReturnThis(),
|
||||
toColorspace: vi.fn().mockReturnThis(),
|
||||
webp: vi.fn().mockReturnThis(),
|
||||
toFile: vi.fn().mockResolvedValue({}),
|
||||
metadata: vi.fn().mockResolvedValue({ width: 200, height: 150 }),
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
vi.mocked(sharp).mockReturnValueOnce(mockSharpSmall as any)
|
||||
await transcodeService.transcodeImage('small.png', outputFile, 300, 80, { isPreview: true })
|
||||
expect(mockSharpSmall.resize).toHaveBeenCalledWith(200, 150, expect.any(Object))
|
||||
|
||||
// 1:10 Tall screenshot (1000x10000) in preview mode -> 53x533
|
||||
const mockSharpTall = {
|
||||
resize: vi.fn().mockReturnThis(),
|
||||
toColorspace: vi.fn().mockReturnThis(),
|
||||
webp: vi.fn().mockReturnThis(),
|
||||
toFile: vi.fn().mockResolvedValue({}),
|
||||
metadata: vi.fn().mockResolvedValue({ width: 1000, height: 10000 }),
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
vi.mocked(sharp).mockReturnValueOnce(mockSharpTall as any)
|
||||
await transcodeService.transcodeImage('tall.png', outputFile, 300, 80, { isPreview: true })
|
||||
expect(mockSharpTall.resize).toHaveBeenCalledWith(53, 533, expect.any(Object))
|
||||
|
||||
// Square full-resolution proxy (10000x10000, isPreview: false) -> capped at WEBP_MAX_DIMENSION (7680)
|
||||
const mockSharpSquareProxy = {
|
||||
resize: vi.fn().mockReturnThis(),
|
||||
toColorspace: vi.fn().mockReturnThis(),
|
||||
webp: vi.fn().mockReturnThis(),
|
||||
toFile: vi.fn().mockResolvedValue({}),
|
||||
metadata: vi.fn().mockResolvedValue({ width: 10000, height: 10000 }),
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
vi.mocked(sharp).mockReturnValueOnce(mockSharpSquareProxy as any)
|
||||
await transcodeService.transcodeImage('square.png', outputFile, 10000, 90, {
|
||||
height: 10000,
|
||||
isPreview: false,
|
||||
})
|
||||
expect(mockSharpSquareProxy.resize).toHaveBeenCalledWith(7680, 7680, expect.any(Object))
|
||||
})
|
||||
|
||||
it('should calculate preview dimensions correctly for 300p (short side 300, max long side 533)', () => {
|
||||
// 16:9 Landscape
|
||||
expect(calculatePreviewDimensions(1920, 1080)).toEqual({ width: 533, height: 300 })
|
||||
// 9:16 Portrait
|
||||
expect(calculatePreviewDimensions(1080, 1920)).toEqual({ width: 300, height: 533 })
|
||||
// 1:1 Square
|
||||
expect(calculatePreviewDimensions(1000, 1000)).toEqual({ width: 300, height: 300 })
|
||||
// 21:9 Ultrawide
|
||||
expect(calculatePreviewDimensions(2560, 1080)).toEqual({ width: 533, height: 225 })
|
||||
// 1:10 Tall screenshot (capped at max long side = 533)
|
||||
expect(calculatePreviewDimensions(1000, 10000)).toEqual({ width: 53, height: 533 })
|
||||
// Small image (no enlargement)
|
||||
expect(calculatePreviewDimensions(200, 150)).toEqual({ width: 200, height: 150 })
|
||||
})
|
||||
|
||||
it('should use ImageMagick for PSD image transcoding', async () => {
|
||||
const outputFile = path.join(tempDir, 'output_psd.webp')
|
||||
const psdBuffer = Buffer.from('8BPS-fake-psd-content')
|
||||
@@ -263,7 +346,7 @@ describe('TranscodeService', () => {
|
||||
expect(sharp).toHaveBeenCalledWith(inputBuffer, { limitInputPixels: false })
|
||||
const mockSharp = vi.mocked(sharp).mock.results[vi.mocked(sharp).mock.results.length - 1].value
|
||||
expect(mockSharp.toColorspace).toHaveBeenCalledWith('srgb')
|
||||
expect(mockSharp.resize).toHaveBeenCalledWith(480, 7680, expect.any(Object))
|
||||
expect(mockSharp.resize).toHaveBeenCalledWith(400, 300, expect.any(Object))
|
||||
expect(mockSharp.webp).toHaveBeenCalledWith({ quality: 80 })
|
||||
expect(mockSharp.toFile).toHaveBeenCalledWith(outputFile)
|
||||
})
|
||||
@@ -450,7 +533,7 @@ describe('TranscodeService', () => {
|
||||
)
|
||||
expect(child_process.execFile).toHaveBeenCalledWith(
|
||||
'ffmpeg',
|
||||
expect.arrayContaining(['-filter_complex', 'scale=w=480:h=-2,tile=10x10']),
|
||||
expect.arrayContaining(['-filter_complex', 'scale=w=300:h=-2,tile=10x10']),
|
||||
expect.any(Function),
|
||||
)
|
||||
expect(child_process.execFile).toHaveBeenCalledWith(
|
||||
@@ -763,5 +846,55 @@ describe('TranscodeService', () => {
|
||||
const stat = fs.statSync(pdfFile)
|
||||
expect(stat.size).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
describe('watermark overlay helpers', () => {
|
||||
it('renderSvgToPng should rasterize the SVG to a PNG buffer', async () => {
|
||||
const svg = '<svg xmlns="http://www.w3.org/2000/svg"><text>WM</text></svg>'
|
||||
const result = await transcodeService.renderSvgToPng(svg)
|
||||
expect(Buffer.isBuffer(result)).toBe(true)
|
||||
// sharp was invoked with the SVG bytes
|
||||
expect(sharp).toHaveBeenCalledWith(Buffer.from(svg))
|
||||
})
|
||||
|
||||
it('downscaleImageToPng should resize, normalize to PNG and return dimensions', async () => {
|
||||
const result = await transcodeService.downscaleImageToPng(Buffer.from('raw-image'), 1024)
|
||||
expect(result.buffer).toBeDefined()
|
||||
expect(result.width).toBe(800)
|
||||
expect(result.height).toBe(600)
|
||||
// resize limited to the max dimension without enlargement
|
||||
const resizeCall = vi.mocked(sharp().resize).mock.calls[0] as unknown[]
|
||||
expect(resizeCall[0]).toBe(1024)
|
||||
expect(resizeCall[1]).toBe(1024)
|
||||
expect(resizeCall[2]).toEqual({
|
||||
fit: 'inside',
|
||||
withoutEnlargement: true,
|
||||
})
|
||||
expect(vi.mocked(sharp().png)).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('compositeOverlayToWebpFile should composite the overlay and write a webp file', async () => {
|
||||
const inputPath = path.join(tempDir, 'input.png')
|
||||
const outputPath = path.join(tempDir, 'output.webp')
|
||||
fs.writeFileSync(inputPath, 'fake-input')
|
||||
|
||||
await transcodeService.compositeOverlayToWebpFile(
|
||||
inputPath,
|
||||
Buffer.from('overlay-png'),
|
||||
outputPath,
|
||||
1920,
|
||||
1080,
|
||||
)
|
||||
|
||||
expect(fs.existsSync(outputPath)).toBe(true)
|
||||
expect(vi.mocked(sharp().resize)).toHaveBeenCalledWith(1920, 1080, {
|
||||
fit: 'inside',
|
||||
})
|
||||
expect(vi.mocked(sharp().composite)).toHaveBeenCalledWith([
|
||||
{ input: Buffer.from('overlay-png') },
|
||||
])
|
||||
expect(vi.mocked(sharp().webp)).toHaveBeenCalledWith({ quality: 90 })
|
||||
expect(vi.mocked(sharp().toFile)).toHaveBeenCalledWith(outputPath)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -110,6 +110,7 @@ export interface TranscodeVideoParams {
|
||||
height: number
|
||||
frameRate?: number | string
|
||||
disableAudio?: boolean
|
||||
overlayFile?: string
|
||||
}
|
||||
|
||||
export interface ExtractVideoFramesParams {
|
||||
@@ -144,6 +145,40 @@ export function isPsdInput(input: string | Buffer): boolean {
|
||||
input[3] === 0x53
|
||||
)
|
||||
}
|
||||
export function calculatePreviewDimensions(
|
||||
origW: number,
|
||||
origH: number,
|
||||
targetShort = 300,
|
||||
maxLong = 533,
|
||||
): { width: number; height: number } {
|
||||
if (origW <= 0 || origH <= 0) {
|
||||
return { width: targetShort, height: targetShort }
|
||||
}
|
||||
|
||||
const origShort = Math.min(origW, origH)
|
||||
const origLong = Math.max(origW, origH)
|
||||
|
||||
if (origShort <= targetShort && origLong <= maxLong) {
|
||||
return { width: origW, height: origH }
|
||||
}
|
||||
|
||||
let scale = targetShort / origShort
|
||||
const scaledLong = Math.round(origLong * scale)
|
||||
|
||||
if (scaledLong > maxLong) {
|
||||
scale = maxLong / origLong
|
||||
}
|
||||
|
||||
const newW = Math.max(1, Math.round(origW * scale))
|
||||
const newH = Math.max(1, Math.round(origH * scale))
|
||||
|
||||
return { width: newW, height: newH }
|
||||
}
|
||||
|
||||
export interface TranscodeImageOptions {
|
||||
height?: number | null
|
||||
isPreview?: boolean
|
||||
}
|
||||
|
||||
export class TranscodeService {
|
||||
constructor(private readonly prismaClient: typeof prisma = prisma) {}
|
||||
@@ -339,13 +374,22 @@ export class TranscodeService {
|
||||
}
|
||||
|
||||
async transcodeVideo(params: TranscodeVideoParams): Promise<void> {
|
||||
let filterComplex = `[0:v]scale=w=${params.width}:h=${params.height}:force_original_aspect_ratio=decrease,scale=w='trunc(iw/2)*2':h='trunc(ih/2)*2'`
|
||||
let filterComplex: string
|
||||
const args: string[] = ['-i', params.inputFile]
|
||||
|
||||
if (params.overlayFile) {
|
||||
args.push('-i', params.overlayFile)
|
||||
filterComplex = `[0:v]scale=${params.width}:${params.height}[vscaled];[vscaled][1:v]overlay=0:0`
|
||||
} else {
|
||||
filterComplex = `[0:v]scale=w=${params.width}:h=${params.height}:force_original_aspect_ratio=decrease,scale=w='trunc(iw/2)*2':h='trunc(ih/2)*2'`
|
||||
}
|
||||
|
||||
if (params.frameRate) {
|
||||
filterComplex += `,fps=${params.frameRate}`
|
||||
}
|
||||
filterComplex += '[vout]'
|
||||
|
||||
const args = ['-i', params.inputFile, '-filter_complex', filterComplex, '-map', '[vout]']
|
||||
args.push('-filter_complex', filterComplex, '-map', '[vout]')
|
||||
|
||||
if (params.frameRate) {
|
||||
let calculatedFps: number
|
||||
@@ -392,8 +436,22 @@ export class TranscodeService {
|
||||
outputFile: string,
|
||||
width: number,
|
||||
quality: number,
|
||||
height: number | null = null,
|
||||
heightOrOptions: number | null | TranscodeImageOptions = null,
|
||||
): Promise<void> {
|
||||
const height =
|
||||
typeof heightOrOptions === 'object' && heightOrOptions !== null
|
||||
? (heightOrOptions.height ?? null)
|
||||
: heightOrOptions
|
||||
let isPreview =
|
||||
typeof heightOrOptions === 'object' && heightOrOptions !== null
|
||||
? (heightOrOptions.isPreview ?? false)
|
||||
: false
|
||||
|
||||
// Backward compatibility shim for legacy queued tasks or old call signatures passing width 480 or height 0
|
||||
if (width === 480 || height === 0) {
|
||||
isPreview = true
|
||||
}
|
||||
|
||||
let input: string | Buffer = inputFile
|
||||
if (typeof inputFile === 'string' && inputFile.startsWith('http')) {
|
||||
const resp = await fetch(inputFile)
|
||||
@@ -404,8 +462,30 @@ export class TranscodeService {
|
||||
}
|
||||
|
||||
const WEBP_MAX_DIMENSION = 7680
|
||||
const targetW = width > 0 ? Math.min(width, WEBP_MAX_DIMENSION) : WEBP_MAX_DIMENSION
|
||||
const targetH = height && height > 0 ? Math.min(height, WEBP_MAX_DIMENSION) : WEBP_MAX_DIMENSION
|
||||
let targetW = width > 0 ? Math.min(width, WEBP_MAX_DIMENSION) : WEBP_MAX_DIMENSION
|
||||
let targetH = height && height > 0 ? Math.min(height, WEBP_MAX_DIMENSION) : WEBP_MAX_DIMENSION
|
||||
|
||||
const sharpInstance = sharp(input, { limitInputPixels: false })
|
||||
|
||||
if (isPreview) {
|
||||
try {
|
||||
const meta = await sharpInstance.metadata()
|
||||
if (meta.width && meta.height) {
|
||||
// Fallback shim: If legacy 480 caller passed width=480, map targetShort to 300
|
||||
const targetShort = width === 480 ? 300 : width
|
||||
const maxLong = Math.round((targetShort * 16) / 9)
|
||||
const dims = calculatePreviewDimensions(meta.width, meta.height, targetShort, maxLong)
|
||||
targetW = dims.width
|
||||
targetH = dims.height
|
||||
}
|
||||
} catch {
|
||||
// Fallback to targetW/targetH as calculated above
|
||||
}
|
||||
}
|
||||
|
||||
// WEBP_MAX_DIMENSION (7680) safety cap is ALWAYS enforced
|
||||
targetW = Math.min(targetW, WEBP_MAX_DIMENSION)
|
||||
targetH = Math.min(targetH, WEBP_MAX_DIMENSION)
|
||||
|
||||
if (isPsdInput(input)) {
|
||||
let psdPath: string
|
||||
@@ -442,8 +522,6 @@ export class TranscodeService {
|
||||
}
|
||||
}
|
||||
|
||||
const sharpInstance = sharp(input, { limitInputPixels: false })
|
||||
|
||||
sharpInstance.toColorspace('srgb').resize(targetW, targetH, {
|
||||
withoutEnlargement: true,
|
||||
fit: 'inside',
|
||||
@@ -459,7 +537,7 @@ export class TranscodeService {
|
||||
duration: number,
|
||||
): Promise<void> {
|
||||
const spriteFps = 100 / duration
|
||||
const filterComplex = `[0:v]fps=${spriteFps},scale=w=480:h=-2,tile=10x10[sprite_out];[0:v]scale=-2:480:force_original_aspect_ratio=decrease,select='eq(n\\,0)'[thumb_out]`
|
||||
const filterComplex = `[0:v]fps=${spriteFps},scale=w=300:h=-2,tile=10x10[sprite_out];[0:v]scale=-2:300:force_original_aspect_ratio=decrease,select='eq(n\\,0)'[thumb_out]`
|
||||
|
||||
const args = [
|
||||
'-i',
|
||||
@@ -547,7 +625,7 @@ export class TranscodeService {
|
||||
'-i',
|
||||
path.join(tmpDir, 'frame_%d.png'),
|
||||
'-filter_complex',
|
||||
'scale=w=480:h=-2,tile=10x10',
|
||||
'scale=w=300:h=-2,tile=10x10',
|
||||
'-frames:v',
|
||||
'1',
|
||||
'-c:v',
|
||||
@@ -560,7 +638,7 @@ export class TranscodeService {
|
||||
|
||||
await sharp(firstPagePath, { limitInputPixels: false })
|
||||
.toColorspace('srgb')
|
||||
.resize(480, null, { withoutEnlargement: true, fit: 'inside' })
|
||||
.resize(300, 533, { withoutEnlargement: true, fit: 'inside' })
|
||||
.webp({ quality: 75 })
|
||||
.toFile(outputPoster)
|
||||
|
||||
@@ -1148,6 +1226,55 @@ export class TranscodeService {
|
||||
this.removeDir(tmpDir)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders an SVG string to a PNG buffer. Used by the watermark workflow to
|
||||
* rasterize the overlay before compositing it onto images or feeding it to
|
||||
* ffmpeg for video overlays.
|
||||
*/
|
||||
async renderSvgToPng(svgString: string): Promise<Buffer> {
|
||||
return sharp(Buffer.from(svgString)).png().toBuffer()
|
||||
}
|
||||
|
||||
/**
|
||||
* Downscales an image buffer to a bounded size and normalizes it to PNG.
|
||||
* Used for watermark block images embedded into the SVG overlay, so large
|
||||
* logo assets don't balloon the SVG/base64 payload.
|
||||
*/
|
||||
async downscaleImageToPng(
|
||||
buffer: Buffer,
|
||||
maxDimension: number,
|
||||
): Promise<{ buffer: Buffer; width: number; height: number }> {
|
||||
const processed = await sharp(buffer, { limitInputPixels: false })
|
||||
.resize(maxDimension, maxDimension, { fit: 'inside', withoutEnlargement: true })
|
||||
.png()
|
||||
.toBuffer()
|
||||
const meta = await sharp(processed).metadata()
|
||||
return {
|
||||
buffer: processed,
|
||||
width: meta.width || 100,
|
||||
height: meta.height || 100,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Composites an overlay PNG onto an image file and writes a WebP file.
|
||||
* Used by the watermark workflow to produce watermarked image proxies.
|
||||
*/
|
||||
async compositeOverlayToWebpFile(
|
||||
inputPath: string,
|
||||
overlayPngBuffer: Buffer,
|
||||
outputPath: string,
|
||||
width: number,
|
||||
height: number,
|
||||
): Promise<void> {
|
||||
await sharp(inputPath, { limitInputPixels: false })
|
||||
.toColorspace('srgb')
|
||||
.resize(width, height, { fit: 'inside' })
|
||||
.composite([{ input: overlayPngBuffer }])
|
||||
.webp({ quality: 90 })
|
||||
.toFile(outputPath)
|
||||
}
|
||||
}
|
||||
|
||||
function renderAnnotationsToSvg(
|
||||
|
||||
@@ -2,6 +2,7 @@ import { describe, expect, it, vi, beforeEach } from 'vitest'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db/test'
|
||||
import { uploadService } from './upload'
|
||||
import { gotenbergService } from '@shumai/core/src/gotenberg/gotenberg'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { AssetStatus, AssetType, WorkflowTaskType } from '@shumai/db'
|
||||
|
||||
@@ -262,6 +263,132 @@ describe('UploadService', () => {
|
||||
expect(workflowTask).toBeNull()
|
||||
})
|
||||
|
||||
it('should confirm file upload and create transcode_pdf for office document when Gotenberg is available', async () => {
|
||||
vi.spyOn(gotenbergService, 'isAvailable').mockResolvedValue(true)
|
||||
const task = await prisma.task.create({
|
||||
data: { creatorId: userId, total: 1, uploaded: 0, type: 'upload' },
|
||||
})
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'document.docx',
|
||||
type: AssetType.file,
|
||||
project: { connect: { id: projectId } },
|
||||
parent: { connect: { id: parentId } },
|
||||
status: AssetStatus.uploading,
|
||||
storageKey: {
|
||||
connectOrCreate: {
|
||||
where: { key: 'test-key' },
|
||||
create: { key: 'test-key' },
|
||||
},
|
||||
},
|
||||
mediaType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
},
|
||||
})
|
||||
|
||||
await uploadService.confirmFileUpload(userId, task.id, { fileId: asset.id })
|
||||
|
||||
const workflowTask = await prisma.workflowTask.findFirst({
|
||||
where: { assetId: asset.id, type: WorkflowTaskType.transcode_pdf },
|
||||
})
|
||||
expect(workflowTask).toBeDefined()
|
||||
})
|
||||
|
||||
it('should mark asset processed without creating transcode_pdf for office document when Gotenberg is unavailable', async () => {
|
||||
vi.spyOn(gotenbergService, 'isAvailable').mockResolvedValue(false)
|
||||
const task = await prisma.task.create({
|
||||
data: { creatorId: userId, total: 1, uploaded: 0, type: 'upload' },
|
||||
})
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'document.docx',
|
||||
type: AssetType.file,
|
||||
project: { connect: { id: projectId } },
|
||||
parent: { connect: { id: parentId } },
|
||||
status: AssetStatus.uploading,
|
||||
storageKey: {
|
||||
connectOrCreate: {
|
||||
where: { key: 'test-key' },
|
||||
create: { key: 'test-key' },
|
||||
},
|
||||
},
|
||||
mediaType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
},
|
||||
})
|
||||
|
||||
await uploadService.confirmFileUpload(userId, task.id, { fileId: asset.id })
|
||||
|
||||
const updatedAsset = await prisma.asset.findUnique({ where: { id: asset.id } })
|
||||
expect(updatedAsset?.status).toBe(AssetStatus.processed)
|
||||
|
||||
const workflowTask = await prisma.workflowTask.findFirst({
|
||||
where: { assetId: asset.id, type: WorkflowTaskType.transcode_pdf },
|
||||
})
|
||||
expect(workflowTask).toBeNull()
|
||||
})
|
||||
|
||||
it('should confirm file upload and create transcode_pdf for HTML document when Gotenberg is available', async () => {
|
||||
vi.spyOn(gotenbergService, 'isAvailable').mockResolvedValue(true)
|
||||
const task = await prisma.task.create({
|
||||
data: { creatorId: userId, total: 1, uploaded: 0, type: 'upload' },
|
||||
})
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'index.html',
|
||||
type: AssetType.file,
|
||||
project: { connect: { id: projectId } },
|
||||
parent: { connect: { id: parentId } },
|
||||
status: AssetStatus.uploading,
|
||||
storageKey: {
|
||||
connectOrCreate: {
|
||||
where: { key: 'test-key-html-1' },
|
||||
create: { key: 'test-key-html-1' },
|
||||
},
|
||||
},
|
||||
mediaType: 'text/html',
|
||||
},
|
||||
})
|
||||
|
||||
await uploadService.confirmFileUpload(userId, task.id, { fileId: asset.id })
|
||||
|
||||
const workflowTask = await prisma.workflowTask.findFirst({
|
||||
where: { assetId: asset.id, type: WorkflowTaskType.transcode_pdf },
|
||||
})
|
||||
expect(workflowTask).toBeDefined()
|
||||
})
|
||||
|
||||
it('should mark asset processed without creating transcode_pdf for HTML document when Gotenberg is unavailable', async () => {
|
||||
vi.spyOn(gotenbergService, 'isAvailable').mockResolvedValue(false)
|
||||
const task = await prisma.task.create({
|
||||
data: { creatorId: userId, total: 1, uploaded: 0, type: 'upload' },
|
||||
})
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'index.html',
|
||||
type: AssetType.file,
|
||||
project: { connect: { id: projectId } },
|
||||
parent: { connect: { id: parentId } },
|
||||
status: AssetStatus.uploading,
|
||||
storageKey: {
|
||||
connectOrCreate: {
|
||||
where: { key: 'test-key-html-2' },
|
||||
create: { key: 'test-key-html-2' },
|
||||
},
|
||||
},
|
||||
mediaType: 'text/html',
|
||||
},
|
||||
})
|
||||
|
||||
await uploadService.confirmFileUpload(userId, task.id, { fileId: asset.id })
|
||||
|
||||
const updatedAsset = await prisma.asset.findUnique({ where: { id: asset.id } })
|
||||
expect(updatedAsset?.status).toBe(AssetStatus.processed)
|
||||
|
||||
const workflowTask = await prisma.workflowTask.findFirst({
|
||||
where: { assetId: asset.id, type: WorkflowTaskType.transcode_pdf },
|
||||
})
|
||||
expect(workflowTask).toBeNull()
|
||||
})
|
||||
|
||||
it('should confirm file upload and resolve empty mediaType using Bun resolver for audio', async () => {
|
||||
const task = await prisma.task.create({
|
||||
data: { creatorId: userId, total: 1, uploaded: 0, type: 'upload' },
|
||||
|
||||
@@ -13,8 +13,9 @@ import {
|
||||
import { ImageTranscoder, PdfTranscoder, VideoTranscoder } from '@shumai/transcode'
|
||||
import { generateKeyBetween } from 'jittered-fractional-indexing'
|
||||
import { ulid } from 'ulid'
|
||||
import { gotenbergService } from '@shumai/core/src/gotenberg/gotenberg'
|
||||
import { sanitizeFilename } from '@shumai/core/src/utils/filename'
|
||||
import { getProxyType } from '@shumai/core/src/utils/mime'
|
||||
import { getProxyType, isHtmlDocument, isOfficeDocument } from '@shumai/core/src/utils/mime'
|
||||
|
||||
export class UploadService {
|
||||
constructor(private readonly prismaClient: typeof prisma = prisma) {}
|
||||
@@ -315,6 +316,20 @@ export class UploadService {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
await new ImageTranscoder(tx as any, asset.id, team.id, projectId).withThumbnail().submit()
|
||||
} else if (isPdf) {
|
||||
const isOffice = isOfficeDocument(asset.mediaType, asset.name)
|
||||
const isHtml = isHtmlDocument(asset.mediaType, asset.name)
|
||||
|
||||
if (isOffice || isHtml) {
|
||||
const gotenbergAvailable = await gotenbergService.isAvailable()
|
||||
if (!gotenbergAvailable) {
|
||||
await tx.asset.update({
|
||||
where: { id: asset.id },
|
||||
data: { status: AssetStatus.processed },
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
await new PdfTranscoder(tx as any, asset.id, team.id, projectId)
|
||||
.withSprite()
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { detectSupportedMimeType, getProxyType } from './mime'
|
||||
import {
|
||||
detectSupportedMimeType,
|
||||
getProxyType,
|
||||
isOfficeDocument,
|
||||
isHtmlDocument,
|
||||
isMarkdownDocument,
|
||||
isCsvDocument,
|
||||
} from './mime'
|
||||
|
||||
describe('detectSupportedMimeType', () => {
|
||||
it('should detect JPEG', () => {
|
||||
@@ -45,6 +52,38 @@ describe('detectSupportedMimeType', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('document helpers', () => {
|
||||
it('isOfficeDocument should correctly identify office files', () => {
|
||||
expect(isOfficeDocument('application/msword', 'letter.doc')).toBe(true)
|
||||
expect(
|
||||
isOfficeDocument(
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'file.docx',
|
||||
),
|
||||
).toBe(true)
|
||||
expect(isOfficeDocument(null, 'sheet.xlsx')).toBe(true)
|
||||
expect(isOfficeDocument(null, 'slides.pptx')).toBe(true)
|
||||
expect(isOfficeDocument(null, 'notes.rtf')).toBe(true)
|
||||
expect(isOfficeDocument('text/plain', 'notes.txt')).toBe(false)
|
||||
})
|
||||
|
||||
it('isHtmlDocument should correctly identify html files', () => {
|
||||
expect(isHtmlDocument('text/html', 'page.html')).toBe(true)
|
||||
expect(isHtmlDocument(null, 'index.htm')).toBe(true)
|
||||
expect(isHtmlDocument('text/plain', 'notes.txt')).toBe(false)
|
||||
})
|
||||
|
||||
it('isMarkdownDocument should correctly identify markdown files', () => {
|
||||
expect(isMarkdownDocument('text/markdown', 'README.md')).toBe(true)
|
||||
expect(isMarkdownDocument(null, 'doc.markdown')).toBe(true)
|
||||
})
|
||||
|
||||
it('isCsvDocument should correctly identify csv files', () => {
|
||||
expect(isCsvDocument('text/csv', 'data.csv')).toBe(true)
|
||||
expect(isCsvDocument(null, 'data.csv')).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('getProxyType', () => {
|
||||
it('should detect image proxyType', () => {
|
||||
expect(getProxyType('image/png', 'test.png')).toBe('image')
|
||||
@@ -61,21 +100,20 @@ describe('getProxyType', () => {
|
||||
expect(getProxyType('audio/mpeg', 'song.mp3')).toBe('audio')
|
||||
})
|
||||
|
||||
it('should detect pdf proxyType only for pdf, csv, txt, and markdown files', () => {
|
||||
it('should detect pdf proxyType for pdf, csv, txt, markdown, html, and office files', () => {
|
||||
expect(getProxyType('application/pdf', 'doc.pdf')).toBe('pdf')
|
||||
expect(getProxyType('text/plain', 'notes.txt')).toBe('pdf')
|
||||
expect(getProxyType('text/csv', 'data.csv')).toBe('pdf')
|
||||
expect(getProxyType('text/markdown', 'README.md')).toBe('pdf')
|
||||
expect(getProxyType('text/x-markdown', 'doc.markdown')).toBe('pdf')
|
||||
expect(getProxyType(null, 'file.txt')).toBe('pdf')
|
||||
expect(getProxyType(null, 'README.md')).toBe('pdf')
|
||||
expect(getProxyType(null, 'doc.markdown')).toBe('pdf')
|
||||
expect(getProxyType('text/html', 'index.html')).toBe('pdf')
|
||||
expect(getProxyType('application/msword', 'letter.doc')).toBe('pdf')
|
||||
expect(getProxyType(null, 'sheet.xlsx')).toBe('pdf')
|
||||
expect(getProxyType(null, 'slides.pptx')).toBe('pdf')
|
||||
})
|
||||
|
||||
it('should return null for unsupported files including office files', () => {
|
||||
it('should return null for unsupported files', () => {
|
||||
expect(getProxyType('application/zip', 'archive.zip')).toBeNull()
|
||||
expect(getProxyType('application/msword', 'letter.doc')).toBeNull()
|
||||
expect(getProxyType(null, 'sheet.xlsx')).toBeNull()
|
||||
expect(getProxyType(null, 'unknown.bin')).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,5 +1,71 @@
|
||||
export type ProxyType = 'image' | 'video' | 'audio' | 'pdf'
|
||||
|
||||
export function isOfficeDocument(mediaType?: string | null, filename?: string | null): boolean {
|
||||
const lowerMediaType = mediaType?.toLowerCase() || ''
|
||||
const lowerFilename = filename?.toLowerCase() || ''
|
||||
|
||||
if (
|
||||
lowerMediaType === 'application/msword' ||
|
||||
lowerMediaType === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
|
||||
lowerMediaType === 'application/vnd.ms-excel' ||
|
||||
lowerMediaType === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ||
|
||||
lowerMediaType === 'application/vnd.ms-powerpoint' ||
|
||||
lowerMediaType ===
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation' ||
|
||||
lowerMediaType === 'application/vnd.oasis.opendocument.text' ||
|
||||
lowerMediaType === 'application/vnd.oasis.opendocument.spreadsheet' ||
|
||||
lowerMediaType === 'application/vnd.oasis.opendocument.presentation' ||
|
||||
lowerMediaType === 'application/rtf' ||
|
||||
lowerMediaType === 'text/rtf'
|
||||
) {
|
||||
return true
|
||||
}
|
||||
|
||||
const officeExtensions = [
|
||||
'.doc',
|
||||
'.docx',
|
||||
'.xls',
|
||||
'.xlsx',
|
||||
'.ppt',
|
||||
'.pptx',
|
||||
'.odt',
|
||||
'.ods',
|
||||
'.odp',
|
||||
'.rtf',
|
||||
]
|
||||
return officeExtensions.some((ext) => lowerFilename.endsWith(ext))
|
||||
}
|
||||
|
||||
export function isHtmlDocument(mediaType?: string | null, filename?: string | null): boolean {
|
||||
const lowerMediaType = mediaType?.toLowerCase() || ''
|
||||
const lowerFilename = filename?.toLowerCase() || ''
|
||||
|
||||
return (
|
||||
lowerMediaType === 'text/html' ||
|
||||
lowerFilename.endsWith('.html') ||
|
||||
lowerFilename.endsWith('.htm')
|
||||
)
|
||||
}
|
||||
|
||||
export function isMarkdownDocument(mediaType?: string | null, filename?: string | null): boolean {
|
||||
const lowerMediaType = mediaType?.toLowerCase() || ''
|
||||
const lowerFilename = filename?.toLowerCase() || ''
|
||||
|
||||
return (
|
||||
lowerMediaType === 'text/markdown' ||
|
||||
lowerMediaType === 'text/x-markdown' ||
|
||||
lowerFilename.endsWith('.md') ||
|
||||
lowerFilename.endsWith('.markdown')
|
||||
)
|
||||
}
|
||||
|
||||
export function isCsvDocument(mediaType?: string | null, filename?: string | null): boolean {
|
||||
const lowerMediaType = mediaType?.toLowerCase() || ''
|
||||
const lowerFilename = filename?.toLowerCase() || ''
|
||||
|
||||
return lowerMediaType === 'text/csv' || lowerFilename.endsWith('.csv')
|
||||
}
|
||||
|
||||
export function getProxyType(
|
||||
mediaType?: string | null,
|
||||
filename?: string | null,
|
||||
@@ -14,14 +80,12 @@ export function getProxyType(
|
||||
if (
|
||||
lowerMediaType === 'application/pdf' ||
|
||||
lowerMediaType === 'text/plain' ||
|
||||
lowerMediaType === 'text/csv' ||
|
||||
lowerMediaType === 'text/markdown' ||
|
||||
lowerMediaType === 'text/x-markdown' ||
|
||||
lowerFilename.endsWith('.pdf') ||
|
||||
lowerFilename.endsWith('.txt') ||
|
||||
lowerFilename.endsWith('.csv') ||
|
||||
lowerFilename.endsWith('.md') ||
|
||||
lowerFilename.endsWith('.markdown')
|
||||
isCsvDocument(mediaType, filename) ||
|
||||
isMarkdownDocument(mediaType, filename) ||
|
||||
isHtmlDocument(mediaType, filename) ||
|
||||
isOfficeDocument(mediaType, filename)
|
||||
) {
|
||||
return 'pdf'
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import type { WatermarkConfigSpec } from '@shumai/dtos'
|
||||
|
||||
export function computeWatermarkConfigHash(config: WatermarkConfigSpec): string {
|
||||
const blockStrings = config.blocks.map((block) => {
|
||||
if (block.type === 'text') {
|
||||
return `text|x:${block.x.toFixed(4)}|y:${block.y.toFixed(4)}|op:${block.opacity.toFixed(2)}|rot:${block.rotation.toFixed(2)}|sz:${block.size.toFixed(4)}|col:${block.color.toLowerCase()}|txt:${block.text}`
|
||||
} else {
|
||||
return `image|x:${block.x.toFixed(4)}|y:${block.y.toFixed(4)}|op:${block.opacity.toFixed(2)}|rot:${block.rotation.toFixed(2)}|sz:${block.size.toFixed(4)}|img:${block.imageAssetKey}`
|
||||
}
|
||||
})
|
||||
blockStrings.sort()
|
||||
const str = blockStrings.join(';')
|
||||
return Bun.hash(str).toString(16)
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import type { WatermarkConfigSpec } from '@shumai/dtos'
|
||||
|
||||
export interface RenderBlockImageData {
|
||||
imageAssetKey: string
|
||||
base64Data: string
|
||||
mimeType: string
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
|
||||
function escapeXml(unsafe: string): string {
|
||||
return unsafe
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
}
|
||||
|
||||
export function generateWatermarkSvg(
|
||||
config: WatermarkConfigSpec,
|
||||
canvasWidth: number,
|
||||
canvasHeight: number,
|
||||
blockImagesMap: Map<string, RenderBlockImageData> = new Map(),
|
||||
): string {
|
||||
const elements: string[] = []
|
||||
|
||||
for (const block of config.blocks) {
|
||||
const cx = canvasWidth * block.x
|
||||
const cy = canvasHeight * block.y
|
||||
const opacity = Math.max(0, Math.min(1, block.opacity))
|
||||
const rotation = block.rotation || 0
|
||||
|
||||
if (block.type === 'text') {
|
||||
// block.size is a FRACTION of the canvas width (0..1), so the watermark
|
||||
// scales proportionally with the output resolution. The editor must store
|
||||
// size as a fraction too (it converts from its %/px UI controls).
|
||||
const fontSize = Math.max(1, Math.round(canvasWidth * block.size))
|
||||
const textContent = escapeXml(block.text || '')
|
||||
const fill = escapeXml(block.color || '#FFFFFF')
|
||||
|
||||
elements.push(
|
||||
`<text x="${cx}" y="${cy}" text-anchor="middle" dominant-baseline="central" font-family="sans-serif" font-size="${fontSize}" font-weight="bold" fill="${fill}" opacity="${opacity}" transform="rotate(${rotation}, ${cx}, ${cy})">${textContent}</text>`,
|
||||
)
|
||||
} else if (block.type === 'image') {
|
||||
const imageData = blockImagesMap.get(block.imageAssetKey)
|
||||
if (!imageData) continue
|
||||
|
||||
// Fraction of canvas width, same as the text blocks above.
|
||||
const targetWidth = Math.max(1, Math.round(canvasWidth * block.size))
|
||||
const aspectRatio = imageData.height > 0 ? imageData.width / imageData.height : 1
|
||||
const targetHeight = Math.max(1, Math.round(targetWidth / aspectRatio))
|
||||
|
||||
const x = cx - targetWidth / 2
|
||||
const y = cy - targetHeight / 2
|
||||
|
||||
elements.push(
|
||||
`<image x="${x}" y="${y}" width="${targetWidth}" height="${targetHeight}" href="data:${imageData.mimeType};base64,${imageData.base64Data}" opacity="${opacity}" transform="rotate(${rotation}, ${cx}, ${cy})"/>`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return `<svg xmlns="http://www.w3.org/2000/svg" width="${canvasWidth}" height="${canvasHeight}">${elements.join(
|
||||
'\n',
|
||||
)}</svg>`
|
||||
}
|
||||
@@ -0,0 +1,543 @@
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db/test'
|
||||
import { watermarkService } from '@shumai/core/src/watermark/watermark'
|
||||
import { generateWatermarkSvg } from '@shumai/core/src/watermark/watermark-svg'
|
||||
import { shareService } from '@shumai/core/src/share/share'
|
||||
import { teamService } from '@shumai/core/src/team/team'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { computeWatermarkConfigHash } from '@shumai/core/src/watermark/watermark-hash'
|
||||
import type { WatermarkConfigSpec } from '@shumai/dtos'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
describe('WatermarkService', () => {
|
||||
setupTestDbHooks()
|
||||
|
||||
const sampleConfig: WatermarkConfigSpec = {
|
||||
blocks: [
|
||||
{
|
||||
id: 'block-1',
|
||||
type: 'text',
|
||||
x: 0.5,
|
||||
y: 0.5,
|
||||
opacity: 0.8,
|
||||
rotation: -30,
|
||||
text: 'CONFIDENTIAL',
|
||||
size: 0.2,
|
||||
color: '#FF0000',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
it('should compute deterministic hash ignoring block id and block order', () => {
|
||||
const config1: WatermarkConfigSpec = {
|
||||
blocks: [
|
||||
{
|
||||
id: 'b1',
|
||||
type: 'text',
|
||||
x: 0.5,
|
||||
y: 0.5,
|
||||
opacity: 0.5,
|
||||
rotation: 0,
|
||||
text: 'A',
|
||||
size: 0.1,
|
||||
color: '#FFFFFF',
|
||||
},
|
||||
{
|
||||
id: 'b2',
|
||||
type: 'text',
|
||||
x: 0.1,
|
||||
y: 0.1,
|
||||
opacity: 0.9,
|
||||
rotation: 15,
|
||||
text: 'B',
|
||||
size: 0.2,
|
||||
color: '#000000',
|
||||
},
|
||||
],
|
||||
}
|
||||
const config2: WatermarkConfigSpec = {
|
||||
blocks: [
|
||||
{
|
||||
id: 'other-id-2',
|
||||
type: 'text',
|
||||
x: 0.1,
|
||||
y: 0.1,
|
||||
opacity: 0.9,
|
||||
rotation: 15,
|
||||
text: 'B',
|
||||
size: 0.2,
|
||||
color: '#000000',
|
||||
},
|
||||
{
|
||||
id: 'other-id-1',
|
||||
type: 'text',
|
||||
x: 0.5,
|
||||
y: 0.5,
|
||||
opacity: 0.5,
|
||||
rotation: 0,
|
||||
text: 'A',
|
||||
size: 0.1,
|
||||
color: '#FFFFFF',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const hash1 = computeWatermarkConfigHash(config1)
|
||||
const hash2 = computeWatermarkConfigHash(config2)
|
||||
expect(hash1).toBe(hash2)
|
||||
})
|
||||
|
||||
it('should generate SVG overlay XML', () => {
|
||||
const svg = generateWatermarkSvg(sampleConfig, 1000, 500)
|
||||
expect(svg).toContain('<svg')
|
||||
expect(svg).toContain('CONFIDENTIAL')
|
||||
expect(svg).toContain('fill="#FF0000"')
|
||||
})
|
||||
|
||||
it('should upsert watermark config by hash', async () => {
|
||||
const config1 = await watermarkService.upsertConfig(sampleConfig)
|
||||
expect(config1.id).toBeDefined()
|
||||
|
||||
const config2 = await watermarkService.upsertConfig(sampleConfig)
|
||||
expect(config2.id).toBe(config1.id)
|
||||
})
|
||||
|
||||
it('should not race when upserting the same config concurrently', async () => {
|
||||
const results = await Promise.all(
|
||||
Array.from({ length: 10 }, () => watermarkService.upsertConfig(sampleConfig)),
|
||||
)
|
||||
const ids = new Set(results.map((r) => r.id))
|
||||
expect(ids.size).toBe(1)
|
||||
})
|
||||
|
||||
it('should manage watermark templates (CRUD)', async () => {
|
||||
const user = await prisma.user.create({
|
||||
data: { name: 'Test User', email: 'test-wm-tpl@example.com' },
|
||||
})
|
||||
const team = await teamService.createTeam(user, { name: 'Watermark Team' })
|
||||
|
||||
const created = await watermarkService.createTemplate(team.id, 'Draft Preset', sampleConfig)
|
||||
expect(created.id).toBeDefined()
|
||||
expect(created.name).toBe('Draft Preset')
|
||||
|
||||
const list = await watermarkService.listTemplates(team.id)
|
||||
expect(list.length).toBe(1)
|
||||
|
||||
const updated = await watermarkService.updateTemplate(created.id, 'Final Preset')
|
||||
expect(updated.name).toBe('Final Preset')
|
||||
|
||||
const fetched = await watermarkService.getTemplate(created.id)
|
||||
expect(fetched.name).toBe('Final Preset')
|
||||
|
||||
await watermarkService.deleteTemplate(created.id)
|
||||
const emptyList = await watermarkService.listTemplates(team.id)
|
||||
expect(emptyList.length).toBe(0)
|
||||
})
|
||||
|
||||
it('should update sharelink watermark and dispatch transcode tasks', async () => {
|
||||
const user = await prisma.user.create({
|
||||
data: { name: 'Share User', email: 'share-wm@example.com' },
|
||||
})
|
||||
const team = await teamService.createTeam(user, { name: 'Share Team' })
|
||||
|
||||
const projectFolder = await prisma.asset.create({
|
||||
data: { name: 'root', type: 'root', status: 'processed' },
|
||||
})
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'Test Project', teamId: team.id, rootFolderId: projectFolder.id },
|
||||
})
|
||||
|
||||
const shareLink = await shareService.createShareLink(project.id, { name: 'My Share' }, user.id)
|
||||
|
||||
// Add a file asset to project and share link
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'sample.mp4',
|
||||
type: 'file',
|
||||
mediaType: 'video/mp4',
|
||||
status: 'processed',
|
||||
projectId: project.id,
|
||||
},
|
||||
})
|
||||
await shareService.addAssetToShare(shareLink.id, { assetIds: [asset.id] })
|
||||
|
||||
// Update sharelink watermark -> enable
|
||||
const updated = await watermarkService.updateShareLinkWatermark(
|
||||
shareLink.id,
|
||||
true,
|
||||
sampleConfig,
|
||||
)
|
||||
expect(updated.watermarkStatus).toBe('processing')
|
||||
expect(updated.watermarkConfigId).toBeDefined()
|
||||
|
||||
// Verify WorkflowTask was created
|
||||
const tasks = await prisma.workflowTask.findMany({
|
||||
where: { assetId: asset.id, type: 'transcode_watermark' },
|
||||
})
|
||||
expect(tasks.length).toBeGreaterThan(0)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
expect((tasks[0].payload as any)?.watermark?.watermarkConfigId).toBe(updated.watermarkConfigId)
|
||||
|
||||
// Attempting update while status is processing should throw conflict error
|
||||
await expect(
|
||||
watermarkService.updateShareLinkWatermark(shareLink.id, true, sampleConfig),
|
||||
).rejects.toThrow('Watermark transcoding is currently in progress')
|
||||
|
||||
// Simulate completion of transcoding
|
||||
await prisma.shareLink.update({
|
||||
where: { id: shareLink.id },
|
||||
data: { watermarkStatus: 'ready' },
|
||||
})
|
||||
|
||||
// Disable watermark after ready
|
||||
const disabled = await watermarkService.updateShareLinkWatermark(shareLink.id, false)
|
||||
expect(disabled.watermarkStatus).toBe('disabled')
|
||||
expect(disabled.watermarkConfigId).toBeNull()
|
||||
})
|
||||
|
||||
it('should resolve media assets including nested symlinks in shared folders', async () => {
|
||||
const user = await prisma.user.create({
|
||||
data: { name: 'Nested User', email: 'nested-wm@example.com' },
|
||||
})
|
||||
const team = await teamService.createTeam(user, { name: 'Nested Team' })
|
||||
|
||||
const projectFolder = await prisma.asset.create({
|
||||
data: { name: 'root', type: 'root', status: 'processed' },
|
||||
})
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'Nested Project', teamId: team.id, rootFolderId: projectFolder.id },
|
||||
})
|
||||
|
||||
const shareLink = await shareService.createShareLink(
|
||||
project.id,
|
||||
{ name: 'Nested Share' },
|
||||
user.id,
|
||||
)
|
||||
|
||||
// Shared folder -> inner folder -> symlink -> media file
|
||||
const sharedFolder = await prisma.asset.create({
|
||||
data: { name: 'shared', type: 'folder', status: 'processed', projectId: project.id },
|
||||
})
|
||||
const innerFolder = await prisma.asset.create({
|
||||
data: { name: 'inner', type: 'folder', status: 'processed', projectId: project.id },
|
||||
})
|
||||
const mediaFile = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'clip.mp4',
|
||||
type: 'file',
|
||||
mediaType: 'video/mp4',
|
||||
status: 'processed',
|
||||
projectId: project.id,
|
||||
parentId: innerFolder.id,
|
||||
},
|
||||
})
|
||||
// symlink inside the shared folder points at the inner folder
|
||||
await prisma.asset.create({
|
||||
data: {
|
||||
name: 'inner-link',
|
||||
type: 'symlink',
|
||||
status: 'processed',
|
||||
projectId: project.id,
|
||||
parentId: sharedFolder.id,
|
||||
targetId: innerFolder.id,
|
||||
},
|
||||
})
|
||||
// root symlink for the share points at the shared folder
|
||||
await prisma.asset.create({
|
||||
data: {
|
||||
name: 'shared-link',
|
||||
type: 'symlink',
|
||||
status: 'processed',
|
||||
projectId: project.id,
|
||||
parentId: shareLink.rootFolderId,
|
||||
targetId: sharedFolder.id,
|
||||
},
|
||||
})
|
||||
|
||||
const mediaIds = await watermarkService.getMediaAssetIdsInShareLink(shareLink.rootFolderId)
|
||||
expect(mediaIds).toContain(mediaFile.id)
|
||||
})
|
||||
|
||||
describe('purgeOrphanWatermarkConfigs', () => {
|
||||
const bucket = 'shumai-gc-test-bucket'
|
||||
|
||||
beforeEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
process.env.S3_BUCKET = bucket
|
||||
})
|
||||
|
||||
// Media with every proxy slot the GC should delete from S3 (plus an
|
||||
// `original` key that must survive).
|
||||
function proxyMedia(): PrismaJson.MediaInfo {
|
||||
return {
|
||||
duration: 0,
|
||||
filesize: 100,
|
||||
frames: 0,
|
||||
proxyType: 'video',
|
||||
videoTranscodes: [
|
||||
{ key: 'files/gc/wm.mp4', width: 1920, height: 1080, resolution: '1080p' },
|
||||
],
|
||||
imageTranscodes: [
|
||||
{ key: 'files/gc/wm.webp', width: 1280, height: 720, quality: 90, format: 'webp' },
|
||||
],
|
||||
videoPreview: { key: 'files/gc/preview.mp4', width: 1280, height: 720 },
|
||||
thumbnail: {
|
||||
key: 'files/gc/thumb.webp',
|
||||
width: 320,
|
||||
height: 180,
|
||||
quality: 90,
|
||||
format: 'webp',
|
||||
},
|
||||
finishedAt: new Date().toISOString(),
|
||||
metadata: null,
|
||||
original: { key: 'files/gc/original.mp4', filesizeInBytes: 0, codec: '' },
|
||||
}
|
||||
}
|
||||
|
||||
async function seedProject() {
|
||||
const team = await prisma.team.create({ data: { name: 'GC Team' } })
|
||||
const projectFolder = await prisma.asset.create({
|
||||
data: { name: 'root', type: 'root', status: 'processed' },
|
||||
})
|
||||
return prisma.project.create({
|
||||
data: { name: 'GC Project', teamId: team.id, rootFolderId: projectFolder.id },
|
||||
})
|
||||
}
|
||||
|
||||
async function seedConfigWithWatermarkFile(config: WatermarkConfigSpec = sampleConfig) {
|
||||
const asset = await prisma.asset.create({
|
||||
data: { name: 'gc-asset.mp4', type: 'file', mediaType: 'video/mp4', status: 'processed' },
|
||||
})
|
||||
const wmConfig = await watermarkService.upsertConfig(config)
|
||||
const watermarkFile = await prisma.watermarkFile.create({
|
||||
data: {
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: wmConfig.id,
|
||||
status: 'completed',
|
||||
media: proxyMedia(),
|
||||
},
|
||||
})
|
||||
return { asset, config: wmConfig, watermarkFile }
|
||||
}
|
||||
|
||||
async function seedWatermarkTask(
|
||||
assetId: string,
|
||||
projectId: string,
|
||||
configId: string,
|
||||
status: 'pending' | 'processing' | 'completed',
|
||||
type: 'transcode_watermark' | 'transcode_video' = 'transcode_watermark',
|
||||
) {
|
||||
return prisma.workflowTask.create({
|
||||
data: {
|
||||
assetId,
|
||||
projectId,
|
||||
type,
|
||||
status,
|
||||
payload: {
|
||||
projectId,
|
||||
watermark: { watermarkConfigId: configId },
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
it('should purge an orphan config, delete its S3 proxies and keep the original key', async () => {
|
||||
const { config, watermarkFile } = await seedConfigWithWatermarkFile()
|
||||
const deleteSpy = vi.spyOn(s3Service, 'deleteObject').mockResolvedValue(0)
|
||||
|
||||
const purgedCount = await watermarkService.purgeOrphanWatermarkConfigs()
|
||||
|
||||
expect(purgedCount).toBe(1)
|
||||
expect(await prisma.watermarkConfig.findUnique({ where: { id: config.id } })).toBeNull()
|
||||
expect(await prisma.watermarkFile.findUnique({ where: { id: watermarkFile.id } })).toBeNull()
|
||||
|
||||
// All proxy slots deleted, but the original file is never touched
|
||||
for (const key of [
|
||||
'files/gc/wm.mp4',
|
||||
'files/gc/wm.webp',
|
||||
'files/gc/preview.mp4',
|
||||
'files/gc/thumb.webp',
|
||||
]) {
|
||||
expect(deleteSpy).toHaveBeenCalledWith(bucket, key)
|
||||
}
|
||||
expect(deleteSpy).not.toHaveBeenCalledWith(bucket, 'files/gc/original.mp4')
|
||||
expect(deleteSpy).toHaveBeenCalledTimes(4)
|
||||
})
|
||||
|
||||
it('should NOT purge a config still referenced by a share link', async () => {
|
||||
const { config } = await seedConfigWithWatermarkFile()
|
||||
const project = await seedProject()
|
||||
const shareFolder = await prisma.asset.create({
|
||||
data: { name: 'share-folder', type: 'share', status: 'processed', projectId: project.id },
|
||||
})
|
||||
await prisma.shareLink.create({
|
||||
data: {
|
||||
name: 'GC Share',
|
||||
projectId: project.id,
|
||||
rootFolderId: shareFolder.id,
|
||||
watermarkConfigId: config.id,
|
||||
},
|
||||
})
|
||||
const deleteSpy = vi.spyOn(s3Service, 'deleteObject').mockResolvedValue(0)
|
||||
|
||||
const purgedCount = await watermarkService.purgeOrphanWatermarkConfigs()
|
||||
|
||||
expect(purgedCount).toBe(0)
|
||||
expect(await prisma.watermarkConfig.findUnique({ where: { id: config.id } })).not.toBeNull()
|
||||
expect(deleteSpy).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it.each(['pending', 'processing'] as const)(
|
||||
'should NOT purge a config with an in-flight %s watermark task',
|
||||
async (status) => {
|
||||
const { asset, config } = await seedConfigWithWatermarkFile()
|
||||
const project = await seedProject()
|
||||
await seedWatermarkTask(asset.id, project.id, config.id, status)
|
||||
const deleteSpy = vi.spyOn(s3Service, 'deleteObject').mockResolvedValue(0)
|
||||
|
||||
const purgedCount = await watermarkService.purgeOrphanWatermarkConfigs()
|
||||
|
||||
expect(purgedCount).toBe(0)
|
||||
expect(await prisma.watermarkConfig.findUnique({ where: { id: config.id } })).not.toBeNull()
|
||||
expect(deleteSpy).not.toHaveBeenCalled()
|
||||
},
|
||||
)
|
||||
|
||||
it('should purge a config once its watermark tasks are all completed', async () => {
|
||||
const { asset, config } = await seedConfigWithWatermarkFile()
|
||||
const project = await seedProject()
|
||||
await seedWatermarkTask(asset.id, project.id, config.id, 'completed')
|
||||
vi.spyOn(s3Service, 'deleteObject').mockResolvedValue(0)
|
||||
|
||||
const purgedCount = await watermarkService.purgeOrphanWatermarkConfigs()
|
||||
|
||||
expect(purgedCount).toBe(1)
|
||||
expect(await prisma.watermarkConfig.findUnique({ where: { id: config.id } })).toBeNull()
|
||||
})
|
||||
|
||||
it('should ignore pending tasks of other types when deciding to purge', async () => {
|
||||
const { asset, config } = await seedConfigWithWatermarkFile()
|
||||
const project = await seedProject()
|
||||
// A pending transcode_video task must not protect the watermark config
|
||||
await seedWatermarkTask(asset.id, project.id, config.id, 'pending', 'transcode_video')
|
||||
vi.spyOn(s3Service, 'deleteObject').mockResolvedValue(0)
|
||||
|
||||
const purgedCount = await watermarkService.purgeOrphanWatermarkConfigs()
|
||||
|
||||
expect(purgedCount).toBe(1)
|
||||
expect(await prisma.watermarkConfig.findUnique({ where: { id: config.id } })).toBeNull()
|
||||
})
|
||||
|
||||
it('should keep purging other configs and S3 keys when one S3 delete fails', async () => {
|
||||
const { config } = await seedConfigWithWatermarkFile()
|
||||
const deleteSpy = vi
|
||||
.spyOn(s3Service, 'deleteObject')
|
||||
.mockRejectedValueOnce(new Error('s3 down'))
|
||||
.mockResolvedValue(0)
|
||||
|
||||
const purgedCount = await watermarkService.purgeOrphanWatermarkConfigs()
|
||||
|
||||
expect(purgedCount).toBe(1)
|
||||
expect(await prisma.watermarkConfig.findUnique({ where: { id: config.id } })).toBeNull()
|
||||
// All 4 proxy keys were attempted even though the first one failed
|
||||
expect(deleteSpy).toHaveBeenCalledTimes(4)
|
||||
})
|
||||
|
||||
it('should purge only the orphan config when another config is still referenced', async () => {
|
||||
const otherConfig: WatermarkConfigSpec = {
|
||||
blocks: [
|
||||
{
|
||||
id: 'other-block',
|
||||
type: 'text',
|
||||
x: 0.3,
|
||||
y: 0.3,
|
||||
opacity: 0.4,
|
||||
rotation: 10,
|
||||
text: 'OTHER TEAM',
|
||||
size: 0.1,
|
||||
color: '#00FF00',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const orphan = await seedConfigWithWatermarkFile()
|
||||
const referenced = await seedConfigWithWatermarkFile(otherConfig)
|
||||
|
||||
const project = await seedProject()
|
||||
const shareFolder = await prisma.asset.create({
|
||||
data: { name: 'share-folder', type: 'share', status: 'processed', projectId: project.id },
|
||||
})
|
||||
await prisma.shareLink.create({
|
||||
data: {
|
||||
name: 'GC Share',
|
||||
projectId: project.id,
|
||||
rootFolderId: shareFolder.id,
|
||||
watermarkConfigId: referenced.config.id,
|
||||
},
|
||||
})
|
||||
vi.spyOn(s3Service, 'deleteObject').mockResolvedValue(0)
|
||||
|
||||
const purgedCount = await watermarkService.purgeOrphanWatermarkConfigs()
|
||||
|
||||
expect(purgedCount).toBe(1)
|
||||
expect(
|
||||
await prisma.watermarkConfig.findUnique({ where: { id: orphan.config.id } }),
|
||||
).toBeNull()
|
||||
expect(
|
||||
await prisma.watermarkConfig.findUnique({ where: { id: referenced.config.id } }),
|
||||
).not.toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
it('should fetch completed watermark media map for asset IDs', async () => {
|
||||
const config = await watermarkService.upsertConfig(sampleConfig)
|
||||
const asset1 = await prisma.asset.create({
|
||||
data: { name: 'asset1.png', type: 'file', status: 'processed' },
|
||||
})
|
||||
const asset2 = await prisma.asset.create({
|
||||
data: { name: 'asset2.png', type: 'file', status: 'processed' },
|
||||
})
|
||||
|
||||
const sampleMedia: PrismaJson.MediaInfo = {
|
||||
duration: 0,
|
||||
filesize: 100,
|
||||
frames: 0,
|
||||
proxyType: 'image',
|
||||
imageTranscodes: [
|
||||
{ key: 'watermarked.webp', width: 100, height: 100, quality: 90, format: 'webp' },
|
||||
],
|
||||
videoTranscodes: [],
|
||||
finishedAt: new Date().toISOString(),
|
||||
metadata: null,
|
||||
original: null,
|
||||
}
|
||||
|
||||
await prisma.watermarkFile.create({
|
||||
data: {
|
||||
assetId: asset1.id,
|
||||
watermarkConfigId: config.id,
|
||||
status: 'completed',
|
||||
media: sampleMedia,
|
||||
},
|
||||
})
|
||||
|
||||
// asset2 has pending status
|
||||
await prisma.watermarkFile.create({
|
||||
data: {
|
||||
assetId: asset2.id,
|
||||
watermarkConfigId: config.id,
|
||||
status: 'pending',
|
||||
},
|
||||
})
|
||||
|
||||
const map = await watermarkService.getCompletedWatermarkMediaMap(
|
||||
[asset1.id, asset2.id],
|
||||
config.id,
|
||||
)
|
||||
|
||||
expect(map.size).toBe(1)
|
||||
expect(map.get(asset1.id)).toBeDefined()
|
||||
expect(map.get(asset1.id)?.imageTranscodes[0].key).toBe('watermarked.webp')
|
||||
expect(map.get(asset2.id)).toBeUndefined()
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,584 @@
|
||||
import {
|
||||
prisma,
|
||||
WorkflowTaskStatus,
|
||||
WorkflowTaskType,
|
||||
WatermarkStatus,
|
||||
WatermarkFileStatus,
|
||||
WatermarkConfig,
|
||||
WatermarkTemplate,
|
||||
} from '@shumai/db'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
import '@shumai/db/src/prisma-json-types'
|
||||
import {
|
||||
WatermarkConfigSpec,
|
||||
WatermarkConfigInfo,
|
||||
WatermarkTemplateInfo,
|
||||
ShareLinkInfo,
|
||||
} from '@shumai/dtos'
|
||||
import { computeWatermarkConfigHash } from '@shumai/core/src/watermark/watermark-hash'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import {
|
||||
ShareLinkNotFoundError,
|
||||
ShareLinkWatermarkProcessingError,
|
||||
} from '@shumai/core/src/share/errors'
|
||||
import { shareService } from '@shumai/core/src/share/share'
|
||||
import { logger } from '@shumai/core/src/logger'
|
||||
|
||||
// Union of the global client and interactive-transaction client, which share the
|
||||
// same delegate shapes for the models used by this service.
|
||||
type WatermarkDbClient = Prisma.TransactionClient | typeof prisma
|
||||
|
||||
export class WatermarkService {
|
||||
constructor(private readonly prismaClient: typeof prisma = prisma) {}
|
||||
|
||||
async upsertConfig(config: WatermarkConfigSpec) {
|
||||
return this.upsertConfigWithClient(this.prismaClient, config)
|
||||
}
|
||||
|
||||
private async upsertConfigWithClient(client: WatermarkDbClient, config: WatermarkConfigSpec) {
|
||||
const hash = computeWatermarkConfigHash(config)
|
||||
// Upsert keyed on the unique hash so concurrent enables of the same config
|
||||
// cannot race into a unique-constraint violation.
|
||||
return client.watermarkConfig.upsert({
|
||||
where: { hash },
|
||||
update: {},
|
||||
create: {
|
||||
hash,
|
||||
config: config as PrismaJson.WatermarkConfigSpec,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Watermark Template CRUD
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
async createTemplate(
|
||||
teamId: string | null,
|
||||
name: string,
|
||||
config: WatermarkConfigSpec,
|
||||
): Promise<WatermarkTemplateInfo> {
|
||||
const tpl = await this.prismaClient.watermarkTemplate.create({
|
||||
data: {
|
||||
name,
|
||||
config: config as PrismaJson.WatermarkConfigSpec,
|
||||
teamId,
|
||||
},
|
||||
})
|
||||
return await this.toWatermarkTemplateInfo(tpl)
|
||||
}
|
||||
|
||||
async updateTemplate(
|
||||
templateId: string,
|
||||
name?: string,
|
||||
config?: WatermarkConfigSpec,
|
||||
): Promise<WatermarkTemplateInfo> {
|
||||
const existing = await this.prismaClient.watermarkTemplate.findUnique({
|
||||
where: { id: templateId },
|
||||
})
|
||||
if (!existing) {
|
||||
throw new Error('Watermark template not found')
|
||||
}
|
||||
|
||||
const tpl = await this.prismaClient.watermarkTemplate.update({
|
||||
where: { id: templateId },
|
||||
data: {
|
||||
name: name ?? undefined,
|
||||
config: config ? (config as PrismaJson.WatermarkConfigSpec) : undefined,
|
||||
},
|
||||
})
|
||||
return await this.toWatermarkTemplateInfo(tpl)
|
||||
}
|
||||
|
||||
async deleteTemplate(templateId: string): Promise<void> {
|
||||
const existing = await this.prismaClient.watermarkTemplate.findUnique({
|
||||
where: { id: templateId },
|
||||
})
|
||||
if (!existing) {
|
||||
throw new Error('Watermark template not found')
|
||||
}
|
||||
await this.prismaClient.watermarkTemplate.delete({
|
||||
where: { id: templateId },
|
||||
})
|
||||
}
|
||||
|
||||
async listTemplates(teamIds?: string | string[] | null): Promise<WatermarkTemplateInfo[]> {
|
||||
const where = teamIds
|
||||
? Array.isArray(teamIds)
|
||||
? { teamId: { in: teamIds } }
|
||||
: { teamId: teamIds }
|
||||
: undefined
|
||||
const tpls = await this.prismaClient.watermarkTemplate.findMany({
|
||||
where,
|
||||
// ULIDs are time-sortable; ordering by id desc is the project convention
|
||||
orderBy: { id: 'desc' },
|
||||
})
|
||||
return await Promise.all(tpls.map((t) => this.toWatermarkTemplateInfo(t)))
|
||||
}
|
||||
|
||||
async getTemplate(templateId: string): Promise<WatermarkTemplateInfo> {
|
||||
const tpl = await this.prismaClient.watermarkTemplate.findUnique({
|
||||
where: { id: templateId },
|
||||
})
|
||||
if (!tpl) {
|
||||
throw new Error('Watermark template not found')
|
||||
}
|
||||
return await this.toWatermarkTemplateInfo(tpl)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// ShareLink Watermark Management
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
async updateShareLinkWatermark(
|
||||
shareLinkId: string,
|
||||
enabled: boolean,
|
||||
config?: WatermarkConfigSpec,
|
||||
): Promise<ShareLinkInfo> {
|
||||
return await this.prismaClient.$transaction(async (tx) => {
|
||||
// Lock the sharelink record SELECT FOR UPDATE
|
||||
const lockedRows = await tx.$queryRaw<
|
||||
{
|
||||
id: string
|
||||
watermarkStatus: WatermarkStatus
|
||||
watermarkConfigId: string | null
|
||||
}[]
|
||||
>`SELECT id, watermark_status AS "watermarkStatus", watermark_config_id AS "watermarkConfigId" FROM share_links WHERE id = ${shareLinkId} FOR UPDATE`
|
||||
|
||||
if (lockedRows.length === 0) {
|
||||
throw new ShareLinkNotFoundError('Share link not found')
|
||||
}
|
||||
|
||||
const currentStatus = lockedRows[0].watermarkStatus
|
||||
|
||||
if (currentStatus === WatermarkStatus.processing) {
|
||||
throw new ShareLinkWatermarkProcessingError(
|
||||
'Watermark transcoding is currently in progress',
|
||||
)
|
||||
}
|
||||
|
||||
if (!enabled) {
|
||||
await tx.shareLink.update({
|
||||
where: { id: shareLinkId },
|
||||
data: {
|
||||
watermarkConfigId: null,
|
||||
watermarkStatus: WatermarkStatus.disabled,
|
||||
},
|
||||
})
|
||||
// Read back through the transaction client: the global client runs on a
|
||||
// different pooled connection and cannot see uncommitted changes.
|
||||
return await shareService.getShareLink(shareLinkId, tx)
|
||||
}
|
||||
|
||||
if (!config || !config.blocks || config.blocks.length === 0) {
|
||||
throw new Error('Watermark configuration is required when enabling watermark')
|
||||
}
|
||||
|
||||
// Upsert watermark config based on hash
|
||||
const watermarkConfig = await this.upsertConfigWithClient(tx, config)
|
||||
|
||||
await tx.shareLink.update({
|
||||
where: { id: shareLinkId },
|
||||
data: {
|
||||
watermarkConfigId: watermarkConfig.id,
|
||||
watermarkStatus: WatermarkStatus.processing,
|
||||
},
|
||||
})
|
||||
|
||||
// Dispatch transcode tasks for all video/image assets in the sharelink
|
||||
await this.triggerWatermarkTranscodeForShareLink(shareLinkId, watermarkConfig.id, tx)
|
||||
|
||||
return await shareService.getShareLink(shareLinkId, tx)
|
||||
})
|
||||
}
|
||||
|
||||
async getShareLinkWatermark(shareLinkId: string): Promise<{
|
||||
watermarkStatus: WatermarkStatus
|
||||
watermarkConfig: WatermarkConfigInfo | null
|
||||
}> {
|
||||
const shareLink = await this.prismaClient.shareLink.findUnique({
|
||||
where: { id: shareLinkId },
|
||||
include: { watermarkConfig: true },
|
||||
})
|
||||
|
||||
if (!shareLink) {
|
||||
throw new ShareLinkNotFoundError('Share link not found')
|
||||
}
|
||||
|
||||
return {
|
||||
watermarkStatus: shareLink.watermarkStatus,
|
||||
watermarkConfig: shareLink.watermarkConfig
|
||||
? await this.toWatermarkConfigInfo(shareLink.watermarkConfig)
|
||||
: null,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all media file asset IDs (videos and images) contained in the sharelink,
|
||||
* including files within symlinked folders, and enqueues transcode workflow tasks.
|
||||
*/
|
||||
async triggerWatermarkTranscodeForShareLink(
|
||||
shareLinkId: string,
|
||||
watermarkConfigId: string,
|
||||
txClient?: WatermarkDbClient,
|
||||
): Promise<number> {
|
||||
const client = txClient || this.prismaClient
|
||||
const shareLink = await client.shareLink.findUnique({
|
||||
where: { id: shareLinkId },
|
||||
})
|
||||
if (!shareLink) return 0
|
||||
|
||||
const targetMediaAssets = await this.getMediaAssetIdsInShareLink(shareLink.rootFolderId, client)
|
||||
|
||||
if (targetMediaAssets.length === 0) {
|
||||
// If no media assets in sharelink, mark sharelink watermark as ready immediately
|
||||
await client.shareLink.update({
|
||||
where: { id: shareLinkId },
|
||||
data: { watermarkStatus: WatermarkStatus.ready },
|
||||
})
|
||||
return 0
|
||||
}
|
||||
|
||||
let dispatchedCount = 0
|
||||
for (const assetId of targetMediaAssets) {
|
||||
// Deliberately one create() per task: the @shumai/db client extension that
|
||||
// submits tasks to the workflow engine only hooks `workflowTask.create`,
|
||||
// not `createMany`.
|
||||
await client.workflowTask.create({
|
||||
data: {
|
||||
assetId,
|
||||
type: WorkflowTaskType.transcode_watermark,
|
||||
status: WorkflowTaskStatus.pending,
|
||||
projectId: shareLink.projectId,
|
||||
payload: {
|
||||
projectId: shareLink.projectId,
|
||||
watermark: {
|
||||
watermarkConfigId,
|
||||
shareLinkId,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
dispatchedCount++
|
||||
}
|
||||
|
||||
return dispatchedCount
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively resolves real media file asset IDs (video and image) under a sharelink root folder.
|
||||
* Walks the tree level-by-level (batched queries) and follows symlinks at any depth.
|
||||
*/
|
||||
async getMediaAssetIdsInShareLink(
|
||||
rootFolderId: string,
|
||||
txClient?: WatermarkDbClient,
|
||||
): Promise<string[]> {
|
||||
const client = txClient || this.prismaClient
|
||||
|
||||
// Fetch symlinks directly under root folder; these point to the shared targets
|
||||
const symlinks = await client.asset.findMany({
|
||||
where: {
|
||||
parentId: rootFolderId,
|
||||
type: 'symlink',
|
||||
isDeleted: false,
|
||||
},
|
||||
select: { targetId: true },
|
||||
})
|
||||
|
||||
const queue = symlinks.map((s) => s.targetId).filter((id): id is string => !!id)
|
||||
|
||||
if (queue.length === 0) return []
|
||||
|
||||
const mediaAssetIds: string[] = []
|
||||
const visited = new Set<string>()
|
||||
|
||||
while (queue.length > 0) {
|
||||
const frontier = queue.splice(0)
|
||||
const assets = await client.asset.findMany({
|
||||
where: { id: { in: frontier } },
|
||||
select: {
|
||||
id: true,
|
||||
type: true,
|
||||
mediaType: true,
|
||||
media: true,
|
||||
isDeleted: true,
|
||||
targetId: true,
|
||||
},
|
||||
})
|
||||
|
||||
const folderIds: string[] = []
|
||||
const next: string[] = []
|
||||
|
||||
for (const asset of assets) {
|
||||
if (visited.has(asset.id)) continue
|
||||
visited.add(asset.id)
|
||||
if (asset.isDeleted) continue
|
||||
|
||||
if (asset.type === 'file') {
|
||||
const mediaInfo = asset.media as PrismaJson.MediaInfo | null
|
||||
const proxyType = mediaInfo?.proxyType
|
||||
const isVideo = proxyType === 'video' || asset.mediaType?.startsWith('video/')
|
||||
const isImage = proxyType === 'image' || asset.mediaType?.startsWith('image/')
|
||||
|
||||
if (isVideo || isImage) {
|
||||
mediaAssetIds.push(asset.id)
|
||||
}
|
||||
} else if (asset.type === 'folder') {
|
||||
folderIds.push(asset.id)
|
||||
} else if (asset.type === 'symlink' && asset.targetId) {
|
||||
// Resolve nested symlinks (e.g. folders that contain their own symlinks)
|
||||
next.push(asset.targetId)
|
||||
}
|
||||
}
|
||||
|
||||
if (folderIds.length > 0) {
|
||||
const children = await client.asset.findMany({
|
||||
where: { parentId: { in: folderIds }, isDeleted: false },
|
||||
select: { id: true },
|
||||
})
|
||||
next.push(...children.map((c) => c.id))
|
||||
}
|
||||
|
||||
queue.push(...next)
|
||||
}
|
||||
|
||||
return mediaAssetIds
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if all required media assets in a sharelink have completed watermark transcodes.
|
||||
* If all are completed, sets ShareLink.watermarkStatus to 'ready'.
|
||||
* If any failed, sets ShareLink.watermarkStatus to 'failed'.
|
||||
*/
|
||||
async checkAndUpdateShareLinkStatus(shareLinkId: string): Promise<WatermarkStatus> {
|
||||
const shareLink = await this.prismaClient.shareLink.findUnique({
|
||||
where: { id: shareLinkId },
|
||||
})
|
||||
if (!shareLink || !shareLink.watermarkConfigId) {
|
||||
return WatermarkStatus.disabled
|
||||
}
|
||||
|
||||
const watermarkConfigId = shareLink.watermarkConfigId
|
||||
const mediaAssetIds = await this.getMediaAssetIdsInShareLink(shareLink.rootFolderId)
|
||||
|
||||
if (mediaAssetIds.length === 0) {
|
||||
await this.prismaClient.shareLink.update({
|
||||
where: { id: shareLinkId },
|
||||
data: { watermarkStatus: WatermarkStatus.ready },
|
||||
})
|
||||
return WatermarkStatus.ready
|
||||
}
|
||||
|
||||
const watermarkFiles = await this.prismaClient.watermarkFile.findMany({
|
||||
where: {
|
||||
assetId: { in: mediaAssetIds },
|
||||
watermarkConfigId,
|
||||
},
|
||||
})
|
||||
|
||||
const statusMap = new Map(watermarkFiles.map((wf) => [wf.assetId, wf.status]))
|
||||
|
||||
let allCompleted = true
|
||||
let anyFailed = false
|
||||
|
||||
for (const assetId of mediaAssetIds) {
|
||||
const status = statusMap.get(assetId)
|
||||
if (status === WatermarkFileStatus.failed) {
|
||||
anyFailed = true
|
||||
allCompleted = false
|
||||
break
|
||||
}
|
||||
if (status !== WatermarkFileStatus.completed) {
|
||||
allCompleted = false
|
||||
}
|
||||
}
|
||||
|
||||
let newStatus: WatermarkStatus
|
||||
if (anyFailed) {
|
||||
newStatus = WatermarkStatus.failed
|
||||
} else if (allCompleted) {
|
||||
newStatus = WatermarkStatus.ready
|
||||
} else {
|
||||
newStatus = WatermarkStatus.processing
|
||||
}
|
||||
|
||||
if (newStatus !== shareLink.watermarkStatus) {
|
||||
await this.prismaClient.shareLink.update({
|
||||
where: { id: shareLinkId },
|
||||
data: { watermarkStatus: newStatus },
|
||||
})
|
||||
}
|
||||
|
||||
return newStatus
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Background Async Garbage Collection
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Background task to prune orphan WatermarkConfig records and delete their storage files.
|
||||
* Runs as part of background cleanup.
|
||||
*/
|
||||
async purgeOrphanWatermarkConfigs(): Promise<number> {
|
||||
const bucket = process.env.S3_BUCKET || 'shumai'
|
||||
|
||||
// 1. Find orphan configs with 0 sharelinks attached and no in-flight watermark
|
||||
// tasks, using FOR UPDATE SKIP LOCKED. Configs with pending/processing tasks
|
||||
// must not be purged, or the running activities would fail with FK violations.
|
||||
const orphanConfigs = await this.prismaClient.$queryRaw<{ id: string }[]>`
|
||||
SELECT wc.id FROM watermark_configs wc
|
||||
WHERE NOT EXISTS (SELECT 1 FROM share_links sl WHERE sl.watermark_config_id = wc.id)
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM workflow_tasks wt
|
||||
WHERE wt.type = 'transcode_watermark'
|
||||
AND wt.status IN ('pending', 'processing')
|
||||
AND wt.payload->'watermark'->>'watermarkConfigId' = wc.id
|
||||
)
|
||||
LIMIT 20
|
||||
FOR UPDATE SKIP LOCKED
|
||||
`
|
||||
|
||||
if (orphanConfigs.length === 0) return 0
|
||||
|
||||
let purgedCount = 0
|
||||
|
||||
for (const config of orphanConfigs) {
|
||||
try {
|
||||
// Fetch all watermark files for this config
|
||||
const watermarkFiles = await this.prismaClient.watermarkFile.findMany({
|
||||
where: { watermarkConfigId: config.id },
|
||||
})
|
||||
|
||||
// Delete proxy files from S3
|
||||
for (const wf of watermarkFiles) {
|
||||
const media = wf.media
|
||||
if (media) {
|
||||
const keysToDelete: string[] = []
|
||||
if (Array.isArray(media.videoTranscodes)) {
|
||||
for (const vt of media.videoTranscodes) {
|
||||
if (vt.key) keysToDelete.push(vt.key)
|
||||
}
|
||||
}
|
||||
if (Array.isArray(media.imageTranscodes)) {
|
||||
for (const it of media.imageTranscodes) {
|
||||
if (it.key) keysToDelete.push(it.key)
|
||||
}
|
||||
}
|
||||
if (media.videoPreview?.key) keysToDelete.push(media.videoPreview.key)
|
||||
if (media.thumbnail?.key) keysToDelete.push(media.thumbnail.key)
|
||||
|
||||
for (const key of keysToDelete) {
|
||||
try {
|
||||
await s3Service.deleteObject(bucket, key)
|
||||
} catch (s3Err) {
|
||||
logger.warn({ key, err: s3Err }, 'Failed to delete watermark proxy file from S3')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete WatermarkFiles and WatermarkConfig in DB
|
||||
await this.prismaClient.$transaction(async (tx) => {
|
||||
await tx.watermarkFile.deleteMany({
|
||||
where: { watermarkConfigId: config.id },
|
||||
})
|
||||
await tx.watermarkConfig.delete({
|
||||
where: { id: config.id },
|
||||
})
|
||||
})
|
||||
|
||||
purgedCount++
|
||||
logger.info({ configId: config.id }, 'Purged orphan watermark config and proxy files')
|
||||
} catch (err) {
|
||||
logger.error({ configId: config.id, err }, 'Failed to purge orphan watermark config')
|
||||
}
|
||||
}
|
||||
|
||||
return purgedCount
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches completed watermark media entries for a list of asset IDs under a specific watermark config.
|
||||
* Returns a map of assetId -> PrismaJson.MediaInfo.
|
||||
*/
|
||||
async getCompletedWatermarkMediaMap(
|
||||
assetIds: string[],
|
||||
watermarkConfigId: string,
|
||||
): Promise<Map<string, PrismaJson.MediaInfo>> {
|
||||
if (assetIds.length === 0) return new Map()
|
||||
|
||||
const watermarkFiles = await prisma.watermarkFile.findMany({
|
||||
where: {
|
||||
assetId: { in: assetIds },
|
||||
watermarkConfigId,
|
||||
status: 'completed',
|
||||
},
|
||||
})
|
||||
|
||||
const map = new Map<string, PrismaJson.MediaInfo>()
|
||||
for (const wf of watermarkFiles) {
|
||||
if (wf.media) {
|
||||
map.set(wf.assetId, wf.media as PrismaJson.MediaInfo)
|
||||
}
|
||||
}
|
||||
return map
|
||||
}
|
||||
|
||||
/**
|
||||
* Enriches image blocks in a watermark config with accessible presigned URLs for WebUI rendering.
|
||||
*/
|
||||
async enrichWatermarkConfigWithPresignedUrls(
|
||||
config: WatermarkConfigSpec,
|
||||
): Promise<WatermarkConfigSpec> {
|
||||
if (!config || !config.blocks || config.blocks.length === 0) return config
|
||||
const bucket = process.env.S3_BUCKET || 'shumai'
|
||||
const enrichedBlocks = await Promise.all(
|
||||
config.blocks.map(async (block) => {
|
||||
if (block.type === 'image' && block.imageAssetKey) {
|
||||
try {
|
||||
const url = await s3Service.presign(bucket, block.imageAssetKey, 'GET')
|
||||
return { ...block, imageAssetUrl: url }
|
||||
} catch (err) {
|
||||
logger.warn({ key: block.imageAssetKey, err }, 'Failed to presign watermark image key')
|
||||
}
|
||||
}
|
||||
return block
|
||||
}),
|
||||
)
|
||||
return { ...config, blocks: enrichedBlocks }
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// DTO Mappers
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
private async toWatermarkTemplateInfo(t: WatermarkTemplate): Promise<WatermarkTemplateInfo> {
|
||||
const config = await this.enrichWatermarkConfigWithPresignedUrls(
|
||||
t.config as WatermarkConfigSpec,
|
||||
)
|
||||
return {
|
||||
id: t.id,
|
||||
name: t.name,
|
||||
config,
|
||||
teamId: t.teamId,
|
||||
createdAt: t.createdAt.toISOString(),
|
||||
updatedAt: t.updatedAt.toISOString(),
|
||||
}
|
||||
}
|
||||
|
||||
private async toWatermarkConfigInfo(c: WatermarkConfig): Promise<WatermarkConfigInfo> {
|
||||
const config = await this.enrichWatermarkConfigWithPresignedUrls(
|
||||
c.config as WatermarkConfigSpec,
|
||||
)
|
||||
return {
|
||||
id: c.id,
|
||||
config,
|
||||
hash: c.hash,
|
||||
createdAt: c.createdAt.toISOString(),
|
||||
updatedAt: c.updatedAt.toISOString(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const watermarkService = new WatermarkService()
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/db",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.5",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "WatermarkStatus" AS ENUM ('disabled', 'processing', 'ready', 'failed');
|
||||
|
||||
-- AlterEnum
|
||||
ALTER TYPE "WorkflowTaskType" ADD VALUE 'transcode_watermark';
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "share_links" ADD COLUMN "watermark_config_id" TEXT,
|
||||
ADD COLUMN "watermark_status" "WatermarkStatus" NOT NULL DEFAULT 'disabled';
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "watermark_configs" (
|
||||
"id" TEXT NOT NULL,
|
||||
"config" JSONB NOT NULL,
|
||||
"hash" TEXT NOT NULL,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "watermark_configs_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "watermark_templates" (
|
||||
"id" TEXT NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"config" JSONB NOT NULL,
|
||||
"team_id" TEXT,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "watermark_templates_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "watermark_files" (
|
||||
"id" TEXT NOT NULL,
|
||||
"asset_id" TEXT NOT NULL,
|
||||
"watermark_config_id" TEXT NOT NULL,
|
||||
"media" JSONB,
|
||||
"status" "WorkflowTaskStatus" NOT NULL DEFAULT 'pending',
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "watermark_files_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "watermark_configs_hash_key" ON "watermark_configs"("hash");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "watermark_templates_team_id_idx" ON "watermark_templates"("team_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "watermark_files_watermark_config_id_idx" ON "watermark_files"("watermark_config_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "watermark_files_asset_id_watermark_config_id_key" ON "watermark_files"("asset_id", "watermark_config_id");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "share_links" ADD CONSTRAINT "share_links_watermark_config_id_fkey" FOREIGN KEY ("watermark_config_id") REFERENCES "watermark_configs"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "watermark_templates" ADD CONSTRAINT "watermark_templates_team_id_fkey" FOREIGN KEY ("team_id") REFERENCES "teams"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "watermark_files" ADD CONSTRAINT "watermark_files_asset_id_fkey" FOREIGN KEY ("asset_id") REFERENCES "assets"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "watermark_files" ADD CONSTRAINT "watermark_files_watermark_config_id_fkey" FOREIGN KEY ("watermark_config_id") REFERENCES "watermark_configs"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -0,0 +1,7 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "WatermarkFileStatus" AS ENUM ('pending', 'processing', 'completed', 'failed');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "watermark_files" ALTER COLUMN "status" DROP DEFAULT;
|
||||
ALTER TABLE "watermark_files" ALTER COLUMN "status" TYPE "WatermarkFileStatus" USING ("status"::text::"WatermarkFileStatus");
|
||||
ALTER TABLE "watermark_files" ALTER COLUMN "status" SET DEFAULT 'pending';
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
-- Data cleanup: remove legacy media JSON fields that are no longer used.
|
||||
--
|
||||
-- WebUI now displays transcoded proxies only and never falls back to the raw
|
||||
-- original file:
|
||||
-- 1. Drop the raw-original marker entries (`isRaw: true`) from
|
||||
-- videoTranscodes / imageTranscodes. They pointed at the original file
|
||||
-- key and were only consumed by the removed display fallbacks and the
|
||||
-- download-menu entries, which now use media.original.key directly.
|
||||
-- 2. Strip the now-removed `isRaw` field from remaining transcode entries.
|
||||
-- 3. Drop `original.downloadUrl` (removed from the AssetInfo DTO; downloads
|
||||
-- resolve a fresh presigned URL from `key` via the download-url APIs).
|
||||
|
||||
UPDATE "assets"
|
||||
SET "media" = jsonb_set(
|
||||
jsonb_set(
|
||||
CASE WHEN jsonb_typeof("media"->'original') = 'object'
|
||||
THEN "media" #- '{original,downloadUrl}'
|
||||
ELSE "media" END,
|
||||
'{videoTranscodes}',
|
||||
COALESCE(
|
||||
(SELECT jsonb_agg(elem - 'isRaw')
|
||||
FROM jsonb_array_elements("media"->'videoTranscodes') elem
|
||||
WHERE jsonb_typeof(elem) = 'object'
|
||||
AND NOT COALESCE((elem->>'isRaw')::boolean, false)),
|
||||
'[]'::jsonb
|
||||
)
|
||||
),
|
||||
'{imageTranscodes}',
|
||||
COALESCE(
|
||||
(SELECT jsonb_agg(elem - 'isRaw')
|
||||
FROM jsonb_array_elements("media"->'imageTranscodes') elem
|
||||
WHERE jsonb_typeof(elem) = 'object'
|
||||
AND NOT COALESCE((elem->>'isRaw')::boolean, false)),
|
||||
'[]'::jsonb
|
||||
)
|
||||
)
|
||||
WHERE "media" IS NOT NULL
|
||||
AND (
|
||||
(jsonb_typeof("media"->'original') = 'object' AND "media"->'original' ? 'downloadUrl')
|
||||
OR EXISTS (
|
||||
SELECT 1 FROM jsonb_array_elements(COALESCE("media"->'videoTranscodes', '[]'::jsonb)) e
|
||||
WHERE jsonb_typeof(e) = 'object' AND e ? 'isRaw'
|
||||
)
|
||||
OR EXISTS (
|
||||
SELECT 1 FROM jsonb_array_elements(COALESCE("media"->'imageTranscodes', '[]'::jsonb)) e
|
||||
WHERE jsonb_typeof(e) = 'object' AND e ? 'isRaw'
|
||||
)
|
||||
);
|
||||
|
||||
-- Same cleanup for watermarked proxy media.
|
||||
UPDATE "watermark_files"
|
||||
SET "media" = jsonb_set(
|
||||
jsonb_set(
|
||||
CASE WHEN jsonb_typeof("media"->'original') = 'object'
|
||||
THEN "media" #- '{original,downloadUrl}'
|
||||
ELSE "media" END,
|
||||
'{videoTranscodes}',
|
||||
COALESCE(
|
||||
(SELECT jsonb_agg(elem - 'isRaw')
|
||||
FROM jsonb_array_elements("media"->'videoTranscodes') elem
|
||||
WHERE jsonb_typeof(elem) = 'object'
|
||||
AND NOT COALESCE((elem->>'isRaw')::boolean, false)),
|
||||
'[]'::jsonb
|
||||
)
|
||||
),
|
||||
'{imageTranscodes}',
|
||||
COALESCE(
|
||||
(SELECT jsonb_agg(elem - 'isRaw')
|
||||
FROM jsonb_array_elements("media"->'imageTranscodes') elem
|
||||
WHERE jsonb_typeof(elem) = 'object'
|
||||
AND NOT COALESCE((elem->>'isRaw')::boolean, false)),
|
||||
'[]'::jsonb
|
||||
)
|
||||
)
|
||||
WHERE "media" IS NOT NULL
|
||||
AND (
|
||||
(jsonb_typeof("media"->'original') = 'object' AND "media"->'original' ? 'downloadUrl')
|
||||
OR EXISTS (
|
||||
SELECT 1 FROM jsonb_array_elements(COALESCE("media"->'videoTranscodes', '[]'::jsonb)) e
|
||||
WHERE jsonb_typeof(e) = 'object' AND e ? 'isRaw'
|
||||
)
|
||||
OR EXISTS (
|
||||
SELECT 1 FROM jsonb_array_elements(COALESCE("media"->'imageTranscodes', '[]'::jsonb)) e
|
||||
WHERE jsonb_typeof(e) = 'object' AND e ? 'isRaw'
|
||||
)
|
||||
);
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "share_links" ADD COLUMN "allow_download" BOOLEAN NOT NULL DEFAULT true;
|
||||
@@ -106,6 +106,7 @@ enum WorkflowTaskType {
|
||||
transcode_pdf_pages
|
||||
transcode_screenshot
|
||||
transcode_image_annotation
|
||||
transcode_watermark
|
||||
ai_metadata_autofill
|
||||
chat
|
||||
ai_embedding
|
||||
@@ -120,6 +121,20 @@ enum WorkflowTaskStatus {
|
||||
failed
|
||||
}
|
||||
|
||||
enum WatermarkStatus {
|
||||
disabled
|
||||
processing
|
||||
ready
|
||||
failed
|
||||
}
|
||||
|
||||
enum WatermarkFileStatus {
|
||||
pending
|
||||
processing
|
||||
completed
|
||||
failed
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Models
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -241,6 +256,7 @@ model Team {
|
||||
agents Agent[] @relation("TeamToAgent")
|
||||
aiUsages AiUsage[] @relation("TeamToAiUsage")
|
||||
auditLogs AuditLog[] @relation("TeamToAuditLog")
|
||||
watermarkTemplates WatermarkTemplate[] @relation("TeamToWatermarkTemplate")
|
||||
|
||||
@@map("teams")
|
||||
}
|
||||
@@ -351,6 +367,7 @@ model ShareLink {
|
||||
expireAt DateTime? @map("expire_at")
|
||||
password String?
|
||||
isDisabled Boolean @default(false) @map("is_disabled")
|
||||
allowDownload Boolean @default(true) @map("allow_download")
|
||||
defaultSortOrder String? @map("default_sort_order")
|
||||
viewMode String? @map("view_mode")
|
||||
/// [ShareLinkFieldVisibility]
|
||||
@@ -367,9 +384,59 @@ model ShareLink {
|
||||
creatorId String? @map("creator_id")
|
||||
creator User? @relation("UserToShareLink", fields: [creatorId], references: [id])
|
||||
|
||||
watermarkConfigId String? @map("watermark_config_id")
|
||||
watermarkStatus WatermarkStatus @default(disabled) @map("watermark_status")
|
||||
watermarkConfig WatermarkConfig? @relation(fields: [watermarkConfigId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@map("share_links")
|
||||
}
|
||||
|
||||
model WatermarkConfig {
|
||||
id String @id @default(ulid())
|
||||
/// [WatermarkConfigSpec]
|
||||
config Json
|
||||
hash String @unique
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
shareLinks ShareLink[]
|
||||
watermarkFiles WatermarkFile[]
|
||||
|
||||
@@map("watermark_configs")
|
||||
}
|
||||
|
||||
model WatermarkTemplate {
|
||||
id String @id @default(ulid())
|
||||
name String
|
||||
/// [WatermarkConfigSpec]
|
||||
config Json
|
||||
teamId String? @map("team_id")
|
||||
team Team? @relation("TeamToWatermarkTemplate", fields: [teamId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@index([teamId])
|
||||
@@map("watermark_templates")
|
||||
}
|
||||
|
||||
model WatermarkFile {
|
||||
id String @id @default(ulid())
|
||||
assetId String @map("asset_id")
|
||||
watermarkConfigId String @map("watermark_config_id")
|
||||
/// [MediaInfo]
|
||||
media Json?
|
||||
status WatermarkFileStatus @default(pending)
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
asset Asset @relation("AssetToWatermarkFile", fields: [assetId], references: [id], onDelete: Cascade)
|
||||
watermarkConfig WatermarkConfig @relation(fields: [watermarkConfigId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([assetId, watermarkConfigId])
|
||||
@@index([watermarkConfigId])
|
||||
@@map("watermark_files")
|
||||
}
|
||||
|
||||
model Asset {
|
||||
id String @id @default(ulid())
|
||||
name String @default("")
|
||||
@@ -421,6 +488,7 @@ model Asset {
|
||||
projectShareRoot Project? @relation("ProjectToShareRoot")
|
||||
shareLinkRootFolder ShareLink? @relation("ShareLinkToRootFolder")
|
||||
agentSessions AgentSession[] @relation("AssetToAgentSession")
|
||||
watermarkFiles WatermarkFile[] @relation("AssetToWatermarkFile")
|
||||
|
||||
@@map("assets")
|
||||
@@index([type])
|
||||
|
||||
+15
@@ -77,6 +77,21 @@ export type ProjectMember = Prisma.ProjectMemberModel
|
||||
*
|
||||
*/
|
||||
export type ShareLink = Prisma.ShareLinkModel
|
||||
/**
|
||||
* Model WatermarkConfig
|
||||
*
|
||||
*/
|
||||
export type WatermarkConfig = Prisma.WatermarkConfigModel
|
||||
/**
|
||||
* Model WatermarkTemplate
|
||||
*
|
||||
*/
|
||||
export type WatermarkTemplate = Prisma.WatermarkTemplateModel
|
||||
/**
|
||||
* Model WatermarkFile
|
||||
*
|
||||
*/
|
||||
export type WatermarkFile = Prisma.WatermarkFileModel
|
||||
/**
|
||||
* Model Asset
|
||||
*
|
||||
|
||||
+15
@@ -101,6 +101,21 @@ export type ProjectMember = Prisma.ProjectMemberModel
|
||||
*
|
||||
*/
|
||||
export type ShareLink = Prisma.ShareLinkModel
|
||||
/**
|
||||
* Model WatermarkConfig
|
||||
*
|
||||
*/
|
||||
export type WatermarkConfig = Prisma.WatermarkConfigModel
|
||||
/**
|
||||
* Model WatermarkTemplate
|
||||
*
|
||||
*/
|
||||
export type WatermarkTemplate = Prisma.WatermarkTemplateModel
|
||||
/**
|
||||
* Model WatermarkFile
|
||||
*
|
||||
*/
|
||||
export type WatermarkFile = Prisma.WatermarkFileModel
|
||||
/**
|
||||
* Model Asset
|
||||
*
|
||||
|
||||
+143
-75
@@ -267,6 +267,91 @@ export type EnumProjectMemberRoleWithAggregatesFilter<$PrismaModel = never> = {
|
||||
_max?: Prisma.NestedEnumProjectMemberRoleFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type EnumWatermarkStatusFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.WatermarkStatus | Prisma.EnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.WatermarkStatus[] | Prisma.ListEnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
notIn?: $Enums.WatermarkStatus[] | Prisma.ListEnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedEnumWatermarkStatusFilter<$PrismaModel> | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type EnumWatermarkStatusWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.WatermarkStatus | Prisma.EnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.WatermarkStatus[] | Prisma.ListEnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
notIn?: $Enums.WatermarkStatus[] | Prisma.ListEnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedEnumWatermarkStatusWithAggregatesFilter<$PrismaModel> | $Enums.WatermarkStatus
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedEnumWatermarkStatusFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedEnumWatermarkStatusFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type JsonFilter<$PrismaModel = never> =
|
||||
| Prisma.PatchUndefined<
|
||||
Prisma.Either<Required<JsonFilterBase<$PrismaModel>>, Exclude<keyof Required<JsonFilterBase<$PrismaModel>>, 'path'>>,
|
||||
Required<JsonFilterBase<$PrismaModel>>
|
||||
>
|
||||
| Prisma.OptionalFlat<Omit<Required<JsonFilterBase<$PrismaModel>>, 'path'>>
|
||||
|
||||
export type JsonFilterBase<$PrismaModel = never> = {
|
||||
equals?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||
path?: string[]
|
||||
mode?: Prisma.QueryMode | Prisma.EnumQueryModeFieldRefInput<$PrismaModel>
|
||||
string_contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
string_starts_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
string_ends_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
array_starts_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
array_ends_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
array_contains?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
lt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
not?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||
}
|
||||
|
||||
export type JsonWithAggregatesFilter<$PrismaModel = never> =
|
||||
| Prisma.PatchUndefined<
|
||||
Prisma.Either<Required<JsonWithAggregatesFilterBase<$PrismaModel>>, Exclude<keyof Required<JsonWithAggregatesFilterBase<$PrismaModel>>, 'path'>>,
|
||||
Required<JsonWithAggregatesFilterBase<$PrismaModel>>
|
||||
>
|
||||
| Prisma.OptionalFlat<Omit<Required<JsonWithAggregatesFilterBase<$PrismaModel>>, 'path'>>
|
||||
|
||||
export type JsonWithAggregatesFilterBase<$PrismaModel = never> = {
|
||||
equals?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||
path?: string[]
|
||||
mode?: Prisma.QueryMode | Prisma.EnumQueryModeFieldRefInput<$PrismaModel>
|
||||
string_contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
string_starts_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
string_ends_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
array_starts_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
array_ends_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
array_contains?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
lt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
not?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedJsonFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedJsonFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type EnumWatermarkFileStatusFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.WatermarkFileStatus | Prisma.EnumWatermarkFileStatusFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.WatermarkFileStatus[] | Prisma.ListEnumWatermarkFileStatusFieldRefInput<$PrismaModel>
|
||||
notIn?: $Enums.WatermarkFileStatus[] | Prisma.ListEnumWatermarkFileStatusFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedEnumWatermarkFileStatusFilter<$PrismaModel> | $Enums.WatermarkFileStatus
|
||||
}
|
||||
|
||||
export type EnumWatermarkFileStatusWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.WatermarkFileStatus | Prisma.EnumWatermarkFileStatusFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.WatermarkFileStatus[] | Prisma.ListEnumWatermarkFileStatusFieldRefInput<$PrismaModel>
|
||||
notIn?: $Enums.WatermarkFileStatus[] | Prisma.ListEnumWatermarkFileStatusFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedEnumWatermarkFileStatusWithAggregatesFilter<$PrismaModel> | $Enums.WatermarkFileStatus
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedEnumWatermarkFileStatusFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedEnumWatermarkFileStatusFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type EnumAssetTypeFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.AssetType | Prisma.EnumAssetTypeFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.AssetType[] | Prisma.ListEnumAssetTypeFieldRefInput<$PrismaModel>
|
||||
@@ -592,30 +677,6 @@ export type EnumAgentTypeFilter<$PrismaModel = never> = {
|
||||
not?: Prisma.NestedEnumAgentTypeFilter<$PrismaModel> | $Enums.AgentType
|
||||
}
|
||||
|
||||
export type JsonFilter<$PrismaModel = never> =
|
||||
| Prisma.PatchUndefined<
|
||||
Prisma.Either<Required<JsonFilterBase<$PrismaModel>>, Exclude<keyof Required<JsonFilterBase<$PrismaModel>>, 'path'>>,
|
||||
Required<JsonFilterBase<$PrismaModel>>
|
||||
>
|
||||
| Prisma.OptionalFlat<Omit<Required<JsonFilterBase<$PrismaModel>>, 'path'>>
|
||||
|
||||
export type JsonFilterBase<$PrismaModel = never> = {
|
||||
equals?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||
path?: string[]
|
||||
mode?: Prisma.QueryMode | Prisma.EnumQueryModeFieldRefInput<$PrismaModel>
|
||||
string_contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
string_starts_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
string_ends_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
array_starts_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
array_ends_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
array_contains?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
lt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
not?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||
}
|
||||
|
||||
export type EnumAgentTypeWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.AgentType | Prisma.EnumAgentTypeFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.AgentType[] | Prisma.ListEnumAgentTypeFieldRefInput<$PrismaModel>
|
||||
@@ -626,33 +687,6 @@ export type EnumAgentTypeWithAggregatesFilter<$PrismaModel = never> = {
|
||||
_max?: Prisma.NestedEnumAgentTypeFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type JsonWithAggregatesFilter<$PrismaModel = never> =
|
||||
| Prisma.PatchUndefined<
|
||||
Prisma.Either<Required<JsonWithAggregatesFilterBase<$PrismaModel>>, Exclude<keyof Required<JsonWithAggregatesFilterBase<$PrismaModel>>, 'path'>>,
|
||||
Required<JsonWithAggregatesFilterBase<$PrismaModel>>
|
||||
>
|
||||
| Prisma.OptionalFlat<Omit<Required<JsonWithAggregatesFilterBase<$PrismaModel>>, 'path'>>
|
||||
|
||||
export type JsonWithAggregatesFilterBase<$PrismaModel = never> = {
|
||||
equals?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||
path?: string[]
|
||||
mode?: Prisma.QueryMode | Prisma.EnumQueryModeFieldRefInput<$PrismaModel>
|
||||
string_contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
string_starts_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
string_ends_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
array_starts_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
array_ends_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
array_contains?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
lt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
not?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedJsonFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedJsonFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type EnumAgentSessionTypeFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.AgentSessionType | Prisma.EnumAgentSessionTypeFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.AgentSessionType[] | Prisma.ListEnumAgentSessionTypeFieldRefInput<$PrismaModel>
|
||||
@@ -936,6 +970,64 @@ export type NestedEnumProjectMemberRoleWithAggregatesFilter<$PrismaModel = never
|
||||
_max?: Prisma.NestedEnumProjectMemberRoleFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedEnumWatermarkStatusFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.WatermarkStatus | Prisma.EnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.WatermarkStatus[] | Prisma.ListEnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
notIn?: $Enums.WatermarkStatus[] | Prisma.ListEnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedEnumWatermarkStatusFilter<$PrismaModel> | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type NestedEnumWatermarkStatusWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.WatermarkStatus | Prisma.EnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.WatermarkStatus[] | Prisma.ListEnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
notIn?: $Enums.WatermarkStatus[] | Prisma.ListEnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedEnumWatermarkStatusWithAggregatesFilter<$PrismaModel> | $Enums.WatermarkStatus
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedEnumWatermarkStatusFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedEnumWatermarkStatusFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedJsonFilter<$PrismaModel = never> =
|
||||
| Prisma.PatchUndefined<
|
||||
Prisma.Either<Required<NestedJsonFilterBase<$PrismaModel>>, Exclude<keyof Required<NestedJsonFilterBase<$PrismaModel>>, 'path'>>,
|
||||
Required<NestedJsonFilterBase<$PrismaModel>>
|
||||
>
|
||||
| Prisma.OptionalFlat<Omit<Required<NestedJsonFilterBase<$PrismaModel>>, 'path'>>
|
||||
|
||||
export type NestedJsonFilterBase<$PrismaModel = never> = {
|
||||
equals?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||
path?: string[]
|
||||
mode?: Prisma.QueryMode | Prisma.EnumQueryModeFieldRefInput<$PrismaModel>
|
||||
string_contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
string_starts_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
string_ends_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
array_starts_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
array_ends_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
array_contains?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
lt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
not?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||
}
|
||||
|
||||
export type NestedEnumWatermarkFileStatusFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.WatermarkFileStatus | Prisma.EnumWatermarkFileStatusFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.WatermarkFileStatus[] | Prisma.ListEnumWatermarkFileStatusFieldRefInput<$PrismaModel>
|
||||
notIn?: $Enums.WatermarkFileStatus[] | Prisma.ListEnumWatermarkFileStatusFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedEnumWatermarkFileStatusFilter<$PrismaModel> | $Enums.WatermarkFileStatus
|
||||
}
|
||||
|
||||
export type NestedEnumWatermarkFileStatusWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.WatermarkFileStatus | Prisma.EnumWatermarkFileStatusFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.WatermarkFileStatus[] | Prisma.ListEnumWatermarkFileStatusFieldRefInput<$PrismaModel>
|
||||
notIn?: $Enums.WatermarkFileStatus[] | Prisma.ListEnumWatermarkFileStatusFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedEnumWatermarkFileStatusWithAggregatesFilter<$PrismaModel> | $Enums.WatermarkFileStatus
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedEnumWatermarkFileStatusFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedEnumWatermarkFileStatusFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedEnumAssetTypeFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.AssetType | Prisma.EnumAssetTypeFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.AssetType[] | Prisma.ListEnumAssetTypeFieldRefInput<$PrismaModel>
|
||||
@@ -1258,30 +1350,6 @@ export type NestedEnumAgentTypeWithAggregatesFilter<$PrismaModel = never> = {
|
||||
_max?: Prisma.NestedEnumAgentTypeFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedJsonFilter<$PrismaModel = never> =
|
||||
| Prisma.PatchUndefined<
|
||||
Prisma.Either<Required<NestedJsonFilterBase<$PrismaModel>>, Exclude<keyof Required<NestedJsonFilterBase<$PrismaModel>>, 'path'>>,
|
||||
Required<NestedJsonFilterBase<$PrismaModel>>
|
||||
>
|
||||
| Prisma.OptionalFlat<Omit<Required<NestedJsonFilterBase<$PrismaModel>>, 'path'>>
|
||||
|
||||
export type NestedJsonFilterBase<$PrismaModel = never> = {
|
||||
equals?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||
path?: string[]
|
||||
mode?: Prisma.QueryMode | Prisma.EnumQueryModeFieldRefInput<$PrismaModel>
|
||||
string_contains?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
string_starts_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
string_ends_with?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
array_starts_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
array_ends_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
array_contains?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null
|
||||
lt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
lte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
gt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
gte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel>
|
||||
not?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter
|
||||
}
|
||||
|
||||
export type NestedEnumAgentSessionTypeFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.AgentSessionType | Prisma.EnumAgentSessionTypeFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.AgentSessionType[] | Prisma.ListEnumAgentSessionTypeFieldRefInput<$PrismaModel>
|
||||
|
||||
+21
@@ -132,6 +132,7 @@ export const WorkflowTaskType = {
|
||||
transcode_pdf_pages: 'transcode_pdf_pages',
|
||||
transcode_screenshot: 'transcode_screenshot',
|
||||
transcode_image_annotation: 'transcode_image_annotation',
|
||||
transcode_watermark: 'transcode_watermark',
|
||||
ai_metadata_autofill: 'ai_metadata_autofill',
|
||||
chat: 'chat',
|
||||
ai_embedding: 'ai_embedding',
|
||||
@@ -152,6 +153,26 @@ export const WorkflowTaskStatus = {
|
||||
export type WorkflowTaskStatus = (typeof WorkflowTaskStatus)[keyof typeof WorkflowTaskStatus]
|
||||
|
||||
|
||||
export const WatermarkStatus = {
|
||||
disabled: 'disabled',
|
||||
processing: 'processing',
|
||||
ready: 'ready',
|
||||
failed: 'failed'
|
||||
} as const
|
||||
|
||||
export type WatermarkStatus = (typeof WatermarkStatus)[keyof typeof WatermarkStatus]
|
||||
|
||||
|
||||
export const WatermarkFileStatus = {
|
||||
pending: 'pending',
|
||||
processing: 'processing',
|
||||
completed: 'completed',
|
||||
failed: 'failed'
|
||||
} as const
|
||||
|
||||
export type WatermarkFileStatus = (typeof WatermarkFileStatus)[keyof typeof WatermarkFileStatus]
|
||||
|
||||
|
||||
export const AgentType = {
|
||||
chat: 'chat',
|
||||
autofill: 'autofill',
|
||||
|
||||
+34
-4
File diff suppressed because one or more lines are too long
+297
-2
@@ -396,6 +396,9 @@ export const ModelName = {
|
||||
Project: 'Project',
|
||||
ProjectMember: 'ProjectMember',
|
||||
ShareLink: 'ShareLink',
|
||||
WatermarkConfig: 'WatermarkConfig',
|
||||
WatermarkTemplate: 'WatermarkTemplate',
|
||||
WatermarkFile: 'WatermarkFile',
|
||||
Asset: 'Asset',
|
||||
StorageKey: 'StorageKey',
|
||||
AssetMetadataValue: 'AssetMetadataValue',
|
||||
@@ -434,7 +437,7 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
||||
omit: GlobalOmitOptions
|
||||
}
|
||||
meta: {
|
||||
modelProps: "user" | "session" | "account" | "verification" | "authToken" | "team" | "sandbox" | "skill" | "teamMember" | "project" | "projectMember" | "shareLink" | "asset" | "storageKey" | "assetMetadataValue" | "assetComment" | "assetCommentAttachment" | "assetEmbedding" | "invite" | "metadataField" | "notification" | "systemSettings" | "task" | "workflowTask" | "agent" | "agentSkill" | "agentSession" | "agentSessionEntry" | "userMetadata" | "model" | "provider" | "collection" | "apiToken" | "aiUsage" | "auditLog"
|
||||
modelProps: "user" | "session" | "account" | "verification" | "authToken" | "team" | "sandbox" | "skill" | "teamMember" | "project" | "projectMember" | "shareLink" | "watermarkConfig" | "watermarkTemplate" | "watermarkFile" | "asset" | "storageKey" | "assetMetadataValue" | "assetComment" | "assetCommentAttachment" | "assetEmbedding" | "invite" | "metadataField" | "notification" | "systemSettings" | "task" | "workflowTask" | "agent" | "agentSkill" | "agentSession" | "agentSessionEntry" | "userMetadata" | "model" | "provider" | "collection" | "apiToken" | "aiUsage" | "auditLog"
|
||||
txIsolationLevel: TransactionIsolationLevel
|
||||
}
|
||||
model: {
|
||||
@@ -1326,6 +1329,228 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
||||
}
|
||||
}
|
||||
}
|
||||
WatermarkConfig: {
|
||||
payload: Prisma.$WatermarkConfigPayload<ExtArgs>
|
||||
fields: Prisma.WatermarkConfigFieldRefs
|
||||
operations: {
|
||||
findUnique: {
|
||||
args: Prisma.WatermarkConfigFindUniqueArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkConfigPayload> | null
|
||||
}
|
||||
findUniqueOrThrow: {
|
||||
args: Prisma.WatermarkConfigFindUniqueOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkConfigPayload>
|
||||
}
|
||||
findFirst: {
|
||||
args: Prisma.WatermarkConfigFindFirstArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkConfigPayload> | null
|
||||
}
|
||||
findFirstOrThrow: {
|
||||
args: Prisma.WatermarkConfigFindFirstOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkConfigPayload>
|
||||
}
|
||||
findMany: {
|
||||
args: Prisma.WatermarkConfigFindManyArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkConfigPayload>[]
|
||||
}
|
||||
create: {
|
||||
args: Prisma.WatermarkConfigCreateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkConfigPayload>
|
||||
}
|
||||
createMany: {
|
||||
args: Prisma.WatermarkConfigCreateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
createManyAndReturn: {
|
||||
args: Prisma.WatermarkConfigCreateManyAndReturnArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkConfigPayload>[]
|
||||
}
|
||||
delete: {
|
||||
args: Prisma.WatermarkConfigDeleteArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkConfigPayload>
|
||||
}
|
||||
update: {
|
||||
args: Prisma.WatermarkConfigUpdateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkConfigPayload>
|
||||
}
|
||||
deleteMany: {
|
||||
args: Prisma.WatermarkConfigDeleteManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateMany: {
|
||||
args: Prisma.WatermarkConfigUpdateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateManyAndReturn: {
|
||||
args: Prisma.WatermarkConfigUpdateManyAndReturnArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkConfigPayload>[]
|
||||
}
|
||||
upsert: {
|
||||
args: Prisma.WatermarkConfigUpsertArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkConfigPayload>
|
||||
}
|
||||
aggregate: {
|
||||
args: Prisma.WatermarkConfigAggregateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.AggregateWatermarkConfig>
|
||||
}
|
||||
groupBy: {
|
||||
args: Prisma.WatermarkConfigGroupByArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.WatermarkConfigGroupByOutputType>[]
|
||||
}
|
||||
count: {
|
||||
args: Prisma.WatermarkConfigCountArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.WatermarkConfigCountAggregateOutputType> | number
|
||||
}
|
||||
}
|
||||
}
|
||||
WatermarkTemplate: {
|
||||
payload: Prisma.$WatermarkTemplatePayload<ExtArgs>
|
||||
fields: Prisma.WatermarkTemplateFieldRefs
|
||||
operations: {
|
||||
findUnique: {
|
||||
args: Prisma.WatermarkTemplateFindUniqueArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkTemplatePayload> | null
|
||||
}
|
||||
findUniqueOrThrow: {
|
||||
args: Prisma.WatermarkTemplateFindUniqueOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkTemplatePayload>
|
||||
}
|
||||
findFirst: {
|
||||
args: Prisma.WatermarkTemplateFindFirstArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkTemplatePayload> | null
|
||||
}
|
||||
findFirstOrThrow: {
|
||||
args: Prisma.WatermarkTemplateFindFirstOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkTemplatePayload>
|
||||
}
|
||||
findMany: {
|
||||
args: Prisma.WatermarkTemplateFindManyArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkTemplatePayload>[]
|
||||
}
|
||||
create: {
|
||||
args: Prisma.WatermarkTemplateCreateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkTemplatePayload>
|
||||
}
|
||||
createMany: {
|
||||
args: Prisma.WatermarkTemplateCreateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
createManyAndReturn: {
|
||||
args: Prisma.WatermarkTemplateCreateManyAndReturnArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkTemplatePayload>[]
|
||||
}
|
||||
delete: {
|
||||
args: Prisma.WatermarkTemplateDeleteArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkTemplatePayload>
|
||||
}
|
||||
update: {
|
||||
args: Prisma.WatermarkTemplateUpdateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkTemplatePayload>
|
||||
}
|
||||
deleteMany: {
|
||||
args: Prisma.WatermarkTemplateDeleteManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateMany: {
|
||||
args: Prisma.WatermarkTemplateUpdateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateManyAndReturn: {
|
||||
args: Prisma.WatermarkTemplateUpdateManyAndReturnArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkTemplatePayload>[]
|
||||
}
|
||||
upsert: {
|
||||
args: Prisma.WatermarkTemplateUpsertArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkTemplatePayload>
|
||||
}
|
||||
aggregate: {
|
||||
args: Prisma.WatermarkTemplateAggregateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.AggregateWatermarkTemplate>
|
||||
}
|
||||
groupBy: {
|
||||
args: Prisma.WatermarkTemplateGroupByArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.WatermarkTemplateGroupByOutputType>[]
|
||||
}
|
||||
count: {
|
||||
args: Prisma.WatermarkTemplateCountArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.WatermarkTemplateCountAggregateOutputType> | number
|
||||
}
|
||||
}
|
||||
}
|
||||
WatermarkFile: {
|
||||
payload: Prisma.$WatermarkFilePayload<ExtArgs>
|
||||
fields: Prisma.WatermarkFileFieldRefs
|
||||
operations: {
|
||||
findUnique: {
|
||||
args: Prisma.WatermarkFileFindUniqueArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkFilePayload> | null
|
||||
}
|
||||
findUniqueOrThrow: {
|
||||
args: Prisma.WatermarkFileFindUniqueOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkFilePayload>
|
||||
}
|
||||
findFirst: {
|
||||
args: Prisma.WatermarkFileFindFirstArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkFilePayload> | null
|
||||
}
|
||||
findFirstOrThrow: {
|
||||
args: Prisma.WatermarkFileFindFirstOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkFilePayload>
|
||||
}
|
||||
findMany: {
|
||||
args: Prisma.WatermarkFileFindManyArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkFilePayload>[]
|
||||
}
|
||||
create: {
|
||||
args: Prisma.WatermarkFileCreateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkFilePayload>
|
||||
}
|
||||
createMany: {
|
||||
args: Prisma.WatermarkFileCreateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
createManyAndReturn: {
|
||||
args: Prisma.WatermarkFileCreateManyAndReturnArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkFilePayload>[]
|
||||
}
|
||||
delete: {
|
||||
args: Prisma.WatermarkFileDeleteArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkFilePayload>
|
||||
}
|
||||
update: {
|
||||
args: Prisma.WatermarkFileUpdateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkFilePayload>
|
||||
}
|
||||
deleteMany: {
|
||||
args: Prisma.WatermarkFileDeleteManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateMany: {
|
||||
args: Prisma.WatermarkFileUpdateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateManyAndReturn: {
|
||||
args: Prisma.WatermarkFileUpdateManyAndReturnArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkFilePayload>[]
|
||||
}
|
||||
upsert: {
|
||||
args: Prisma.WatermarkFileUpsertArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$WatermarkFilePayload>
|
||||
}
|
||||
aggregate: {
|
||||
args: Prisma.WatermarkFileAggregateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.AggregateWatermarkFile>
|
||||
}
|
||||
groupBy: {
|
||||
args: Prisma.WatermarkFileGroupByArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.WatermarkFileGroupByOutputType>[]
|
||||
}
|
||||
count: {
|
||||
args: Prisma.WatermarkFileCountArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.WatermarkFileCountAggregateOutputType> | number
|
||||
}
|
||||
}
|
||||
}
|
||||
Asset: {
|
||||
payload: Prisma.$AssetPayload<ExtArgs>
|
||||
fields: Prisma.AssetFieldRefs
|
||||
@@ -3225,6 +3450,7 @@ export const ShareLinkScalarFieldEnum = {
|
||||
expireAt: 'expireAt',
|
||||
password: 'password',
|
||||
isDisabled: 'isDisabled',
|
||||
allowDownload: 'allowDownload',
|
||||
defaultSortOrder: 'defaultSortOrder',
|
||||
viewMode: 'viewMode',
|
||||
fieldVisibility: 'fieldVisibility',
|
||||
@@ -3232,12 +3458,50 @@ export const ShareLinkScalarFieldEnum = {
|
||||
updatedAt: 'updatedAt',
|
||||
projectId: 'projectId',
|
||||
rootFolderId: 'rootFolderId',
|
||||
creatorId: 'creatorId'
|
||||
creatorId: 'creatorId',
|
||||
watermarkConfigId: 'watermarkConfigId',
|
||||
watermarkStatus: 'watermarkStatus'
|
||||
} as const
|
||||
|
||||
export type ShareLinkScalarFieldEnum = (typeof ShareLinkScalarFieldEnum)[keyof typeof ShareLinkScalarFieldEnum]
|
||||
|
||||
|
||||
export const WatermarkConfigScalarFieldEnum = {
|
||||
id: 'id',
|
||||
config: 'config',
|
||||
hash: 'hash',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt'
|
||||
} as const
|
||||
|
||||
export type WatermarkConfigScalarFieldEnum = (typeof WatermarkConfigScalarFieldEnum)[keyof typeof WatermarkConfigScalarFieldEnum]
|
||||
|
||||
|
||||
export const WatermarkTemplateScalarFieldEnum = {
|
||||
id: 'id',
|
||||
name: 'name',
|
||||
config: 'config',
|
||||
teamId: 'teamId',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt'
|
||||
} as const
|
||||
|
||||
export type WatermarkTemplateScalarFieldEnum = (typeof WatermarkTemplateScalarFieldEnum)[keyof typeof WatermarkTemplateScalarFieldEnum]
|
||||
|
||||
|
||||
export const WatermarkFileScalarFieldEnum = {
|
||||
id: 'id',
|
||||
assetId: 'assetId',
|
||||
watermarkConfigId: 'watermarkConfigId',
|
||||
media: 'media',
|
||||
status: 'status',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt'
|
||||
} as const
|
||||
|
||||
export type WatermarkFileScalarFieldEnum = (typeof WatermarkFileScalarFieldEnum)[keyof typeof WatermarkFileScalarFieldEnum]
|
||||
|
||||
|
||||
export const AssetScalarFieldEnum = {
|
||||
id: 'id',
|
||||
name: 'name',
|
||||
@@ -3736,6 +4000,34 @@ export type ListEnumProjectMemberRoleFieldRefInput<$PrismaModel> = FieldRefInput
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'WatermarkStatus'
|
||||
*/
|
||||
export type EnumWatermarkStatusFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'WatermarkStatus'>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'WatermarkStatus[]'
|
||||
*/
|
||||
export type ListEnumWatermarkStatusFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'WatermarkStatus[]'>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'WatermarkFileStatus'
|
||||
*/
|
||||
export type EnumWatermarkFileStatusFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'WatermarkFileStatus'>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'WatermarkFileStatus[]'
|
||||
*/
|
||||
export type ListEnumWatermarkFileStatusFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'WatermarkFileStatus[]'>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'AssetType'
|
||||
*/
|
||||
@@ -4067,6 +4359,9 @@ export type GlobalOmitConfig = {
|
||||
project?: Prisma.ProjectOmit
|
||||
projectMember?: Prisma.ProjectMemberOmit
|
||||
shareLink?: Prisma.ShareLinkOmit
|
||||
watermarkConfig?: Prisma.WatermarkConfigOmit
|
||||
watermarkTemplate?: Prisma.WatermarkTemplateOmit
|
||||
watermarkFile?: Prisma.WatermarkFileOmit
|
||||
asset?: Prisma.AssetOmit
|
||||
storageKey?: Prisma.StorageKeyOmit
|
||||
assetMetadataValue?: Prisma.AssetMetadataValueOmit
|
||||
|
||||
@@ -63,6 +63,9 @@ export const ModelName = {
|
||||
Project: 'Project',
|
||||
ProjectMember: 'ProjectMember',
|
||||
ShareLink: 'ShareLink',
|
||||
WatermarkConfig: 'WatermarkConfig',
|
||||
WatermarkTemplate: 'WatermarkTemplate',
|
||||
WatermarkFile: 'WatermarkFile',
|
||||
Asset: 'Asset',
|
||||
StorageKey: 'StorageKey',
|
||||
AssetMetadataValue: 'AssetMetadataValue',
|
||||
@@ -262,6 +265,7 @@ export const ShareLinkScalarFieldEnum = {
|
||||
expireAt: 'expireAt',
|
||||
password: 'password',
|
||||
isDisabled: 'isDisabled',
|
||||
allowDownload: 'allowDownload',
|
||||
defaultSortOrder: 'defaultSortOrder',
|
||||
viewMode: 'viewMode',
|
||||
fieldVisibility: 'fieldVisibility',
|
||||
@@ -269,12 +273,50 @@ export const ShareLinkScalarFieldEnum = {
|
||||
updatedAt: 'updatedAt',
|
||||
projectId: 'projectId',
|
||||
rootFolderId: 'rootFolderId',
|
||||
creatorId: 'creatorId'
|
||||
creatorId: 'creatorId',
|
||||
watermarkConfigId: 'watermarkConfigId',
|
||||
watermarkStatus: 'watermarkStatus'
|
||||
} as const
|
||||
|
||||
export type ShareLinkScalarFieldEnum = (typeof ShareLinkScalarFieldEnum)[keyof typeof ShareLinkScalarFieldEnum]
|
||||
|
||||
|
||||
export const WatermarkConfigScalarFieldEnum = {
|
||||
id: 'id',
|
||||
config: 'config',
|
||||
hash: 'hash',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt'
|
||||
} as const
|
||||
|
||||
export type WatermarkConfigScalarFieldEnum = (typeof WatermarkConfigScalarFieldEnum)[keyof typeof WatermarkConfigScalarFieldEnum]
|
||||
|
||||
|
||||
export const WatermarkTemplateScalarFieldEnum = {
|
||||
id: 'id',
|
||||
name: 'name',
|
||||
config: 'config',
|
||||
teamId: 'teamId',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt'
|
||||
} as const
|
||||
|
||||
export type WatermarkTemplateScalarFieldEnum = (typeof WatermarkTemplateScalarFieldEnum)[keyof typeof WatermarkTemplateScalarFieldEnum]
|
||||
|
||||
|
||||
export const WatermarkFileScalarFieldEnum = {
|
||||
id: 'id',
|
||||
assetId: 'assetId',
|
||||
watermarkConfigId: 'watermarkConfigId',
|
||||
media: 'media',
|
||||
status: 'status',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt'
|
||||
} as const
|
||||
|
||||
export type WatermarkFileScalarFieldEnum = (typeof WatermarkFileScalarFieldEnum)[keyof typeof WatermarkFileScalarFieldEnum]
|
||||
|
||||
|
||||
export const AssetScalarFieldEnum = {
|
||||
id: 'id',
|
||||
name: 'name',
|
||||
|
||||
+3
@@ -20,6 +20,9 @@ export type * from './models/TeamMember.ts'
|
||||
export type * from './models/Project.ts'
|
||||
export type * from './models/ProjectMember.ts'
|
||||
export type * from './models/ShareLink.ts'
|
||||
export type * from './models/WatermarkConfig.ts'
|
||||
export type * from './models/WatermarkTemplate.ts'
|
||||
export type * from './models/WatermarkFile.ts'
|
||||
export type * from './models/Asset.ts'
|
||||
export type * from './models/StorageKey.ts'
|
||||
export type * from './models/AssetMetadataValue.ts'
|
||||
|
||||
+294
@@ -368,6 +368,7 @@ export type AssetWhereInput = {
|
||||
projectShareRoot?: Prisma.XOR<Prisma.ProjectNullableScalarRelationFilter, Prisma.ProjectWhereInput> | null
|
||||
shareLinkRootFolder?: Prisma.XOR<Prisma.ShareLinkNullableScalarRelationFilter, Prisma.ShareLinkWhereInput> | null
|
||||
agentSessions?: Prisma.AgentSessionListRelationFilter
|
||||
watermarkFiles?: Prisma.WatermarkFileListRelationFilter
|
||||
}
|
||||
|
||||
export type AssetOrderByWithRelationInput = {
|
||||
@@ -411,6 +412,7 @@ export type AssetOrderByWithRelationInput = {
|
||||
projectShareRoot?: Prisma.ProjectOrderByWithRelationInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkOrderByWithRelationInput
|
||||
agentSessions?: Prisma.AgentSessionOrderByRelationAggregateInput
|
||||
watermarkFiles?: Prisma.WatermarkFileOrderByRelationAggregateInput
|
||||
}
|
||||
|
||||
export type AssetWhereUniqueInput = Prisma.AtLeast<{
|
||||
@@ -458,6 +460,7 @@ export type AssetWhereUniqueInput = Prisma.AtLeast<{
|
||||
projectShareRoot?: Prisma.XOR<Prisma.ProjectNullableScalarRelationFilter, Prisma.ProjectWhereInput> | null
|
||||
shareLinkRootFolder?: Prisma.XOR<Prisma.ShareLinkNullableScalarRelationFilter, Prisma.ShareLinkWhereInput> | null
|
||||
agentSessions?: Prisma.AgentSessionListRelationFilter
|
||||
watermarkFiles?: Prisma.WatermarkFileListRelationFilter
|
||||
}, "id" | "parentIdTargetId">
|
||||
|
||||
export type AssetOrderByWithAggregationInput = {
|
||||
@@ -553,6 +556,7 @@ export type AssetCreateInput = {
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateInput = {
|
||||
@@ -590,6 +594,7 @@ export type AssetUncheckedCreateInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUpdateInput = {
|
||||
@@ -627,6 +632,7 @@ export type AssetUpdateInput = {
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateInput = {
|
||||
@@ -664,6 +670,7 @@ export type AssetUncheckedUpdateInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetCreateManyInput = {
|
||||
@@ -987,6 +994,20 @@ export type AssetUpdateOneRequiredWithoutShareLinkRootFolderNestedInput = {
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.AssetUpdateToOneWithWhereWithoutShareLinkRootFolderInput, Prisma.AssetUpdateWithoutShareLinkRootFolderInput>, Prisma.AssetUncheckedUpdateWithoutShareLinkRootFolderInput>
|
||||
}
|
||||
|
||||
export type AssetCreateNestedOneWithoutWatermarkFilesInput = {
|
||||
create?: Prisma.XOR<Prisma.AssetCreateWithoutWatermarkFilesInput, Prisma.AssetUncheckedCreateWithoutWatermarkFilesInput>
|
||||
connectOrCreate?: Prisma.AssetCreateOrConnectWithoutWatermarkFilesInput
|
||||
connect?: Prisma.AssetWhereUniqueInput
|
||||
}
|
||||
|
||||
export type AssetUpdateOneRequiredWithoutWatermarkFilesNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.AssetCreateWithoutWatermarkFilesInput, Prisma.AssetUncheckedCreateWithoutWatermarkFilesInput>
|
||||
connectOrCreate?: Prisma.AssetCreateOrConnectWithoutWatermarkFilesInput
|
||||
upsert?: Prisma.AssetUpsertWithoutWatermarkFilesInput
|
||||
connect?: Prisma.AssetWhereUniqueInput
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.AssetUpdateToOneWithWhereWithoutWatermarkFilesInput, Prisma.AssetUpdateWithoutWatermarkFilesInput>, Prisma.AssetUncheckedUpdateWithoutWatermarkFilesInput>
|
||||
}
|
||||
|
||||
export type AssetCreatenameNgramInput = {
|
||||
set: string[]
|
||||
}
|
||||
@@ -1342,6 +1363,7 @@ export type AssetCreateWithoutCreatorInput = {
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutCreatorInput = {
|
||||
@@ -1378,6 +1400,7 @@ export type AssetUncheckedCreateWithoutCreatorInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutCreatorInput = {
|
||||
@@ -1468,6 +1491,7 @@ export type AssetCreateWithoutTeamRootFolderInput = {
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutTeamRootFolderInput = {
|
||||
@@ -1504,6 +1528,7 @@ export type AssetUncheckedCreateWithoutTeamRootFolderInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutTeamRootFolderInput = {
|
||||
@@ -1556,6 +1581,7 @@ export type AssetUpdateWithoutTeamRootFolderInput = {
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutTeamRootFolderInput = {
|
||||
@@ -1592,6 +1618,7 @@ export type AssetUncheckedUpdateWithoutTeamRootFolderInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetCreateWithoutProjectRootFolderInput = {
|
||||
@@ -1628,6 +1655,7 @@ export type AssetCreateWithoutProjectRootFolderInput = {
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutProjectRootFolderInput = {
|
||||
@@ -1664,6 +1692,7 @@ export type AssetUncheckedCreateWithoutProjectRootFolderInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutProjectRootFolderInput = {
|
||||
@@ -1705,6 +1734,7 @@ export type AssetCreateWithoutProjectShareRootInput = {
|
||||
projectRootFolder?: Prisma.ProjectCreateNestedOneWithoutRootFolderInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutProjectShareRootInput = {
|
||||
@@ -1741,6 +1771,7 @@ export type AssetUncheckedCreateWithoutProjectShareRootInput = {
|
||||
projectRootFolder?: Prisma.ProjectUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutProjectShareRootInput = {
|
||||
@@ -1782,6 +1813,7 @@ export type AssetCreateWithoutProjectInput = {
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutProjectInput = {
|
||||
@@ -1818,6 +1850,7 @@ export type AssetUncheckedCreateWithoutProjectInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutProjectInput = {
|
||||
@@ -1875,6 +1908,7 @@ export type AssetUpdateWithoutProjectRootFolderInput = {
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutProjectRootFolderInput = {
|
||||
@@ -1911,6 +1945,7 @@ export type AssetUncheckedUpdateWithoutProjectRootFolderInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUpsertWithoutProjectShareRootInput = {
|
||||
@@ -1958,6 +1993,7 @@ export type AssetUpdateWithoutProjectShareRootInput = {
|
||||
projectRootFolder?: Prisma.ProjectUpdateOneWithoutRootFolderNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutProjectShareRootInput = {
|
||||
@@ -1994,6 +2030,7 @@ export type AssetUncheckedUpdateWithoutProjectShareRootInput = {
|
||||
projectRootFolder?: Prisma.ProjectUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUpsertWithWhereUniqueWithoutProjectInput = {
|
||||
@@ -2046,6 +2083,7 @@ export type AssetCreateWithoutShareLinkRootFolderInput = {
|
||||
projectRootFolder?: Prisma.ProjectCreateNestedOneWithoutRootFolderInput
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutShareLinkRootFolderInput = {
|
||||
@@ -2082,6 +2120,7 @@ export type AssetUncheckedCreateWithoutShareLinkRootFolderInput = {
|
||||
projectRootFolder?: Prisma.ProjectUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutShareLinkRootFolderInput = {
|
||||
@@ -2134,6 +2173,7 @@ export type AssetUpdateWithoutShareLinkRootFolderInput = {
|
||||
projectRootFolder?: Prisma.ProjectUpdateOneWithoutRootFolderNestedInput
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutShareLinkRootFolderInput = {
|
||||
@@ -2170,6 +2210,171 @@ export type AssetUncheckedUpdateWithoutShareLinkRootFolderInput = {
|
||||
projectRootFolder?: Prisma.ProjectUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetCreateWithoutWatermarkFilesInput = {
|
||||
id?: string
|
||||
name?: string
|
||||
nameNgram?: Prisma.AssetCreatenameNgramInput | string[]
|
||||
type: $Enums.AssetType
|
||||
mediaType?: string | null
|
||||
fileCount?: number
|
||||
sizeByte?: bigint | number
|
||||
status: $Enums.AssetStatus
|
||||
transcodeTaskId?: string | null
|
||||
media?:PrismaJson.MediaInfo | Prisma.NullableJsonNullValueInput
|
||||
autofillContext?: string | null
|
||||
isDeleted?: boolean
|
||||
deletedAt?: Date | string | null
|
||||
sortIndex?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
parent?: Prisma.AssetCreateNestedOneWithoutChildrenInput
|
||||
children?: Prisma.AssetCreateNestedManyWithoutParentInput
|
||||
target?: Prisma.AssetCreateNestedOneWithoutSymlinksInput
|
||||
symlinks?: Prisma.AssetCreateNestedManyWithoutTargetInput
|
||||
storageKey?: Prisma.StorageKeyCreateNestedOneWithoutAssetsInput
|
||||
metadataValues?: Prisma.AssetMetadataValueCreateNestedManyWithoutAssetInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutAssetsInput
|
||||
task?: Prisma.TaskCreateNestedOneWithoutAssetsInput
|
||||
project?: Prisma.ProjectCreateNestedOneWithoutAssetsInput
|
||||
comments?: Prisma.AssetCommentCreateNestedManyWithoutAssetInput
|
||||
commentAttachments?: Prisma.AssetCommentAttachmentCreateNestedManyWithoutAssetInput
|
||||
notifications?: Prisma.NotificationCreateNestedManyWithoutAssetInput
|
||||
embeddings?: Prisma.AssetEmbeddingCreateNestedManyWithoutAssetInput
|
||||
teamRootFolder?: Prisma.TeamCreateNestedOneWithoutRootFolderInput
|
||||
projectRootFolder?: Prisma.ProjectCreateNestedOneWithoutRootFolderInput
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutWatermarkFilesInput = {
|
||||
id?: string
|
||||
name?: string
|
||||
nameNgram?: Prisma.AssetCreatenameNgramInput | string[]
|
||||
type: $Enums.AssetType
|
||||
mediaType?: string | null
|
||||
fileCount?: number
|
||||
sizeByte?: bigint | number
|
||||
status: $Enums.AssetStatus
|
||||
transcodeTaskId?: string | null
|
||||
media?:PrismaJson.MediaInfo | Prisma.NullableJsonNullValueInput
|
||||
autofillContext?: string | null
|
||||
isDeleted?: boolean
|
||||
deletedAt?: Date | string | null
|
||||
sortIndex?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
parentId?: string | null
|
||||
targetId?: string | null
|
||||
storageKeyId?: string | null
|
||||
creatorId?: string | null
|
||||
taskId?: string | null
|
||||
projectId?: string | null
|
||||
children?: Prisma.AssetUncheckedCreateNestedManyWithoutParentInput
|
||||
symlinks?: Prisma.AssetUncheckedCreateNestedManyWithoutTargetInput
|
||||
metadataValues?: Prisma.AssetMetadataValueUncheckedCreateNestedManyWithoutAssetInput
|
||||
comments?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutAssetInput
|
||||
commentAttachments?: Prisma.AssetCommentAttachmentUncheckedCreateNestedManyWithoutAssetInput
|
||||
notifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutAssetInput
|
||||
embeddings?: Prisma.AssetEmbeddingUncheckedCreateNestedManyWithoutAssetInput
|
||||
teamRootFolder?: Prisma.TeamUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
projectRootFolder?: Prisma.ProjectUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutWatermarkFilesInput = {
|
||||
where: Prisma.AssetWhereUniqueInput
|
||||
create: Prisma.XOR<Prisma.AssetCreateWithoutWatermarkFilesInput, Prisma.AssetUncheckedCreateWithoutWatermarkFilesInput>
|
||||
}
|
||||
|
||||
export type AssetUpsertWithoutWatermarkFilesInput = {
|
||||
update: Prisma.XOR<Prisma.AssetUpdateWithoutWatermarkFilesInput, Prisma.AssetUncheckedUpdateWithoutWatermarkFilesInput>
|
||||
create: Prisma.XOR<Prisma.AssetCreateWithoutWatermarkFilesInput, Prisma.AssetUncheckedCreateWithoutWatermarkFilesInput>
|
||||
where?: Prisma.AssetWhereInput
|
||||
}
|
||||
|
||||
export type AssetUpdateToOneWithWhereWithoutWatermarkFilesInput = {
|
||||
where?: Prisma.AssetWhereInput
|
||||
data: Prisma.XOR<Prisma.AssetUpdateWithoutWatermarkFilesInput, Prisma.AssetUncheckedUpdateWithoutWatermarkFilesInput>
|
||||
}
|
||||
|
||||
export type AssetUpdateWithoutWatermarkFilesInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
nameNgram?: Prisma.AssetUpdatenameNgramInput | string[]
|
||||
type?: Prisma.EnumAssetTypeFieldUpdateOperationsInput | $Enums.AssetType
|
||||
mediaType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fileCount?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
sizeByte?: Prisma.BigIntFieldUpdateOperationsInput | bigint | number
|
||||
status?: Prisma.EnumAssetStatusFieldUpdateOperationsInput | $Enums.AssetStatus
|
||||
transcodeTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
media?:PrismaJson.MediaInfo | Prisma.NullableJsonNullValueInput
|
||||
autofillContext?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDeleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
sortIndex?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
parent?: Prisma.AssetUpdateOneWithoutChildrenNestedInput
|
||||
children?: Prisma.AssetUpdateManyWithoutParentNestedInput
|
||||
target?: Prisma.AssetUpdateOneWithoutSymlinksNestedInput
|
||||
symlinks?: Prisma.AssetUpdateManyWithoutTargetNestedInput
|
||||
storageKey?: Prisma.StorageKeyUpdateOneWithoutAssetsNestedInput
|
||||
metadataValues?: Prisma.AssetMetadataValueUpdateManyWithoutAssetNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutAssetsNestedInput
|
||||
task?: Prisma.TaskUpdateOneWithoutAssetsNestedInput
|
||||
project?: Prisma.ProjectUpdateOneWithoutAssetsNestedInput
|
||||
comments?: Prisma.AssetCommentUpdateManyWithoutAssetNestedInput
|
||||
commentAttachments?: Prisma.AssetCommentAttachmentUpdateManyWithoutAssetNestedInput
|
||||
notifications?: Prisma.NotificationUpdateManyWithoutAssetNestedInput
|
||||
embeddings?: Prisma.AssetEmbeddingUpdateManyWithoutAssetNestedInput
|
||||
teamRootFolder?: Prisma.TeamUpdateOneWithoutRootFolderNestedInput
|
||||
projectRootFolder?: Prisma.ProjectUpdateOneWithoutRootFolderNestedInput
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutWatermarkFilesInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
nameNgram?: Prisma.AssetUpdatenameNgramInput | string[]
|
||||
type?: Prisma.EnumAssetTypeFieldUpdateOperationsInput | $Enums.AssetType
|
||||
mediaType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fileCount?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
sizeByte?: Prisma.BigIntFieldUpdateOperationsInput | bigint | number
|
||||
status?: Prisma.EnumAssetStatusFieldUpdateOperationsInput | $Enums.AssetStatus
|
||||
transcodeTaskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
media?:PrismaJson.MediaInfo | Prisma.NullableJsonNullValueInput
|
||||
autofillContext?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDeleted?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
deletedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
sortIndex?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
parentId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
targetId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
storageKeyId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
taskId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
projectId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
children?: Prisma.AssetUncheckedUpdateManyWithoutParentNestedInput
|
||||
symlinks?: Prisma.AssetUncheckedUpdateManyWithoutTargetNestedInput
|
||||
metadataValues?: Prisma.AssetMetadataValueUncheckedUpdateManyWithoutAssetNestedInput
|
||||
comments?: Prisma.AssetCommentUncheckedUpdateManyWithoutAssetNestedInput
|
||||
commentAttachments?: Prisma.AssetCommentAttachmentUncheckedUpdateManyWithoutAssetNestedInput
|
||||
notifications?: Prisma.NotificationUncheckedUpdateManyWithoutAssetNestedInput
|
||||
embeddings?: Prisma.AssetEmbeddingUncheckedUpdateManyWithoutAssetNestedInput
|
||||
teamRootFolder?: Prisma.TeamUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
projectRootFolder?: Prisma.ProjectUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetCreateWithoutChildrenInput = {
|
||||
@@ -2206,6 +2411,7 @@ export type AssetCreateWithoutChildrenInput = {
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutChildrenInput = {
|
||||
@@ -2242,6 +2448,7 @@ export type AssetUncheckedCreateWithoutChildrenInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutChildrenInput = {
|
||||
@@ -2283,6 +2490,7 @@ export type AssetCreateWithoutParentInput = {
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutParentInput = {
|
||||
@@ -2319,6 +2527,7 @@ export type AssetUncheckedCreateWithoutParentInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutParentInput = {
|
||||
@@ -2365,6 +2574,7 @@ export type AssetCreateWithoutSymlinksInput = {
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutSymlinksInput = {
|
||||
@@ -2401,6 +2611,7 @@ export type AssetUncheckedCreateWithoutSymlinksInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutSymlinksInput = {
|
||||
@@ -2442,6 +2653,7 @@ export type AssetCreateWithoutTargetInput = {
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutTargetInput = {
|
||||
@@ -2478,6 +2690,7 @@ export type AssetUncheckedCreateWithoutTargetInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutTargetInput = {
|
||||
@@ -2535,6 +2748,7 @@ export type AssetUpdateWithoutChildrenInput = {
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutChildrenInput = {
|
||||
@@ -2571,6 +2785,7 @@ export type AssetUncheckedUpdateWithoutChildrenInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUpsertWithWhereUniqueWithoutParentInput = {
|
||||
@@ -2634,6 +2849,7 @@ export type AssetUpdateWithoutSymlinksInput = {
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutSymlinksInput = {
|
||||
@@ -2670,6 +2886,7 @@ export type AssetUncheckedUpdateWithoutSymlinksInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUpsertWithWhereUniqueWithoutTargetInput = {
|
||||
@@ -2722,6 +2939,7 @@ export type AssetCreateWithoutStorageKeyInput = {
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutStorageKeyInput = {
|
||||
@@ -2758,6 +2976,7 @@ export type AssetUncheckedCreateWithoutStorageKeyInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutStorageKeyInput = {
|
||||
@@ -2820,6 +3039,7 @@ export type AssetCreateWithoutMetadataValuesInput = {
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutMetadataValuesInput = {
|
||||
@@ -2856,6 +3076,7 @@ export type AssetUncheckedCreateWithoutMetadataValuesInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutMetadataValuesInput = {
|
||||
@@ -2908,6 +3129,7 @@ export type AssetUpdateWithoutMetadataValuesInput = {
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutMetadataValuesInput = {
|
||||
@@ -2944,6 +3166,7 @@ export type AssetUncheckedUpdateWithoutMetadataValuesInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetCreateWithoutCommentsInput = {
|
||||
@@ -2980,6 +3203,7 @@ export type AssetCreateWithoutCommentsInput = {
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutCommentsInput = {
|
||||
@@ -3016,6 +3240,7 @@ export type AssetUncheckedCreateWithoutCommentsInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutCommentsInput = {
|
||||
@@ -3068,6 +3293,7 @@ export type AssetUpdateWithoutCommentsInput = {
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutCommentsInput = {
|
||||
@@ -3104,6 +3330,7 @@ export type AssetUncheckedUpdateWithoutCommentsInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetCreateWithoutCommentAttachmentsInput = {
|
||||
@@ -3140,6 +3367,7 @@ export type AssetCreateWithoutCommentAttachmentsInput = {
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutCommentAttachmentsInput = {
|
||||
@@ -3176,6 +3404,7 @@ export type AssetUncheckedCreateWithoutCommentAttachmentsInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutCommentAttachmentsInput = {
|
||||
@@ -3228,6 +3457,7 @@ export type AssetUpdateWithoutCommentAttachmentsInput = {
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutCommentAttachmentsInput = {
|
||||
@@ -3264,6 +3494,7 @@ export type AssetUncheckedUpdateWithoutCommentAttachmentsInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetCreateWithoutEmbeddingsInput = {
|
||||
@@ -3300,6 +3531,7 @@ export type AssetCreateWithoutEmbeddingsInput = {
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutEmbeddingsInput = {
|
||||
@@ -3336,6 +3568,7 @@ export type AssetUncheckedCreateWithoutEmbeddingsInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutEmbeddingsInput = {
|
||||
@@ -3388,6 +3621,7 @@ export type AssetUpdateWithoutEmbeddingsInput = {
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutEmbeddingsInput = {
|
||||
@@ -3424,6 +3658,7 @@ export type AssetUncheckedUpdateWithoutEmbeddingsInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetCreateWithoutNotificationsInput = {
|
||||
@@ -3460,6 +3695,7 @@ export type AssetCreateWithoutNotificationsInput = {
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutNotificationsInput = {
|
||||
@@ -3496,6 +3732,7 @@ export type AssetUncheckedCreateWithoutNotificationsInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutNotificationsInput = {
|
||||
@@ -3548,6 +3785,7 @@ export type AssetUpdateWithoutNotificationsInput = {
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutNotificationsInput = {
|
||||
@@ -3584,6 +3822,7 @@ export type AssetUncheckedUpdateWithoutNotificationsInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetCreateWithoutTaskInput = {
|
||||
@@ -3620,6 +3859,7 @@ export type AssetCreateWithoutTaskInput = {
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutTaskInput = {
|
||||
@@ -3656,6 +3896,7 @@ export type AssetUncheckedCreateWithoutTaskInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutAssetInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutTaskInput = {
|
||||
@@ -3718,6 +3959,7 @@ export type AssetCreateWithoutAgentSessionsInput = {
|
||||
projectRootFolder?: Prisma.ProjectCreateNestedOneWithoutRootFolderInput
|
||||
projectShareRoot?: Prisma.ProjectCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkCreateNestedOneWithoutRootFolderInput
|
||||
watermarkFiles?: Prisma.WatermarkFileCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedCreateWithoutAgentSessionsInput = {
|
||||
@@ -3754,6 +3996,7 @@ export type AssetUncheckedCreateWithoutAgentSessionsInput = {
|
||||
projectRootFolder?: Prisma.ProjectUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
projectShareRoot?: Prisma.ProjectUncheckedCreateNestedOneWithoutShareRootInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedCreateNestedOneWithoutRootFolderInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedCreateNestedManyWithoutAssetInput
|
||||
}
|
||||
|
||||
export type AssetCreateOrConnectWithoutAgentSessionsInput = {
|
||||
@@ -3806,6 +4049,7 @@ export type AssetUpdateWithoutAgentSessionsInput = {
|
||||
projectRootFolder?: Prisma.ProjectUpdateOneWithoutRootFolderNestedInput
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutAgentSessionsInput = {
|
||||
@@ -3842,6 +4086,7 @@ export type AssetUncheckedUpdateWithoutAgentSessionsInput = {
|
||||
projectRootFolder?: Prisma.ProjectUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetCreateManyCreatorInput = {
|
||||
@@ -3902,6 +4147,7 @@ export type AssetUpdateWithoutCreatorInput = {
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutCreatorInput = {
|
||||
@@ -3938,6 +4184,7 @@ export type AssetUncheckedUpdateWithoutCreatorInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateManyWithoutCreatorInput = {
|
||||
@@ -4022,6 +4269,7 @@ export type AssetUpdateWithoutProjectInput = {
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutProjectInput = {
|
||||
@@ -4058,6 +4306,7 @@ export type AssetUncheckedUpdateWithoutProjectInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateManyWithoutProjectInput = {
|
||||
@@ -4166,6 +4415,7 @@ export type AssetUpdateWithoutParentInput = {
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutParentInput = {
|
||||
@@ -4202,6 +4452,7 @@ export type AssetUncheckedUpdateWithoutParentInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateManyWithoutParentInput = {
|
||||
@@ -4262,6 +4513,7 @@ export type AssetUpdateWithoutTargetInput = {
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutTargetInput = {
|
||||
@@ -4298,6 +4550,7 @@ export type AssetUncheckedUpdateWithoutTargetInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateManyWithoutTargetInput = {
|
||||
@@ -4382,6 +4635,7 @@ export type AssetUpdateWithoutStorageKeyInput = {
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutStorageKeyInput = {
|
||||
@@ -4418,6 +4672,7 @@ export type AssetUncheckedUpdateWithoutStorageKeyInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateManyWithoutStorageKeyInput = {
|
||||
@@ -4502,6 +4757,7 @@ export type AssetUpdateWithoutTaskInput = {
|
||||
projectShareRoot?: Prisma.ProjectUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateWithoutTaskInput = {
|
||||
@@ -4538,6 +4794,7 @@ export type AssetUncheckedUpdateWithoutTaskInput = {
|
||||
projectShareRoot?: Prisma.ProjectUncheckedUpdateOneWithoutShareRootNestedInput
|
||||
shareLinkRootFolder?: Prisma.ShareLinkUncheckedUpdateOneWithoutRootFolderNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutAssetNestedInput
|
||||
watermarkFiles?: Prisma.WatermarkFileUncheckedUpdateManyWithoutAssetNestedInput
|
||||
}
|
||||
|
||||
export type AssetUncheckedUpdateManyWithoutTaskInput = {
|
||||
@@ -4578,6 +4835,7 @@ export type AssetCountOutputType = {
|
||||
notifications: number
|
||||
embeddings: number
|
||||
agentSessions: number
|
||||
watermarkFiles: number
|
||||
}
|
||||
|
||||
export type AssetCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
@@ -4589,6 +4847,7 @@ export type AssetCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.
|
||||
notifications?: boolean | AssetCountOutputTypeCountNotificationsArgs
|
||||
embeddings?: boolean | AssetCountOutputTypeCountEmbeddingsArgs
|
||||
agentSessions?: boolean | AssetCountOutputTypeCountAgentSessionsArgs
|
||||
watermarkFiles?: boolean | AssetCountOutputTypeCountWatermarkFilesArgs
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -4657,6 +4916,13 @@ export type AssetCountOutputTypeCountAgentSessionsArgs<ExtArgs extends runtime.T
|
||||
where?: Prisma.AgentSessionWhereInput
|
||||
}
|
||||
|
||||
/**
|
||||
* AssetCountOutputType without action
|
||||
*/
|
||||
export type AssetCountOutputTypeCountWatermarkFilesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
where?: Prisma.WatermarkFileWhereInput
|
||||
}
|
||||
|
||||
|
||||
export type AssetSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
|
||||
id?: boolean
|
||||
@@ -4699,6 +4965,7 @@ export type AssetSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs =
|
||||
projectShareRoot?: boolean | Prisma.Asset$projectShareRootArgs<ExtArgs>
|
||||
shareLinkRootFolder?: boolean | Prisma.Asset$shareLinkRootFolderArgs<ExtArgs>
|
||||
agentSessions?: boolean | Prisma.Asset$agentSessionsArgs<ExtArgs>
|
||||
watermarkFiles?: boolean | Prisma.Asset$watermarkFilesArgs<ExtArgs>
|
||||
_count?: boolean | Prisma.AssetCountOutputTypeDefaultArgs<ExtArgs>
|
||||
}, ExtArgs["result"]["asset"]>
|
||||
|
||||
@@ -4809,6 +5076,7 @@ export type AssetInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs =
|
||||
projectShareRoot?: boolean | Prisma.Asset$projectShareRootArgs<ExtArgs>
|
||||
shareLinkRootFolder?: boolean | Prisma.Asset$shareLinkRootFolderArgs<ExtArgs>
|
||||
agentSessions?: boolean | Prisma.Asset$agentSessionsArgs<ExtArgs>
|
||||
watermarkFiles?: boolean | Prisma.Asset$watermarkFilesArgs<ExtArgs>
|
||||
_count?: boolean | Prisma.AssetCountOutputTypeDefaultArgs<ExtArgs>
|
||||
}
|
||||
export type AssetIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
@@ -4849,6 +5117,7 @@ export type $AssetPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs
|
||||
projectShareRoot: Prisma.$ProjectPayload<ExtArgs> | null
|
||||
shareLinkRootFolder: Prisma.$ShareLinkPayload<ExtArgs> | null
|
||||
agentSessions: Prisma.$AgentSessionPayload<ExtArgs>[]
|
||||
watermarkFiles: Prisma.$WatermarkFilePayload<ExtArgs>[]
|
||||
}
|
||||
scalars: runtime.Types.Extensions.GetPayloadResult<{
|
||||
id: string
|
||||
@@ -5288,6 +5557,7 @@ export interface Prisma__AssetClient<T, Null = never, ExtArgs extends runtime.Ty
|
||||
projectShareRoot<T extends Prisma.Asset$projectShareRootArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Asset$projectShareRootArgs<ExtArgs>>): Prisma.Prisma__ProjectClient<runtime.Types.Result.GetResult<Prisma.$ProjectPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
|
||||
shareLinkRootFolder<T extends Prisma.Asset$shareLinkRootFolderArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Asset$shareLinkRootFolderArgs<ExtArgs>>): Prisma.Prisma__ShareLinkClient<runtime.Types.Result.GetResult<Prisma.$ShareLinkPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
|
||||
agentSessions<T extends Prisma.Asset$agentSessionsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Asset$agentSessionsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$AgentSessionPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
||||
watermarkFiles<T extends Prisma.Asset$watermarkFilesArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Asset$watermarkFilesArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$WatermarkFilePayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
@@ -6121,6 +6391,30 @@ export type Asset$agentSessionsArgs<ExtArgs extends runtime.Types.Extensions.Int
|
||||
distinct?: Prisma.AgentSessionScalarFieldEnum | Prisma.AgentSessionScalarFieldEnum[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Asset.watermarkFiles
|
||||
*/
|
||||
export type Asset$watermarkFilesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
/**
|
||||
* Select specific fields to fetch from the WatermarkFile
|
||||
*/
|
||||
select?: Prisma.WatermarkFileSelect<ExtArgs> | null
|
||||
/**
|
||||
* Omit specific fields from the WatermarkFile
|
||||
*/
|
||||
omit?: Prisma.WatermarkFileOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.WatermarkFileInclude<ExtArgs> | null
|
||||
where?: Prisma.WatermarkFileWhereInput
|
||||
orderBy?: Prisma.WatermarkFileOrderByWithRelationInput | Prisma.WatermarkFileOrderByWithRelationInput[]
|
||||
cursor?: Prisma.WatermarkFileWhereUniqueInput
|
||||
take?: number
|
||||
skip?: number
|
||||
distinct?: Prisma.WatermarkFileScalarFieldEnum | Prisma.WatermarkFileScalarFieldEnum[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Asset without action
|
||||
*/
|
||||
|
||||
+345
-1
@@ -32,6 +32,7 @@ export type ShareLinkMinAggregateOutputType = {
|
||||
expireAt: Date | null
|
||||
password: string | null
|
||||
isDisabled: boolean | null
|
||||
allowDownload: boolean | null
|
||||
defaultSortOrder: string | null
|
||||
viewMode: string | null
|
||||
createdAt: Date | null
|
||||
@@ -39,6 +40,8 @@ export type ShareLinkMinAggregateOutputType = {
|
||||
projectId: string | null
|
||||
rootFolderId: string | null
|
||||
creatorId: string | null
|
||||
watermarkConfigId: string | null
|
||||
watermarkStatus: $Enums.WatermarkStatus | null
|
||||
}
|
||||
|
||||
export type ShareLinkMaxAggregateOutputType = {
|
||||
@@ -47,6 +50,7 @@ export type ShareLinkMaxAggregateOutputType = {
|
||||
expireAt: Date | null
|
||||
password: string | null
|
||||
isDisabled: boolean | null
|
||||
allowDownload: boolean | null
|
||||
defaultSortOrder: string | null
|
||||
viewMode: string | null
|
||||
createdAt: Date | null
|
||||
@@ -54,6 +58,8 @@ export type ShareLinkMaxAggregateOutputType = {
|
||||
projectId: string | null
|
||||
rootFolderId: string | null
|
||||
creatorId: string | null
|
||||
watermarkConfigId: string | null
|
||||
watermarkStatus: $Enums.WatermarkStatus | null
|
||||
}
|
||||
|
||||
export type ShareLinkCountAggregateOutputType = {
|
||||
@@ -62,6 +68,7 @@ export type ShareLinkCountAggregateOutputType = {
|
||||
expireAt: number
|
||||
password: number
|
||||
isDisabled: number
|
||||
allowDownload: number
|
||||
defaultSortOrder: number
|
||||
viewMode: number
|
||||
fieldVisibility:PrismaJson.ShareLinkFieldVisibility
|
||||
@@ -70,6 +77,8 @@ export type ShareLinkCountAggregateOutputType = {
|
||||
projectId: number
|
||||
rootFolderId: number
|
||||
creatorId: number
|
||||
watermarkConfigId: number
|
||||
watermarkStatus: number
|
||||
_all: number
|
||||
}
|
||||
|
||||
@@ -80,6 +89,7 @@ export type ShareLinkMinAggregateInputType = {
|
||||
expireAt?: true
|
||||
password?: true
|
||||
isDisabled?: true
|
||||
allowDownload?: true
|
||||
defaultSortOrder?: true
|
||||
viewMode?: true
|
||||
createdAt?: true
|
||||
@@ -87,6 +97,8 @@ export type ShareLinkMinAggregateInputType = {
|
||||
projectId?: true
|
||||
rootFolderId?: true
|
||||
creatorId?: true
|
||||
watermarkConfigId?: true
|
||||
watermarkStatus?: true
|
||||
}
|
||||
|
||||
export type ShareLinkMaxAggregateInputType = {
|
||||
@@ -95,6 +107,7 @@ export type ShareLinkMaxAggregateInputType = {
|
||||
expireAt?: true
|
||||
password?: true
|
||||
isDisabled?: true
|
||||
allowDownload?: true
|
||||
defaultSortOrder?: true
|
||||
viewMode?: true
|
||||
createdAt?: true
|
||||
@@ -102,6 +115,8 @@ export type ShareLinkMaxAggregateInputType = {
|
||||
projectId?: true
|
||||
rootFolderId?: true
|
||||
creatorId?: true
|
||||
watermarkConfigId?: true
|
||||
watermarkStatus?: true
|
||||
}
|
||||
|
||||
export type ShareLinkCountAggregateInputType = {
|
||||
@@ -110,6 +125,7 @@ export type ShareLinkCountAggregateInputType = {
|
||||
expireAt?: true
|
||||
password?: true
|
||||
isDisabled?: true
|
||||
allowDownload?: true
|
||||
defaultSortOrder?: true
|
||||
viewMode?: true
|
||||
fieldVisibility?: true
|
||||
@@ -118,6 +134,8 @@ export type ShareLinkCountAggregateInputType = {
|
||||
projectId?: true
|
||||
rootFolderId?: true
|
||||
creatorId?: true
|
||||
watermarkConfigId?: true
|
||||
watermarkStatus?: true
|
||||
_all?: true
|
||||
}
|
||||
|
||||
@@ -199,6 +217,7 @@ export type ShareLinkGroupByOutputType = {
|
||||
expireAt: Date | null
|
||||
password: string | null
|
||||
isDisabled: boolean
|
||||
allowDownload: boolean
|
||||
defaultSortOrder: string | null
|
||||
viewMode: string | null
|
||||
fieldVisibility:PrismaJson.ShareLinkFieldVisibility | null
|
||||
@@ -207,6 +226,8 @@ export type ShareLinkGroupByOutputType = {
|
||||
projectId: string
|
||||
rootFolderId: string
|
||||
creatorId: string | null
|
||||
watermarkConfigId: string | null
|
||||
watermarkStatus: $Enums.WatermarkStatus
|
||||
_count: ShareLinkCountAggregateOutputType | null
|
||||
_min: ShareLinkMinAggregateOutputType | null
|
||||
_max: ShareLinkMaxAggregateOutputType | null
|
||||
@@ -236,6 +257,7 @@ export type ShareLinkWhereInput = {
|
||||
expireAt?: Prisma.DateTimeNullableFilter<"ShareLink"> | Date | string | null
|
||||
password?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
isDisabled?: Prisma.BoolFilter<"ShareLink"> | boolean
|
||||
allowDownload?: Prisma.BoolFilter<"ShareLink"> | boolean
|
||||
defaultSortOrder?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
viewMode?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
fieldVisibility?: Prisma.JsonNullableFilter<"ShareLink">
|
||||
@@ -244,9 +266,12 @@ export type ShareLinkWhereInput = {
|
||||
projectId?: Prisma.StringFilter<"ShareLink"> | string
|
||||
rootFolderId?: Prisma.StringFilter<"ShareLink"> | string
|
||||
creatorId?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
watermarkConfigId?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFilter<"ShareLink"> | $Enums.WatermarkStatus
|
||||
project?: Prisma.XOR<Prisma.ProjectScalarRelationFilter, Prisma.ProjectWhereInput>
|
||||
rootFolder?: Prisma.XOR<Prisma.AssetScalarRelationFilter, Prisma.AssetWhereInput>
|
||||
creator?: Prisma.XOR<Prisma.UserNullableScalarRelationFilter, Prisma.UserWhereInput> | null
|
||||
watermarkConfig?: Prisma.XOR<Prisma.WatermarkConfigNullableScalarRelationFilter, Prisma.WatermarkConfigWhereInput> | null
|
||||
}
|
||||
|
||||
export type ShareLinkOrderByWithRelationInput = {
|
||||
@@ -255,6 +280,7 @@ export type ShareLinkOrderByWithRelationInput = {
|
||||
expireAt?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
password?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
isDisabled?: Prisma.SortOrder
|
||||
allowDownload?: Prisma.SortOrder
|
||||
defaultSortOrder?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
viewMode?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
fieldVisibility?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
@@ -263,9 +289,12 @@ export type ShareLinkOrderByWithRelationInput = {
|
||||
projectId?: Prisma.SortOrder
|
||||
rootFolderId?: Prisma.SortOrder
|
||||
creatorId?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
watermarkConfigId?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
watermarkStatus?: Prisma.SortOrder
|
||||
project?: Prisma.ProjectOrderByWithRelationInput
|
||||
rootFolder?: Prisma.AssetOrderByWithRelationInput
|
||||
creator?: Prisma.UserOrderByWithRelationInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigOrderByWithRelationInput
|
||||
}
|
||||
|
||||
export type ShareLinkWhereUniqueInput = Prisma.AtLeast<{
|
||||
@@ -278,6 +307,7 @@ export type ShareLinkWhereUniqueInput = Prisma.AtLeast<{
|
||||
expireAt?: Prisma.DateTimeNullableFilter<"ShareLink"> | Date | string | null
|
||||
password?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
isDisabled?: Prisma.BoolFilter<"ShareLink"> | boolean
|
||||
allowDownload?: Prisma.BoolFilter<"ShareLink"> | boolean
|
||||
defaultSortOrder?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
viewMode?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
fieldVisibility?: Prisma.JsonNullableFilter<"ShareLink">
|
||||
@@ -285,9 +315,12 @@ export type ShareLinkWhereUniqueInput = Prisma.AtLeast<{
|
||||
updatedAt?: Prisma.DateTimeFilter<"ShareLink"> | Date | string
|
||||
projectId?: Prisma.StringFilter<"ShareLink"> | string
|
||||
creatorId?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
watermarkConfigId?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFilter<"ShareLink"> | $Enums.WatermarkStatus
|
||||
project?: Prisma.XOR<Prisma.ProjectScalarRelationFilter, Prisma.ProjectWhereInput>
|
||||
rootFolder?: Prisma.XOR<Prisma.AssetScalarRelationFilter, Prisma.AssetWhereInput>
|
||||
creator?: Prisma.XOR<Prisma.UserNullableScalarRelationFilter, Prisma.UserWhereInput> | null
|
||||
watermarkConfig?: Prisma.XOR<Prisma.WatermarkConfigNullableScalarRelationFilter, Prisma.WatermarkConfigWhereInput> | null
|
||||
}, "id" | "rootFolderId">
|
||||
|
||||
export type ShareLinkOrderByWithAggregationInput = {
|
||||
@@ -296,6 +329,7 @@ export type ShareLinkOrderByWithAggregationInput = {
|
||||
expireAt?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
password?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
isDisabled?: Prisma.SortOrder
|
||||
allowDownload?: Prisma.SortOrder
|
||||
defaultSortOrder?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
viewMode?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
fieldVisibility?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
@@ -304,6 +338,8 @@ export type ShareLinkOrderByWithAggregationInput = {
|
||||
projectId?: Prisma.SortOrder
|
||||
rootFolderId?: Prisma.SortOrder
|
||||
creatorId?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
watermarkConfigId?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
watermarkStatus?: Prisma.SortOrder
|
||||
_count?: Prisma.ShareLinkCountOrderByAggregateInput
|
||||
_max?: Prisma.ShareLinkMaxOrderByAggregateInput
|
||||
_min?: Prisma.ShareLinkMinOrderByAggregateInput
|
||||
@@ -318,6 +354,7 @@ export type ShareLinkScalarWhereWithAggregatesInput = {
|
||||
expireAt?: Prisma.DateTimeNullableWithAggregatesFilter<"ShareLink"> | Date | string | null
|
||||
password?: Prisma.StringNullableWithAggregatesFilter<"ShareLink"> | string | null
|
||||
isDisabled?: Prisma.BoolWithAggregatesFilter<"ShareLink"> | boolean
|
||||
allowDownload?: Prisma.BoolWithAggregatesFilter<"ShareLink"> | boolean
|
||||
defaultSortOrder?: Prisma.StringNullableWithAggregatesFilter<"ShareLink"> | string | null
|
||||
viewMode?: Prisma.StringNullableWithAggregatesFilter<"ShareLink"> | string | null
|
||||
fieldVisibility?: Prisma.JsonNullableWithAggregatesFilter<"ShareLink">
|
||||
@@ -326,6 +363,8 @@ export type ShareLinkScalarWhereWithAggregatesInput = {
|
||||
projectId?: Prisma.StringWithAggregatesFilter<"ShareLink"> | string
|
||||
rootFolderId?: Prisma.StringWithAggregatesFilter<"ShareLink"> | string
|
||||
creatorId?: Prisma.StringNullableWithAggregatesFilter<"ShareLink"> | string | null
|
||||
watermarkConfigId?: Prisma.StringNullableWithAggregatesFilter<"ShareLink"> | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusWithAggregatesFilter<"ShareLink"> | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkCreateInput = {
|
||||
@@ -334,14 +373,17 @@ export type ShareLinkCreateInput = {
|
||||
expireAt?: Date | string | null
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
project: Prisma.ProjectCreateNestedOneWithoutShareLinksInput
|
||||
rootFolder: Prisma.AssetCreateNestedOneWithoutShareLinkRootFolderInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutShareLinksInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigCreateNestedOneWithoutShareLinksInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedCreateInput = {
|
||||
@@ -350,6 +392,7 @@ export type ShareLinkUncheckedCreateInput = {
|
||||
expireAt?: Date | string | null
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
@@ -358,6 +401,8 @@ export type ShareLinkUncheckedCreateInput = {
|
||||
projectId: string
|
||||
rootFolderId: string
|
||||
creatorId?: string | null
|
||||
watermarkConfigId?: string | null
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkUpdateInput = {
|
||||
@@ -366,14 +411,17 @@ export type ShareLinkUpdateInput = {
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
project?: Prisma.ProjectUpdateOneRequiredWithoutShareLinksNestedInput
|
||||
rootFolder?: Prisma.AssetUpdateOneRequiredWithoutShareLinkRootFolderNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutShareLinksNestedInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigUpdateOneWithoutShareLinksNestedInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateInput = {
|
||||
@@ -382,6 +430,7 @@ export type ShareLinkUncheckedUpdateInput = {
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
@@ -390,6 +439,8 @@ export type ShareLinkUncheckedUpdateInput = {
|
||||
projectId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
rootFolderId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkConfigId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkCreateManyInput = {
|
||||
@@ -398,6 +449,7 @@ export type ShareLinkCreateManyInput = {
|
||||
expireAt?: Date | string | null
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
@@ -406,6 +458,8 @@ export type ShareLinkCreateManyInput = {
|
||||
projectId: string
|
||||
rootFolderId: string
|
||||
creatorId?: string | null
|
||||
watermarkConfigId?: string | null
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkUpdateManyMutationInput = {
|
||||
@@ -414,11 +468,13 @@ export type ShareLinkUpdateManyMutationInput = {
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateManyInput = {
|
||||
@@ -427,6 +483,7 @@ export type ShareLinkUncheckedUpdateManyInput = {
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
@@ -435,6 +492,8 @@ export type ShareLinkUncheckedUpdateManyInput = {
|
||||
projectId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
rootFolderId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkConfigId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkListRelationFilter = {
|
||||
@@ -453,6 +512,7 @@ export type ShareLinkCountOrderByAggregateInput = {
|
||||
expireAt?: Prisma.SortOrder
|
||||
password?: Prisma.SortOrder
|
||||
isDisabled?: Prisma.SortOrder
|
||||
allowDownload?: Prisma.SortOrder
|
||||
defaultSortOrder?: Prisma.SortOrder
|
||||
viewMode?: Prisma.SortOrder
|
||||
fieldVisibility?: Prisma.SortOrder
|
||||
@@ -461,6 +521,8 @@ export type ShareLinkCountOrderByAggregateInput = {
|
||||
projectId?: Prisma.SortOrder
|
||||
rootFolderId?: Prisma.SortOrder
|
||||
creatorId?: Prisma.SortOrder
|
||||
watermarkConfigId?: Prisma.SortOrder
|
||||
watermarkStatus?: Prisma.SortOrder
|
||||
}
|
||||
|
||||
export type ShareLinkMaxOrderByAggregateInput = {
|
||||
@@ -469,6 +531,7 @@ export type ShareLinkMaxOrderByAggregateInput = {
|
||||
expireAt?: Prisma.SortOrder
|
||||
password?: Prisma.SortOrder
|
||||
isDisabled?: Prisma.SortOrder
|
||||
allowDownload?: Prisma.SortOrder
|
||||
defaultSortOrder?: Prisma.SortOrder
|
||||
viewMode?: Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
@@ -476,6 +539,8 @@ export type ShareLinkMaxOrderByAggregateInput = {
|
||||
projectId?: Prisma.SortOrder
|
||||
rootFolderId?: Prisma.SortOrder
|
||||
creatorId?: Prisma.SortOrder
|
||||
watermarkConfigId?: Prisma.SortOrder
|
||||
watermarkStatus?: Prisma.SortOrder
|
||||
}
|
||||
|
||||
export type ShareLinkMinOrderByAggregateInput = {
|
||||
@@ -484,6 +549,7 @@ export type ShareLinkMinOrderByAggregateInput = {
|
||||
expireAt?: Prisma.SortOrder
|
||||
password?: Prisma.SortOrder
|
||||
isDisabled?: Prisma.SortOrder
|
||||
allowDownload?: Prisma.SortOrder
|
||||
defaultSortOrder?: Prisma.SortOrder
|
||||
viewMode?: Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
@@ -491,6 +557,8 @@ export type ShareLinkMinOrderByAggregateInput = {
|
||||
projectId?: Prisma.SortOrder
|
||||
rootFolderId?: Prisma.SortOrder
|
||||
creatorId?: Prisma.SortOrder
|
||||
watermarkConfigId?: Prisma.SortOrder
|
||||
watermarkStatus?: Prisma.SortOrder
|
||||
}
|
||||
|
||||
export type ShareLinkNullableScalarRelationFilter = {
|
||||
@@ -582,6 +650,52 @@ export type ShareLinkUncheckedUpdateManyWithoutProjectNestedInput = {
|
||||
deleteMany?: Prisma.ShareLinkScalarWhereInput | Prisma.ShareLinkScalarWhereInput[]
|
||||
}
|
||||
|
||||
export type EnumWatermarkStatusFieldUpdateOperationsInput = {
|
||||
set?: $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkCreateNestedManyWithoutWatermarkConfigInput = {
|
||||
create?: Prisma.XOR<Prisma.ShareLinkCreateWithoutWatermarkConfigInput, Prisma.ShareLinkUncheckedCreateWithoutWatermarkConfigInput> | Prisma.ShareLinkCreateWithoutWatermarkConfigInput[] | Prisma.ShareLinkUncheckedCreateWithoutWatermarkConfigInput[]
|
||||
connectOrCreate?: Prisma.ShareLinkCreateOrConnectWithoutWatermarkConfigInput | Prisma.ShareLinkCreateOrConnectWithoutWatermarkConfigInput[]
|
||||
createMany?: Prisma.ShareLinkCreateManyWatermarkConfigInputEnvelope
|
||||
connect?: Prisma.ShareLinkWhereUniqueInput | Prisma.ShareLinkWhereUniqueInput[]
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedCreateNestedManyWithoutWatermarkConfigInput = {
|
||||
create?: Prisma.XOR<Prisma.ShareLinkCreateWithoutWatermarkConfigInput, Prisma.ShareLinkUncheckedCreateWithoutWatermarkConfigInput> | Prisma.ShareLinkCreateWithoutWatermarkConfigInput[] | Prisma.ShareLinkUncheckedCreateWithoutWatermarkConfigInput[]
|
||||
connectOrCreate?: Prisma.ShareLinkCreateOrConnectWithoutWatermarkConfigInput | Prisma.ShareLinkCreateOrConnectWithoutWatermarkConfigInput[]
|
||||
createMany?: Prisma.ShareLinkCreateManyWatermarkConfigInputEnvelope
|
||||
connect?: Prisma.ShareLinkWhereUniqueInput | Prisma.ShareLinkWhereUniqueInput[]
|
||||
}
|
||||
|
||||
export type ShareLinkUpdateManyWithoutWatermarkConfigNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.ShareLinkCreateWithoutWatermarkConfigInput, Prisma.ShareLinkUncheckedCreateWithoutWatermarkConfigInput> | Prisma.ShareLinkCreateWithoutWatermarkConfigInput[] | Prisma.ShareLinkUncheckedCreateWithoutWatermarkConfigInput[]
|
||||
connectOrCreate?: Prisma.ShareLinkCreateOrConnectWithoutWatermarkConfigInput | Prisma.ShareLinkCreateOrConnectWithoutWatermarkConfigInput[]
|
||||
upsert?: Prisma.ShareLinkUpsertWithWhereUniqueWithoutWatermarkConfigInput | Prisma.ShareLinkUpsertWithWhereUniqueWithoutWatermarkConfigInput[]
|
||||
createMany?: Prisma.ShareLinkCreateManyWatermarkConfigInputEnvelope
|
||||
set?: Prisma.ShareLinkWhereUniqueInput | Prisma.ShareLinkWhereUniqueInput[]
|
||||
disconnect?: Prisma.ShareLinkWhereUniqueInput | Prisma.ShareLinkWhereUniqueInput[]
|
||||
delete?: Prisma.ShareLinkWhereUniqueInput | Prisma.ShareLinkWhereUniqueInput[]
|
||||
connect?: Prisma.ShareLinkWhereUniqueInput | Prisma.ShareLinkWhereUniqueInput[]
|
||||
update?: Prisma.ShareLinkUpdateWithWhereUniqueWithoutWatermarkConfigInput | Prisma.ShareLinkUpdateWithWhereUniqueWithoutWatermarkConfigInput[]
|
||||
updateMany?: Prisma.ShareLinkUpdateManyWithWhereWithoutWatermarkConfigInput | Prisma.ShareLinkUpdateManyWithWhereWithoutWatermarkConfigInput[]
|
||||
deleteMany?: Prisma.ShareLinkScalarWhereInput | Prisma.ShareLinkScalarWhereInput[]
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateManyWithoutWatermarkConfigNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.ShareLinkCreateWithoutWatermarkConfigInput, Prisma.ShareLinkUncheckedCreateWithoutWatermarkConfigInput> | Prisma.ShareLinkCreateWithoutWatermarkConfigInput[] | Prisma.ShareLinkUncheckedCreateWithoutWatermarkConfigInput[]
|
||||
connectOrCreate?: Prisma.ShareLinkCreateOrConnectWithoutWatermarkConfigInput | Prisma.ShareLinkCreateOrConnectWithoutWatermarkConfigInput[]
|
||||
upsert?: Prisma.ShareLinkUpsertWithWhereUniqueWithoutWatermarkConfigInput | Prisma.ShareLinkUpsertWithWhereUniqueWithoutWatermarkConfigInput[]
|
||||
createMany?: Prisma.ShareLinkCreateManyWatermarkConfigInputEnvelope
|
||||
set?: Prisma.ShareLinkWhereUniqueInput | Prisma.ShareLinkWhereUniqueInput[]
|
||||
disconnect?: Prisma.ShareLinkWhereUniqueInput | Prisma.ShareLinkWhereUniqueInput[]
|
||||
delete?: Prisma.ShareLinkWhereUniqueInput | Prisma.ShareLinkWhereUniqueInput[]
|
||||
connect?: Prisma.ShareLinkWhereUniqueInput | Prisma.ShareLinkWhereUniqueInput[]
|
||||
update?: Prisma.ShareLinkUpdateWithWhereUniqueWithoutWatermarkConfigInput | Prisma.ShareLinkUpdateWithWhereUniqueWithoutWatermarkConfigInput[]
|
||||
updateMany?: Prisma.ShareLinkUpdateManyWithWhereWithoutWatermarkConfigInput | Prisma.ShareLinkUpdateManyWithWhereWithoutWatermarkConfigInput[]
|
||||
deleteMany?: Prisma.ShareLinkScalarWhereInput | Prisma.ShareLinkScalarWhereInput[]
|
||||
}
|
||||
|
||||
export type ShareLinkCreateNestedOneWithoutRootFolderInput = {
|
||||
create?: Prisma.XOR<Prisma.ShareLinkCreateWithoutRootFolderInput, Prisma.ShareLinkUncheckedCreateWithoutRootFolderInput>
|
||||
connectOrCreate?: Prisma.ShareLinkCreateOrConnectWithoutRootFolderInput
|
||||
@@ -620,13 +734,16 @@ export type ShareLinkCreateWithoutCreatorInput = {
|
||||
expireAt?: Date | string | null
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
project: Prisma.ProjectCreateNestedOneWithoutShareLinksInput
|
||||
rootFolder: Prisma.AssetCreateNestedOneWithoutShareLinkRootFolderInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigCreateNestedOneWithoutShareLinksInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedCreateWithoutCreatorInput = {
|
||||
@@ -635,6 +752,7 @@ export type ShareLinkUncheckedCreateWithoutCreatorInput = {
|
||||
expireAt?: Date | string | null
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
@@ -642,6 +760,8 @@ export type ShareLinkUncheckedCreateWithoutCreatorInput = {
|
||||
updatedAt?: Date | string
|
||||
projectId: string
|
||||
rootFolderId: string
|
||||
watermarkConfigId?: string | null
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkCreateOrConnectWithoutCreatorInput = {
|
||||
@@ -679,6 +799,7 @@ export type ShareLinkScalarWhereInput = {
|
||||
expireAt?: Prisma.DateTimeNullableFilter<"ShareLink"> | Date | string | null
|
||||
password?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
isDisabled?: Prisma.BoolFilter<"ShareLink"> | boolean
|
||||
allowDownload?: Prisma.BoolFilter<"ShareLink"> | boolean
|
||||
defaultSortOrder?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
viewMode?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
fieldVisibility?: Prisma.JsonNullableFilter<"ShareLink">
|
||||
@@ -687,6 +808,8 @@ export type ShareLinkScalarWhereInput = {
|
||||
projectId?: Prisma.StringFilter<"ShareLink"> | string
|
||||
rootFolderId?: Prisma.StringFilter<"ShareLink"> | string
|
||||
creatorId?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
watermarkConfigId?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFilter<"ShareLink"> | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkCreateWithoutProjectInput = {
|
||||
@@ -695,13 +818,16 @@ export type ShareLinkCreateWithoutProjectInput = {
|
||||
expireAt?: Date | string | null
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
rootFolder: Prisma.AssetCreateNestedOneWithoutShareLinkRootFolderInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutShareLinksInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigCreateNestedOneWithoutShareLinksInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedCreateWithoutProjectInput = {
|
||||
@@ -710,6 +836,7 @@ export type ShareLinkUncheckedCreateWithoutProjectInput = {
|
||||
expireAt?: Date | string | null
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
@@ -717,6 +844,8 @@ export type ShareLinkUncheckedCreateWithoutProjectInput = {
|
||||
updatedAt?: Date | string
|
||||
rootFolderId: string
|
||||
creatorId?: string | null
|
||||
watermarkConfigId?: string | null
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkCreateOrConnectWithoutProjectInput = {
|
||||
@@ -745,19 +874,84 @@ export type ShareLinkUpdateManyWithWhereWithoutProjectInput = {
|
||||
data: Prisma.XOR<Prisma.ShareLinkUpdateManyMutationInput, Prisma.ShareLinkUncheckedUpdateManyWithoutProjectInput>
|
||||
}
|
||||
|
||||
export type ShareLinkCreateWithoutWatermarkConfigInput = {
|
||||
id?: string
|
||||
name: string
|
||||
expireAt?: Date | string | null
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
project: Prisma.ProjectCreateNestedOneWithoutShareLinksInput
|
||||
rootFolder: Prisma.AssetCreateNestedOneWithoutShareLinkRootFolderInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutShareLinksInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedCreateWithoutWatermarkConfigInput = {
|
||||
id?: string
|
||||
name: string
|
||||
expireAt?: Date | string | null
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
projectId: string
|
||||
rootFolderId: string
|
||||
creatorId?: string | null
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkCreateOrConnectWithoutWatermarkConfigInput = {
|
||||
where: Prisma.ShareLinkWhereUniqueInput
|
||||
create: Prisma.XOR<Prisma.ShareLinkCreateWithoutWatermarkConfigInput, Prisma.ShareLinkUncheckedCreateWithoutWatermarkConfigInput>
|
||||
}
|
||||
|
||||
export type ShareLinkCreateManyWatermarkConfigInputEnvelope = {
|
||||
data: Prisma.ShareLinkCreateManyWatermarkConfigInput | Prisma.ShareLinkCreateManyWatermarkConfigInput[]
|
||||
skipDuplicates?: boolean
|
||||
}
|
||||
|
||||
export type ShareLinkUpsertWithWhereUniqueWithoutWatermarkConfigInput = {
|
||||
where: Prisma.ShareLinkWhereUniqueInput
|
||||
update: Prisma.XOR<Prisma.ShareLinkUpdateWithoutWatermarkConfigInput, Prisma.ShareLinkUncheckedUpdateWithoutWatermarkConfigInput>
|
||||
create: Prisma.XOR<Prisma.ShareLinkCreateWithoutWatermarkConfigInput, Prisma.ShareLinkUncheckedCreateWithoutWatermarkConfigInput>
|
||||
}
|
||||
|
||||
export type ShareLinkUpdateWithWhereUniqueWithoutWatermarkConfigInput = {
|
||||
where: Prisma.ShareLinkWhereUniqueInput
|
||||
data: Prisma.XOR<Prisma.ShareLinkUpdateWithoutWatermarkConfigInput, Prisma.ShareLinkUncheckedUpdateWithoutWatermarkConfigInput>
|
||||
}
|
||||
|
||||
export type ShareLinkUpdateManyWithWhereWithoutWatermarkConfigInput = {
|
||||
where: Prisma.ShareLinkScalarWhereInput
|
||||
data: Prisma.XOR<Prisma.ShareLinkUpdateManyMutationInput, Prisma.ShareLinkUncheckedUpdateManyWithoutWatermarkConfigInput>
|
||||
}
|
||||
|
||||
export type ShareLinkCreateWithoutRootFolderInput = {
|
||||
id?: string
|
||||
name: string
|
||||
expireAt?: Date | string | null
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
project: Prisma.ProjectCreateNestedOneWithoutShareLinksInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutShareLinksInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigCreateNestedOneWithoutShareLinksInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedCreateWithoutRootFolderInput = {
|
||||
@@ -766,6 +960,7 @@ export type ShareLinkUncheckedCreateWithoutRootFolderInput = {
|
||||
expireAt?: Date | string | null
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
@@ -773,6 +968,8 @@ export type ShareLinkUncheckedCreateWithoutRootFolderInput = {
|
||||
updatedAt?: Date | string
|
||||
projectId: string
|
||||
creatorId?: string | null
|
||||
watermarkConfigId?: string | null
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkCreateOrConnectWithoutRootFolderInput = {
|
||||
@@ -797,13 +994,16 @@ export type ShareLinkUpdateWithoutRootFolderInput = {
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
project?: Prisma.ProjectUpdateOneRequiredWithoutShareLinksNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutShareLinksNestedInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigUpdateOneWithoutShareLinksNestedInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateWithoutRootFolderInput = {
|
||||
@@ -812,6 +1012,7 @@ export type ShareLinkUncheckedUpdateWithoutRootFolderInput = {
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
@@ -819,6 +1020,8 @@ export type ShareLinkUncheckedUpdateWithoutRootFolderInput = {
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
projectId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkConfigId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkCreateManyCreatorInput = {
|
||||
@@ -827,6 +1030,7 @@ export type ShareLinkCreateManyCreatorInput = {
|
||||
expireAt?: Date | string | null
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
@@ -834,6 +1038,8 @@ export type ShareLinkCreateManyCreatorInput = {
|
||||
updatedAt?: Date | string
|
||||
projectId: string
|
||||
rootFolderId: string
|
||||
watermarkConfigId?: string | null
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkUpdateWithoutCreatorInput = {
|
||||
@@ -842,13 +1048,16 @@ export type ShareLinkUpdateWithoutCreatorInput = {
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
project?: Prisma.ProjectUpdateOneRequiredWithoutShareLinksNestedInput
|
||||
rootFolder?: Prisma.AssetUpdateOneRequiredWithoutShareLinkRootFolderNestedInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigUpdateOneWithoutShareLinksNestedInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateWithoutCreatorInput = {
|
||||
@@ -857,6 +1066,7 @@ export type ShareLinkUncheckedUpdateWithoutCreatorInput = {
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
@@ -864,6 +1074,8 @@ export type ShareLinkUncheckedUpdateWithoutCreatorInput = {
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
projectId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
rootFolderId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
watermarkConfigId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateManyWithoutCreatorInput = {
|
||||
@@ -872,6 +1084,7 @@ export type ShareLinkUncheckedUpdateManyWithoutCreatorInput = {
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
@@ -879,6 +1092,8 @@ export type ShareLinkUncheckedUpdateManyWithoutCreatorInput = {
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
projectId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
rootFolderId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
watermarkConfigId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkCreateManyProjectInput = {
|
||||
@@ -887,6 +1102,7 @@ export type ShareLinkCreateManyProjectInput = {
|
||||
expireAt?: Date | string | null
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
@@ -894,6 +1110,8 @@ export type ShareLinkCreateManyProjectInput = {
|
||||
updatedAt?: Date | string
|
||||
rootFolderId: string
|
||||
creatorId?: string | null
|
||||
watermarkConfigId?: string | null
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkUpdateWithoutProjectInput = {
|
||||
@@ -902,13 +1120,16 @@ export type ShareLinkUpdateWithoutProjectInput = {
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
rootFolder?: Prisma.AssetUpdateOneRequiredWithoutShareLinkRootFolderNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutShareLinksNestedInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigUpdateOneWithoutShareLinksNestedInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateWithoutProjectInput = {
|
||||
@@ -917,6 +1138,7 @@ export type ShareLinkUncheckedUpdateWithoutProjectInput = {
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
@@ -924,6 +1146,8 @@ export type ShareLinkUncheckedUpdateWithoutProjectInput = {
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
rootFolderId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkConfigId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateManyWithoutProjectInput = {
|
||||
@@ -932,6 +1156,7 @@ export type ShareLinkUncheckedUpdateManyWithoutProjectInput = {
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
@@ -939,6 +1164,80 @@ export type ShareLinkUncheckedUpdateManyWithoutProjectInput = {
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
rootFolderId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkConfigId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkCreateManyWatermarkConfigInput = {
|
||||
id?: string
|
||||
name: string
|
||||
expireAt?: Date | string | null
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
projectId: string
|
||||
rootFolderId: string
|
||||
creatorId?: string | null
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkUpdateWithoutWatermarkConfigInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
project?: Prisma.ProjectUpdateOneRequiredWithoutShareLinksNestedInput
|
||||
rootFolder?: Prisma.AssetUpdateOneRequiredWithoutShareLinkRootFolderNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutShareLinksNestedInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateWithoutWatermarkConfigInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
projectId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
rootFolderId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateManyWithoutWatermarkConfigInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
projectId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
rootFolderId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
|
||||
@@ -949,6 +1248,7 @@ export type ShareLinkSelect<ExtArgs extends runtime.Types.Extensions.InternalArg
|
||||
expireAt?: boolean
|
||||
password?: boolean
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: boolean
|
||||
viewMode?: boolean
|
||||
fieldVisibility?: boolean
|
||||
@@ -957,9 +1257,12 @@ export type ShareLinkSelect<ExtArgs extends runtime.Types.Extensions.InternalArg
|
||||
projectId?: boolean
|
||||
rootFolderId?: boolean
|
||||
creatorId?: boolean
|
||||
watermarkConfigId?: boolean
|
||||
watermarkStatus?: boolean
|
||||
project?: boolean | Prisma.ProjectDefaultArgs<ExtArgs>
|
||||
rootFolder?: boolean | Prisma.AssetDefaultArgs<ExtArgs>
|
||||
creator?: boolean | Prisma.ShareLink$creatorArgs<ExtArgs>
|
||||
watermarkConfig?: boolean | Prisma.ShareLink$watermarkConfigArgs<ExtArgs>
|
||||
}, ExtArgs["result"]["shareLink"]>
|
||||
|
||||
export type ShareLinkSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
|
||||
@@ -968,6 +1271,7 @@ export type ShareLinkSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Ext
|
||||
expireAt?: boolean
|
||||
password?: boolean
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: boolean
|
||||
viewMode?: boolean
|
||||
fieldVisibility?: boolean
|
||||
@@ -976,9 +1280,12 @@ export type ShareLinkSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Ext
|
||||
projectId?: boolean
|
||||
rootFolderId?: boolean
|
||||
creatorId?: boolean
|
||||
watermarkConfigId?: boolean
|
||||
watermarkStatus?: boolean
|
||||
project?: boolean | Prisma.ProjectDefaultArgs<ExtArgs>
|
||||
rootFolder?: boolean | Prisma.AssetDefaultArgs<ExtArgs>
|
||||
creator?: boolean | Prisma.ShareLink$creatorArgs<ExtArgs>
|
||||
watermarkConfig?: boolean | Prisma.ShareLink$watermarkConfigArgs<ExtArgs>
|
||||
}, ExtArgs["result"]["shareLink"]>
|
||||
|
||||
export type ShareLinkSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
|
||||
@@ -987,6 +1294,7 @@ export type ShareLinkSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Ext
|
||||
expireAt?: boolean
|
||||
password?: boolean
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: boolean
|
||||
viewMode?: boolean
|
||||
fieldVisibility?: boolean
|
||||
@@ -995,9 +1303,12 @@ export type ShareLinkSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Ext
|
||||
projectId?: boolean
|
||||
rootFolderId?: boolean
|
||||
creatorId?: boolean
|
||||
watermarkConfigId?: boolean
|
||||
watermarkStatus?: boolean
|
||||
project?: boolean | Prisma.ProjectDefaultArgs<ExtArgs>
|
||||
rootFolder?: boolean | Prisma.AssetDefaultArgs<ExtArgs>
|
||||
creator?: boolean | Prisma.ShareLink$creatorArgs<ExtArgs>
|
||||
watermarkConfig?: boolean | Prisma.ShareLink$watermarkConfigArgs<ExtArgs>
|
||||
}, ExtArgs["result"]["shareLink"]>
|
||||
|
||||
export type ShareLinkSelectScalar = {
|
||||
@@ -1006,6 +1317,7 @@ export type ShareLinkSelectScalar = {
|
||||
expireAt?: boolean
|
||||
password?: boolean
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: boolean
|
||||
viewMode?: boolean
|
||||
fieldVisibility?: boolean
|
||||
@@ -1014,23 +1326,28 @@ export type ShareLinkSelectScalar = {
|
||||
projectId?: boolean
|
||||
rootFolderId?: boolean
|
||||
creatorId?: boolean
|
||||
watermarkConfigId?: boolean
|
||||
watermarkStatus?: boolean
|
||||
}
|
||||
|
||||
export type ShareLinkOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "name" | "expireAt" | "password" | "isDisabled" | "defaultSortOrder" | "viewMode" | "fieldVisibility" | "createdAt" | "updatedAt" | "projectId" | "rootFolderId" | "creatorId", ExtArgs["result"]["shareLink"]>
|
||||
export type ShareLinkOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "name" | "expireAt" | "password" | "isDisabled" | "allowDownload" | "defaultSortOrder" | "viewMode" | "fieldVisibility" | "createdAt" | "updatedAt" | "projectId" | "rootFolderId" | "creatorId" | "watermarkConfigId" | "watermarkStatus", ExtArgs["result"]["shareLink"]>
|
||||
export type ShareLinkInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
project?: boolean | Prisma.ProjectDefaultArgs<ExtArgs>
|
||||
rootFolder?: boolean | Prisma.AssetDefaultArgs<ExtArgs>
|
||||
creator?: boolean | Prisma.ShareLink$creatorArgs<ExtArgs>
|
||||
watermarkConfig?: boolean | Prisma.ShareLink$watermarkConfigArgs<ExtArgs>
|
||||
}
|
||||
export type ShareLinkIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
project?: boolean | Prisma.ProjectDefaultArgs<ExtArgs>
|
||||
rootFolder?: boolean | Prisma.AssetDefaultArgs<ExtArgs>
|
||||
creator?: boolean | Prisma.ShareLink$creatorArgs<ExtArgs>
|
||||
watermarkConfig?: boolean | Prisma.ShareLink$watermarkConfigArgs<ExtArgs>
|
||||
}
|
||||
export type ShareLinkIncludeUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
project?: boolean | Prisma.ProjectDefaultArgs<ExtArgs>
|
||||
rootFolder?: boolean | Prisma.AssetDefaultArgs<ExtArgs>
|
||||
creator?: boolean | Prisma.ShareLink$creatorArgs<ExtArgs>
|
||||
watermarkConfig?: boolean | Prisma.ShareLink$watermarkConfigArgs<ExtArgs>
|
||||
}
|
||||
|
||||
export type $ShareLinkPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
@@ -1039,6 +1356,7 @@ export type $ShareLinkPayload<ExtArgs extends runtime.Types.Extensions.InternalA
|
||||
project: Prisma.$ProjectPayload<ExtArgs>
|
||||
rootFolder: Prisma.$AssetPayload<ExtArgs>
|
||||
creator: Prisma.$UserPayload<ExtArgs> | null
|
||||
watermarkConfig: Prisma.$WatermarkConfigPayload<ExtArgs> | null
|
||||
}
|
||||
scalars: runtime.Types.Extensions.GetPayloadResult<{
|
||||
id: string
|
||||
@@ -1046,6 +1364,7 @@ export type $ShareLinkPayload<ExtArgs extends runtime.Types.Extensions.InternalA
|
||||
expireAt: Date | null
|
||||
password: string | null
|
||||
isDisabled: boolean
|
||||
allowDownload: boolean
|
||||
defaultSortOrder: string | null
|
||||
viewMode: string | null
|
||||
/**
|
||||
@@ -1057,6 +1376,8 @@ export type $ShareLinkPayload<ExtArgs extends runtime.Types.Extensions.InternalA
|
||||
projectId: string
|
||||
rootFolderId: string
|
||||
creatorId: string | null
|
||||
watermarkConfigId: string | null
|
||||
watermarkStatus: $Enums.WatermarkStatus
|
||||
}, ExtArgs["result"]["shareLink"]>
|
||||
composites: {}
|
||||
}
|
||||
@@ -1454,6 +1775,7 @@ export interface Prisma__ShareLinkClient<T, Null = never, ExtArgs extends runtim
|
||||
project<T extends Prisma.ProjectDefaultArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.ProjectDefaultArgs<ExtArgs>>): Prisma.Prisma__ProjectClient<runtime.Types.Result.GetResult<Prisma.$ProjectPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions>
|
||||
rootFolder<T extends Prisma.AssetDefaultArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.AssetDefaultArgs<ExtArgs>>): Prisma.Prisma__AssetClient<runtime.Types.Result.GetResult<Prisma.$AssetPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions>
|
||||
creator<T extends Prisma.ShareLink$creatorArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.ShareLink$creatorArgs<ExtArgs>>): Prisma.Prisma__UserClient<runtime.Types.Result.GetResult<Prisma.$UserPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
|
||||
watermarkConfig<T extends Prisma.ShareLink$watermarkConfigArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.ShareLink$watermarkConfigArgs<ExtArgs>>): Prisma.Prisma__WatermarkConfigClient<runtime.Types.Result.GetResult<Prisma.$WatermarkConfigPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
@@ -1488,6 +1810,7 @@ export interface ShareLinkFieldRefs {
|
||||
readonly expireAt: Prisma.FieldRef<"ShareLink", 'DateTime'>
|
||||
readonly password: Prisma.FieldRef<"ShareLink", 'String'>
|
||||
readonly isDisabled: Prisma.FieldRef<"ShareLink", 'Boolean'>
|
||||
readonly allowDownload: Prisma.FieldRef<"ShareLink", 'Boolean'>
|
||||
readonly defaultSortOrder: Prisma.FieldRef<"ShareLink", 'String'>
|
||||
readonly viewMode: Prisma.FieldRef<"ShareLink", 'String'>
|
||||
readonly fieldVisibility: Prisma.FieldRef<"ShareLink", 'Json'>
|
||||
@@ -1496,6 +1819,8 @@ export interface ShareLinkFieldRefs {
|
||||
readonly projectId: Prisma.FieldRef<"ShareLink", 'String'>
|
||||
readonly rootFolderId: Prisma.FieldRef<"ShareLink", 'String'>
|
||||
readonly creatorId: Prisma.FieldRef<"ShareLink", 'String'>
|
||||
readonly watermarkConfigId: Prisma.FieldRef<"ShareLink", 'String'>
|
||||
readonly watermarkStatus: Prisma.FieldRef<"ShareLink", 'WatermarkStatus'>
|
||||
}
|
||||
|
||||
|
||||
@@ -1915,6 +2240,25 @@ export type ShareLink$creatorArgs<ExtArgs extends runtime.Types.Extensions.Inter
|
||||
where?: Prisma.UserWhereInput
|
||||
}
|
||||
|
||||
/**
|
||||
* ShareLink.watermarkConfig
|
||||
*/
|
||||
export type ShareLink$watermarkConfigArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
/**
|
||||
* Select specific fields to fetch from the WatermarkConfig
|
||||
*/
|
||||
select?: Prisma.WatermarkConfigSelect<ExtArgs> | null
|
||||
/**
|
||||
* Omit specific fields from the WatermarkConfig
|
||||
*/
|
||||
omit?: Prisma.WatermarkConfigOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.WatermarkConfigInclude<ExtArgs> | null
|
||||
where?: Prisma.WatermarkConfigWhereInput
|
||||
}
|
||||
|
||||
/**
|
||||
* ShareLink without action
|
||||
*/
|
||||
|
||||
+212
@@ -201,6 +201,7 @@ export type TeamWhereInput = {
|
||||
agents?: Prisma.AgentListRelationFilter
|
||||
aiUsages?: Prisma.AiUsageListRelationFilter
|
||||
auditLogs?: Prisma.AuditLogListRelationFilter
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateListRelationFilter
|
||||
}
|
||||
|
||||
export type TeamOrderByWithRelationInput = {
|
||||
@@ -223,6 +224,7 @@ export type TeamOrderByWithRelationInput = {
|
||||
agents?: Prisma.AgentOrderByRelationAggregateInput
|
||||
aiUsages?: Prisma.AiUsageOrderByRelationAggregateInput
|
||||
auditLogs?: Prisma.AuditLogOrderByRelationAggregateInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateOrderByRelationAggregateInput
|
||||
}
|
||||
|
||||
export type TeamWhereUniqueInput = Prisma.AtLeast<{
|
||||
@@ -248,6 +250,7 @@ export type TeamWhereUniqueInput = Prisma.AtLeast<{
|
||||
agents?: Prisma.AgentListRelationFilter
|
||||
aiUsages?: Prisma.AiUsageListRelationFilter
|
||||
auditLogs?: Prisma.AuditLogListRelationFilter
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateListRelationFilter
|
||||
}, "id" | "rootFolderId">
|
||||
|
||||
export type TeamOrderByWithAggregationInput = {
|
||||
@@ -293,6 +296,7 @@ export type TeamCreateInput = {
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateInput = {
|
||||
@@ -314,6 +318,7 @@ export type TeamUncheckedCreateInput = {
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUpdateInput = {
|
||||
@@ -335,6 +340,7 @@ export type TeamUpdateInput = {
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateInput = {
|
||||
@@ -356,6 +362,7 @@ export type TeamUncheckedUpdateInput = {
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateManyInput = {
|
||||
@@ -475,6 +482,22 @@ export type TeamUpdateOneRequiredWithoutProjectsNestedInput = {
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.TeamUpdateToOneWithWhereWithoutProjectsInput, Prisma.TeamUpdateWithoutProjectsInput>, Prisma.TeamUncheckedUpdateWithoutProjectsInput>
|
||||
}
|
||||
|
||||
export type TeamCreateNestedOneWithoutWatermarkTemplatesInput = {
|
||||
create?: Prisma.XOR<Prisma.TeamCreateWithoutWatermarkTemplatesInput, Prisma.TeamUncheckedCreateWithoutWatermarkTemplatesInput>
|
||||
connectOrCreate?: Prisma.TeamCreateOrConnectWithoutWatermarkTemplatesInput
|
||||
connect?: Prisma.TeamWhereUniqueInput
|
||||
}
|
||||
|
||||
export type TeamUpdateOneWithoutWatermarkTemplatesNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.TeamCreateWithoutWatermarkTemplatesInput, Prisma.TeamUncheckedCreateWithoutWatermarkTemplatesInput>
|
||||
connectOrCreate?: Prisma.TeamCreateOrConnectWithoutWatermarkTemplatesInput
|
||||
upsert?: Prisma.TeamUpsertWithoutWatermarkTemplatesInput
|
||||
disconnect?: Prisma.TeamWhereInput | boolean
|
||||
delete?: Prisma.TeamWhereInput | boolean
|
||||
connect?: Prisma.TeamWhereUniqueInput
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.TeamUpdateToOneWithWhereWithoutWatermarkTemplatesInput, Prisma.TeamUpdateWithoutWatermarkTemplatesInput>, Prisma.TeamUncheckedUpdateWithoutWatermarkTemplatesInput>
|
||||
}
|
||||
|
||||
export type TeamCreateNestedOneWithoutRootFolderInput = {
|
||||
create?: Prisma.XOR<Prisma.TeamCreateWithoutRootFolderInput, Prisma.TeamUncheckedCreateWithoutRootFolderInput>
|
||||
connectOrCreate?: Prisma.TeamCreateOrConnectWithoutRootFolderInput
|
||||
@@ -639,6 +662,7 @@ export type TeamCreateWithoutSandboxInput = {
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutSandboxInput = {
|
||||
@@ -659,6 +683,7 @@ export type TeamUncheckedCreateWithoutSandboxInput = {
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutSandboxInput = {
|
||||
@@ -695,6 +720,7 @@ export type TeamUpdateWithoutSandboxInput = {
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutSandboxInput = {
|
||||
@@ -715,6 +741,7 @@ export type TeamUncheckedUpdateWithoutSandboxInput = {
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutSkillsInput = {
|
||||
@@ -735,6 +762,7 @@ export type TeamCreateWithoutSkillsInput = {
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutSkillsInput = {
|
||||
@@ -755,6 +783,7 @@ export type TeamUncheckedCreateWithoutSkillsInput = {
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutSkillsInput = {
|
||||
@@ -791,6 +820,7 @@ export type TeamUpdateWithoutSkillsInput = {
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutSkillsInput = {
|
||||
@@ -811,6 +841,7 @@ export type TeamUncheckedUpdateWithoutSkillsInput = {
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutMembersInput = {
|
||||
@@ -831,6 +862,7 @@ export type TeamCreateWithoutMembersInput = {
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutMembersInput = {
|
||||
@@ -851,6 +883,7 @@ export type TeamUncheckedCreateWithoutMembersInput = {
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutMembersInput = {
|
||||
@@ -887,6 +920,7 @@ export type TeamUpdateWithoutMembersInput = {
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutMembersInput = {
|
||||
@@ -907,6 +941,7 @@ export type TeamUncheckedUpdateWithoutMembersInput = {
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutProjectsInput = {
|
||||
@@ -927,6 +962,7 @@ export type TeamCreateWithoutProjectsInput = {
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutProjectsInput = {
|
||||
@@ -947,6 +983,7 @@ export type TeamUncheckedCreateWithoutProjectsInput = {
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutProjectsInput = {
|
||||
@@ -983,6 +1020,7 @@ export type TeamUpdateWithoutProjectsInput = {
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutProjectsInput = {
|
||||
@@ -1003,6 +1041,107 @@ export type TeamUncheckedUpdateWithoutProjectsInput = {
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutWatermarkTemplatesInput = {
|
||||
id?: string
|
||||
name: string
|
||||
settings?:PrismaJson.Settings | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
rootFolder?: Prisma.AssetCreateNestedOneWithoutTeamRootFolderInput
|
||||
members?: Prisma.TeamMemberCreateNestedManyWithoutTeamInput
|
||||
projects?: Prisma.ProjectCreateNestedManyWithoutTeamInput
|
||||
metadataFields?: Prisma.MetadataFieldCreateNestedManyWithoutTeamInput
|
||||
invites?: Prisma.InviteCreateNestedManyWithoutTeamInput
|
||||
notifications?: Prisma.NotificationCreateNestedManyWithoutTeamInput
|
||||
userMetadata?: Prisma.UserMetadataCreateNestedManyWithoutTeamInput
|
||||
providers?: Prisma.ProviderCreateNestedManyWithoutTeamInput
|
||||
skills?: Prisma.SkillCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutWatermarkTemplatesInput = {
|
||||
id?: string
|
||||
name: string
|
||||
settings?:PrismaJson.Settings | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
rootFolderId?: string | null
|
||||
members?: Prisma.TeamMemberUncheckedCreateNestedManyWithoutTeamInput
|
||||
projects?: Prisma.ProjectUncheckedCreateNestedManyWithoutTeamInput
|
||||
metadataFields?: Prisma.MetadataFieldUncheckedCreateNestedManyWithoutTeamInput
|
||||
invites?: Prisma.InviteUncheckedCreateNestedManyWithoutTeamInput
|
||||
notifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutTeamInput
|
||||
userMetadata?: Prisma.UserMetadataUncheckedCreateNestedManyWithoutTeamInput
|
||||
providers?: Prisma.ProviderUncheckedCreateNestedManyWithoutTeamInput
|
||||
skills?: Prisma.SkillUncheckedCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxUncheckedCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutWatermarkTemplatesInput = {
|
||||
where: Prisma.TeamWhereUniqueInput
|
||||
create: Prisma.XOR<Prisma.TeamCreateWithoutWatermarkTemplatesInput, Prisma.TeamUncheckedCreateWithoutWatermarkTemplatesInput>
|
||||
}
|
||||
|
||||
export type TeamUpsertWithoutWatermarkTemplatesInput = {
|
||||
update: Prisma.XOR<Prisma.TeamUpdateWithoutWatermarkTemplatesInput, Prisma.TeamUncheckedUpdateWithoutWatermarkTemplatesInput>
|
||||
create: Prisma.XOR<Prisma.TeamCreateWithoutWatermarkTemplatesInput, Prisma.TeamUncheckedCreateWithoutWatermarkTemplatesInput>
|
||||
where?: Prisma.TeamWhereInput
|
||||
}
|
||||
|
||||
export type TeamUpdateToOneWithWhereWithoutWatermarkTemplatesInput = {
|
||||
where?: Prisma.TeamWhereInput
|
||||
data: Prisma.XOR<Prisma.TeamUpdateWithoutWatermarkTemplatesInput, Prisma.TeamUncheckedUpdateWithoutWatermarkTemplatesInput>
|
||||
}
|
||||
|
||||
export type TeamUpdateWithoutWatermarkTemplatesInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
settings?:PrismaJson.Settings | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
rootFolder?: Prisma.AssetUpdateOneWithoutTeamRootFolderNestedInput
|
||||
members?: Prisma.TeamMemberUpdateManyWithoutTeamNestedInput
|
||||
projects?: Prisma.ProjectUpdateManyWithoutTeamNestedInput
|
||||
metadataFields?: Prisma.MetadataFieldUpdateManyWithoutTeamNestedInput
|
||||
invites?: Prisma.InviteUpdateManyWithoutTeamNestedInput
|
||||
notifications?: Prisma.NotificationUpdateManyWithoutTeamNestedInput
|
||||
userMetadata?: Prisma.UserMetadataUpdateManyWithoutTeamNestedInput
|
||||
providers?: Prisma.ProviderUpdateManyWithoutTeamNestedInput
|
||||
skills?: Prisma.SkillUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutWatermarkTemplatesInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
settings?:PrismaJson.Settings | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
rootFolderId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
members?: Prisma.TeamMemberUncheckedUpdateManyWithoutTeamNestedInput
|
||||
projects?: Prisma.ProjectUncheckedUpdateManyWithoutTeamNestedInput
|
||||
metadataFields?: Prisma.MetadataFieldUncheckedUpdateManyWithoutTeamNestedInput
|
||||
invites?: Prisma.InviteUncheckedUpdateManyWithoutTeamNestedInput
|
||||
notifications?: Prisma.NotificationUncheckedUpdateManyWithoutTeamNestedInput
|
||||
userMetadata?: Prisma.UserMetadataUncheckedUpdateManyWithoutTeamNestedInput
|
||||
providers?: Prisma.ProviderUncheckedUpdateManyWithoutTeamNestedInput
|
||||
skills?: Prisma.SkillUncheckedUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUncheckedUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutRootFolderInput = {
|
||||
@@ -1023,6 +1162,7 @@ export type TeamCreateWithoutRootFolderInput = {
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutRootFolderInput = {
|
||||
@@ -1043,6 +1183,7 @@ export type TeamUncheckedCreateWithoutRootFolderInput = {
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutRootFolderInput = {
|
||||
@@ -1079,6 +1220,7 @@ export type TeamUpdateWithoutRootFolderInput = {
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutRootFolderInput = {
|
||||
@@ -1099,6 +1241,7 @@ export type TeamUncheckedUpdateWithoutRootFolderInput = {
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutInvitesInput = {
|
||||
@@ -1119,6 +1262,7 @@ export type TeamCreateWithoutInvitesInput = {
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutInvitesInput = {
|
||||
@@ -1139,6 +1283,7 @@ export type TeamUncheckedCreateWithoutInvitesInput = {
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutInvitesInput = {
|
||||
@@ -1175,6 +1320,7 @@ export type TeamUpdateWithoutInvitesInput = {
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutInvitesInput = {
|
||||
@@ -1195,6 +1341,7 @@ export type TeamUncheckedUpdateWithoutInvitesInput = {
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutMetadataFieldsInput = {
|
||||
@@ -1215,6 +1362,7 @@ export type TeamCreateWithoutMetadataFieldsInput = {
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutMetadataFieldsInput = {
|
||||
@@ -1235,6 +1383,7 @@ export type TeamUncheckedCreateWithoutMetadataFieldsInput = {
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutMetadataFieldsInput = {
|
||||
@@ -1271,6 +1420,7 @@ export type TeamUpdateWithoutMetadataFieldsInput = {
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutMetadataFieldsInput = {
|
||||
@@ -1291,6 +1441,7 @@ export type TeamUncheckedUpdateWithoutMetadataFieldsInput = {
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutNotificationsInput = {
|
||||
@@ -1311,6 +1462,7 @@ export type TeamCreateWithoutNotificationsInput = {
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutNotificationsInput = {
|
||||
@@ -1331,6 +1483,7 @@ export type TeamUncheckedCreateWithoutNotificationsInput = {
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutNotificationsInput = {
|
||||
@@ -1367,6 +1520,7 @@ export type TeamUpdateWithoutNotificationsInput = {
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutNotificationsInput = {
|
||||
@@ -1387,6 +1541,7 @@ export type TeamUncheckedUpdateWithoutNotificationsInput = {
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutAgentsInput = {
|
||||
@@ -1407,6 +1562,7 @@ export type TeamCreateWithoutAgentsInput = {
|
||||
sandbox?: Prisma.SandboxCreateNestedOneWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutAgentsInput = {
|
||||
@@ -1427,6 +1583,7 @@ export type TeamUncheckedCreateWithoutAgentsInput = {
|
||||
sandbox?: Prisma.SandboxUncheckedCreateNestedOneWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutAgentsInput = {
|
||||
@@ -1463,6 +1620,7 @@ export type TeamUpdateWithoutAgentsInput = {
|
||||
sandbox?: Prisma.SandboxUpdateOneWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutAgentsInput = {
|
||||
@@ -1483,6 +1641,7 @@ export type TeamUncheckedUpdateWithoutAgentsInput = {
|
||||
sandbox?: Prisma.SandboxUncheckedUpdateOneWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutUserMetadataInput = {
|
||||
@@ -1503,6 +1662,7 @@ export type TeamCreateWithoutUserMetadataInput = {
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutUserMetadataInput = {
|
||||
@@ -1523,6 +1683,7 @@ export type TeamUncheckedCreateWithoutUserMetadataInput = {
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutUserMetadataInput = {
|
||||
@@ -1559,6 +1720,7 @@ export type TeamUpdateWithoutUserMetadataInput = {
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutUserMetadataInput = {
|
||||
@@ -1579,6 +1741,7 @@ export type TeamUncheckedUpdateWithoutUserMetadataInput = {
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutProvidersInput = {
|
||||
@@ -1599,6 +1762,7 @@ export type TeamCreateWithoutProvidersInput = {
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutProvidersInput = {
|
||||
@@ -1619,6 +1783,7 @@ export type TeamUncheckedCreateWithoutProvidersInput = {
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutProvidersInput = {
|
||||
@@ -1655,6 +1820,7 @@ export type TeamUpdateWithoutProvidersInput = {
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutProvidersInput = {
|
||||
@@ -1675,6 +1841,7 @@ export type TeamUncheckedUpdateWithoutProvidersInput = {
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutAiUsagesInput = {
|
||||
@@ -1695,6 +1862,7 @@ export type TeamCreateWithoutAiUsagesInput = {
|
||||
sandbox?: Prisma.SandboxCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutAiUsagesInput = {
|
||||
@@ -1715,6 +1883,7 @@ export type TeamUncheckedCreateWithoutAiUsagesInput = {
|
||||
sandbox?: Prisma.SandboxUncheckedCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutAiUsagesInput = {
|
||||
@@ -1751,6 +1920,7 @@ export type TeamUpdateWithoutAiUsagesInput = {
|
||||
sandbox?: Prisma.SandboxUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutAiUsagesInput = {
|
||||
@@ -1771,6 +1941,7 @@ export type TeamUncheckedUpdateWithoutAiUsagesInput = {
|
||||
sandbox?: Prisma.SandboxUncheckedUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
auditLogs?: Prisma.AuditLogUncheckedUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutAuditLogsInput = {
|
||||
@@ -1791,6 +1962,7 @@ export type TeamCreateWithoutAuditLogsInput = {
|
||||
sandbox?: Prisma.SandboxCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutAuditLogsInput = {
|
||||
@@ -1811,6 +1983,7 @@ export type TeamUncheckedCreateWithoutAuditLogsInput = {
|
||||
sandbox?: Prisma.SandboxUncheckedCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutAuditLogsInput = {
|
||||
@@ -1847,6 +2020,7 @@ export type TeamUpdateWithoutAuditLogsInput = {
|
||||
sandbox?: Prisma.SandboxUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutAuditLogsInput = {
|
||||
@@ -1867,6 +2041,7 @@ export type TeamUncheckedUpdateWithoutAuditLogsInput = {
|
||||
sandbox?: Prisma.SandboxUncheckedUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
watermarkTemplates?: Prisma.WatermarkTemplateUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
|
||||
@@ -1886,6 +2061,7 @@ export type TeamCountOutputType = {
|
||||
agents: number
|
||||
aiUsages: number
|
||||
auditLogs: number
|
||||
watermarkTemplates: number
|
||||
}
|
||||
|
||||
export type TeamCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
@@ -1900,6 +2076,7 @@ export type TeamCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.I
|
||||
agents?: boolean | TeamCountOutputTypeCountAgentsArgs
|
||||
aiUsages?: boolean | TeamCountOutputTypeCountAiUsagesArgs
|
||||
auditLogs?: boolean | TeamCountOutputTypeCountAuditLogsArgs
|
||||
watermarkTemplates?: boolean | TeamCountOutputTypeCountWatermarkTemplatesArgs
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1989,6 +2166,13 @@ export type TeamCountOutputTypeCountAuditLogsArgs<ExtArgs extends runtime.Types.
|
||||
where?: Prisma.AuditLogWhereInput
|
||||
}
|
||||
|
||||
/**
|
||||
* TeamCountOutputType without action
|
||||
*/
|
||||
export type TeamCountOutputTypeCountWatermarkTemplatesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
where?: Prisma.WatermarkTemplateWhereInput
|
||||
}
|
||||
|
||||
|
||||
export type TeamSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
|
||||
id?: boolean
|
||||
@@ -2010,6 +2194,7 @@ export type TeamSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = r
|
||||
agents?: boolean | Prisma.Team$agentsArgs<ExtArgs>
|
||||
aiUsages?: boolean | Prisma.Team$aiUsagesArgs<ExtArgs>
|
||||
auditLogs?: boolean | Prisma.Team$auditLogsArgs<ExtArgs>
|
||||
watermarkTemplates?: boolean | Prisma.Team$watermarkTemplatesArgs<ExtArgs>
|
||||
_count?: boolean | Prisma.TeamCountOutputTypeDefaultArgs<ExtArgs>
|
||||
}, ExtArgs["result"]["team"]>
|
||||
|
||||
@@ -2057,6 +2242,7 @@ export type TeamInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs =
|
||||
agents?: boolean | Prisma.Team$agentsArgs<ExtArgs>
|
||||
aiUsages?: boolean | Prisma.Team$aiUsagesArgs<ExtArgs>
|
||||
auditLogs?: boolean | Prisma.Team$auditLogsArgs<ExtArgs>
|
||||
watermarkTemplates?: boolean | Prisma.Team$watermarkTemplatesArgs<ExtArgs>
|
||||
_count?: boolean | Prisma.TeamCountOutputTypeDefaultArgs<ExtArgs>
|
||||
}
|
||||
export type TeamIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
@@ -2082,6 +2268,7 @@ export type $TeamPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs =
|
||||
agents: Prisma.$AgentPayload<ExtArgs>[]
|
||||
aiUsages: Prisma.$AiUsagePayload<ExtArgs>[]
|
||||
auditLogs: Prisma.$AuditLogPayload<ExtArgs>[]
|
||||
watermarkTemplates: Prisma.$WatermarkTemplatePayload<ExtArgs>[]
|
||||
}
|
||||
scalars: runtime.Types.Extensions.GetPayloadResult<{
|
||||
id: string
|
||||
@@ -2500,6 +2687,7 @@ export interface Prisma__TeamClient<T, Null = never, ExtArgs extends runtime.Typ
|
||||
agents<T extends Prisma.Team$agentsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Team$agentsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$AgentPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
||||
aiUsages<T extends Prisma.Team$aiUsagesArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Team$aiUsagesArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$AiUsagePayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
||||
auditLogs<T extends Prisma.Team$auditLogsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Team$auditLogsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$AuditLogPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
||||
watermarkTemplates<T extends Prisma.Team$watermarkTemplatesArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Team$watermarkTemplatesArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$WatermarkTemplatePayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
@@ -3237,6 +3425,30 @@ export type Team$auditLogsArgs<ExtArgs extends runtime.Types.Extensions.Internal
|
||||
distinct?: Prisma.AuditLogScalarFieldEnum | Prisma.AuditLogScalarFieldEnum[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Team.watermarkTemplates
|
||||
*/
|
||||
export type Team$watermarkTemplatesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
/**
|
||||
* Select specific fields to fetch from the WatermarkTemplate
|
||||
*/
|
||||
select?: Prisma.WatermarkTemplateSelect<ExtArgs> | null
|
||||
/**
|
||||
* Omit specific fields from the WatermarkTemplate
|
||||
*/
|
||||
omit?: Prisma.WatermarkTemplateOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.WatermarkTemplateInclude<ExtArgs> | null
|
||||
where?: Prisma.WatermarkTemplateWhereInput
|
||||
orderBy?: Prisma.WatermarkTemplateOrderByWithRelationInput | Prisma.WatermarkTemplateOrderByWithRelationInput[]
|
||||
cursor?: Prisma.WatermarkTemplateWhereUniqueInput
|
||||
take?: number
|
||||
skip?: number
|
||||
distinct?: Prisma.WatermarkTemplateScalarFieldEnum | Prisma.WatermarkTemplateScalarFieldEnum[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Team without action
|
||||
*/
|
||||
|
||||
+1447
File diff suppressed because it is too large
Load Diff
+1556
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -74,7 +74,6 @@ declare global {
|
||||
width: number
|
||||
height: number
|
||||
resolution?: string
|
||||
isRaw?: boolean
|
||||
}
|
||||
|
||||
export interface ImageTranscode {
|
||||
@@ -84,7 +83,7 @@ declare global {
|
||||
height: number
|
||||
quality: number
|
||||
format: string
|
||||
isRaw?: boolean
|
||||
isPreview?: boolean
|
||||
}
|
||||
|
||||
export interface SpriteInfo {
|
||||
@@ -117,7 +116,6 @@ declare global {
|
||||
|
||||
export interface OriginalInfo {
|
||||
key: string
|
||||
downloadUrl: string
|
||||
filesizeInBytes: number
|
||||
codec: string
|
||||
}
|
||||
@@ -134,7 +132,7 @@ declare global {
|
||||
proxyType?: 'image' | 'video' | 'audio' | 'pdf'
|
||||
imageTranscodes: ImageTranscode[]
|
||||
videoTranscodes: VideoTranscode[]
|
||||
videoPreview: VideoTranscode
|
||||
videoPreview?: VideoTranscode
|
||||
pdfTranscode?: PdfTranscode
|
||||
sprite?: SpriteInfo
|
||||
poster?: PosterInfo
|
||||
@@ -277,6 +275,7 @@ declare global {
|
||||
screenshot?: ScreenshotSpec
|
||||
imageAnnotation?: ImageAnnotationSpec
|
||||
pdfPages?: PdfPagesSpec
|
||||
watermark?: WatermarkTaskPayload
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
@@ -322,5 +321,43 @@ declare global {
|
||||
// ----------------------------------------------------------------------
|
||||
export type SkillEnvironmentVariable = import('@shumai/dtos').SkillEnvironmentVariable
|
||||
export type SkillConfig = import('@shumai/dtos').SkillConfig
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Watermark Config
|
||||
// ----------------------------------------------------------------------
|
||||
export interface WatermarkBlockText {
|
||||
id: string
|
||||
type: 'text'
|
||||
x: number
|
||||
y: number
|
||||
opacity: number
|
||||
rotation: number
|
||||
text: string
|
||||
size: number
|
||||
color: string
|
||||
}
|
||||
|
||||
export interface WatermarkBlockImage {
|
||||
id: string
|
||||
type: 'image'
|
||||
x: number
|
||||
y: number
|
||||
opacity: number
|
||||
rotation: number
|
||||
imageAssetKey: string
|
||||
imageAssetUrl?: string
|
||||
size: number
|
||||
}
|
||||
|
||||
export type WatermarkBlock = WatermarkBlockText | WatermarkBlockImage
|
||||
|
||||
export interface WatermarkConfigSpec {
|
||||
blocks: WatermarkBlock[]
|
||||
}
|
||||
|
||||
export interface WatermarkTaskPayload {
|
||||
watermarkConfigId: string
|
||||
shareLinkId?: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/dtos",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.5",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -77,7 +77,7 @@ export const assetInfoSchema = z.object({
|
||||
|
||||
media: z
|
||||
.object({
|
||||
original: z.object({ downloadUrl: z.string(), key: z.string().optional() }).optional(),
|
||||
original: z.object({ key: z.string().optional() }).optional(),
|
||||
videoTranscodes: z
|
||||
.array(
|
||||
z.object({
|
||||
@@ -87,7 +87,6 @@ export const assetInfoSchema = z.object({
|
||||
width: z.number(),
|
||||
height: z.number(),
|
||||
size: z.number(),
|
||||
isRaw: z.boolean(),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
@@ -100,7 +99,6 @@ export const assetInfoSchema = z.object({
|
||||
width: z.number(),
|
||||
height: z.number(),
|
||||
size: z.number(),
|
||||
isRaw: z.boolean(),
|
||||
}),
|
||||
)
|
||||
.optional(),
|
||||
@@ -285,7 +283,6 @@ export interface ImageTranscode {
|
||||
width: number
|
||||
height: number
|
||||
size: number
|
||||
isRaw: boolean
|
||||
}
|
||||
|
||||
export interface VideoTranscode {
|
||||
@@ -295,7 +292,6 @@ export interface VideoTranscode {
|
||||
width: number
|
||||
height: number
|
||||
size: number
|
||||
isRaw: boolean
|
||||
}
|
||||
|
||||
export const postAttachmentRequestSchema = z.object({
|
||||
|
||||
@@ -20,3 +20,4 @@ export * from './user-metadata'
|
||||
export * from './versionStack'
|
||||
export * from './chat'
|
||||
export * from './auditLog'
|
||||
export * from './watermark'
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { z } from 'zod'
|
||||
import { paginationParamsSchema } from './pagination'
|
||||
import type { WatermarkConfigSpec } from './watermark'
|
||||
|
||||
export interface ShareLinkInfo {
|
||||
id: string
|
||||
name: string
|
||||
expireAt?: string
|
||||
isDisabled: boolean
|
||||
allowDownload: boolean
|
||||
hasPassword: boolean
|
||||
password?: string | null
|
||||
defaultSortOrder?: string
|
||||
@@ -14,6 +16,13 @@ export interface ShareLinkInfo {
|
||||
rootFolderId: string
|
||||
projectId: string
|
||||
isExpired: boolean
|
||||
watermarkConfigId?: string | null
|
||||
watermarkStatus?: 'disabled' | 'processing' | 'ready' | 'failed'
|
||||
watermarkConfig?: {
|
||||
id: string
|
||||
config: WatermarkConfigSpec
|
||||
hash: string
|
||||
} | null
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
creator?: { id: string; name: string; image?: string | null } | null
|
||||
@@ -24,6 +33,7 @@ export const createShareLinkRequestSchema = z.object({
|
||||
expireAt: z.string().datetime().optional(),
|
||||
password: z.string().optional(),
|
||||
isDisabled: z.boolean().optional(),
|
||||
allowDownload: z.boolean().optional(),
|
||||
defaultSortOrder: z.string().optional(),
|
||||
viewMode: z.string().optional(),
|
||||
})
|
||||
@@ -35,6 +45,7 @@ export const updateShareLinkRequestSchema = z.object({
|
||||
expireAt: z.string().datetime().optional().nullable(),
|
||||
password: z.string().optional().nullable(),
|
||||
isDisabled: z.boolean().optional(),
|
||||
allowDownload: z.boolean().optional(),
|
||||
defaultSortOrder: z.string().optional().nullable(),
|
||||
viewMode: z.string().optional().nullable(),
|
||||
fieldVisibility: z.record(z.string(), z.boolean()).optional().nullable(),
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const watermarkBlockTextSchema = z.object({
|
||||
id: z.string(),
|
||||
type: z.literal('text'),
|
||||
x: z.number().min(0).max(1),
|
||||
y: z.number().min(0).max(1),
|
||||
opacity: z.number().min(0).max(1),
|
||||
rotation: z.number().min(-180).max(180),
|
||||
text: z.string(),
|
||||
// size is a FRACTION (0..1) of the canvas width, so the watermark scales
|
||||
// proportionally with the output resolution.
|
||||
size: z.number().positive().max(1),
|
||||
color: z.string(),
|
||||
})
|
||||
|
||||
export type WatermarkBlockText = z.infer<typeof watermarkBlockTextSchema>
|
||||
|
||||
export const watermarkBlockImageSchema = z.object({
|
||||
id: z.string(),
|
||||
type: z.literal('image'),
|
||||
x: z.number().min(0).max(1),
|
||||
y: z.number().min(0).max(1),
|
||||
opacity: z.number().min(0).max(1),
|
||||
rotation: z.number().min(-180).max(180),
|
||||
imageAssetKey: z.string().min(1),
|
||||
imageAssetUrl: z.string().optional(),
|
||||
// size is a FRACTION (0..1) of the canvas width, same as text blocks.
|
||||
size: z.number().positive().max(1),
|
||||
})
|
||||
|
||||
export type WatermarkBlockImage = z.infer<typeof watermarkBlockImageSchema>
|
||||
|
||||
export const watermarkBlockSchema = z.discriminatedUnion('type', [
|
||||
watermarkBlockTextSchema,
|
||||
watermarkBlockImageSchema,
|
||||
])
|
||||
|
||||
export type WatermarkBlock = z.infer<typeof watermarkBlockSchema>
|
||||
|
||||
export const watermarkConfigSpecSchema = z.object({
|
||||
blocks: z.array(watermarkBlockSchema),
|
||||
})
|
||||
|
||||
export type WatermarkConfigSpec = z.infer<typeof watermarkConfigSpecSchema>
|
||||
|
||||
export interface WatermarkConfigInfo {
|
||||
id: string
|
||||
config: WatermarkConfigSpec
|
||||
hash: string
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export interface WatermarkTemplateInfo {
|
||||
id: string
|
||||
name: string
|
||||
config: WatermarkConfigSpec
|
||||
teamId?: string | null
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
}
|
||||
|
||||
export const createWatermarkTemplateRequestSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
teamId: z.string().optional(),
|
||||
config: watermarkConfigSpecSchema,
|
||||
})
|
||||
|
||||
export type CreateWatermarkTemplateRequest = z.infer<typeof createWatermarkTemplateRequestSchema>
|
||||
|
||||
export const updateWatermarkTemplateRequestSchema = z.object({
|
||||
name: z.string().min(1).optional(),
|
||||
config: watermarkConfigSpecSchema.optional(),
|
||||
})
|
||||
|
||||
export type UpdateWatermarkTemplateRequest = z.infer<typeof updateWatermarkTemplateRequestSchema>
|
||||
|
||||
export const updateShareLinkWatermarkRequestSchema = z
|
||||
.object({
|
||||
enabled: z.boolean(),
|
||||
config: watermarkConfigSpecSchema.optional(),
|
||||
})
|
||||
.superRefine((val, ctx) => {
|
||||
if (val.enabled && (!val.config || val.config.blocks.length === 0)) {
|
||||
ctx.addIssue({
|
||||
code: 'custom',
|
||||
path: ['config'],
|
||||
message: 'Watermark configuration is required when enabling watermark',
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
export type UpdateShareLinkWatermarkRequest = z.infer<typeof updateShareLinkWatermarkRequestSchema>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/e2e",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.5",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
|
||||
@@ -0,0 +1,321 @@
|
||||
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest'
|
||||
import { prisma, AssetStatus } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db/test'
|
||||
import { workflowService, TaskQueueTranscode } from '@shumai/workflow-core'
|
||||
import { initTranscodeWorkflows } from '@shumai/transcode'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { fileURLToPath } from 'url'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
import { GenericContainer, StartedTestContainer } from 'testcontainers'
|
||||
|
||||
const currentDir = path.dirname(fileURLToPath(import.meta.url))
|
||||
const transcodeWorkflowsPath = path.resolve(currentDir, '../../../apps/transcode/src/workflows.ts')
|
||||
const fixturesDir = path.resolve(currentDir, '../fixtures')
|
||||
|
||||
describe.each(['local', 'temporal'] as const)(
|
||||
'Workflow E2E - Real Gotenberg Transcode (executor: %s)',
|
||||
(mode) => {
|
||||
setupTestDbHooks()
|
||||
|
||||
let transcodeWorkerPromise: Promise<void> | null = null
|
||||
let gotenbergContainer: StartedTestContainer | null = null
|
||||
|
||||
beforeAll(async () => {
|
||||
process.env.S3_BUCKET = 'shumai-e2e-test-bucket-gotenberg'
|
||||
|
||||
console.log('Starting Gotenberg container via testcontainers...')
|
||||
try {
|
||||
gotenbergContainer = await new GenericContainer('gotenberg/gotenberg:8')
|
||||
.withExposedPorts(3000)
|
||||
.start()
|
||||
const host = gotenbergContainer.getHost()
|
||||
const port = gotenbergContainer.getMappedPort(3000)
|
||||
process.env.GOTENBERG_URL = `http://${host}:${port}`
|
||||
console.log(`Gotenberg container ready at ${process.env.GOTENBERG_URL}`)
|
||||
} catch (err) {
|
||||
console.error('Failed to start Gotenberg container:', err)
|
||||
throw err
|
||||
}
|
||||
|
||||
workflowService.setExecutorType(mode)
|
||||
initTranscodeWorkflows()
|
||||
|
||||
if (mode === 'temporal') {
|
||||
console.log('Starting background worker for transcode Temporal E2E tests...')
|
||||
transcodeWorkerPromise = workflowService.startWorkers(TaskQueueTranscode, {
|
||||
workflowsPath: transcodeWorkflowsPath,
|
||||
})
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000))
|
||||
} else {
|
||||
console.log('Starting local workflow service polling...')
|
||||
workflowService.start()
|
||||
}
|
||||
}, 120000)
|
||||
|
||||
afterAll(async () => {
|
||||
if (mode === 'temporal') {
|
||||
console.log('Shutting down Temporal workers...')
|
||||
await workflowService.shutdownWorkers()
|
||||
await Promise.all([transcodeWorkerPromise].filter(Boolean))
|
||||
}
|
||||
workflowService.close()
|
||||
vi.restoreAllMocks()
|
||||
|
||||
if (gotenbergContainer) {
|
||||
console.log('Stopping Gotenberg container...')
|
||||
await gotenbergContainer.stop()
|
||||
}
|
||||
|
||||
try {
|
||||
console.log('Cleaning up E2E storage files...')
|
||||
await s3Service.deletePrefix('shumai-e2e-test-bucket-gotenberg', '')
|
||||
} catch (err) {
|
||||
console.error('Failed to clean up E2E storage folder:', err)
|
||||
}
|
||||
}, 120000)
|
||||
|
||||
it('should process real office Word document (.docx) transcode PDF task using Gotenberg', async () => {
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Gotenberg DOCX Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Gotenberg DOCX Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/test.docx',
|
||||
status: 'active',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'test.docx',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
const docxPath = path.join(fixturesDir, 'test.docx')
|
||||
const docxBuffer = fs.readFileSync(docxPath)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-gotenberg',
|
||||
'projects/e2e/test.docx',
|
||||
docxBuffer,
|
||||
docxBuffer.length,
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
)
|
||||
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_pdf',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
transcode: {
|
||||
poster: true,
|
||||
sprite: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
console.log(
|
||||
`Submitted E2E Gotenberg DOCX Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 60000)
|
||||
|
||||
expect(completedTask.status).toBe('completed')
|
||||
|
||||
const updatedAsset = await prisma.asset.findUnique({
|
||||
where: { id: asset.id },
|
||||
})
|
||||
expect(updatedAsset?.status).toBe(AssetStatus.processed)
|
||||
|
||||
const mediaInfo = updatedAsset?.media as unknown as {
|
||||
proxyType?: string
|
||||
pdfTranscode?: { key: string }
|
||||
poster?: { key: string }
|
||||
sprite?: { key: string }
|
||||
frames?: number
|
||||
}
|
||||
expect(mediaInfo).toBeDefined()
|
||||
expect(mediaInfo.proxyType).toBe('pdf')
|
||||
expect(mediaInfo.pdfTranscode?.key).toBe(`files/${asset.id}/proxy.pdf`)
|
||||
expect(mediaInfo.poster?.key).toContain('poster.webp')
|
||||
expect(mediaInfo.sprite?.key).toContain('sprite.webp')
|
||||
expect(mediaInfo.frames).toBeGreaterThan(0)
|
||||
}, 90000)
|
||||
|
||||
it('should process real office PowerPoint presentation (.pptx) transcode PDF task using Gotenberg', async () => {
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Gotenberg PPTX Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Gotenberg PPTX Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/test.pptx',
|
||||
status: 'active',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'test.pptx',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
const pptxPath = path.join(fixturesDir, 'test.pptx')
|
||||
const pptxBuffer = fs.readFileSync(pptxPath)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-gotenberg',
|
||||
'projects/e2e/test.pptx',
|
||||
pptxBuffer,
|
||||
pptxBuffer.length,
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
)
|
||||
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_pdf',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
transcode: {
|
||||
poster: true,
|
||||
sprite: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
console.log(
|
||||
`Submitted E2E Gotenberg PPTX Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 60000)
|
||||
|
||||
expect(completedTask.status).toBe('completed')
|
||||
|
||||
const updatedAsset = await prisma.asset.findUnique({
|
||||
where: { id: asset.id },
|
||||
})
|
||||
expect(updatedAsset?.status).toBe(AssetStatus.processed)
|
||||
|
||||
const mediaInfo = updatedAsset?.media as unknown as {
|
||||
proxyType?: string
|
||||
pdfTranscode?: { key: string }
|
||||
poster?: { key: string }
|
||||
sprite?: { key: string }
|
||||
frames?: number
|
||||
}
|
||||
expect(mediaInfo).toBeDefined()
|
||||
expect(mediaInfo.proxyType).toBe('pdf')
|
||||
expect(mediaInfo.pdfTranscode?.key).toBe(`files/${asset.id}/proxy.pdf`)
|
||||
expect(mediaInfo.poster?.key).toContain('poster.webp')
|
||||
expect(mediaInfo.sprite?.key).toContain('sprite.webp')
|
||||
expect(mediaInfo.frames).toBeGreaterThan(0)
|
||||
}, 90000)
|
||||
|
||||
it('should process real office Excel spreadsheet (.xlsx) transcode PDF task using Gotenberg', async () => {
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Gotenberg XLSX Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Gotenberg XLSX Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/test.xlsx',
|
||||
status: 'active',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'test.xlsx',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
const xlsxPath = path.join(fixturesDir, 'test.xlsx')
|
||||
const xlsxBuffer = fs.readFileSync(xlsxPath)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-gotenberg',
|
||||
'projects/e2e/test.xlsx',
|
||||
xlsxBuffer,
|
||||
xlsxBuffer.length,
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
)
|
||||
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_pdf',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
transcode: {
|
||||
poster: true,
|
||||
sprite: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
console.log(
|
||||
`Submitted E2E Gotenberg XLSX Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 60000)
|
||||
|
||||
expect(completedTask.status).toBe('completed')
|
||||
|
||||
const updatedAsset = await prisma.asset.findUnique({
|
||||
where: { id: asset.id },
|
||||
})
|
||||
expect(updatedAsset?.status).toBe(AssetStatus.processed)
|
||||
|
||||
const mediaInfo = updatedAsset?.media as unknown as {
|
||||
proxyType?: string
|
||||
pdfTranscode?: { key: string }
|
||||
poster?: { key: string }
|
||||
sprite?: { key: string }
|
||||
frames?: number
|
||||
}
|
||||
expect(mediaInfo).toBeDefined()
|
||||
expect(mediaInfo.proxyType).toBe('pdf')
|
||||
expect(mediaInfo.pdfTranscode?.key).toBe(`files/${asset.id}/proxy.pdf`)
|
||||
expect(mediaInfo.poster?.key).toContain('poster.webp')
|
||||
expect(mediaInfo.sprite?.key).toContain('sprite.webp')
|
||||
expect(mediaInfo.frames).toBeGreaterThan(0)
|
||||
}, 90000)
|
||||
},
|
||||
)
|
||||
@@ -0,0 +1,458 @@
|
||||
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest'
|
||||
import { prisma, WatermarkFileStatus } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db/test'
|
||||
import { workflowService, TaskQueueTranscode } from '@shumai/workflow-core'
|
||||
import { initTranscodeWorkflows } from '@shumai/transcode'
|
||||
import { watermarkService } from '@shumai/core/src/watermark/watermark'
|
||||
import { shareService } from '@shumai/core/src/share/share'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { fileURLToPath } from 'url'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
import type { WatermarkConfigSpec } from '@shumai/dtos'
|
||||
|
||||
const currentDir = path.dirname(fileURLToPath(import.meta.url))
|
||||
const transcodeWorkflowsPath = path.resolve(currentDir, '../../../apps/transcode/src/workflows.ts')
|
||||
const fixturesDir = path.resolve(currentDir, '../fixtures')
|
||||
|
||||
describe.each(['local', 'temporal'] as const)(
|
||||
'Workflow E2E - transcodeWatermarkWorkflow (executor: %s)',
|
||||
(mode) => {
|
||||
setupTestDbHooks()
|
||||
|
||||
let transcodeWorkerPromise: Promise<void> | null = null
|
||||
|
||||
beforeAll(async () => {
|
||||
process.env.S3_BUCKET = 'shumai-e2e-test-bucket-watermark'
|
||||
|
||||
workflowService.setExecutorType(mode)
|
||||
initTranscodeWorkflows()
|
||||
|
||||
if (mode === 'temporal') {
|
||||
console.log('Starting background worker for watermark Temporal E2E tests...')
|
||||
transcodeWorkerPromise = workflowService.startWorkers(TaskQueueTranscode, {
|
||||
workflowsPath: transcodeWorkflowsPath,
|
||||
})
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000))
|
||||
} else {
|
||||
console.log('Starting local workflow service polling...')
|
||||
workflowService.start()
|
||||
}
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
if (mode === 'temporal') {
|
||||
console.log('Shutting down Temporal workers...')
|
||||
await workflowService.shutdownWorkers()
|
||||
await Promise.all([transcodeWorkerPromise].filter(Boolean))
|
||||
}
|
||||
workflowService.close()
|
||||
vi.restoreAllMocks()
|
||||
try {
|
||||
await s3Service.deletePrefix('shumai-e2e-test-bucket-watermark', '')
|
||||
} catch (err) {
|
||||
console.error('Failed to clean up E2E storage folder:', err)
|
||||
}
|
||||
})
|
||||
|
||||
it('should generate watermark proxy for an image asset and update sharelink status to ready', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Watermark Team' },
|
||||
})
|
||||
const projectFolder = await prisma.asset.create({
|
||||
data: { name: 'root', type: 'root', status: 'processed' },
|
||||
})
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Watermark Project', teamId: team.id, rootFolderId: projectFolder.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: { key: 'files/e2e-watermark-asset/original.png' },
|
||||
})
|
||||
|
||||
const sampleImagePath = path.join(fixturesDir, 'sample.png')
|
||||
let sampleBuffer: Buffer
|
||||
if (fs.existsSync(sampleImagePath)) {
|
||||
sampleBuffer = fs.readFileSync(sampleImagePath)
|
||||
} else {
|
||||
// Minimal 1x1 PNG fallback if fixture is missing
|
||||
sampleBuffer = Buffer.from(
|
||||
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==',
|
||||
'base64',
|
||||
)
|
||||
}
|
||||
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-watermark',
|
||||
storageKey.key,
|
||||
sampleBuffer,
|
||||
sampleBuffer.length,
|
||||
'image/png',
|
||||
)
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'sample.png',
|
||||
type: 'file',
|
||||
mediaType: 'image/png',
|
||||
status: 'processed',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
media: {
|
||||
duration: 0,
|
||||
filesize: sampleBuffer.length,
|
||||
frames: 0,
|
||||
proxyType: 'image',
|
||||
imageTranscodes: [
|
||||
{ key: storageKey.key, width: 100, height: 100, quality: 90, format: 'webp' },
|
||||
],
|
||||
videoTranscodes: [],
|
||||
videoPreview: { width: 100, height: 100 },
|
||||
finishedAt: new Date().toISOString(),
|
||||
metadata: {
|
||||
originalWidth: 100,
|
||||
originalHeight: 100,
|
||||
duration: 0,
|
||||
bitRate: 0,
|
||||
frameRate: 0,
|
||||
totalFrames: 0,
|
||||
startTimecode: '00:00:00:00',
|
||||
hasAudio: false,
|
||||
format: {},
|
||||
},
|
||||
original: {
|
||||
key: storageKey.key,
|
||||
filesizeInBytes: sampleBuffer.length,
|
||||
codec: '',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const shareLink = await shareService.createShareLink(project.id, {
|
||||
name: 'Public Watermarked Share',
|
||||
})
|
||||
await shareService.addAssetToShare(shareLink.id, { assetIds: [asset.id] })
|
||||
|
||||
const watermarkConfig: WatermarkConfigSpec = {
|
||||
blocks: [
|
||||
{
|
||||
id: 'b1',
|
||||
type: 'text',
|
||||
x: 0.5,
|
||||
y: 0.5,
|
||||
opacity: 0.5,
|
||||
rotation: 0,
|
||||
text: 'CONFIDENTIAL E2E',
|
||||
size: 0.2,
|
||||
color: '#FF0000',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
// 2. Enable Watermark on Sharelink
|
||||
const updatedShare = await watermarkService.updateShareLinkWatermark(
|
||||
shareLink.id,
|
||||
true,
|
||||
watermarkConfig,
|
||||
)
|
||||
expect(updatedShare.watermarkStatus).toBe('processing')
|
||||
|
||||
// 3. Poll for WorkflowTask completion & ShareLink status 'ready'
|
||||
let finalShare = await shareService.getShareLink(shareLink.id)
|
||||
const startTime = Date.now()
|
||||
while (finalShare.watermarkStatus === 'processing' && Date.now() - startTime < 15000) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 500))
|
||||
finalShare = await shareService.getShareLink(shareLink.id)
|
||||
}
|
||||
|
||||
expect(finalShare.watermarkStatus).toBe('ready')
|
||||
|
||||
// Verify WatermarkFile record was created and completed
|
||||
const watermarkFile = await prisma.watermarkFile.findUnique({
|
||||
where: {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
assetId_watermarkConfigId: {
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: updatedShare.watermarkConfigId!,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
expect(watermarkFile).toBeDefined()
|
||||
expect(watermarkFile?.status).toBe(WatermarkFileStatus.completed)
|
||||
expect(watermarkFile?.media).toBeDefined()
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
expect((watermarkFile?.media as any)?.imageTranscodes?.length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
it('should generate watermark proxy for a video asset and update sharelink status to ready', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Watermark Video Team' },
|
||||
})
|
||||
const projectFolder = await prisma.asset.create({
|
||||
data: { name: 'root', type: 'root', status: 'processed' },
|
||||
})
|
||||
const project = await prisma.project.create({
|
||||
data: {
|
||||
name: 'E2E Watermark Video Project',
|
||||
teamId: team.id,
|
||||
rootFolderId: projectFolder.id,
|
||||
},
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: { key: 'files/e2e-watermark-video/original.mp4' },
|
||||
})
|
||||
|
||||
const videoPath = path.join(fixturesDir, 'small.mp4')
|
||||
const videoBuffer = fs.readFileSync(videoPath)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-watermark',
|
||||
storageKey.key,
|
||||
videoBuffer,
|
||||
videoBuffer.length,
|
||||
'video/mp4',
|
||||
)
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'small.mp4',
|
||||
type: 'file',
|
||||
mediaType: 'video/mp4',
|
||||
status: 'processed',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
media: {
|
||||
duration: 1,
|
||||
filesize: videoBuffer.length,
|
||||
frames: 30,
|
||||
proxyType: 'video',
|
||||
imageTranscodes: [],
|
||||
videoTranscodes: [{ key: storageKey.key, width: 640, height: 360, resolution: '360p' }],
|
||||
videoPreview: { width: 640, height: 360 },
|
||||
finishedAt: new Date().toISOString(),
|
||||
metadata: {
|
||||
originalWidth: 640,
|
||||
originalHeight: 360,
|
||||
duration: 1,
|
||||
bitRate: 0,
|
||||
frameRate: 30,
|
||||
totalFrames: 30,
|
||||
startTimecode: '00:00:00:00',
|
||||
hasAudio: false,
|
||||
format: {},
|
||||
},
|
||||
original: {
|
||||
key: storageKey.key,
|
||||
filesizeInBytes: videoBuffer.length,
|
||||
codec: '',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const shareLink = await shareService.createShareLink(project.id, {
|
||||
name: 'Public Watermarked Video Share',
|
||||
})
|
||||
await shareService.addAssetToShare(shareLink.id, { assetIds: [asset.id] })
|
||||
|
||||
const watermarkConfig: WatermarkConfigSpec = {
|
||||
blocks: [
|
||||
{
|
||||
id: 'b1',
|
||||
type: 'text',
|
||||
x: 0.5,
|
||||
y: 0.5,
|
||||
opacity: 0.5,
|
||||
rotation: 0,
|
||||
text: 'CONFIDENTIAL VIDEO',
|
||||
size: 0.2,
|
||||
color: '#FF0000',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
// 2. Enable Watermark on Sharelink
|
||||
const updatedShare = await watermarkService.updateShareLinkWatermark(
|
||||
shareLink.id,
|
||||
true,
|
||||
watermarkConfig,
|
||||
)
|
||||
expect(updatedShare.watermarkStatus).toBe('processing')
|
||||
|
||||
// 3. Poll for WorkflowTask completion & ShareLink status 'ready'
|
||||
let finalShare = await shareService.getShareLink(shareLink.id)
|
||||
const startTime = Date.now()
|
||||
while (finalShare.watermarkStatus === 'processing' && Date.now() - startTime < 30000) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 500))
|
||||
finalShare = await shareService.getShareLink(shareLink.id)
|
||||
}
|
||||
|
||||
expect(finalShare.watermarkStatus).toBe('ready')
|
||||
|
||||
const watermarkFile = await prisma.watermarkFile.findUnique({
|
||||
where: {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
assetId_watermarkConfigId: {
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: updatedShare.watermarkConfigId!,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
expect(watermarkFile).toBeDefined()
|
||||
expect(watermarkFile?.status).toBe(WatermarkFileStatus.completed)
|
||||
expect(watermarkFile?.media).toBeDefined()
|
||||
// The transcoded proxy should be watermarked, producing exactly one proxy.
|
||||
const mediaInfo = watermarkFile?.media as PrismaJson.MediaInfo | null
|
||||
expect(mediaInfo?.videoTranscodes?.length).toBe(1)
|
||||
expect(mediaInfo?.videoTranscodes?.[0].resolution).toBe('360p')
|
||||
})
|
||||
|
||||
it('should watermark a newly added asset after the sharelink is already ready', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Watermark Team' },
|
||||
})
|
||||
const projectFolder = await prisma.asset.create({
|
||||
data: { name: 'root', type: 'root', status: 'processed' },
|
||||
})
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Watermark Project', teamId: team.id, rootFolderId: projectFolder.id },
|
||||
})
|
||||
|
||||
const readSampleImage = (): Buffer => {
|
||||
const sampleImagePath = path.join(fixturesDir, 'sample.png')
|
||||
if (fs.existsSync(sampleImagePath)) {
|
||||
return fs.readFileSync(sampleImagePath)
|
||||
}
|
||||
// Minimal 1x1 PNG fallback if fixture is missing
|
||||
return Buffer.from(
|
||||
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==',
|
||||
'base64',
|
||||
)
|
||||
}
|
||||
|
||||
const createImageAsset = async (key: string, name: string) => {
|
||||
const buffer = readSampleImage()
|
||||
const storageKey = await prisma.storageKey.create({ data: { key } })
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-watermark',
|
||||
key,
|
||||
buffer,
|
||||
buffer.length,
|
||||
'image/png',
|
||||
)
|
||||
return await prisma.asset.create({
|
||||
data: {
|
||||
name,
|
||||
type: 'file',
|
||||
mediaType: 'image/png',
|
||||
status: 'processed',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
media: {
|
||||
duration: 0,
|
||||
filesize: buffer.length,
|
||||
frames: 0,
|
||||
proxyType: 'image',
|
||||
imageTranscodes: [{ key, width: 100, height: 100, quality: 90, format: 'webp' }],
|
||||
videoTranscodes: [],
|
||||
videoPreview: { width: 100, height: 100 },
|
||||
finishedAt: new Date().toISOString(),
|
||||
metadata: {
|
||||
originalWidth: 100,
|
||||
originalHeight: 100,
|
||||
duration: 0,
|
||||
bitRate: 0,
|
||||
frameRate: 0,
|
||||
totalFrames: 0,
|
||||
startTimecode: '00:00:00:00',
|
||||
hasAudio: false,
|
||||
format: {},
|
||||
},
|
||||
original: {
|
||||
key,
|
||||
filesizeInBytes: buffer.length,
|
||||
codec: '',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const assetA = await createImageAsset('files/e2e-add-after-ready/a.png', 'a.png')
|
||||
const shareLink = await shareService.createShareLink(project.id, {
|
||||
name: 'Public Watermarked Share',
|
||||
})
|
||||
await shareService.addAssetToShare(shareLink.id, { assetIds: [assetA.id] })
|
||||
|
||||
const watermarkConfig: WatermarkConfigSpec = {
|
||||
blocks: [
|
||||
{
|
||||
id: 'b1',
|
||||
type: 'text',
|
||||
x: 0.5,
|
||||
y: 0.5,
|
||||
opacity: 0.5,
|
||||
rotation: 0,
|
||||
text: 'CONFIDENTIAL E2E',
|
||||
size: 0.2,
|
||||
color: '#FF0000',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
// 2. Enable Watermark on Sharelink and wait for initial 'ready'
|
||||
const updatedShare = await watermarkService.updateShareLinkWatermark(
|
||||
shareLink.id,
|
||||
true,
|
||||
watermarkConfig,
|
||||
)
|
||||
expect(updatedShare.watermarkStatus).toBe('processing')
|
||||
|
||||
let share = await shareService.getShareLink(shareLink.id)
|
||||
let startTime = Date.now()
|
||||
while (share.watermarkStatus === 'processing' && Date.now() - startTime < 30000) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 500))
|
||||
share = await shareService.getShareLink(shareLink.id)
|
||||
}
|
||||
expect(share.watermarkStatus).toBe('ready')
|
||||
expect(share.watermarkConfigId).toBe(updatedShare.watermarkConfigId)
|
||||
|
||||
// 3. Add a NEW asset to the ready sharelink
|
||||
const assetB = await createImageAsset('files/e2e-add-after-ready/b.png', 'b.png')
|
||||
await shareService.addAssetToShare(shareLink.id, { assetIds: [assetB.id] })
|
||||
|
||||
// 4. Status flips back to 'processing' while the new asset is transcoded
|
||||
share = await shareService.getShareLink(shareLink.id)
|
||||
expect(share.watermarkStatus).toBe('processing')
|
||||
|
||||
// 5. Poll until the sharelink is 'ready' again
|
||||
startTime = Date.now()
|
||||
while (share.watermarkStatus === 'processing' && Date.now() - startTime < 30000) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 500))
|
||||
share = await shareService.getShareLink(shareLink.id)
|
||||
}
|
||||
expect(share.watermarkStatus).toBe('ready')
|
||||
|
||||
// 6. Both assets now have completed watermark files
|
||||
for (const asset of [assetA, assetB]) {
|
||||
const wf = await prisma.watermarkFile.findUnique({
|
||||
where: {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
assetId_watermarkConfigId: {
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: updatedShare.watermarkConfigId!,
|
||||
},
|
||||
},
|
||||
})
|
||||
expect(wf).toBeDefined()
|
||||
expect(wf?.status).toBe(WatermarkFileStatus.completed)
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/tableprinter",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.5",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/transcode",
|
||||
"version": "0.3.3",
|
||||
"version": "0.3.5",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -3,6 +3,7 @@ import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db/test'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { gotenbergService } from '@shumai/core/src/gotenberg/gotenberg'
|
||||
import { transcodeService } from '@shumai/core/src/transcode/transcode'
|
||||
import * as child_process from 'child_process'
|
||||
|
||||
@@ -37,39 +38,43 @@ vi.mock('@shumai/core/src/s3/s3', () => ({
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('@shumai/core/src/transcode/transcode', () => ({
|
||||
transcodeService: {
|
||||
getVideoInfo: vi.fn(),
|
||||
getAudioInfo: vi.fn(),
|
||||
getImageInfo: vi.fn(),
|
||||
getPdfInfo: vi.fn().mockResolvedValue({
|
||||
originalWidth: 800,
|
||||
originalHeight: 1000,
|
||||
duration: 0,
|
||||
bitRate: 0,
|
||||
frameRate: 0,
|
||||
totalFrames: 10,
|
||||
hasAudio: false,
|
||||
mimeType: 'application/pdf',
|
||||
}),
|
||||
transcodeVideo: vi.fn(),
|
||||
transcodeAudio: vi.fn(),
|
||||
transcodeImage: vi.fn(),
|
||||
generateSprite: vi.fn(),
|
||||
generatePdfSprite: vi.fn().mockResolvedValue({
|
||||
pageCount: 10,
|
||||
originalWidth: 800,
|
||||
originalHeight: 1000,
|
||||
}),
|
||||
generatePdfFromText: vi.fn(),
|
||||
generatePdfFromCsv: vi.fn(),
|
||||
createTempDir: vi.fn().mockReturnValue('/tmp'),
|
||||
removeDir: vi.fn(),
|
||||
takeScreenshots: vi.fn(),
|
||||
overlayAnnotations: vi.fn(),
|
||||
renderPdfPages: vi.fn(),
|
||||
},
|
||||
}))
|
||||
vi.mock('@shumai/core/src/transcode/transcode', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('@shumai/core/src/transcode/transcode')>()
|
||||
return {
|
||||
...actual,
|
||||
transcodeService: {
|
||||
getVideoInfo: vi.fn(),
|
||||
getAudioInfo: vi.fn(),
|
||||
getImageInfo: vi.fn(),
|
||||
getPdfInfo: vi.fn().mockResolvedValue({
|
||||
originalWidth: 800,
|
||||
originalHeight: 1000,
|
||||
duration: 0,
|
||||
bitRate: 0,
|
||||
frameRate: 0,
|
||||
totalFrames: 10,
|
||||
hasAudio: false,
|
||||
mimeType: 'application/pdf',
|
||||
}),
|
||||
transcodeVideo: vi.fn(),
|
||||
transcodeAudio: vi.fn(),
|
||||
transcodeImage: vi.fn(),
|
||||
generateSprite: vi.fn(),
|
||||
generatePdfSprite: vi.fn().mockResolvedValue({
|
||||
pageCount: 10,
|
||||
originalWidth: 800,
|
||||
originalHeight: 1000,
|
||||
}),
|
||||
generatePdfFromText: vi.fn(),
|
||||
generatePdfFromCsv: vi.fn(),
|
||||
createTempDir: vi.fn().mockReturnValue('/tmp'),
|
||||
removeDir: vi.fn(),
|
||||
takeScreenshots: vi.fn(),
|
||||
overlayAnnotations: vi.fn(),
|
||||
renderPdfPages: vi.fn(),
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('@shumai/core/src/metadata/metadata', () => ({
|
||||
metadataService: {
|
||||
@@ -92,8 +97,70 @@ vi.mock('fs', async (importOriginal) => {
|
||||
describe('Transcode Activities', () => {
|
||||
setupTestDbHooks()
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach(async () => {
|
||||
vi.clearAllMocks()
|
||||
const fs = await import('fs')
|
||||
vi.mocked(fs.readFileSync).mockImplementation(() => Buffer.from('fake data') as never)
|
||||
})
|
||||
|
||||
it('should convert CSV via Gotenberg in landscape mode when maxCols > 5', async () => {
|
||||
const asset = await prisma.asset.create({
|
||||
data: { name: 'wide.csv', type: 'file', status: 'uploaded' },
|
||||
})
|
||||
|
||||
const fs = await import('fs')
|
||||
vi.mocked(fs.readFileSync).mockImplementation((_path: unknown, options?: unknown) => {
|
||||
if (options) {
|
||||
return 'c1,c2,c3,c4,c5,c6,c7\n1,2,3,4,5,6,7' as never
|
||||
}
|
||||
return Buffer.from('fake data') as never
|
||||
})
|
||||
vi.spyOn(gotenbergService, 'isAvailable').mockResolvedValue(true)
|
||||
const convertSpy = vi
|
||||
.spyOn(gotenbergService, 'convertDocumentToPdf')
|
||||
.mockResolvedValue(Buffer.from('fake pdf landscape csv'))
|
||||
|
||||
const res = await generatePdfProxyActivity({
|
||||
assetId: asset.id,
|
||||
assetKey: 'files/asset1/wide.csv',
|
||||
filePath: '/tmp/wide.csv',
|
||||
mediaType: 'text/csv',
|
||||
filename: 'wide.csv',
|
||||
})
|
||||
|
||||
expect(res.pdfProxyKey).toBe(`files/${asset.id}/proxy.pdf`)
|
||||
expect(convertSpy).toHaveBeenCalledWith('/tmp/wide.csv', 'wide.csv', { landscape: true })
|
||||
vi.mocked(fs.readFileSync).mockImplementation(() => Buffer.from('fake data') as never)
|
||||
})
|
||||
|
||||
it('should convert CSV via Gotenberg in portrait mode when maxCols <= 5', async () => {
|
||||
const asset = await prisma.asset.create({
|
||||
data: { name: 'narrow.csv', type: 'file', status: 'uploaded' },
|
||||
})
|
||||
|
||||
const fs = await import('fs')
|
||||
vi.mocked(fs.readFileSync).mockImplementation((_path: unknown, options?: unknown) => {
|
||||
if (options) {
|
||||
return 'c1,c2,c3\n1,2,3' as never
|
||||
}
|
||||
return Buffer.from('fake data') as never
|
||||
})
|
||||
vi.spyOn(gotenbergService, 'isAvailable').mockResolvedValue(true)
|
||||
const convertSpy = vi
|
||||
.spyOn(gotenbergService, 'convertDocumentToPdf')
|
||||
.mockResolvedValue(Buffer.from('fake pdf portrait csv'))
|
||||
|
||||
const res = await generatePdfProxyActivity({
|
||||
assetId: asset.id,
|
||||
assetKey: 'files/asset1/narrow.csv',
|
||||
filePath: '/tmp/narrow.csv',
|
||||
mediaType: 'text/csv',
|
||||
filename: 'narrow.csv',
|
||||
})
|
||||
|
||||
expect(res.pdfProxyKey).toBe(`files/${asset.id}/proxy.pdf`)
|
||||
expect(convertSpy).toHaveBeenCalledWith('/tmp/narrow.csv', 'narrow.csv', { landscape: false })
|
||||
vi.mocked(fs.readFileSync).mockImplementation(() => Buffer.from('fake data') as never)
|
||||
})
|
||||
|
||||
it('should call getVideoInfo and set file_type to video', async () => {
|
||||
@@ -245,6 +312,7 @@ describe('Transcode Activities', () => {
|
||||
data: { name: 'test.txt', type: 'file', status: 'uploaded' },
|
||||
})
|
||||
|
||||
vi.spyOn(gotenbergService, 'isAvailable').mockResolvedValue(false)
|
||||
const generatePdfFromTextSpy = vi
|
||||
.spyOn(transcodeService, 'generatePdfFromText')
|
||||
.mockImplementation(async (_inPath, outPath) => {
|
||||
@@ -270,6 +338,7 @@ describe('Transcode Activities', () => {
|
||||
data: { name: 'README.md', type: 'file', status: 'uploaded' },
|
||||
})
|
||||
|
||||
vi.spyOn(gotenbergService, 'isAvailable').mockResolvedValue(false)
|
||||
const generatePdfFromTextSpy = vi
|
||||
.spyOn(transcodeService, 'generatePdfFromText')
|
||||
.mockImplementation(async (_inPath, outPath) => {
|
||||
@@ -293,6 +362,188 @@ describe('Transcode Activities', () => {
|
||||
generatePdfFromTextSpy.mockRestore()
|
||||
})
|
||||
|
||||
it('should convert markdown document via Gotenberg Chromium in generatePdfProxyActivity when available', async () => {
|
||||
const asset = await prisma.asset.create({
|
||||
data: { name: 'README.md', type: 'file', status: 'uploaded' },
|
||||
})
|
||||
|
||||
vi.spyOn(gotenbergService, 'isAvailable').mockResolvedValue(true)
|
||||
const convertMdSpy = vi
|
||||
.spyOn(gotenbergService, 'convertMarkdownToPdf')
|
||||
.mockResolvedValue(Buffer.from('fake pdf from gotenberg markdown'))
|
||||
|
||||
const res = await generatePdfProxyActivity({
|
||||
assetId: asset.id,
|
||||
assetKey: 'files/asset1/README.md',
|
||||
filePath: '/tmp/README.md',
|
||||
mediaType: 'text/markdown',
|
||||
filename: 'README.md',
|
||||
})
|
||||
|
||||
expect(res.pdfProxyKey).toBe(`files/${asset.id}/proxy.pdf`)
|
||||
expect(convertMdSpy).toHaveBeenCalledWith('/tmp/README.md', 'README.md')
|
||||
})
|
||||
|
||||
it('should convert office document via Gotenberg in generatePdfProxyActivity when available', async () => {
|
||||
const asset = await prisma.asset.create({
|
||||
data: { name: 'document.docx', type: 'file', status: 'uploaded' },
|
||||
})
|
||||
|
||||
vi.spyOn(gotenbergService, 'isAvailable').mockResolvedValue(true)
|
||||
const convertSpy = vi
|
||||
.spyOn(gotenbergService, 'convertDocumentToPdf')
|
||||
.mockResolvedValue(Buffer.from('fake pdf from gotenberg office'))
|
||||
|
||||
const res = await generatePdfProxyActivity({
|
||||
assetId: asset.id,
|
||||
assetKey: 'files/asset1/document.docx',
|
||||
filePath: '/tmp/document.docx',
|
||||
mediaType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
filename: 'document.docx',
|
||||
})
|
||||
|
||||
expect(res.pdfProxyKey).toBe(`files/${asset.id}/proxy.pdf`)
|
||||
expect(convertSpy).toHaveBeenCalledWith('/tmp/document.docx', 'document.docx')
|
||||
})
|
||||
|
||||
it('should convert html document via Gotenberg Chromium in generatePdfProxyActivity when available', async () => {
|
||||
const asset = await prisma.asset.create({
|
||||
data: { name: 'index.html', type: 'file', status: 'uploaded' },
|
||||
})
|
||||
|
||||
vi.spyOn(gotenbergService, 'isAvailable').mockResolvedValue(true)
|
||||
const convertHtmlSpy = vi
|
||||
.spyOn(gotenbergService, 'convertHtmlToPdf')
|
||||
.mockResolvedValue(Buffer.from('fake pdf from gotenberg html'))
|
||||
|
||||
const res = await generatePdfProxyActivity({
|
||||
assetId: asset.id,
|
||||
assetKey: 'files/asset1/index.html',
|
||||
filePath: '/tmp/index.html',
|
||||
mediaType: 'text/html',
|
||||
filename: 'index.html',
|
||||
})
|
||||
|
||||
expect(res.pdfProxyKey).toBe(`files/${asset.id}/proxy.pdf`)
|
||||
expect(convertHtmlSpy).toHaveBeenCalledWith('/tmp/index.html', 'index.html')
|
||||
})
|
||||
|
||||
it('should throw ApplicationFailure when Office document conversion is attempted but Gotenberg is unavailable', async () => {
|
||||
const asset = await prisma.asset.create({
|
||||
data: { name: 'sheet.xlsx', type: 'file', status: 'uploaded' },
|
||||
})
|
||||
|
||||
vi.spyOn(gotenbergService, 'isAvailable').mockResolvedValue(false)
|
||||
|
||||
await expect(
|
||||
generatePdfProxyActivity({
|
||||
assetId: asset.id,
|
||||
assetKey: 'files/asset1/sheet.xlsx',
|
||||
filePath: '/tmp/sheet.xlsx',
|
||||
mediaType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
filename: 'sheet.xlsx',
|
||||
}),
|
||||
).rejects.toThrow('Gotenberg service is required for Office document conversion')
|
||||
})
|
||||
|
||||
it('should throw ApplicationFailure when HTML document conversion is attempted but Gotenberg is unavailable', async () => {
|
||||
const asset = await prisma.asset.create({
|
||||
data: { name: 'index.html', type: 'file', status: 'uploaded' },
|
||||
})
|
||||
|
||||
vi.spyOn(gotenbergService, 'isAvailable').mockResolvedValue(false)
|
||||
|
||||
await expect(
|
||||
generatePdfProxyActivity({
|
||||
assetId: asset.id,
|
||||
assetKey: 'files/asset1/index.html',
|
||||
filePath: '/tmp/index.html',
|
||||
mediaType: 'text/html',
|
||||
filename: 'index.html',
|
||||
}),
|
||||
).rejects.toThrow('Gotenberg service is required for HTML document conversion')
|
||||
})
|
||||
|
||||
it('should fallback to transcodeService.generatePdfFromCsv for CSV when Gotenberg is unavailable', async () => {
|
||||
const asset = await prisma.asset.create({
|
||||
data: { name: 'data.csv', type: 'file', status: 'uploaded' },
|
||||
})
|
||||
|
||||
vi.spyOn(gotenbergService, 'isAvailable').mockResolvedValue(false)
|
||||
const generatePdfFromCsvSpy = vi
|
||||
.spyOn(transcodeService, 'generatePdfFromCsv')
|
||||
.mockImplementation(async (_inPath, outPath) => {
|
||||
const fs = await import('fs')
|
||||
fs.writeFileSync(outPath, 'fake pdf from csv fallback')
|
||||
})
|
||||
|
||||
const res = await generatePdfProxyActivity({
|
||||
assetId: asset.id,
|
||||
assetKey: 'files/asset1/data.csv',
|
||||
filePath: '/tmp/data.csv',
|
||||
mediaType: 'text/csv',
|
||||
filename: 'data.csv',
|
||||
})
|
||||
|
||||
expect(res.pdfProxyKey).toBe(`files/${asset.id}/proxy.pdf`)
|
||||
expect(generatePdfFromCsvSpy).toHaveBeenCalledWith(
|
||||
'/tmp/data.csv',
|
||||
expect.stringContaining('proxy.pdf'),
|
||||
)
|
||||
generatePdfFromCsvSpy.mockRestore()
|
||||
})
|
||||
|
||||
it('should convert TXT document via Gotenberg when available', async () => {
|
||||
const asset = await prisma.asset.create({
|
||||
data: { name: 'notes.txt', type: 'file', status: 'uploaded' },
|
||||
})
|
||||
|
||||
vi.spyOn(gotenbergService, 'isAvailable').mockResolvedValue(true)
|
||||
const convertSpy = vi
|
||||
.spyOn(gotenbergService, 'convertDocumentToPdf')
|
||||
.mockResolvedValue(Buffer.from('fake pdf from txt gotenberg'))
|
||||
|
||||
const res = await generatePdfProxyActivity({
|
||||
assetId: asset.id,
|
||||
assetKey: 'files/asset1/notes.txt',
|
||||
filePath: '/tmp/notes.txt',
|
||||
mediaType: 'text/plain',
|
||||
filename: 'notes.txt',
|
||||
})
|
||||
|
||||
expect(res.pdfProxyKey).toBe(`files/${asset.id}/proxy.pdf`)
|
||||
expect(convertSpy).toHaveBeenCalledWith('/tmp/notes.txt', 'notes.txt')
|
||||
})
|
||||
|
||||
it('should fallback to transcodeService.generatePdfFromText for TXT when Gotenberg is unavailable', async () => {
|
||||
const asset = await prisma.asset.create({
|
||||
data: { name: 'notes.txt', type: 'file', status: 'uploaded' },
|
||||
})
|
||||
|
||||
vi.spyOn(gotenbergService, 'isAvailable').mockResolvedValue(false)
|
||||
const generatePdfFromTextSpy = vi
|
||||
.spyOn(transcodeService, 'generatePdfFromText')
|
||||
.mockImplementation(async (_inPath, outPath) => {
|
||||
const fs = await import('fs')
|
||||
fs.writeFileSync(outPath, 'fake pdf from txt fallback')
|
||||
})
|
||||
|
||||
const res = await generatePdfProxyActivity({
|
||||
assetId: asset.id,
|
||||
assetKey: 'files/asset1/notes.txt',
|
||||
filePath: '/tmp/notes.txt',
|
||||
mediaType: 'text/plain',
|
||||
filename: 'notes.txt',
|
||||
})
|
||||
|
||||
expect(res.pdfProxyKey).toBe(`files/${asset.id}/proxy.pdf`)
|
||||
expect(generatePdfFromTextSpy).toHaveBeenCalledWith(
|
||||
'/tmp/notes.txt',
|
||||
expect.stringContaining('proxy.pdf'),
|
||||
)
|
||||
generatePdfFromTextSpy.mockRestore()
|
||||
})
|
||||
|
||||
it('should set file_type to file for unknown types', async () => {
|
||||
const asset = await prisma.asset.create({
|
||||
data: { name: 'u.xyz', type: 'file', status: 'uploaded' },
|
||||
|
||||
@@ -3,7 +3,15 @@ import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { transcodeService } from '@shumai/core/src/transcode/transcode'
|
||||
import { metadataService } from '@shumai/core/src/metadata/metadata'
|
||||
import { stemFromKey } from '@shumai/core/src/utils/filename'
|
||||
import { getProxyType } from '@shumai/core/src/utils/mime'
|
||||
import { gotenbergService } from '@shumai/core/src/gotenberg/gotenberg'
|
||||
import { parseCsvContent } from '@shumai/core/src/transcode/transcode'
|
||||
import {
|
||||
getProxyType,
|
||||
isCsvDocument,
|
||||
isHtmlDocument,
|
||||
isMarkdownDocument,
|
||||
isOfficeDocument,
|
||||
} from '@shumai/core/src/utils/mime'
|
||||
import { ApplicationFailure } from '@temporalio/activity'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
@@ -75,7 +83,6 @@ export async function getMediaInfoActivity(params: {
|
||||
metadata: null,
|
||||
original: {
|
||||
key: '', // Will be filled by caller or updated later
|
||||
downloadUrl: '',
|
||||
filesizeInBytes: 0,
|
||||
codec: '',
|
||||
},
|
||||
@@ -378,6 +385,10 @@ export async function transcodeImageActivity(
|
||||
outputFile,
|
||||
params.imageSpec.width,
|
||||
params.imageSpec.quality,
|
||||
{
|
||||
height: params.imageSpec.height || null,
|
||||
isPreview: params.imageSpec.isPreview ?? false,
|
||||
},
|
||||
)
|
||||
const buffer = fs.readFileSync(outputFile)
|
||||
await s3Service.putObject(bucket, key, buffer, buffer.length, 'image/webp')
|
||||
@@ -508,16 +519,13 @@ export interface GeneratePdfProxyActivityParams {
|
||||
export async function generatePdfProxyActivity(
|
||||
params: GeneratePdfProxyActivityParams,
|
||||
): Promise<{ pdfProxyKey: string; pdfFilePath: string }> {
|
||||
const isTxt =
|
||||
params.mediaType === 'text/plain' ||
|
||||
params.mediaType === 'text/markdown' ||
|
||||
params.mediaType === 'text/x-markdown' ||
|
||||
params.filename.toLowerCase().endsWith('.txt') ||
|
||||
params.filename.toLowerCase().endsWith('.md') ||
|
||||
params.filename.toLowerCase().endsWith('.markdown')
|
||||
const isCsv = params.mediaType === 'text/csv' || params.filename.toLowerCase().endsWith('.csv')
|
||||
const isOffice = isOfficeDocument(params.mediaType, params.filename)
|
||||
const isHtml = isHtmlDocument(params.mediaType, params.filename)
|
||||
const isMd = isMarkdownDocument(params.mediaType, params.filename)
|
||||
const isCsv = isCsvDocument(params.mediaType, params.filename)
|
||||
const isTxt = params.mediaType === 'text/plain' || params.filename.toLowerCase().endsWith('.txt')
|
||||
|
||||
if (!isTxt && !isCsv) {
|
||||
if (!isOffice && !isHtml && !isMd && !isCsv && !isTxt) {
|
||||
return { pdfProxyKey: params.assetKey, pdfFilePath: params.filePath }
|
||||
}
|
||||
|
||||
@@ -527,10 +535,67 @@ export async function generatePdfProxyActivity(
|
||||
const pdfFilePath = path.join(tmpDir, 'proxy.pdf')
|
||||
|
||||
try {
|
||||
if (isCsv) {
|
||||
await transcodeService.generatePdfFromCsv(params.filePath, pdfFilePath)
|
||||
} else {
|
||||
await transcodeService.generatePdfFromText(params.filePath, pdfFilePath)
|
||||
const gotenbergAvailable = await gotenbergService.isAvailable()
|
||||
|
||||
if (isOffice) {
|
||||
if (!gotenbergAvailable) {
|
||||
throw new Error(
|
||||
'Gotenberg service is required for Office document conversion but is unavailable.',
|
||||
)
|
||||
}
|
||||
const pdfBuffer = await gotenbergService.convertDocumentToPdf(
|
||||
params.filePath,
|
||||
params.filename,
|
||||
)
|
||||
fs.writeFileSync(pdfFilePath, pdfBuffer)
|
||||
} else if (isHtml) {
|
||||
if (!gotenbergAvailable) {
|
||||
throw new Error(
|
||||
'Gotenberg service is required for HTML document conversion but is unavailable.',
|
||||
)
|
||||
}
|
||||
const pdfBuffer = await gotenbergService.convertHtmlToPdf(params.filePath, params.filename)
|
||||
fs.writeFileSync(pdfFilePath, pdfBuffer)
|
||||
} else if (isCsv) {
|
||||
if (gotenbergAvailable) {
|
||||
let isLandscape = false
|
||||
try {
|
||||
const content = String(fs.readFileSync(params.filePath, 'utf-8'))
|
||||
const rows = parseCsvContent(content)
|
||||
const maxCols = Math.max(...rows.map((r) => r.length), 0)
|
||||
isLandscape = maxCols > 5
|
||||
} catch {
|
||||
// Fallback landscape calculation
|
||||
}
|
||||
const pdfBuffer = await gotenbergService.convertDocumentToPdf(
|
||||
params.filePath,
|
||||
params.filename,
|
||||
{ landscape: isLandscape },
|
||||
)
|
||||
fs.writeFileSync(pdfFilePath, pdfBuffer)
|
||||
} else {
|
||||
await transcodeService.generatePdfFromCsv(params.filePath, pdfFilePath)
|
||||
}
|
||||
} else if (isMd) {
|
||||
if (gotenbergAvailable) {
|
||||
const pdfBuffer = await gotenbergService.convertMarkdownToPdf(
|
||||
params.filePath,
|
||||
params.filename,
|
||||
)
|
||||
fs.writeFileSync(pdfFilePath, pdfBuffer)
|
||||
} else {
|
||||
await transcodeService.generatePdfFromText(params.filePath, pdfFilePath)
|
||||
}
|
||||
} else if (isTxt) {
|
||||
if (gotenbergAvailable) {
|
||||
const pdfBuffer = await gotenbergService.convertDocumentToPdf(
|
||||
params.filePath,
|
||||
params.filename,
|
||||
)
|
||||
fs.writeFileSync(pdfFilePath, pdfBuffer)
|
||||
} else {
|
||||
await transcodeService.generatePdfFromText(params.filePath, pdfFilePath)
|
||||
}
|
||||
}
|
||||
|
||||
const stat = fs.statSync(pdfFilePath)
|
||||
@@ -541,7 +606,7 @@ export async function generatePdfProxyActivity(
|
||||
} catch (err) {
|
||||
const { message } = getErrorDetails(err)
|
||||
throw ApplicationFailure.create({
|
||||
message: `Failed to generate PDF proxy for text/csv/markdown: ${message}`,
|
||||
message: `Failed to generate PDF proxy: ${message}`,
|
||||
nonRetryable: true,
|
||||
cause: err instanceof Error ? err : undefined,
|
||||
})
|
||||
|
||||
@@ -0,0 +1,402 @@
|
||||
import { prisma, WatermarkFileStatus } from '@shumai/db'
|
||||
import '@shumai/db/src/prisma-json-types'
|
||||
import { setupTestDbHooks } from '@shumai/db/test'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { transcodeService } from '@shumai/core/src/transcode/transcode'
|
||||
import {
|
||||
initWatermarkFileActivity,
|
||||
waitForWatermarkFileActivity,
|
||||
transcodeWatermarkMediaActivity,
|
||||
completeWatermarkFileActivity,
|
||||
} from './watermark'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
vi.mock('child_process', () => ({
|
||||
execFile: vi.fn(
|
||||
(_cmd: string, args: string[], cb: (err: unknown, stdout: string, stderr: string) => void) => {
|
||||
const outFile = args[args.length - 1]
|
||||
if (outFile && typeof outFile === 'string') {
|
||||
try {
|
||||
fs.writeFileSync(outFile, 'fake-transcoded-output')
|
||||
} catch {
|
||||
// ignore directory creation errors in mock
|
||||
}
|
||||
}
|
||||
cb(null, '', '')
|
||||
},
|
||||
),
|
||||
}))
|
||||
|
||||
vi.mock('@shumai/core/src/s3/s3', () => ({
|
||||
s3Service: {
|
||||
getObject: vi.fn(),
|
||||
putObject: vi.fn(),
|
||||
presign: vi.fn(),
|
||||
downloadToFile: vi.fn().mockImplementation(async (_b, _k, dest) => {
|
||||
fs.writeFileSync(dest, 'fake-raw')
|
||||
}),
|
||||
downloadMediaToTmp: vi.fn().mockImplementation(async () => ({
|
||||
filePath: '/tmp/raw-file',
|
||||
tmpDir: '/tmp',
|
||||
})),
|
||||
deleteObject: vi.fn(),
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('@shumai/core/src/transcode/transcode', () => ({
|
||||
transcodeService: {
|
||||
getVideoInfo: vi.fn(),
|
||||
getImageInfo: vi.fn(),
|
||||
createTempDir: vi.fn().mockReturnValue('/tmp'),
|
||||
removeDir: vi.fn(),
|
||||
renderSvgToPng: vi.fn().mockResolvedValue(Buffer.from('fake-overlay-png')),
|
||||
downscaleImageToPng: vi.fn().mockResolvedValue({
|
||||
buffer: Buffer.from('fake-block-png'),
|
||||
width: 32,
|
||||
height: 32,
|
||||
}),
|
||||
compositeOverlayToWebpFile: vi.fn().mockImplementation(async (_in, _overlay, out) => {
|
||||
fs.writeFileSync(out, 'fake-webp')
|
||||
}),
|
||||
transcodeVideo: vi.fn().mockImplementation(async (params) => {
|
||||
fs.writeFileSync(params.outputFile, 'fake-mp4')
|
||||
}),
|
||||
},
|
||||
}))
|
||||
|
||||
describe('Watermark Activities', () => {
|
||||
setupTestDbHooks()
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
describe('initWatermarkFileActivity', () => {
|
||||
async function seedAssetAndConfig() {
|
||||
const asset = await prisma.asset.create({
|
||||
data: { name: 'wm-target.png', type: 'file', status: 'processed' },
|
||||
})
|
||||
const config = await prisma.watermarkConfig.create({
|
||||
data: {
|
||||
hash: 'init-hash-' + Math.random(),
|
||||
config: { blocks: [] },
|
||||
},
|
||||
})
|
||||
return { asset, config }
|
||||
}
|
||||
|
||||
it('creates a processing row when none exists', async () => {
|
||||
const { asset, config } = await seedAssetAndConfig()
|
||||
const res = await initWatermarkFileActivity({
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: config.id,
|
||||
})
|
||||
expect(res.action).toBe('created')
|
||||
const row = await prisma.watermarkFile.findUnique({
|
||||
where: {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
assetId_watermarkConfigId: {
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: config.id,
|
||||
},
|
||||
},
|
||||
})
|
||||
expect(row?.status).toBe(WatermarkFileStatus.processing)
|
||||
})
|
||||
|
||||
it('returns completed action when a completed watermark file exists', async () => {
|
||||
const { asset, config } = await seedAssetAndConfig()
|
||||
await prisma.watermarkFile.create({
|
||||
data: {
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: config.id,
|
||||
status: WatermarkFileStatus.completed,
|
||||
},
|
||||
})
|
||||
const res = await initWatermarkFileActivity({
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: config.id,
|
||||
})
|
||||
expect(res.action).toBe('completed')
|
||||
})
|
||||
|
||||
it('returns processing action when a processing row exists', async () => {
|
||||
const { asset, config } = await seedAssetAndConfig()
|
||||
await prisma.watermarkFile.create({
|
||||
data: {
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: config.id,
|
||||
status: WatermarkFileStatus.processing,
|
||||
},
|
||||
})
|
||||
const res = await initWatermarkFileActivity({
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: config.id,
|
||||
})
|
||||
expect(res.action).toBe('processing')
|
||||
})
|
||||
|
||||
it('returns failed action when a failed row exists', async () => {
|
||||
const { asset, config } = await seedAssetAndConfig()
|
||||
await prisma.watermarkFile.create({
|
||||
data: {
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: config.id,
|
||||
status: WatermarkFileStatus.failed,
|
||||
},
|
||||
})
|
||||
const res = await initWatermarkFileActivity({
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: config.id,
|
||||
})
|
||||
expect(res.action).toBe('failed')
|
||||
})
|
||||
|
||||
it('waits for watermark file completion in waitForWatermarkFileActivity', async () => {
|
||||
const { asset, config } = await seedAssetAndConfig()
|
||||
const wf = await prisma.watermarkFile.create({
|
||||
data: {
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: config.id,
|
||||
status: WatermarkFileStatus.processing,
|
||||
},
|
||||
})
|
||||
|
||||
setTimeout(async () => {
|
||||
await prisma.watermarkFile.update({
|
||||
where: { id: wf.id },
|
||||
data: { status: WatermarkFileStatus.completed },
|
||||
})
|
||||
}, 50)
|
||||
|
||||
const res = await waitForWatermarkFileActivity({
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: config.id,
|
||||
})
|
||||
expect(res.status).toBe(WatermarkFileStatus.completed)
|
||||
})
|
||||
})
|
||||
|
||||
describe('transcodeWatermarkMediaActivity', () => {
|
||||
const bucket = process.env.S3_BUCKET || 'shumai'
|
||||
|
||||
async function seedAsset(name: string, mediaType: string, key: string, proxyType: string) {
|
||||
const storageKey = await prisma.storageKey.create({ data: { key } })
|
||||
return prisma.asset.create({
|
||||
data: {
|
||||
name,
|
||||
type: 'file',
|
||||
mediaType,
|
||||
status: 'processed',
|
||||
storageKeyId: storageKey.id,
|
||||
media: {
|
||||
duration: 0,
|
||||
filesize: 0,
|
||||
frames: 0,
|
||||
proxyType,
|
||||
videoTranscodes: [{ key, width: 100, height: 100, resolution: '100p' }],
|
||||
imageTranscodes: [{ key, width: 100, height: 100, quality: 90, format: 'webp' }],
|
||||
videoPreview: { width: 100, height: 100 },
|
||||
finishedAt: new Date().toISOString(),
|
||||
metadata: {
|
||||
originalWidth: 100,
|
||||
originalHeight: 100,
|
||||
duration: 0,
|
||||
bitRate: 0,
|
||||
frameRate: 0,
|
||||
totalFrames: 0,
|
||||
startTimecode: '00:00:00:00',
|
||||
hasAudio: false,
|
||||
format: {},
|
||||
},
|
||||
original: {
|
||||
key,
|
||||
filesizeInBytes: 0,
|
||||
codec: '',
|
||||
},
|
||||
} as PrismaJson.MediaInfo,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
async function seedConfig() {
|
||||
return prisma.watermarkConfig.create({
|
||||
data: {
|
||||
config: {
|
||||
blocks: [
|
||||
{
|
||||
id: 'b1',
|
||||
type: 'text',
|
||||
x: 0.5,
|
||||
y: 0.5,
|
||||
opacity: 0.5,
|
||||
rotation: 0,
|
||||
text: 'TEST WM',
|
||||
size: 0.2,
|
||||
color: '#FF0000',
|
||||
},
|
||||
],
|
||||
},
|
||||
hash: 'test-hash-' + Math.random(),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
it('produces a watermarked webp proxy for an image asset', async () => {
|
||||
const assetKey = 'files/e2e-wm/test.png'
|
||||
const asset = await seedAsset('test.png', 'image/png', assetKey, 'image')
|
||||
const config = await seedConfig()
|
||||
|
||||
vi.mocked(transcodeService.getImageInfo).mockResolvedValue({
|
||||
originalWidth: 100,
|
||||
originalHeight: 100,
|
||||
duration: 0,
|
||||
bitRate: 0,
|
||||
frameRate: 0,
|
||||
totalFrames: 0,
|
||||
hasAudio: false,
|
||||
mimeType: 'image/png',
|
||||
})
|
||||
vi.mocked(s3Service.putObject).mockResolvedValue(undefined as never)
|
||||
|
||||
// compositeOverlayToWebpFile is mocked, but the activity stats the output
|
||||
// file afterwards, so pre-create it at the expected path.
|
||||
const outFileName = `test-watermark-${config.id}-100x100.webp`
|
||||
const outFilePath = path.join('/tmp', outFileName)
|
||||
fs.writeFileSync(outFilePath, Buffer.from('fake webp'))
|
||||
|
||||
const media = await transcodeWatermarkMediaActivity({
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: config.id,
|
||||
})
|
||||
|
||||
expect(media.proxyType).toBe('image')
|
||||
expect(media.imageTranscodes?.length).toBeGreaterThan(0)
|
||||
expect(media.imageTranscodes?.[0].key).toContain('watermark-')
|
||||
expect(transcodeService.renderSvgToPng).toHaveBeenCalled()
|
||||
expect(transcodeService.compositeOverlayToWebpFile).toHaveBeenCalledWith(
|
||||
expect.stringContaining('test.png'),
|
||||
Buffer.from('fake-overlay-png'),
|
||||
outFilePath,
|
||||
100,
|
||||
100,
|
||||
)
|
||||
expect(s3Service.putObject).toHaveBeenCalledWith(
|
||||
bucket,
|
||||
expect.stringContaining('watermark-'),
|
||||
expect.anything(),
|
||||
expect.any(Number),
|
||||
'image/webp',
|
||||
)
|
||||
|
||||
fs.rmSync(outFilePath, { force: true })
|
||||
})
|
||||
|
||||
it('produces a watermarked mp4 proxy for a video asset (ffmpeg path)', async () => {
|
||||
const assetKey = 'files/e2e-wm/video.mp4'
|
||||
const asset = await seedAsset('video.mp4', 'video/mp4', assetKey, 'video')
|
||||
const config = await seedConfig()
|
||||
|
||||
vi.mocked(transcodeService.getVideoInfo).mockResolvedValue({
|
||||
originalWidth: 1920,
|
||||
originalHeight: 1080,
|
||||
duration: 10,
|
||||
bitRate: 1000,
|
||||
frameRate: 30,
|
||||
totalFrames: 300,
|
||||
startTimecode: '00:00:00:00',
|
||||
hasAudio: true,
|
||||
mimeType: 'video/mp4',
|
||||
})
|
||||
vi.mocked(s3Service.putObject).mockResolvedValue(undefined as never)
|
||||
|
||||
// The ffmpeg execFile call is mocked, but the activity stats the output
|
||||
// file afterwards, so pre-create it at the expected path.
|
||||
const stem = 'video'
|
||||
const configId = config.id
|
||||
const outFilePath = path.join('/tmp', `${stem}-watermark-${configId}-100p.mp4`)
|
||||
fs.writeFileSync(outFilePath, Buffer.from('fake mp4'))
|
||||
|
||||
const media = await transcodeWatermarkMediaActivity({
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: config.id,
|
||||
})
|
||||
|
||||
expect(media.proxyType).toBe('video')
|
||||
expect(media.videoTranscodes?.length).toBeGreaterThan(0)
|
||||
expect(media.videoTranscodes?.[0].key).toContain('watermark-')
|
||||
expect(s3Service.putObject).toHaveBeenCalledWith(
|
||||
bucket,
|
||||
expect.stringContaining('watermark-'),
|
||||
expect.anything(),
|
||||
expect.any(Number),
|
||||
'video/mp4',
|
||||
)
|
||||
|
||||
fs.rmSync(outFilePath, { force: true })
|
||||
})
|
||||
})
|
||||
|
||||
describe('completeWatermarkFileActivity', () => {
|
||||
it('upserts a completed watermark file with media', async () => {
|
||||
const asset = await prisma.asset.create({
|
||||
data: { name: 'wm-complete.png', type: 'file', status: 'processed' },
|
||||
})
|
||||
const config = await prisma.watermarkConfig.create({
|
||||
data: {
|
||||
hash: 'complete-hash-' + Math.random(),
|
||||
config: { blocks: [] },
|
||||
},
|
||||
})
|
||||
const media: PrismaJson.MediaInfo = {
|
||||
duration: 0,
|
||||
filesize: 0,
|
||||
frames: 0,
|
||||
proxyType: 'image',
|
||||
imageTranscodes: [
|
||||
{ key: 'files/x/out.webp', width: 100, height: 100, quality: 90, format: 'webp' },
|
||||
],
|
||||
videoTranscodes: [],
|
||||
videoPreview: { width: 100, height: 100 },
|
||||
finishedAt: new Date().toISOString(),
|
||||
metadata: {
|
||||
originalWidth: 100,
|
||||
originalHeight: 100,
|
||||
duration: 0,
|
||||
bitRate: 0,
|
||||
frameRate: 0,
|
||||
totalFrames: 0,
|
||||
startTimecode: '00:00:00:00',
|
||||
hasAudio: false,
|
||||
format: {},
|
||||
},
|
||||
original: {
|
||||
key: 'files/x/original.png',
|
||||
filesizeInBytes: 0,
|
||||
codec: '',
|
||||
},
|
||||
}
|
||||
|
||||
await completeWatermarkFileActivity({
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: config.id,
|
||||
mediaInfo: media,
|
||||
status: WatermarkFileStatus.completed,
|
||||
})
|
||||
|
||||
const row = await prisma.watermarkFile.findUnique({
|
||||
where: {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
assetId_watermarkConfigId: {
|
||||
assetId: asset.id,
|
||||
watermarkConfigId: config.id,
|
||||
},
|
||||
},
|
||||
})
|
||||
expect(row?.status).toBe(WatermarkFileStatus.completed)
|
||||
expect(row?.media).toBeDefined()
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,395 @@
|
||||
import { prisma, WatermarkFileStatus } from '@shumai/db'
|
||||
import '@shumai/db/src/prisma-json-types'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { transcodeService } from '@shumai/core/src/transcode/transcode'
|
||||
import {
|
||||
generateWatermarkSvg,
|
||||
RenderBlockImageData,
|
||||
} from '@shumai/core/src/watermark/watermark-svg'
|
||||
import { watermarkService } from '@shumai/core/src/watermark/watermark'
|
||||
import { logger } from '@shumai/core/src/logger'
|
||||
import { stemFromKey } from '@shumai/core/src/utils/filename'
|
||||
import { ApplicationFailure } from '@temporalio/activity'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
import { ulid } from 'ulid'
|
||||
import type { WatermarkConfigSpec, WatermarkBlockImage } from '@shumai/dtos'
|
||||
|
||||
// Max dimension for watermark block images embedded into the SVG overlay.
|
||||
// Bounding this keeps the SVG (and its base64 payload) small for large logos.
|
||||
const MAX_BLOCK_IMAGE_DIMENSION = 1024
|
||||
|
||||
export interface InitWatermarkFileParams {
|
||||
assetId: string
|
||||
watermarkConfigId: string
|
||||
}
|
||||
|
||||
export type InitWatermarkFileAction = 'created' | 'completed' | 'processing' | 'failed'
|
||||
|
||||
export interface InitWatermarkFileResult {
|
||||
action: InitWatermarkFileAction
|
||||
media?: PrismaJson.MediaInfo | null
|
||||
}
|
||||
|
||||
export async function initWatermarkFileActivity(
|
||||
params: InitWatermarkFileParams,
|
||||
): Promise<InitWatermarkFileResult> {
|
||||
return await prisma.$transaction(async (tx) => {
|
||||
const rows = await tx.$queryRaw<
|
||||
Array<{
|
||||
id: string
|
||||
status: WatermarkFileStatus
|
||||
media: PrismaJson.MediaInfo | null
|
||||
}>
|
||||
>`
|
||||
SELECT id, status, media
|
||||
FROM watermark_files
|
||||
WHERE asset_id = ${params.assetId}
|
||||
AND watermark_config_id = ${params.watermarkConfigId}
|
||||
FOR UPDATE
|
||||
`
|
||||
|
||||
if (rows.length > 0) {
|
||||
const existing = rows[0]
|
||||
if (existing.status === WatermarkFileStatus.completed) {
|
||||
return { action: 'completed', media: existing.media }
|
||||
}
|
||||
if (existing.status === WatermarkFileStatus.failed) {
|
||||
return { action: 'failed' }
|
||||
}
|
||||
return { action: 'processing' }
|
||||
}
|
||||
|
||||
await tx.watermarkFile.create({
|
||||
data: {
|
||||
assetId: params.assetId,
|
||||
watermarkConfigId: params.watermarkConfigId,
|
||||
status: WatermarkFileStatus.processing,
|
||||
},
|
||||
})
|
||||
|
||||
return { action: 'created' }
|
||||
})
|
||||
}
|
||||
|
||||
export interface WaitForWatermarkFileParams {
|
||||
assetId: string
|
||||
watermarkConfigId: string
|
||||
}
|
||||
|
||||
export interface WaitForWatermarkFileResult {
|
||||
status: WatermarkFileStatus
|
||||
media?: PrismaJson.MediaInfo | null
|
||||
}
|
||||
|
||||
export async function waitForWatermarkFileActivity(
|
||||
params: WaitForWatermarkFileParams,
|
||||
): Promise<WaitForWatermarkFileResult> {
|
||||
const pollIntervalMs = 1000
|
||||
const maxWaitMs = 600000 // 10 minutes timeout
|
||||
|
||||
const startTime = Date.now()
|
||||
|
||||
while (Date.now() - startTime < maxWaitMs) {
|
||||
const wf = await prisma.watermarkFile.findUnique({
|
||||
where: {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
assetId_watermarkConfigId: {
|
||||
assetId: params.assetId,
|
||||
watermarkConfigId: params.watermarkConfigId,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
if (wf && wf.status !== WatermarkFileStatus.processing) {
|
||||
return { status: wf.status, media: wf.media }
|
||||
}
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs))
|
||||
}
|
||||
|
||||
return { status: WatermarkFileStatus.failed }
|
||||
}
|
||||
|
||||
export interface TranscodeWatermarkMediaParams {
|
||||
assetId: string
|
||||
watermarkConfigId: string
|
||||
}
|
||||
|
||||
export async function transcodeWatermarkMediaActivity(
|
||||
params: TranscodeWatermarkMediaParams,
|
||||
): Promise<PrismaJson.MediaInfo> {
|
||||
const bucket = process.env.S3_BUCKET || 'shumai'
|
||||
|
||||
const watermarkConfigRecord = await prisma.watermarkConfig.findUnique({
|
||||
where: { id: params.watermarkConfigId },
|
||||
})
|
||||
if (!watermarkConfigRecord) {
|
||||
throw ApplicationFailure.create({
|
||||
message: `Watermark config not found: ${params.watermarkConfigId}`,
|
||||
nonRetryable: true,
|
||||
})
|
||||
}
|
||||
|
||||
const asset = await prisma.asset.findUnique({
|
||||
where: { id: params.assetId },
|
||||
include: { storageKey: true },
|
||||
})
|
||||
|
||||
if (!asset || !asset.storageKey?.key) {
|
||||
throw ApplicationFailure.create({
|
||||
message: `Asset or storage key not found: ${params.assetId}`,
|
||||
nonRetryable: true,
|
||||
})
|
||||
}
|
||||
|
||||
// The config column is declared as PrismaJson.WatermarkConfigSpec, which is
|
||||
// structurally identical to the DTO type, so no cast is required.
|
||||
const config: WatermarkConfigSpec = watermarkConfigRecord.config
|
||||
const assetKey = asset.storageKey.key
|
||||
const stem = stemFromKey(assetKey)
|
||||
|
||||
const tmpDir = transcodeService.createTempDir('watermark-')
|
||||
const rawFilePath = path.join(tmpDir, path.basename(assetKey))
|
||||
|
||||
try {
|
||||
await s3Service.downloadToFile(bucket, assetKey, rawFilePath)
|
||||
|
||||
const isVideo =
|
||||
asset.mediaType?.startsWith('video/') ||
|
||||
(asset.media as PrismaJson.MediaInfo | null)?.proxyType === 'video'
|
||||
const isImage =
|
||||
asset.mediaType?.startsWith('image/') ||
|
||||
(asset.media as PrismaJson.MediaInfo | null)?.proxyType === 'image'
|
||||
|
||||
let originalWidth = 1920
|
||||
let originalHeight = 1080
|
||||
let duration = 0
|
||||
let frameRate = 30
|
||||
let totalFrames = 0
|
||||
let startTimecode = '00:00:00:00'
|
||||
let hasAudio = false
|
||||
|
||||
if (isVideo) {
|
||||
const info = await transcodeService.getVideoInfo(rawFilePath)
|
||||
originalWidth = info.originalWidth
|
||||
originalHeight = info.originalHeight
|
||||
duration = info.duration
|
||||
frameRate = info.frameRate
|
||||
totalFrames = info.totalFrames
|
||||
startTimecode = info.startTimecode || '00:00:00:00'
|
||||
hasAudio = info.hasAudio
|
||||
} else if (isImage) {
|
||||
const info = await transcodeService.getImageInfo(rawFilePath)
|
||||
originalWidth = info.originalWidth
|
||||
originalHeight = info.originalHeight
|
||||
} else {
|
||||
throw ApplicationFailure.create({
|
||||
message: `Asset ${params.assetId} is neither video nor image`,
|
||||
nonRetryable: true,
|
||||
})
|
||||
}
|
||||
|
||||
// Process image blocks if any
|
||||
const blockImagesMap = new Map<string, RenderBlockImageData>()
|
||||
const imageBlocks = (config.blocks || []).filter(
|
||||
(b) => b.type === 'image',
|
||||
) as WatermarkBlockImage[]
|
||||
|
||||
for (const imgBlock of imageBlocks) {
|
||||
if (!imgBlock.imageAssetKey) continue
|
||||
try {
|
||||
const imgTmpPath = path.join(tmpDir, `block-${ulid()}`)
|
||||
await s3Service.downloadToFile(bucket, imgBlock.imageAssetKey, imgTmpPath)
|
||||
const buffer = fs.readFileSync(imgTmpPath)
|
||||
// Downscale to a bounded size and normalize to PNG so large logo assets
|
||||
// don't balloon the SVG/base64 payload.
|
||||
const processed = await transcodeService.downscaleImageToPng(
|
||||
buffer,
|
||||
MAX_BLOCK_IMAGE_DIMENSION,
|
||||
)
|
||||
blockImagesMap.set(imgBlock.imageAssetKey, {
|
||||
imageAssetKey: imgBlock.imageAssetKey,
|
||||
base64Data: processed.buffer.toString('base64'),
|
||||
mimeType: 'image/png',
|
||||
width: processed.width,
|
||||
height: processed.height,
|
||||
})
|
||||
} catch (err) {
|
||||
logger.warn(
|
||||
{ imageAssetKey: imgBlock.imageAssetKey, err },
|
||||
'Failed to load watermark block image',
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const originalMedia = asset.media as PrismaJson.MediaInfo | null
|
||||
|
||||
const mediaInfo: PrismaJson.MediaInfo = {
|
||||
duration,
|
||||
filesize: 0,
|
||||
frames: totalFrames,
|
||||
proxyType: isVideo ? 'video' : 'image',
|
||||
imageTranscodes: [],
|
||||
videoTranscodes: [],
|
||||
finishedAt: new Date().toISOString(),
|
||||
metadata: {
|
||||
originalWidth,
|
||||
originalHeight,
|
||||
duration,
|
||||
bitRate: 0,
|
||||
frameRate,
|
||||
totalFrames,
|
||||
startTimecode,
|
||||
hasAudio,
|
||||
format: {},
|
||||
},
|
||||
original: {
|
||||
key: assetKey,
|
||||
filesizeInBytes: 0,
|
||||
codec: '',
|
||||
},
|
||||
}
|
||||
|
||||
if (isImage) {
|
||||
const originalTranscodes = originalMedia?.imageTranscodes || []
|
||||
let totalSize = 0
|
||||
|
||||
for (let i = 0; i < originalTranscodes.length; i++) {
|
||||
const it = originalTranscodes[i]
|
||||
const targetWidth = it.width || originalWidth
|
||||
const targetHeight = it.height || originalHeight
|
||||
|
||||
const svgString = generateWatermarkSvg(config, targetWidth, targetHeight, blockImagesMap)
|
||||
const overlayPngBuffer = await transcodeService.renderSvgToPng(svgString)
|
||||
|
||||
const outFileName = `${stem}-watermark-${params.watermarkConfigId}-${targetWidth}x${targetHeight}.webp`
|
||||
const outFilePath = path.join(tmpDir, outFileName)
|
||||
|
||||
await transcodeService.compositeOverlayToWebpFile(
|
||||
rawFilePath,
|
||||
overlayPngBuffer,
|
||||
outFilePath,
|
||||
targetWidth,
|
||||
targetHeight,
|
||||
)
|
||||
|
||||
const stat = fs.statSync(outFilePath)
|
||||
totalSize += stat.size
|
||||
const outputKey = path.posix.join(path.posix.dirname(assetKey), outFileName)
|
||||
|
||||
await s3Service.putObject(
|
||||
bucket,
|
||||
outputKey,
|
||||
Bun.file(outFilePath).stream(),
|
||||
stat.size,
|
||||
'image/webp',
|
||||
)
|
||||
|
||||
mediaInfo.imageTranscodes.push({
|
||||
key: outputKey,
|
||||
width: targetWidth,
|
||||
height: targetHeight,
|
||||
quality: it.quality ?? 90,
|
||||
format: it.format ?? 'webp',
|
||||
})
|
||||
}
|
||||
mediaInfo.filesize = totalSize
|
||||
} else if (isVideo) {
|
||||
const originalTranscodes = originalMedia?.videoTranscodes || []
|
||||
let totalSize = 0
|
||||
|
||||
for (let i = 0; i < originalTranscodes.length; i++) {
|
||||
const vt = originalTranscodes[i]
|
||||
const targetWidth = vt.width || originalWidth
|
||||
const targetHeight = vt.height || originalHeight
|
||||
const resolution = vt.resolution || `${targetHeight}p`
|
||||
|
||||
const svgString = generateWatermarkSvg(config, targetWidth, targetHeight, blockImagesMap)
|
||||
const overlayPngBuffer = await transcodeService.renderSvgToPng(svgString)
|
||||
|
||||
const overlayPngPath = path.join(tmpDir, `watermarkOverlay-${i}.png`)
|
||||
fs.writeFileSync(overlayPngPath, overlayPngBuffer)
|
||||
|
||||
const outFileName = `${stem}-watermark-${params.watermarkConfigId}-${resolution}.mp4`
|
||||
const outFilePath = path.join(tmpDir, outFileName)
|
||||
|
||||
await transcodeService.transcodeVideo({
|
||||
inputFile: rawFilePath,
|
||||
outputFile: outFilePath,
|
||||
width: targetWidth,
|
||||
height: targetHeight,
|
||||
disableAudio: !hasAudio,
|
||||
overlayFile: overlayPngPath,
|
||||
})
|
||||
|
||||
const stat = fs.statSync(outFilePath)
|
||||
totalSize += stat.size
|
||||
const outputKey = path.posix.join(path.posix.dirname(assetKey), outFileName)
|
||||
|
||||
await s3Service.putObject(
|
||||
bucket,
|
||||
outputKey,
|
||||
Bun.file(outFilePath).stream(),
|
||||
stat.size,
|
||||
'video/mp4',
|
||||
)
|
||||
|
||||
mediaInfo.videoTranscodes.push({
|
||||
key: outputKey,
|
||||
width: targetWidth,
|
||||
height: targetHeight,
|
||||
resolution,
|
||||
})
|
||||
}
|
||||
mediaInfo.filesize = totalSize
|
||||
}
|
||||
|
||||
return mediaInfo
|
||||
} catch (err) {
|
||||
logger.error({ assetId: params.assetId, err }, 'Failed to generate watermark proxy')
|
||||
throw ApplicationFailure.create({
|
||||
message: `Failed to generate watermark proxy: ${err instanceof Error ? err.message : String(err)}`,
|
||||
nonRetryable: true,
|
||||
cause: err instanceof Error ? err : undefined,
|
||||
})
|
||||
} finally {
|
||||
transcodeService.removeDir(tmpDir)
|
||||
}
|
||||
}
|
||||
|
||||
export interface CompleteWatermarkFileParams {
|
||||
assetId: string
|
||||
watermarkConfigId: string
|
||||
mediaInfo?: PrismaJson.MediaInfo | null
|
||||
status: WatermarkFileStatus
|
||||
shareLinkId?: string | null
|
||||
}
|
||||
|
||||
export async function completeWatermarkFileActivity(
|
||||
params: CompleteWatermarkFileParams,
|
||||
): Promise<void> {
|
||||
await prisma.watermarkFile.upsert({
|
||||
where: {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
assetId_watermarkConfigId: {
|
||||
assetId: params.assetId,
|
||||
watermarkConfigId: params.watermarkConfigId,
|
||||
},
|
||||
},
|
||||
create: {
|
||||
assetId: params.assetId,
|
||||
watermarkConfigId: params.watermarkConfigId,
|
||||
media: params.mediaInfo ?? undefined,
|
||||
status: params.status,
|
||||
},
|
||||
update: {
|
||||
media: params.mediaInfo ?? undefined,
|
||||
status: params.status,
|
||||
},
|
||||
})
|
||||
|
||||
if (params.shareLinkId) {
|
||||
await watermarkService.checkAndUpdateShareLinkStatus(params.shareLinkId)
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
import { WorkflowTaskType } from '@shumai/db'
|
||||
import { registerActivities, registerWorkflow } from '@shumai/workflow-core'
|
||||
import * as transcodeActivities from './activities/transcode'
|
||||
import * as watermarkActivities from './activities/watermark'
|
||||
import { transcodeVideoWorkflow } from './workflows/transcode-video'
|
||||
import { transcodeImageWorkflow } from './workflows/transcode-image'
|
||||
import { transcodePdfWorkflow } from './workflows/transcode-pdf'
|
||||
import { renderPdfPagesWorkflow } from './workflows/render-pdf-pages'
|
||||
import { takeVideoScreenshotsWorkflow } from './workflows/take-video-screenshots'
|
||||
import { overlayImageAnnotationWorkflow } from './workflows/overlay-image-annotation'
|
||||
import { transcodeWatermarkWorkflow } from './workflows/transcode-watermark'
|
||||
import { transcodeMedia } from './workflows/transcode'
|
||||
|
||||
export function initTranscodeWorkflows() {
|
||||
@@ -17,9 +19,13 @@ export function initTranscodeWorkflows() {
|
||||
registerWorkflow(WorkflowTaskType.transcode_pdf_pages, renderPdfPagesWorkflow)
|
||||
registerWorkflow(WorkflowTaskType.transcode_screenshot, takeVideoScreenshotsWorkflow)
|
||||
registerWorkflow(WorkflowTaskType.transcode_image_annotation, overlayImageAnnotationWorkflow)
|
||||
registerWorkflow(WorkflowTaskType.transcode_watermark, transcodeWatermarkWorkflow)
|
||||
registerActivities(transcodeActivities)
|
||||
registerActivities(watermarkActivities)
|
||||
}
|
||||
|
||||
export * from './transcoder'
|
||||
export * from './workflows/transcode'
|
||||
export * from './workflows/transcode-watermark'
|
||||
export * from './activities/transcode'
|
||||
export * from './activities/watermark'
|
||||
|
||||
@@ -115,8 +115,8 @@ describe('transcodeImageWorkflow', () => {
|
||||
|
||||
mockActivities.transcodeImageActivity.mockResolvedValue({
|
||||
key: 't.webp',
|
||||
width: 480,
|
||||
height: 480,
|
||||
width: 300,
|
||||
height: 300,
|
||||
format: 'webp',
|
||||
})
|
||||
|
||||
@@ -132,8 +132,8 @@ describe('transcodeImageWorkflow', () => {
|
||||
mediaInfo: expect.objectContaining({
|
||||
thumbnail: expect.objectContaining({
|
||||
key: 't.webp',
|
||||
width: 480,
|
||||
height: 480,
|
||||
width: 300,
|
||||
height: 300,
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -49,7 +49,6 @@ export async function transcodeImageWorkflow(task: WorkflowTask): Promise<void>
|
||||
|
||||
mediaInfo.original = {
|
||||
key,
|
||||
downloadUrl: '',
|
||||
filesizeInBytes: 0,
|
||||
codec: '',
|
||||
}
|
||||
@@ -76,7 +75,7 @@ export async function transcodeImageWorkflow(task: WorkflowTask): Promise<void>
|
||||
const thumbTranscode = await executeActivity(workerQueue, transcodeImageActivity, {
|
||||
assetKey: key,
|
||||
filePath,
|
||||
imageSpec: { width: 480, height: 0, quality: 80, format: 'webp' },
|
||||
imageSpec: { width: 300, height: 300, quality: 80, format: 'webp', isPreview: true },
|
||||
})
|
||||
mediaInfo.thumbnail = thumbTranscode
|
||||
}
|
||||
|
||||
@@ -60,7 +60,6 @@ export async function transcodePdfWorkflow(task: WorkflowTask): Promise<void> {
|
||||
|
||||
mediaInfo.original = {
|
||||
key,
|
||||
downloadUrl: '',
|
||||
filesizeInBytes: 0,
|
||||
codec: '',
|
||||
}
|
||||
|
||||
@@ -124,8 +124,8 @@ describe('transcodeVideoWorkflow', () => {
|
||||
})
|
||||
mockActivities.transcodeImageActivity.mockResolvedValue({
|
||||
key: 't.webp',
|
||||
width: 480,
|
||||
height: 270,
|
||||
width: 300,
|
||||
height: 300,
|
||||
})
|
||||
|
||||
await transcodeVideoWorkflow(task)
|
||||
@@ -210,7 +210,6 @@ describe('transcodeVideoWorkflow', () => {
|
||||
},
|
||||
original: {
|
||||
key: 'audio.wav',
|
||||
downloadUrl: '',
|
||||
filesizeInBytes: 0,
|
||||
codec: '',
|
||||
},
|
||||
|
||||
@@ -54,7 +54,6 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
|
||||
mediaInfo.original = {
|
||||
key,
|
||||
downloadUrl: '',
|
||||
filesizeInBytes: 0,
|
||||
codec: '',
|
||||
}
|
||||
@@ -94,13 +93,6 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
mediaInfo.videoTranscodes.push(videoTranscode)
|
||||
}
|
||||
}
|
||||
|
||||
mediaInfo.videoTranscodes.push({
|
||||
key: mediaInfo.original?.key,
|
||||
width: metadata.originalWidth,
|
||||
height: metadata.originalHeight,
|
||||
isRaw: true,
|
||||
})
|
||||
}
|
||||
|
||||
const isAudio = mediaInfo.proxyType === 'audio'
|
||||
@@ -116,7 +108,7 @@ export async function transcodeVideoWorkflow(task: WorkflowTask): Promise<void>
|
||||
const thumbTranscode = await executeActivity(workerQueue, transcodeImageActivity, {
|
||||
assetKey: key,
|
||||
filePath,
|
||||
imageSpec: { width: 480, height: 0, quality: 80, format: 'webp' },
|
||||
imageSpec: { width: 300, height: 300, quality: 80, format: 'webp', isPreview: true },
|
||||
})
|
||||
mediaInfo.thumbnail = thumbTranscode
|
||||
}
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
import type { WorkflowTask } from '@shumai/db'
|
||||
import '@shumai/db/src/prisma-json-types'
|
||||
import { executeActivity, getActivities } from '@shumai/workflow-core'
|
||||
import { ApplicationFailure } from '@temporalio/workflow'
|
||||
import { getWorkerQueueAndStartTask, completeTask, failTask } from './common'
|
||||
|
||||
export async function transcodeWatermarkWorkflow(task: WorkflowTask): Promise<void> {
|
||||
let workerQueue = ''
|
||||
const watermarkConfigId = task.payload?.watermark?.watermarkConfigId
|
||||
const shareLinkId = task.payload?.watermark?.shareLinkId
|
||||
|
||||
if (!watermarkConfigId) {
|
||||
throw ApplicationFailure.create({
|
||||
message: 'watermarkConfigId is required in task payload',
|
||||
nonRetryable: true,
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
workerQueue = await getWorkerQueueAndStartTask(task)
|
||||
|
||||
const {
|
||||
initWatermarkFileActivity,
|
||||
waitForWatermarkFileActivity,
|
||||
transcodeWatermarkMediaActivity,
|
||||
completeWatermarkFileActivity,
|
||||
} = getActivities()
|
||||
|
||||
const initResult = await executeActivity(workerQueue, initWatermarkFileActivity, {
|
||||
assetId: task.assetId,
|
||||
watermarkConfigId,
|
||||
})
|
||||
|
||||
if (initResult.action === 'completed') {
|
||||
if (shareLinkId) {
|
||||
await executeActivity(workerQueue, completeWatermarkFileActivity, {
|
||||
assetId: task.assetId,
|
||||
watermarkConfigId,
|
||||
status: 'completed',
|
||||
shareLinkId,
|
||||
})
|
||||
}
|
||||
await completeTask(workerQueue, task.id)
|
||||
return
|
||||
}
|
||||
|
||||
if (initResult.action === 'failed') {
|
||||
throw ApplicationFailure.create({
|
||||
message: 'Watermark file generation failed in another task',
|
||||
nonRetryable: true,
|
||||
})
|
||||
}
|
||||
|
||||
if (initResult.action === 'processing') {
|
||||
const waitResult = await executeActivity(workerQueue, waitForWatermarkFileActivity, {
|
||||
assetId: task.assetId,
|
||||
watermarkConfigId,
|
||||
})
|
||||
|
||||
if (waitResult.status === 'completed') {
|
||||
if (shareLinkId) {
|
||||
await executeActivity(workerQueue, completeWatermarkFileActivity, {
|
||||
assetId: task.assetId,
|
||||
watermarkConfigId,
|
||||
status: 'completed',
|
||||
shareLinkId,
|
||||
})
|
||||
}
|
||||
await completeTask(workerQueue, task.id)
|
||||
return
|
||||
}
|
||||
|
||||
throw ApplicationFailure.create({
|
||||
message: 'Watermark file generation failed in in-flight task',
|
||||
nonRetryable: true,
|
||||
})
|
||||
}
|
||||
|
||||
const mediaInfo = await executeActivity(workerQueue, transcodeWatermarkMediaActivity, {
|
||||
assetId: task.assetId,
|
||||
watermarkConfigId,
|
||||
})
|
||||
|
||||
await executeActivity(workerQueue, completeWatermarkFileActivity, {
|
||||
assetId: task.assetId,
|
||||
watermarkConfigId,
|
||||
mediaInfo,
|
||||
status: 'completed',
|
||||
shareLinkId,
|
||||
})
|
||||
|
||||
await completeTask(workerQueue, task.id)
|
||||
} catch (err) {
|
||||
if (workerQueue && watermarkConfigId) {
|
||||
const { completeWatermarkFileActivity } = getActivities()
|
||||
try {
|
||||
await executeActivity(workerQueue, completeWatermarkFileActivity, {
|
||||
assetId: task.assetId,
|
||||
watermarkConfigId,
|
||||
status: 'failed',
|
||||
shareLinkId,
|
||||
})
|
||||
} catch (e) {
|
||||
console.error('Failed to update watermark file status to failed:', e)
|
||||
}
|
||||
}
|
||||
await failTask(workerQueue, task.id, err)
|
||||
throw err
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import { transcodePdfWorkflow } from './transcode-pdf'
|
||||
import { renderPdfPagesWorkflow } from './render-pdf-pages'
|
||||
import { takeVideoScreenshotsWorkflow } from './take-video-screenshots'
|
||||
import { overlayImageAnnotationWorkflow } from './overlay-image-annotation'
|
||||
import { transcodeWatermarkWorkflow } from './transcode-watermark'
|
||||
|
||||
/**
|
||||
* @deprecated Legacy monolithic transcode workflow. Prefer using focused workflows:
|
||||
@@ -13,6 +14,9 @@ import { overlayImageAnnotationWorkflow } from './overlay-image-annotation'
|
||||
*/
|
||||
export async function transcodeMedia(task: WorkflowTask): Promise<void> {
|
||||
const payload = task.payload
|
||||
if (payload?.watermark || task.type === 'transcode_watermark') {
|
||||
return transcodeWatermarkWorkflow(task)
|
||||
}
|
||||
if (payload?.pdfPages) {
|
||||
return renderPdfPagesWorkflow(task)
|
||||
}
|
||||
@@ -42,5 +46,6 @@ export * from './transcode-pdf'
|
||||
export * from './render-pdf-pages'
|
||||
export * from './take-video-screenshots'
|
||||
export * from './overlay-image-annotation'
|
||||
export * from './transcode-watermark'
|
||||
export * from './common'
|
||||
export * from './transcode-utils'
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user