mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-20 01:16:54 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72654e84b2 | ||
|
|
cec3821d00 | ||
|
|
dc3dbcb73e | ||
|
|
6226090fd1 | ||
|
|
d052c56d39 | ||
|
|
bd13fa7774 | ||
|
|
5e462cc7b1 | ||
|
|
73c11af9a3 | ||
|
|
adb73b56a2 | ||
|
|
e5dcf02b26 | ||
|
|
684f88a406 | ||
|
|
8ec970e2bf | ||
|
|
3eb7894df9 | ||
|
|
464167ec83 | ||
|
|
dc8c898dae | ||
|
|
ecc382af61 | ||
|
|
78dec7626b | ||
|
|
f87033bd3d | ||
|
|
d1b0f3b64f | ||
|
|
8cdbc403db | ||
|
|
90adc496dd | ||
|
|
8d1c51abca | ||
|
|
21de21902e | ||
|
|
330a0b99a9 | ||
|
|
df013aa4bb | ||
|
|
2c04c97a02 | ||
|
|
f6c0a41151 | ||
|
|
f93c8ea524 | ||
|
|
783daa6d3f | ||
|
|
1c44e5aff7 | ||
|
|
2552d68b98 | ||
|
|
1f714af366 | ||
|
|
f0ca7c180b | ||
|
|
8aadaa70bf |
@@ -32,7 +32,7 @@ jobs:
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ripgrep bubblewrap socat ffmpeg poppler-utils
|
||||
sudo apt-get install -y ripgrep bubblewrap socat ffmpeg poppler-utils imagemagick
|
||||
|
||||
- name: Lint
|
||||
run: bun run lint
|
||||
@@ -157,7 +157,7 @@ jobs:
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ripgrep bubblewrap socat ffmpeg poppler-utils
|
||||
sudo apt-get install -y ripgrep bubblewrap socat ffmpeg poppler-utils imagemagick
|
||||
|
||||
- name: Run Workflow E2E Tests
|
||||
run: bun run test:e2e:workflow
|
||||
|
||||
@@ -48,7 +48,7 @@ jobs:
|
||||
- name: Install system dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ripgrep bubblewrap socat ffmpeg poppler-utils libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev fd-find
|
||||
sudo apt-get install -y ripgrep bubblewrap socat ffmpeg poppler-utils imagemagick libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev fd-find
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install
|
||||
|
||||
@@ -50,6 +50,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
bubblewrap \
|
||||
gosu \
|
||||
poppler-utils \
|
||||
imagemagick \
|
||||
fonts-noto-cjk \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
@@ -126,23 +126,24 @@ Shumai requires the following system packages on Linux:
|
||||
|
||||
- **`ffmpeg`** – Used for media transcoding and metadata extraction.
|
||||
- **`poppler`** (`poppler-utils`) – Used for PDF page image extraction and PDF sprite preview generation (`pdftoppm`).
|
||||
- **`imagemagick`** – Used for PSD format transcoding and color profile conversion to sRGB.
|
||||
- **`bubblewrap`**, **`socat`**, and **`ripgrep`** – Required by the AI agent sandbox (`anthropic-experimental/sandbox-runtime`) for process isolation, networking, and workspace search.
|
||||
|
||||
Install all required packages with one command:
|
||||
|
||||
> Ubuntu/Debian
|
||||
```bash
|
||||
sudo apt install -y ffmpeg poppler-utils bubblewrap socat ripgrep
|
||||
sudo apt install -y ffmpeg poppler-utils imagemagick bubblewrap socat ripgrep
|
||||
```
|
||||
|
||||
> Fedora
|
||||
```bash
|
||||
sudo dnf install -y ffmpeg poppler-utils bubblewrap socat ripgrep
|
||||
sudo dnf install -y ffmpeg poppler-utils ImageMagick bubblewrap socat ripgrep
|
||||
```
|
||||
|
||||
> Arch Linux
|
||||
```bash
|
||||
sudo pacman -S --noconfirm ffmpeg poppler bubblewrap socat ripgrep
|
||||
sudo pacman -S --noconfirm ffmpeg poppler imagemagick bubblewrap socat ripgrep
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
@@ -164,12 +165,13 @@ Shumai requires:
|
||||
|
||||
- **`ffmpeg`** – Used for media transcoding and metadata extraction.
|
||||
- **`poppler`** – Used for PDF page image extraction and PDF sprite preview generation (`pdftoppm`).
|
||||
- **`imagemagick`** – Used for PSD format transcoding and color profile conversion to sRGB.
|
||||
- **`ripgrep`** – Required by the AI agent sandbox (`anthropic-experimental/sandbox-runtime`).
|
||||
|
||||
Install the required packages with Homebrew:
|
||||
|
||||
```bash
|
||||
brew install ffmpeg poppler ripgrep
|
||||
brew install ffmpeg poppler imagemagick ripgrep
|
||||
```
|
||||
|
||||
---
|
||||
@@ -190,17 +192,18 @@ brew install ffmpeg poppler ripgrep
|
||||
Shumai requires:
|
||||
|
||||
- **`ffmpeg`** – Used for media transcoding and metadata extraction.
|
||||
- **`imagemagick`** – Used for PSD format transcoding and color profile conversion to sRGB.
|
||||
|
||||
Install `ffmpeg` using your preferred package manager:
|
||||
Install required packages using your preferred package manager:
|
||||
|
||||
**winget**
|
||||
```powershell
|
||||
winget install Gyan.FFmpeg
|
||||
winget install Gyan.FFmpeg ImageMagick.ImageMagick
|
||||
```
|
||||
|
||||
**Chocolatey**
|
||||
```powershell
|
||||
choco install ffmpeg
|
||||
choco install ffmpeg imagemagick
|
||||
```
|
||||
|
||||
#### Step 4: Install Shumai globally
|
||||
|
||||
+10
-7
@@ -140,23 +140,24 @@ mkdir shumai && cd shumai
|
||||
|
||||
- **`ffmpeg`** —— 用于媒体转码和元数据提取。
|
||||
- **`poppler`** (`poppler-utils`) —— 用于 PDF 页面图像提取和 PDF 雪碧图预览生成 (`pdftoppm`)。
|
||||
- **`imagemagick`** —— 用于 PSD 格式图像转码和 sRGB 色彩空间转换。
|
||||
- **`bubblewrap`**、**`socat`** 和 **`ripgrep`** —— AI Agent 沙箱(`anthropic-experimental/sandbox-runtime`)所需,用于进程隔离、网络通信和工作区搜索。
|
||||
|
||||
可以使用以下命令一次性安装所有依赖:
|
||||
|
||||
> Ubuntu/Debian
|
||||
```bash
|
||||
sudo apt install -y ffmpeg poppler-utils bubblewrap socat ripgrep
|
||||
sudo apt install -y ffmpeg poppler-utils imagemagick bubblewrap socat ripgrep
|
||||
```
|
||||
|
||||
> Fedora
|
||||
```bash
|
||||
sudo dnf install -y ffmpeg poppler-utils bubblewrap socat ripgrep
|
||||
sudo dnf install -y ffmpeg poppler-utils ImageMagick bubblewrap socat ripgrep
|
||||
```
|
||||
|
||||
> Arch Linux
|
||||
```bash
|
||||
sudo pacman -S --noconfirm ffmpeg poppler bubblewrap socat ripgrep
|
||||
sudo pacman -S --noconfirm ffmpeg poppler imagemagick bubblewrap socat ripgrep
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
@@ -178,12 +179,13 @@ sudo pacman -S --noconfirm ffmpeg poppler bubblewrap socat ripgrep
|
||||
|
||||
- **`ffmpeg`** —— 用于媒体转码和元数据提取。
|
||||
- **`poppler`** —— 用于 PDF 页面图像提取和 PDF 雪碧图预览生成 (`pdftoppm`)。
|
||||
- **`imagemagick`** —— 用于 PSD 格式图像转码和 sRGB 色彩空间转换。
|
||||
- **`ripgrep`** —— AI Agent 沙箱(`anthropic-experimental/sandbox-runtime`)所需。
|
||||
|
||||
使用 Homebrew 安装所需依赖:
|
||||
|
||||
```bash
|
||||
brew install ffmpeg poppler ripgrep
|
||||
brew install ffmpeg poppler imagemagick ripgrep
|
||||
```
|
||||
|
||||
---
|
||||
@@ -204,17 +206,18 @@ brew install ffmpeg poppler ripgrep
|
||||
在 Windows 上运行 Shumai 需要:
|
||||
|
||||
- **`ffmpeg`** —— 用于媒体转码和元数据提取。
|
||||
- **`imagemagick`** —— 用于 PSD 格式图像转码和 sRGB 色彩空间转换。
|
||||
|
||||
使用你偏好的包管理器安装 `ffmpeg`:
|
||||
使用你偏好的包管理器安装所需依赖:
|
||||
|
||||
**winget**
|
||||
```powershell
|
||||
winget install Gyan.FFmpeg
|
||||
winget install Gyan.FFmpeg ImageMagick.ImageMagick
|
||||
```
|
||||
|
||||
**Chocolatey**
|
||||
```powershell
|
||||
choco install ffmpeg
|
||||
choco install ffmpeg imagemagick
|
||||
```
|
||||
|
||||
#### 第四步:全局安装 Shumai
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/agent-app",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"bin": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/cli",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"bin": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/transcode-app",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"bin": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/web-app",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
},
|
||||
"apps/agent": {
|
||||
"name": "@shumai/agent-app",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.2",
|
||||
"bin": {
|
||||
"shumai-agent": "./src/index.ts",
|
||||
},
|
||||
@@ -45,7 +45,7 @@
|
||||
},
|
||||
"apps/cli": {
|
||||
"name": "@shumai/cli",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.2",
|
||||
"bin": {
|
||||
"shumai-cli": "./src/index.ts",
|
||||
},
|
||||
@@ -60,7 +60,7 @@
|
||||
},
|
||||
"apps/transcode": {
|
||||
"name": "@shumai/transcode-app",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.2",
|
||||
"bin": {
|
||||
"shumai-transcode": "./src/index.ts",
|
||||
},
|
||||
@@ -72,7 +72,7 @@
|
||||
},
|
||||
"apps/web": {
|
||||
"name": "@shumai/web-app",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.2",
|
||||
"dependencies": {
|
||||
"@shumai/agent": "workspace:*",
|
||||
"@shumai/api": "workspace:*",
|
||||
@@ -92,7 +92,7 @@
|
||||
},
|
||||
"packages/agent": {
|
||||
"name": "@shumai/agent",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.2",
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sandbox-runtime": "0.0.52",
|
||||
"@earendil-works/pi-agent-core": "0.78.0",
|
||||
@@ -117,7 +117,7 @@
|
||||
},
|
||||
"packages/api": {
|
||||
"name": "@shumai/api",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.2",
|
||||
"dependencies": {
|
||||
"@hono/zod-validator": "0.7.6",
|
||||
"@shumai/core": "workspace:*",
|
||||
@@ -131,7 +131,7 @@
|
||||
},
|
||||
"packages/core": {
|
||||
"name": "@shumai/core",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.2",
|
||||
"dependencies": {
|
||||
"@earendil-works/pi-agent-core": "0.78.0",
|
||||
"@shumai/db": "workspace:*",
|
||||
@@ -162,7 +162,7 @@
|
||||
},
|
||||
"packages/db": {
|
||||
"name": "@shumai/db",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.2",
|
||||
"dependencies": {
|
||||
"@earendil-works/pi-agent-core": "0.78.0",
|
||||
"@prisma/adapter-pg": "7.8.0",
|
||||
@@ -178,7 +178,7 @@
|
||||
},
|
||||
"packages/dtos": {
|
||||
"name": "@shumai/dtos",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.2",
|
||||
"dependencies": {
|
||||
"@earendil-works/pi-agent-core": "0.78.0",
|
||||
"zod": "4.4.3",
|
||||
@@ -186,7 +186,7 @@
|
||||
},
|
||||
"packages/e2e": {
|
||||
"name": "@shumai/e2e",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.2",
|
||||
"dependencies": {
|
||||
"@earendil-works/pi-agent-core": "0.78.0",
|
||||
"@google/genai": "1.52.0",
|
||||
@@ -196,15 +196,16 @@
|
||||
"@shumai/dtos": "workspace:*",
|
||||
"@shumai/transcode": "workspace:*",
|
||||
"@shumai/workflow-core": "workspace:*",
|
||||
"sharp": "0.35.3",
|
||||
},
|
||||
},
|
||||
"packages/tableprinter": {
|
||||
"name": "@shumai/tableprinter",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.2",
|
||||
},
|
||||
"packages/transcode": {
|
||||
"name": "@shumai/transcode",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.2",
|
||||
"dependencies": {
|
||||
"@shumai/core": "workspace:*",
|
||||
"@shumai/db": "workspace:*",
|
||||
@@ -218,7 +219,7 @@
|
||||
},
|
||||
"packages/webui": {
|
||||
"name": "@shumai/webui",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.2",
|
||||
"dependencies": {
|
||||
"@base-ui/react": "1.5.0",
|
||||
"@dnd-kit/abstract": "0.4.0",
|
||||
@@ -316,7 +317,7 @@
|
||||
},
|
||||
"packages/workflow-core": {
|
||||
"name": "@shumai/workflow-core",
|
||||
"version": "0.2.0",
|
||||
"version": "0.2.2",
|
||||
"dependencies": {
|
||||
"@shumai/core": "workspace:*",
|
||||
"@shumai/db": "workspace:*",
|
||||
@@ -581,6 +582,8 @@
|
||||
|
||||
"@img/sharp-darwin-x64": ["@img/sharp-darwin-x64@0.34.5", "", { "optionalDependencies": { "@img/sharp-libvips-darwin-x64": "1.2.4" }, "os": "darwin", "cpu": "x64" }, "sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw=="],
|
||||
|
||||
"@img/sharp-freebsd-wasm32": ["@img/sharp-freebsd-wasm32@0.35.3", "", { "dependencies": { "@img/sharp-wasm32": "0.35.3" }, "os": "freebsd" }, "sha512-lUxcqWIj2wMQ9BrwNjngcr1gWUr5xgaGThBRqPPalIC2n67Cqj1uPh8NnA/ZhAg8hUbKl+kVHKwgUIwe6ZYPrg=="],
|
||||
|
||||
"@img/sharp-libvips-darwin-arm64": ["@img/sharp-libvips-darwin-arm64@1.2.4", "", { "os": "darwin", "cpu": "arm64" }, "sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g=="],
|
||||
|
||||
"@img/sharp-libvips-darwin-x64": ["@img/sharp-libvips-darwin-x64@1.2.4", "", { "os": "darwin", "cpu": "x64" }, "sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg=="],
|
||||
@@ -619,6 +622,8 @@
|
||||
|
||||
"@img/sharp-wasm32": ["@img/sharp-wasm32@0.34.5", "", { "dependencies": { "@emnapi/runtime": "^1.7.0" }, "cpu": "none" }, "sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw=="],
|
||||
|
||||
"@img/sharp-webcontainers-wasm32": ["@img/sharp-webcontainers-wasm32@0.35.3", "", { "dependencies": { "@img/sharp-wasm32": "0.35.3" }, "cpu": "none" }, "sha512-2rnq7bX3NzeR2T4YWgz8qiG4h3TSdMe+vN1iQXpJleSJ3SM5zQ8Fy2SyyXAWlbxpEZ2Y+Z4u1BePgJEYbSy80Q=="],
|
||||
|
||||
"@img/sharp-win32-arm64": ["@img/sharp-win32-arm64@0.34.5", "", { "os": "win32", "cpu": "arm64" }, "sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g=="],
|
||||
|
||||
"@img/sharp-win32-ia32": ["@img/sharp-win32-ia32@0.34.5", "", { "os": "win32", "cpu": "ia32" }, "sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg=="],
|
||||
@@ -2829,6 +2834,10 @@
|
||||
|
||||
"@grpc/grpc-js/@grpc/proto-loader": ["@grpc/proto-loader@0.8.1", "", { "dependencies": { "lodash.camelcase": "^4.3.0", "long": "^5.0.0", "protobufjs": "^7.5.5", "yargs": "^17.7.2" }, "bin": { "proto-loader-gen-types": "build/bin/proto-loader-gen-types.js" } }, "sha512-wtF6h+DY6M3YaDBPAmvuuA6jV8Sif9MjtOI5euKFWRgCDl5PeDpPsHR9u2l6St5ceY8AZgoNDww5+HvEsXFsGg=="],
|
||||
|
||||
"@img/sharp-freebsd-wasm32/@img/sharp-wasm32": ["@img/sharp-wasm32@0.35.3", "", { "dependencies": { "@emnapi/runtime": "^1.11.1" } }, "sha512-cZ0XkcYGpHZkqW6iCkqTcmUC0CD9DhD5d/qeZlZkfRBn6GnHniZXLUo5+9xw8Iv76YE6LQFN9YNBlKREcCG76w=="],
|
||||
|
||||
"@img/sharp-webcontainers-wasm32/@img/sharp-wasm32": ["@img/sharp-wasm32@0.35.3", "", { "dependencies": { "@emnapi/runtime": "^1.11.1" } }, "sha512-cZ0XkcYGpHZkqW6iCkqTcmUC0CD9DhD5d/qeZlZkfRBn6GnHniZXLUo5+9xw8Iv76YE6LQFN9YNBlKREcCG76w=="],
|
||||
|
||||
"@inlang/sdk/@sinclair/typebox": ["@sinclair/typebox@0.31.28", "", {}, "sha512-/s55Jujywdw/Jpan+vsy6JZs1z2ZTGxTmbZTPiuSL2wz9mfzA2gN1zzaqmvfi4pq+uOt7Du85fkiwv5ymW84aQ=="],
|
||||
|
||||
"@inlang/sdk/uuid": ["uuid@14.0.0", "", { "bin": { "uuid": "dist-node/bin/uuid" } }, "sha512-Qo+uWgilfSmAhXCMav1uYFynlQO7fMFiMVZsQqZRMIXp0O7rR7qjkj+cPvBHLgBqi960QCoo/PH2/6ZtVqKvrg=="],
|
||||
@@ -3039,6 +3048,8 @@
|
||||
|
||||
"@reduxjs/toolkit/immer": ["immer@11.1.8", "", {}, "sha512-/tbkHMW7y10Lx6i1crLjD4/OhNkRG+Fo7byZHtah0547nIeXYcpIXaUh0IAQY6gO5459qpGGYapcEOHtFXkIuA=="],
|
||||
|
||||
"@shumai/e2e/sharp": ["sharp@0.35.3", "", { "dependencies": { "@img/colour": "^1.1.0", "detect-libc": "^2.1.2", "semver": "^7.8.5" }, "optionalDependencies": { "@img/sharp-darwin-arm64": "0.35.3", "@img/sharp-darwin-x64": "0.35.3", "@img/sharp-freebsd-wasm32": "0.35.3", "@img/sharp-libvips-darwin-arm64": "1.3.2", "@img/sharp-libvips-darwin-x64": "1.3.2", "@img/sharp-libvips-linux-arm": "1.3.2", "@img/sharp-libvips-linux-arm64": "1.3.2", "@img/sharp-libvips-linux-ppc64": "1.3.2", "@img/sharp-libvips-linux-riscv64": "1.3.2", "@img/sharp-libvips-linux-s390x": "1.3.2", "@img/sharp-libvips-linux-x64": "1.3.2", "@img/sharp-libvips-linuxmusl-arm64": "1.3.2", "@img/sharp-libvips-linuxmusl-x64": "1.3.2", "@img/sharp-linux-arm": "0.35.3", "@img/sharp-linux-arm64": "0.35.3", "@img/sharp-linux-ppc64": "0.35.3", "@img/sharp-linux-riscv64": "0.35.3", "@img/sharp-linux-s390x": "0.35.3", "@img/sharp-linux-x64": "0.35.3", "@img/sharp-linuxmusl-arm64": "0.35.3", "@img/sharp-linuxmusl-x64": "0.35.3", "@img/sharp-webcontainers-wasm32": "0.35.3", "@img/sharp-win32-arm64": "0.35.3", "@img/sharp-win32-ia32": "0.35.3", "@img/sharp-win32-x64": "0.35.3" }, "peerDependencies": { "@types/node": "*" }, "optionalPeers": ["@types/node"] }, "sha512-ej0zVHuZGHCiABXcNxeYhpRnPNPAcvbG8RMdBAhDAxLKkCRVSpK3Iyu7qbqw3JMzoj0REeM6f3tJLtVwl0023Q=="],
|
||||
|
||||
"@tailwindcss/oxide-wasm32-wasi/@emnapi/core": ["@emnapi/core@1.10.0", "", { "dependencies": { "@emnapi/wasi-threads": "1.2.1", "tslib": "^2.4.0" }, "bundled": true }, "sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw=="],
|
||||
|
||||
"@tailwindcss/oxide-wasm32-wasi/@emnapi/runtime": ["@emnapi/runtime@1.10.0", "", { "dependencies": { "tslib": "^2.4.0" }, "bundled": true }, "sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA=="],
|
||||
@@ -3249,6 +3260,10 @@
|
||||
|
||||
"@earendil-works/pi-agent-core/@earendil-works/pi-ai/@mistralai/mistralai": ["@mistralai/mistralai@2.2.1", "", { "dependencies": { "ws": "^8.18.0", "zod": "^3.25.0 || ^4.0.0", "zod-to-json-schema": "^3.25.0" } }, "sha512-uKU8CZmL2RzYKmplsU01hii4p3pe4HqJefpWNRWXm1Tcm0Sm4xXfwSLIy4k7ZCPlbETCGcp69E7hZs+WOJ5itQ=="],
|
||||
|
||||
"@img/sharp-freebsd-wasm32/@img/sharp-wasm32/@emnapi/runtime": ["@emnapi/runtime@1.11.2", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-kyOl3X0DuTiT1h2ft8r2fYO8JYtU9a9Xis/zBSiGArNaagCOWx90N1k2wxp18czFDH+OgcWGb5ZP/XMt3dcyPA=="],
|
||||
|
||||
"@img/sharp-webcontainers-wasm32/@img/sharp-wasm32/@emnapi/runtime": ["@emnapi/runtime@1.11.2", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-kyOl3X0DuTiT1h2ft8r2fYO8JYtU9a9Xis/zBSiGArNaagCOWx90N1k2wxp18czFDH+OgcWGb5ZP/XMt3dcyPA=="],
|
||||
|
||||
"@isaacs/cliui/string-width/emoji-regex": ["emoji-regex@9.2.2", "", {}, "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="],
|
||||
|
||||
"@isaacs/cliui/strip-ansi/ansi-regex": ["ansi-regex@6.2.2", "", {}, "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg=="],
|
||||
@@ -3357,6 +3372,54 @@
|
||||
|
||||
"@radix-ui/react-tooltip/@radix-ui/react-use-controllable-state/@radix-ui/react-use-layout-effect": ["@radix-ui/react-use-layout-effect@1.1.1", "", { "peerDependencies": { "@types/react": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-RbJRS4UWQFkzHTTwVymMTUv8EqYhOp8dOOviLj2ugtTiXRaRQS7GLGxZTLL1jWhMeoSCf5zmcZkqTl9IiYfXcQ=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-darwin-arm64": ["@img/sharp-darwin-arm64@0.35.3", "", { "optionalDependencies": { "@img/sharp-libvips-darwin-arm64": "1.3.2" }, "os": "darwin", "cpu": "arm64" }, "sha512-RMnFX7YQsMoh7lWfcM4NEHHymBX/rLuKNPVM84XE9ONPcaSCDgE7CHIHpSgPcO2xcRthgBy1HfNO319mwhIAkg=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-darwin-x64": ["@img/sharp-darwin-x64@0.35.3", "", { "optionalDependencies": { "@img/sharp-libvips-darwin-x64": "1.3.2" }, "os": "darwin", "cpu": "x64" }, "sha512-Xo+5uFBtLN0BKqieTxiFzFPQAUlBbbH5iBKyRX/z1JrbnYsHTfKJnUfL8+p2TPXr1pXqao4eeL4Rl144uDpK9w=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-libvips-darwin-arm64": ["@img/sharp-libvips-darwin-arm64@1.3.2", "", { "os": "darwin", "cpu": "arm64" }, "sha512-9J6ypZFpQBj4YnePGoq/S38w6nz+vqg5WZLrLGY4YuSemdMq47GMLBPO42MzwdGwpg/agZ7xzZcFHa48xlywfg=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-libvips-darwin-x64": ["@img/sharp-libvips-darwin-x64@1.3.2", "", { "os": "darwin", "cpu": "x64" }, "sha512-m2pW1n6cns9VaubNwsZ+c3CRYjxNQWgJ5gPlnL1nbBcpkBvFm6SCFN5o0psFHI8w9n11NKhFkeEDns98tiqbEw=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-libvips-linux-arm": ["@img/sharp-libvips-linux-arm@1.3.2", "", { "os": "linux", "cpu": "arm" }, "sha512-1eMLzy92I4J6rmi4mAT8yC3HxOtniyGELlzGbNMLLeqe052ahFQ0h6LFq+lh5DsDIdYViIDst08abvSbcEdLXQ=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-libvips-linux-arm64": ["@img/sharp-libvips-linux-arm64@1.3.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-dqVSFynCox4C/J8kT16V7SIFAns0IjgLwkvYT7p8LQVmJ5OS5b6tI9IGflxTeuBS//zXeFIUbwt5dwxyZ17cnA=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-libvips-linux-ppc64": ["@img/sharp-libvips-linux-ppc64@1.3.2", "", { "os": "linux", "cpu": "ppc64" }, "sha512-3z0NHDxD6n5I9gc05U1eW1AyRm+Gznzq3naMrthPNqE6oYykcogW0l/jfpJdjYnuNl8R7yI9pNbE1XiUeyq0Aw=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-libvips-linux-riscv64": ["@img/sharp-libvips-linux-riscv64@1.3.2", "", { "os": "linux", "cpu": "none" }, "sha512-bsb4rI+NldGOsXuej2r8OdSS8+zXDVaCWxyWrcv6kneTOlgAHtZABRzBBCwdsPiD90J4myNJuHpg6kA20ImW/w=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-libvips-linux-s390x": ["@img/sharp-libvips-linux-s390x@1.3.2", "", { "os": "linux", "cpu": "s390x" }, "sha512-/ABshyj8gCpyIrNXnHn4LorDJ0HHm1VhXPBlxZ8zAtfVPAaSafXPGn+sUSIRiwaSBy0mmFjSjiXI5mkcwdChKQ=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-libvips-linux-x64": ["@img/sharp-libvips-linux-x64@1.3.2", "", { "os": "linux", "cpu": "x64" }, "sha512-ITPEtgffGJ0S6G9dRyw/366tJQqFRcHWPHhC+Stpg3Z8AEMrDrTr2lhdz4f/Y/HMbRh//7Z5mBzEpVdi62Oc3w=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-libvips-linuxmusl-arm64": ["@img/sharp-libvips-linuxmusl-arm64@1.3.2", "", { "os": "linux", "cpu": "arm64" }, "sha512-zE9EdiUzUmg5mDT5a1rk5fYJ6GWPloTwWBYDS14naqHsL+EaMpDj1AWnpLgh3u0YCORv2Tt50wrcrpYqkP97Kw=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-libvips-linuxmusl-x64": ["@img/sharp-libvips-linuxmusl-x64@1.3.2", "", { "os": "linux", "cpu": "x64" }, "sha512-m0lrLiUt+lBYnCFr8qV/65yMR4E/c7/wf78I5eKTdkEakFAlZ9QlzEM3QIhhAwVeUhLAHLcCq7a7Vszq/oFNZQ=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-linux-arm": ["@img/sharp-linux-arm@0.35.3", "", { "optionalDependencies": { "@img/sharp-libvips-linux-arm": "1.3.2" }, "os": "linux", "cpu": "arm" }, "sha512-affVWCTLooy8TSxbDx2qkzuDeaWLNVBA+P//FNBirHsXpP2fuBhk5AuboYUnrDnzoXes8GFjpTx0SBFOCRg+FA=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-linux-arm64": ["@img/sharp-linux-arm64@0.35.3", "", { "optionalDependencies": { "@img/sharp-libvips-linux-arm64": "1.3.2" }, "os": "linux", "cpu": "arm64" }, "sha512-QgKDspHPnrU+GQ55XPhGwyhC8acLVOOSyAvo1oVfFmrIXLkDNmGWzAfDZ4xK8oSA1qBQrALcHX0G5UZni/SuFQ=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-linux-ppc64": ["@img/sharp-linux-ppc64@0.35.3", "", { "optionalDependencies": { "@img/sharp-libvips-linux-ppc64": "1.3.2" }, "os": "linux", "cpu": "ppc64" }, "sha512-sMd8rDxmpLOwv/7N44klFjOD5DUO7FLdjiXDI0hoxYaf7Ar262dQIEkosE98bps+5HPLtp/EvNqeqQtOycP/IA=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-linux-riscv64": ["@img/sharp-linux-riscv64@0.35.3", "", { "optionalDependencies": { "@img/sharp-libvips-linux-riscv64": "1.3.2" }, "os": "linux", "cpu": "none" }, "sha512-0Eob78yjlYPfL5vMNWAW55l3R9Y6BQS/gOfe0ZcP9mEz9ohhKSt4im1hayiknXgf8AWrFqMvJcKIdmLmEe7yeQ=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-linux-s390x": ["@img/sharp-linux-s390x@0.35.3", "", { "optionalDependencies": { "@img/sharp-libvips-linux-s390x": "1.3.2" }, "os": "linux", "cpu": "s390x" }, "sha512-KgAxQ0DxpNOq1rG2t5cgTgShJFGSuU7XO45cqC+1NVOuZnP6tlgZRuSYOfNupGkHID0o3cJOsw4DVeJpMovcGw=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-linux-x64": ["@img/sharp-linux-x64@0.35.3", "", { "optionalDependencies": { "@img/sharp-libvips-linux-x64": "1.3.2" }, "os": "linux", "cpu": "x64" }, "sha512-8pqvxubL2PGdhlPy6GLqzDYMUjyRmKAwKHYKixpdJYBUK7PJ0C029XdsnpFIdgRZG68fZiGdHVWcKPvtiPB4cA=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-linuxmusl-arm64": ["@img/sharp-linuxmusl-arm64@0.35.3", "", { "optionalDependencies": { "@img/sharp-libvips-linuxmusl-arm64": "1.3.2" }, "os": "linux", "cpu": "arm64" }, "sha512-Vz0iQjzzcSX3HCbfwFfCSG/9SCIqyO0mH2sXyiHaAYfBk0cRsCWXRyQYX0ovCK/PAQBbTzQ0dsPQHh5MAFL59w=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-linuxmusl-x64": ["@img/sharp-linuxmusl-x64@0.35.3", "", { "optionalDependencies": { "@img/sharp-libvips-linuxmusl-x64": "1.3.2" }, "os": "linux", "cpu": "x64" }, "sha512-6O1NPKcDVj9QEdg7Hx549EX8U0rp6yXQERqru6yRN7fGBn32UvIRJUlWnk+8xDCiG76hXVBbX82NZ/ZKr0euIg=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-win32-arm64": ["@img/sharp-win32-arm64@0.35.3", "", { "os": "win32", "cpu": "arm64" }, "sha512-4bPwFdMbeC4JQ8L8LOyWp6nsHcboP5fxkp6iPOXz2Vg49R42TuMs2whkJ5OAP4/Ul035qOzy0AecOF9VOscn4w=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-win32-ia32": ["@img/sharp-win32-ia32@0.35.3", "", { "os": "win32", "cpu": "ia32" }, "sha512-r53mXsBN6lFUDiST764SvgwUdHAqM4rPAiDzAmf4fLoB6X/rkfyTrLCg6+g17wJJiCmB3JYgHuUldCWUIRFSXw=="],
|
||||
|
||||
"@shumai/e2e/sharp/@img/sharp-win32-x64": ["@img/sharp-win32-x64@0.35.3", "", { "os": "win32", "cpu": "x64" }, "sha512-D4y1vNeZrIIJCN+uHaWVtH86B+aCrdMYYjicy9pXHvbGZeGYLLSd3wdVuC37FxVXlU1ARsk84eKWfWMXGYEqvA=="],
|
||||
|
||||
"@shumai/e2e/sharp/semver": ["semver@7.8.5", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA=="],
|
||||
|
||||
"@tanstack/react-router/@tanstack/react-store/@tanstack/store": ["@tanstack/store@0.9.3", "", {}, "sha512-8reSzl/qGWGGVKhBoxXPMWzATSbZLZFWhwBAFO9NAyp0TxzfBP0mIrGb8CP8KrQTmvzXlR/vFPPUrHTLBGyFyw=="],
|
||||
|
||||
"@temporalio/proto/protobufjs/@types/node": ["@types/node@22.19.19", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-dyh/xO2Fh5bYrfWaaqGrRQQGkNdmYw6AmaAUvYeUMNTWQtvb796ikLdmTchRmOlOiIJ1TDXfWgVx1QkUlQ6Hew=="],
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "shumai",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/agent",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -56,6 +56,7 @@ describe('Agent Activities', () => {
|
||||
|
||||
it('should call agentChatActivity and prompt the harness', async () => {
|
||||
const mockHarness = {
|
||||
subscribe: vi.fn(),
|
||||
prompt: vi.fn().mockResolvedValue({
|
||||
content: [{ type: 'text', text: 'AI response' }],
|
||||
usage: { input: 10, output: 20 },
|
||||
@@ -95,6 +96,84 @@ describe('Agent Activities', () => {
|
||||
expect(piAgent.createAgentSession).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should subscribe to harness events and record usage for assistant message_end events', async () => {
|
||||
const { aiUsageService } = await import('@shumai/core/src/ai-usage/ai-usage')
|
||||
const spyRecordUsage = vi.spyOn(aiUsageService, 'recordUsage').mockResolvedValue()
|
||||
|
||||
let subscribeListener!: (event: unknown) => Promise<void>
|
||||
const mockHarness = {
|
||||
subscribe: vi.fn().mockImplementation((listener) => {
|
||||
subscribeListener = listener
|
||||
}),
|
||||
prompt: vi.fn().mockImplementation(async () => {
|
||||
// Trigger assistant message end event during turn
|
||||
if (subscribeListener) {
|
||||
await subscribeListener({
|
||||
type: 'message_end',
|
||||
message: {
|
||||
role: 'assistant',
|
||||
usage: {
|
||||
input: 150,
|
||||
output: 75,
|
||||
cacheRead: 25,
|
||||
totalTokens: 225,
|
||||
cost: { total: 0.0015 },
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
return {
|
||||
content: [{ type: 'text', text: 'Subscribed response' }],
|
||||
usage: { input: 150, output: 75 },
|
||||
}
|
||||
}),
|
||||
}
|
||||
|
||||
const mockSession = {
|
||||
getEntries: vi.fn().mockResolvedValue([]),
|
||||
getStorage: vi.fn().mockReturnValue({ sessionId: 'mock-session-id' }),
|
||||
}
|
||||
|
||||
vi.mocked(piAgent.createAgentSession).mockResolvedValue({
|
||||
session: mockSession as unknown as Session<DatabaseSessionMetadata>,
|
||||
harness: mockHarness as unknown as AgentHarness,
|
||||
})
|
||||
|
||||
const context = {
|
||||
agent: { id: 'b1', provider: { name: 'google' }, modelRef: { modelId: 'gemini' } },
|
||||
dbProviders: [],
|
||||
teamSkills: [],
|
||||
allowedDomains: [],
|
||||
} as unknown as AgentExecutionContext
|
||||
|
||||
const res = await agentChatActivity({
|
||||
teamId: 'team123',
|
||||
agentId: 'b1',
|
||||
message: 'Hi',
|
||||
imageUrls: [],
|
||||
projectId: 'p1',
|
||||
folderId: 'f1',
|
||||
sessionId: 'mock-session-id',
|
||||
userId: 'user123',
|
||||
context,
|
||||
})
|
||||
|
||||
expect(res.text).toBe('Subscribed response')
|
||||
expect(res.usage.inputTokens).toBe(150)
|
||||
expect(res.usage.outputTokens).toBe(75)
|
||||
expect(res.usage.cacheReadTokens).toBe(25)
|
||||
expect(res.usage.cost).toBe(0.0015)
|
||||
expect(spyRecordUsage).toHaveBeenCalledWith({
|
||||
teamId: 'team123',
|
||||
userId: 'user123',
|
||||
inputTokens: 150,
|
||||
outputTokens: 75,
|
||||
cacheReadTokens: 25,
|
||||
totalTokens: 225,
|
||||
cost: 0.0015,
|
||||
})
|
||||
})
|
||||
|
||||
it('should register local cancellation handler and call harness.abort when cancelled in local mode', async () => {
|
||||
let resolvePrompt!: (value: {
|
||||
content: Array<{ type: string; text: string } | { type: string }>
|
||||
@@ -107,6 +186,7 @@ describe('Agent Activities', () => {
|
||||
})
|
||||
|
||||
const mockHarness = {
|
||||
subscribe: vi.fn(),
|
||||
prompt: vi.fn().mockReturnValue(promptPromise),
|
||||
abort: vi.fn(),
|
||||
}
|
||||
@@ -174,6 +254,7 @@ describe('Agent Activities', () => {
|
||||
})
|
||||
|
||||
const mockHarness = {
|
||||
subscribe: vi.fn(),
|
||||
prompt: vi.fn().mockReturnValue(promptPromise),
|
||||
abort: vi.fn(),
|
||||
}
|
||||
@@ -234,6 +315,7 @@ describe('Agent Activities', () => {
|
||||
|
||||
it('should include error message in text when stopReason is error', async () => {
|
||||
const mockHarness = {
|
||||
subscribe: vi.fn(),
|
||||
prompt: vi.fn().mockResolvedValue({
|
||||
content: [],
|
||||
usage: { input: 0, output: 0 },
|
||||
@@ -274,6 +356,7 @@ describe('Agent Activities', () => {
|
||||
|
||||
it('should pass thinkingLevel from agent config to createAgentSession', async () => {
|
||||
const mockHarness = {
|
||||
subscribe: vi.fn(),
|
||||
prompt: vi.fn().mockResolvedValue({
|
||||
content: [],
|
||||
usage: { input: 0, output: 0 },
|
||||
@@ -322,6 +405,7 @@ describe('Agent Activities', () => {
|
||||
|
||||
it('should call autofillAiActivity and run autofill tool', async () => {
|
||||
const mockHarness = {
|
||||
subscribe: vi.fn(),
|
||||
prompt: vi.fn().mockResolvedValue({
|
||||
content: [{ type: 'text', text: 'Captured' }],
|
||||
usage: { input: 5, output: 5 },
|
||||
@@ -962,6 +1046,7 @@ describe('Agent Database Activities Integration', () => {
|
||||
})
|
||||
|
||||
const mockHarness = {
|
||||
subscribe: vi.fn(),
|
||||
prompt: vi.fn().mockResolvedValue({
|
||||
content: [{ type: 'text', text: ' "Summarized Chat Title" ' }],
|
||||
}),
|
||||
|
||||
@@ -25,11 +25,15 @@ import {
|
||||
type DbProviderInfo,
|
||||
} from '../index'
|
||||
|
||||
import { aiUsageService } from '@shumai/core/src/ai-usage/ai-usage'
|
||||
import { UpdateAssetMetadataRequest } from '@shumai/dtos'
|
||||
|
||||
export interface Usage {
|
||||
inputTokens: number
|
||||
outputTokens: number
|
||||
cacheReadTokens: number
|
||||
totalTokens: number
|
||||
cost: number
|
||||
model: string
|
||||
}
|
||||
|
||||
@@ -209,8 +213,56 @@ If you need to create files in the local filesystem (for example, a temporary fi
|
||||
} as unknown as SessionTreeEntry)
|
||||
}
|
||||
|
||||
let totalInputTokens = 0
|
||||
let totalOutputTokens = 0
|
||||
let totalCacheReadTokens = 0
|
||||
let grandTotalTokens = 0
|
||||
let totalCost = 0
|
||||
|
||||
harness.subscribe(async (event) => {
|
||||
if (event.type === 'message_end' && event.message.role === 'assistant') {
|
||||
const assistantMsg = event.message
|
||||
const u = assistantMsg.usage
|
||||
if (u) {
|
||||
const inputTokens = u.input || 0
|
||||
const outputTokens = u.output || 0
|
||||
const cacheReadTokens = u.cacheRead || 0
|
||||
const totalTokens = u.totalTokens || inputTokens + outputTokens
|
||||
const cost = u.cost?.total || 0
|
||||
|
||||
totalInputTokens += inputTokens
|
||||
totalOutputTokens += outputTokens
|
||||
totalCacheReadTokens += cacheReadTokens
|
||||
grandTotalTokens += totalTokens
|
||||
totalCost += cost
|
||||
|
||||
try {
|
||||
await aiUsageService.recordUsage({
|
||||
teamId: params.teamId,
|
||||
userId: params.userId,
|
||||
inputTokens,
|
||||
outputTokens,
|
||||
cacheReadTokens,
|
||||
totalTokens,
|
||||
cost,
|
||||
})
|
||||
} catch (err) {
|
||||
logger.error({ err }, 'Failed to record AI usage')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const assistantMessage = await harness.prompt(params.prompt, { images: imagesToPass })
|
||||
|
||||
if (totalInputTokens === 0 && totalOutputTokens === 0 && assistantMessage.usage) {
|
||||
totalInputTokens = assistantMessage.usage.input || 0
|
||||
totalOutputTokens = assistantMessage.usage.output || 0
|
||||
totalCacheReadTokens = assistantMessage.usage.cacheRead || 0
|
||||
grandTotalTokens = assistantMessage.usage.totalTokens || totalInputTokens + totalOutputTokens
|
||||
totalCost = assistantMessage.usage.cost?.total || 0
|
||||
}
|
||||
|
||||
const sessionEntries = await session.getEntries()
|
||||
sessionEntries.forEach((entry) => {
|
||||
if (entry.type === 'message') {
|
||||
@@ -243,8 +295,11 @@ If you need to create files in the local filesystem (for example, a temporary fi
|
||||
|
||||
const usage: Usage = {
|
||||
model: modelId,
|
||||
inputTokens: assistantMessage.usage?.input || 0,
|
||||
outputTokens: assistantMessage.usage?.output || 0,
|
||||
inputTokens: totalInputTokens,
|
||||
outputTokens: totalOutputTokens,
|
||||
cacheReadTokens: totalCacheReadTokens,
|
||||
totalTokens: grandTotalTokens,
|
||||
cost: totalCost,
|
||||
}
|
||||
|
||||
const storage = session.getStorage()
|
||||
|
||||
+17
-17
@@ -7,21 +7,21 @@ import {
|
||||
} from '@earendil-works/pi-agent-core'
|
||||
import { NodeExecutionEnv } from '@earendil-works/pi-agent-core/node'
|
||||
import { getModel } from '@earendil-works/pi-ai/compat'
|
||||
import { agentService } from '@shumai/core/src/agent/agent'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { Type, type TSchema } from '@sinclair/typebox'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { agentService } from '@shumai/core/src/agent/agent'
|
||||
import { DatabaseSessionStorage } from './database-session-storage'
|
||||
import { createAnalyzeImageTool } from './tools/analyze-image'
|
||||
import { createScreenshotTool } from './tools/screenshot'
|
||||
import { createReadPdfPagesTool } from './tools/read-pdf-pages'
|
||||
import { createCreateFileTool } from './tools/create-file'
|
||||
import { createCreateFolderTool } from './tools/create-folder'
|
||||
import { createCreateVersionTool } from './tools/create-version'
|
||||
import { createListAssetsTool } from './tools/list-assets'
|
||||
import { createReadPdfPagesTool } from './tools/read-pdf-pages'
|
||||
import { createReadSkillTool } from './tools/read-skill'
|
||||
import { createSandboxedBashTool } from './tools/sandboxed-bash'
|
||||
import { createScreenshotTool } from './tools/screenshot'
|
||||
|
||||
export interface DbModelInfo {
|
||||
modelId: string
|
||||
@@ -380,15 +380,15 @@ export function formatSkillsForPrompt(
|
||||
return lines.join('\n')
|
||||
}
|
||||
|
||||
import { registerWorkflow, registerActivities } from '@shumai/workflow-core'
|
||||
import { WorkflowTaskType } from '@shumai/db'
|
||||
import { agentEmbeddingMedia } from './workflows/agent-embedding'
|
||||
import { queryEmbeddingForSearch } from './workflows/query-embedding-for-search'
|
||||
import { agentAutofillMedia } from './workflows/agent-autofill'
|
||||
import { agentChat } from './workflows/agent-chat'
|
||||
import { agentToolCall } from './workflows/agent-tool-call'
|
||||
import { registerActivities, registerWorkflow } from '@shumai/workflow-core'
|
||||
import * as agentActivities from './activities/agent'
|
||||
import * as aiActivities from './activities/ai'
|
||||
import { agentAutofillMedia } from './workflows/agent-autofill'
|
||||
import { agentChat } from './workflows/agent-chat'
|
||||
import { agentEmbeddingMedia } from './workflows/agent-embedding'
|
||||
import { agentToolCall } from './workflows/agent-tool-call'
|
||||
import { queryEmbeddingForSearch } from './workflows/query-embedding-for-search'
|
||||
|
||||
export function initAgentWorkflows() {
|
||||
registerWorkflow(WorkflowTaskType.ai_embedding, agentEmbeddingMedia)
|
||||
@@ -401,19 +401,19 @@ export function initAgentWorkflows() {
|
||||
registerActivities(aiActivities)
|
||||
}
|
||||
|
||||
export * from './database-session-storage'
|
||||
export * from './activities/agent'
|
||||
export {
|
||||
extractAiMetadataActivity,
|
||||
generateEmbeddingActivity,
|
||||
generateImageEmbeddingActivity,
|
||||
generateTextEmbeddingActivity,
|
||||
generateVideoChunkEmbeddingActivity,
|
||||
type ExtractAiMetadataParams,
|
||||
type GeneratedEmbedding,
|
||||
type GenerateEmbeddingParams,
|
||||
generateEmbeddingActivity,
|
||||
type GenerateTextEmbeddingParams,
|
||||
generateTextEmbeddingActivity,
|
||||
type ExtractAiMetadataParams,
|
||||
extractAiMetadataActivity,
|
||||
generateImageEmbeddingActivity,
|
||||
generateVideoChunkEmbeddingActivity,
|
||||
} from './activities/ai'
|
||||
export * from './database-session-storage'
|
||||
export * from './workflows/agent-autofill'
|
||||
export * from './workflows/agent-chat'
|
||||
export * from './workflows/agent-embedding'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/api",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -37,6 +37,13 @@ vi.mock('@shumai/core/src/user/api-token', () => ({
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('@shumai/core/src/ai-usage/ai-usage', () => ({
|
||||
aiUsageService: {
|
||||
recordUsage: vi.fn(),
|
||||
getTeamUsageStats: vi.fn(),
|
||||
},
|
||||
}))
|
||||
|
||||
describe('team api', () => {
|
||||
const app = new Hono().use('*', authMiddleware).route('/', teamRoute)
|
||||
let mockCreateTeam: any // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
@@ -403,5 +410,66 @@ describe('team api', () => {
|
||||
expect(data).toEqual({ success: true })
|
||||
expect(apiTokenService.deleteToken).toHaveBeenCalledWith('user1', 'token1')
|
||||
})
|
||||
|
||||
it('GET /teams/:teamId/ai-usage returns team usage stats for owner', async () => {
|
||||
const { aiUsageService } = await import('@shumai/core/src/ai-usage/ai-usage')
|
||||
vi.mocked(aiUsageService.getTeamUsageStats).mockResolvedValue({
|
||||
timeframe: '30d',
|
||||
team: {
|
||||
inputTokens: 1000,
|
||||
outputTokens: 500,
|
||||
cacheReadTokens: 200,
|
||||
totalTokens: 1500,
|
||||
cost: 0.005,
|
||||
},
|
||||
})
|
||||
|
||||
const res = await app.request('/teams/t1/ai-usage?timeframe=30d')
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
const data = await res.json()
|
||||
expect(data.team.totalTokens).toBe(1500)
|
||||
expect(authzService.hasPermission).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
permission: Permission.Admin,
|
||||
type: ResourceType.Team,
|
||||
id: 't1',
|
||||
}),
|
||||
)
|
||||
expect(aiUsageService.getTeamUsageStats).toHaveBeenCalledWith({
|
||||
teamId: 't1',
|
||||
timeframe: '30d',
|
||||
userId: undefined,
|
||||
})
|
||||
})
|
||||
|
||||
it('GET /teams/:teamId/ai-usage?userId=user1 returns specific member usage stats', async () => {
|
||||
const { aiUsageService } = await import('@shumai/core/src/ai-usage/ai-usage')
|
||||
vi.mocked(aiUsageService.getTeamUsageStats).mockResolvedValue({
|
||||
timeframe: '7d',
|
||||
member: {
|
||||
userId: 'user1',
|
||||
userName: 'Test User',
|
||||
userEmail: 'user1@example.com',
|
||||
role: 'owner',
|
||||
inputTokens: 400,
|
||||
outputTokens: 200,
|
||||
cacheReadTokens: 50,
|
||||
totalTokens: 600,
|
||||
cost: 0.002,
|
||||
},
|
||||
})
|
||||
|
||||
const res = await app.request('/teams/t1/ai-usage?timeframe=7d&userId=user1')
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
const data = await res.json()
|
||||
expect(data.member.userId).toBe('user1')
|
||||
expect(aiUsageService.getTeamUsageStats).toHaveBeenCalledWith({
|
||||
teamId: 't1',
|
||||
timeframe: '7d',
|
||||
userId: 'user1',
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -15,8 +15,9 @@ import {
|
||||
updateTeamMemberRoleRequestSchema,
|
||||
createApiTokenRequestSchema,
|
||||
} from '@shumai/dtos'
|
||||
import { updateUserMetadataRequestSchema } from '@shumai/dtos'
|
||||
import { updateUserMetadataRequestSchema, getTeamAiUsageQuerySchema } from '@shumai/dtos'
|
||||
import { apiTokenService } from '@shumai/core/src/user/api-token'
|
||||
import { aiUsageService } from '@shumai/core/src/ai-usage/ai-usage'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
@@ -313,5 +314,25 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
await apiTokenService.deleteToken(user.id, tokenId)
|
||||
return c.json({ success: true })
|
||||
})
|
||||
.get('/teams/:teamId/ai-usage', zValidator('query', getTeamAiUsageQuerySchema), async (c) => {
|
||||
const user = c.get('user')
|
||||
const teamId = c.req.param('teamId')
|
||||
const { timeframe, userId } = c.req.valid('query')
|
||||
|
||||
await authzService.hasPermission({
|
||||
user,
|
||||
permission: Permission.Admin,
|
||||
type: ResourceType.Team,
|
||||
id: teamId,
|
||||
})
|
||||
|
||||
const stats = await aiUsageService.getTeamUsageStats({
|
||||
teamId,
|
||||
timeframe,
|
||||
userId,
|
||||
})
|
||||
|
||||
return c.json(stats)
|
||||
})
|
||||
|
||||
export default route
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/core",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -0,0 +1,313 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db/test'
|
||||
import { aiUsageService } from './ai-usage'
|
||||
import { HTTPException } from 'hono/http-exception'
|
||||
|
||||
describe('AiUsageService', () => {
|
||||
setupTestDbHooks()
|
||||
|
||||
async function createTestTeamAndUser() {
|
||||
const user = await prisma.user.create({
|
||||
data: {
|
||||
name: 'Usage Test User',
|
||||
email: `usage-test-${Date.now()}-${Math.random()}@example.com`,
|
||||
},
|
||||
})
|
||||
|
||||
const team = await prisma.team.create({
|
||||
data: {
|
||||
name: 'Usage Test Team',
|
||||
},
|
||||
})
|
||||
|
||||
const teamMember = await prisma.teamMember.create({
|
||||
data: {
|
||||
teamId: team.id,
|
||||
userId: user.id,
|
||||
role: 'owner',
|
||||
},
|
||||
})
|
||||
|
||||
return { user, team, teamMember }
|
||||
}
|
||||
|
||||
it('records usage for both team total and specific member', async () => {
|
||||
const { team, user } = await createTestTeamAndUser()
|
||||
|
||||
const now = new Date()
|
||||
await aiUsageService.recordUsage({
|
||||
teamId: team.id,
|
||||
userId: user.id,
|
||||
inputTokens: 100,
|
||||
outputTokens: 50,
|
||||
cacheReadTokens: 20,
|
||||
totalTokens: 150,
|
||||
cost: 0.001,
|
||||
timestamp: now,
|
||||
})
|
||||
|
||||
// Verify database rows
|
||||
const records = await prisma.aiUsage.findMany({
|
||||
where: { teamId: team.id },
|
||||
})
|
||||
|
||||
expect(records).toHaveLength(2)
|
||||
|
||||
const teamRecord = records.find((r) => r.userId === null)
|
||||
expect(teamRecord).toBeDefined()
|
||||
expect(teamRecord?.inputTokens).toBe(100)
|
||||
expect(teamRecord?.outputTokens).toBe(50)
|
||||
expect(teamRecord?.cacheReadTokens).toBe(20)
|
||||
expect(teamRecord?.totalTokens).toBe(150)
|
||||
expect(teamRecord?.cost).toBeCloseTo(0.001)
|
||||
|
||||
const memberRecord = records.find((r) => r.userId === user.id)
|
||||
expect(memberRecord).toBeDefined()
|
||||
expect(memberRecord?.inputTokens).toBe(100)
|
||||
expect(memberRecord?.outputTokens).toBe(50)
|
||||
expect(memberRecord?.cacheReadTokens).toBe(20)
|
||||
expect(memberRecord?.totalTokens).toBe(150)
|
||||
expect(memberRecord?.cost).toBeCloseTo(0.001)
|
||||
})
|
||||
|
||||
it('increments existing hourly buckets for team and member', async () => {
|
||||
const { team, user } = await createTestTeamAndUser()
|
||||
|
||||
const now = new Date()
|
||||
await aiUsageService.recordUsage({
|
||||
teamId: team.id,
|
||||
userId: user.id,
|
||||
inputTokens: 100,
|
||||
outputTokens: 50,
|
||||
cacheReadTokens: 10,
|
||||
totalTokens: 150,
|
||||
cost: 0.001,
|
||||
timestamp: now,
|
||||
})
|
||||
|
||||
await aiUsageService.recordUsage({
|
||||
teamId: team.id,
|
||||
userId: user.id,
|
||||
inputTokens: 200,
|
||||
outputTokens: 100,
|
||||
cacheReadTokens: 30,
|
||||
totalTokens: 300,
|
||||
cost: 0.002,
|
||||
timestamp: now,
|
||||
})
|
||||
|
||||
const teamStats = await aiUsageService.getTeamUsageStats({
|
||||
teamId: team.id,
|
||||
timeframe: '1h',
|
||||
})
|
||||
|
||||
expect(teamStats.team).toBeDefined()
|
||||
expect(teamStats.team?.inputTokens).toBe(300)
|
||||
expect(teamStats.team?.outputTokens).toBe(150)
|
||||
expect(teamStats.team?.cacheReadTokens).toBe(40)
|
||||
expect(teamStats.team?.totalTokens).toBe(450)
|
||||
expect(teamStats.team?.cost).toBeCloseTo(0.003)
|
||||
|
||||
const memberStats = await aiUsageService.getTeamUsageStats({
|
||||
teamId: team.id,
|
||||
timeframe: '1h',
|
||||
userId: user.id,
|
||||
})
|
||||
|
||||
expect(memberStats.member).toBeDefined()
|
||||
expect(memberStats.member?.userId).toBe(user.id)
|
||||
expect(memberStats.member?.inputTokens).toBe(300)
|
||||
expect(memberStats.member?.outputTokens).toBe(150)
|
||||
expect(memberStats.member?.cacheReadTokens).toBe(40)
|
||||
expect(memberStats.member?.totalTokens).toBe(450)
|
||||
expect(memberStats.member?.cost).toBeCloseTo(0.003)
|
||||
})
|
||||
|
||||
it('handles background system tasks with no userId', async () => {
|
||||
const { team } = await createTestTeamAndUser()
|
||||
|
||||
await aiUsageService.recordUsage({
|
||||
teamId: team.id,
|
||||
userId: null,
|
||||
inputTokens: 50,
|
||||
outputTokens: 25,
|
||||
cacheReadTokens: 5,
|
||||
totalTokens: 75,
|
||||
cost: 0.0005,
|
||||
})
|
||||
|
||||
const records = await prisma.aiUsage.findMany({
|
||||
where: { teamId: team.id },
|
||||
})
|
||||
|
||||
expect(records).toHaveLength(1)
|
||||
expect(records[0].userId).toBeNull()
|
||||
expect(records[0].inputTokens).toBe(50)
|
||||
})
|
||||
|
||||
it('filters statistics correctly by timeframe', async () => {
|
||||
vi.useFakeTimers()
|
||||
const now = new Date('2026-07-23T15:30:00Z')
|
||||
vi.setSystemTime(now)
|
||||
|
||||
try {
|
||||
const { team, user } = await createTestTeamAndUser()
|
||||
|
||||
// 5 minutes ago (within current 1h bucket)
|
||||
const recent = new Date(now.getTime() - 5 * 60 * 1000)
|
||||
// 2 hours ago (within 24h, outside 1h)
|
||||
const twoHoursAgo = new Date(now.getTime() - 2 * 60 * 60 * 1000)
|
||||
// 3 days ago (within 7d, outside 24h)
|
||||
const threeDaysAgo = new Date(now.getTime() - 3 * 24 * 60 * 60 * 1000)
|
||||
|
||||
await aiUsageService.recordUsage({
|
||||
teamId: team.id,
|
||||
userId: user.id,
|
||||
inputTokens: 100,
|
||||
outputTokens: 50,
|
||||
cacheReadTokens: 10,
|
||||
totalTokens: 150,
|
||||
cost: 0.001,
|
||||
timestamp: recent,
|
||||
})
|
||||
|
||||
await aiUsageService.recordUsage({
|
||||
teamId: team.id,
|
||||
userId: user.id,
|
||||
inputTokens: 200,
|
||||
outputTokens: 100,
|
||||
cacheReadTokens: 20,
|
||||
totalTokens: 300,
|
||||
cost: 0.002,
|
||||
timestamp: twoHoursAgo,
|
||||
})
|
||||
|
||||
await aiUsageService.recordUsage({
|
||||
teamId: team.id,
|
||||
userId: user.id,
|
||||
inputTokens: 400,
|
||||
outputTokens: 200,
|
||||
cacheReadTokens: 40,
|
||||
totalTokens: 600,
|
||||
cost: 0.004,
|
||||
timestamp: threeDaysAgo,
|
||||
})
|
||||
|
||||
// 1h timeframe should only include recent
|
||||
const stats1h = await aiUsageService.getTeamUsageStats({
|
||||
teamId: team.id,
|
||||
timeframe: '1h',
|
||||
})
|
||||
expect(stats1h.team?.inputTokens).toBe(100)
|
||||
|
||||
// 24h timeframe should include recent + 2 hours ago
|
||||
const stats24h = await aiUsageService.getTeamUsageStats({
|
||||
teamId: team.id,
|
||||
timeframe: '24h',
|
||||
})
|
||||
expect(stats24h.team?.inputTokens).toBe(300)
|
||||
|
||||
// 7d timeframe should include all 3
|
||||
const stats7d = await aiUsageService.getTeamUsageStats({
|
||||
teamId: team.id,
|
||||
timeframe: '7d',
|
||||
})
|
||||
expect(stats7d.team?.inputTokens).toBe(700)
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
|
||||
it('throws 404 when querying non-existent team member', async () => {
|
||||
const { team } = await createTestTeamAndUser()
|
||||
|
||||
await expect(
|
||||
aiUsageService.getTeamUsageStats({
|
||||
teamId: team.id,
|
||||
timeframe: '30d',
|
||||
userId: 'non-existent-user-id',
|
||||
}),
|
||||
).rejects.toThrow(HTTPException)
|
||||
})
|
||||
|
||||
it('targets only current hour bucket for 1h timeframe instead of including previous hour bucket', async () => {
|
||||
const { team, user } = await createTestTeamAndUser()
|
||||
|
||||
// 10:15 AM (previous hour)
|
||||
const prevHour = new Date('2026-07-23T10:15:00Z')
|
||||
// 11:10 AM (current hour)
|
||||
const currHour = new Date('2026-07-23T11:10:00Z')
|
||||
|
||||
await aiUsageService.recordUsage({
|
||||
teamId: team.id,
|
||||
userId: user.id,
|
||||
inputTokens: 100,
|
||||
outputTokens: 0,
|
||||
cacheReadTokens: 0,
|
||||
totalTokens: 100,
|
||||
cost: 0.001,
|
||||
timestamp: prevHour,
|
||||
})
|
||||
|
||||
await aiUsageService.recordUsage({
|
||||
teamId: team.id,
|
||||
userId: user.id,
|
||||
inputTokens: 50,
|
||||
outputTokens: 0,
|
||||
cacheReadTokens: 0,
|
||||
totalTokens: 50,
|
||||
cost: 0.0005,
|
||||
timestamp: currHour,
|
||||
})
|
||||
|
||||
vi.useFakeTimers()
|
||||
vi.setSystemTime(new Date('2026-07-23T11:15:00Z'))
|
||||
|
||||
try {
|
||||
const stats1h = await aiUsageService.getTeamUsageStats({
|
||||
teamId: team.id,
|
||||
timeframe: '1h',
|
||||
})
|
||||
expect(stats1h.team?.inputTokens).toBe(50)
|
||||
} finally {
|
||||
vi.useRealTimers()
|
||||
}
|
||||
})
|
||||
|
||||
it('handles concurrent recordUsage calls for the same team and user without duplication or race errors', async () => {
|
||||
const { team, user } = await createTestTeamAndUser()
|
||||
const now = new Date()
|
||||
|
||||
await Promise.all([
|
||||
aiUsageService.recordUsage({
|
||||
teamId: team.id,
|
||||
userId: user.id,
|
||||
inputTokens: 100,
|
||||
outputTokens: 50,
|
||||
cacheReadTokens: 10,
|
||||
totalTokens: 150,
|
||||
cost: 0.001,
|
||||
timestamp: now,
|
||||
}),
|
||||
aiUsageService.recordUsage({
|
||||
teamId: team.id,
|
||||
userId: user.id,
|
||||
inputTokens: 200,
|
||||
outputTokens: 100,
|
||||
cacheReadTokens: 20,
|
||||
totalTokens: 300,
|
||||
cost: 0.002,
|
||||
timestamp: now,
|
||||
}),
|
||||
])
|
||||
|
||||
const stats = await aiUsageService.getTeamUsageStats({
|
||||
teamId: team.id,
|
||||
timeframe: '1h',
|
||||
})
|
||||
|
||||
expect(stats.team?.inputTokens).toBe(300)
|
||||
expect(stats.team?.outputTokens).toBe(150)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,263 @@
|
||||
import { prisma, Prisma } from '@shumai/db'
|
||||
import type { TeamUsageStatsResponse, Timeframe } from '@shumai/dtos'
|
||||
import { HTTPException } from 'hono/http-exception'
|
||||
|
||||
export interface RecordUsageParams {
|
||||
teamId: string
|
||||
userId?: string | null
|
||||
inputTokens: number
|
||||
outputTokens: number
|
||||
cacheReadTokens: number
|
||||
totalTokens: number
|
||||
cost: number
|
||||
timestamp?: Date
|
||||
}
|
||||
|
||||
export interface GetTeamUsageStatsParams {
|
||||
teamId: string
|
||||
timeframe: Timeframe
|
||||
userId?: string
|
||||
}
|
||||
|
||||
export class AiUsageService {
|
||||
private async incrementBucket(params: {
|
||||
teamId: string
|
||||
userId: string | null
|
||||
periodStart: Date
|
||||
inputTokens: number
|
||||
outputTokens: number
|
||||
cacheReadTokens: number
|
||||
totalTokens: number
|
||||
cost: number
|
||||
}): Promise<void> {
|
||||
if (params.userId !== null) {
|
||||
await prisma.aiUsage.upsert({
|
||||
where: {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
teamId_userId_periodStart: {
|
||||
teamId: params.teamId,
|
||||
userId: params.userId,
|
||||
periodStart: params.periodStart,
|
||||
},
|
||||
},
|
||||
update: {
|
||||
inputTokens: { increment: params.inputTokens },
|
||||
outputTokens: { increment: params.outputTokens },
|
||||
cacheReadTokens: { increment: params.cacheReadTokens },
|
||||
totalTokens: { increment: params.totalTokens },
|
||||
cost: { increment: params.cost },
|
||||
},
|
||||
create: {
|
||||
teamId: params.teamId,
|
||||
userId: params.userId,
|
||||
periodStart: params.periodStart,
|
||||
inputTokens: params.inputTokens,
|
||||
outputTokens: params.outputTokens,
|
||||
cacheReadTokens: params.cacheReadTokens,
|
||||
totalTokens: params.totalTokens,
|
||||
cost: params.cost,
|
||||
},
|
||||
})
|
||||
} else {
|
||||
const existing = await prisma.aiUsage.findFirst({
|
||||
where: {
|
||||
teamId: params.teamId,
|
||||
userId: null,
|
||||
periodStart: params.periodStart,
|
||||
},
|
||||
})
|
||||
|
||||
if (existing) {
|
||||
await prisma.aiUsage.update({
|
||||
where: { id: existing.id },
|
||||
data: {
|
||||
inputTokens: { increment: params.inputTokens },
|
||||
outputTokens: { increment: params.outputTokens },
|
||||
cacheReadTokens: { increment: params.cacheReadTokens },
|
||||
totalTokens: { increment: params.totalTokens },
|
||||
cost: { increment: params.cost },
|
||||
},
|
||||
})
|
||||
} else {
|
||||
try {
|
||||
await prisma.aiUsage.create({
|
||||
data: {
|
||||
teamId: params.teamId,
|
||||
userId: null,
|
||||
periodStart: params.periodStart,
|
||||
inputTokens: params.inputTokens,
|
||||
outputTokens: params.outputTokens,
|
||||
cacheReadTokens: params.cacheReadTokens,
|
||||
totalTokens: params.totalTokens,
|
||||
cost: params.cost,
|
||||
},
|
||||
})
|
||||
} catch (err) {
|
||||
if (err instanceof Prisma.PrismaClientKnownRequestError && err.code === 'P2002') {
|
||||
await prisma.aiUsage.updateMany({
|
||||
where: {
|
||||
teamId: params.teamId,
|
||||
userId: null,
|
||||
periodStart: params.periodStart,
|
||||
},
|
||||
data: {
|
||||
inputTokens: { increment: params.inputTokens },
|
||||
outputTokens: { increment: params.outputTokens },
|
||||
cacheReadTokens: { increment: params.cacheReadTokens },
|
||||
totalTokens: { increment: params.totalTokens },
|
||||
cost: { increment: params.cost },
|
||||
},
|
||||
})
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async recordUsage(params: RecordUsageParams): Promise<void> {
|
||||
const timestamp = params.timestamp ?? new Date()
|
||||
const periodStart = new Date(timestamp)
|
||||
periodStart.setMinutes(0, 0, 0)
|
||||
|
||||
// 1. Update/create Team Total record (userId = null)
|
||||
await this.incrementBucket({
|
||||
teamId: params.teamId,
|
||||
userId: null,
|
||||
periodStart,
|
||||
inputTokens: params.inputTokens,
|
||||
outputTokens: params.outputTokens,
|
||||
cacheReadTokens: params.cacheReadTokens,
|
||||
totalTokens: params.totalTokens,
|
||||
cost: params.cost,
|
||||
})
|
||||
|
||||
// 2. If triggered by a team member, update/create Member Usage record (userId = params.userId)
|
||||
if (params.userId) {
|
||||
await this.incrementBucket({
|
||||
teamId: params.teamId,
|
||||
userId: params.userId,
|
||||
periodStart,
|
||||
inputTokens: params.inputTokens,
|
||||
outputTokens: params.outputTokens,
|
||||
cacheReadTokens: params.cacheReadTokens,
|
||||
totalTokens: params.totalTokens,
|
||||
cost: params.cost,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async getTeamUsageStats(params: GetTeamUsageStatsParams): Promise<TeamUsageStatsResponse> {
|
||||
const now = new Date()
|
||||
const since = new Date(now)
|
||||
|
||||
switch (params.timeframe) {
|
||||
case '1h':
|
||||
// For 1h, target the current 1h bucket floored to start of current hour
|
||||
since.setMinutes(0, 0, 0)
|
||||
break
|
||||
case '24h':
|
||||
since.setDate(since.getDate() - 1)
|
||||
since.setMinutes(0, 0, 0)
|
||||
break
|
||||
case '7d':
|
||||
since.setDate(since.getDate() - 7)
|
||||
since.setMinutes(0, 0, 0)
|
||||
break
|
||||
case '30d':
|
||||
since.setDate(since.getDate() - 30)
|
||||
since.setMinutes(0, 0, 0)
|
||||
break
|
||||
}
|
||||
|
||||
if (!params.userId) {
|
||||
// Return Team-Level Usage (userId = null)
|
||||
const teamRecords = await prisma.aiUsage.findMany({
|
||||
where: {
|
||||
teamId: params.teamId,
|
||||
userId: null,
|
||||
periodStart: { gte: since },
|
||||
},
|
||||
})
|
||||
|
||||
let inputTokens = 0
|
||||
let outputTokens = 0
|
||||
let cacheReadTokens = 0
|
||||
let totalTokens = 0
|
||||
let cost = 0
|
||||
|
||||
for (const r of teamRecords) {
|
||||
inputTokens += r.inputTokens
|
||||
outputTokens += r.outputTokens
|
||||
cacheReadTokens += r.cacheReadTokens
|
||||
totalTokens += r.totalTokens
|
||||
cost += r.cost
|
||||
}
|
||||
|
||||
return {
|
||||
timeframe: params.timeframe,
|
||||
team: {
|
||||
inputTokens,
|
||||
outputTokens,
|
||||
cacheReadTokens,
|
||||
totalTokens,
|
||||
cost: Math.round((cost + Number.EPSILON) * 1000000) / 1000000,
|
||||
},
|
||||
}
|
||||
} else {
|
||||
// Return Specific Member Usage
|
||||
const teamMember = await prisma.teamMember.findFirst({
|
||||
where: {
|
||||
teamId: params.teamId,
|
||||
userId: params.userId,
|
||||
},
|
||||
include: { user: true },
|
||||
})
|
||||
|
||||
if (!teamMember) {
|
||||
throw new HTTPException(404, { message: 'Team member not found' })
|
||||
}
|
||||
|
||||
const memberRecords = await prisma.aiUsage.findMany({
|
||||
where: {
|
||||
teamId: params.teamId,
|
||||
userId: params.userId,
|
||||
periodStart: { gte: since },
|
||||
},
|
||||
})
|
||||
|
||||
let inputTokens = 0
|
||||
let outputTokens = 0
|
||||
let cacheReadTokens = 0
|
||||
let totalTokens = 0
|
||||
let cost = 0
|
||||
|
||||
for (const r of memberRecords) {
|
||||
inputTokens += r.inputTokens
|
||||
outputTokens += r.outputTokens
|
||||
cacheReadTokens += r.cacheReadTokens
|
||||
totalTokens += r.totalTokens
|
||||
cost += r.cost
|
||||
}
|
||||
|
||||
return {
|
||||
timeframe: params.timeframe,
|
||||
member: {
|
||||
userId: teamMember.user.id,
|
||||
userName: teamMember.user.name,
|
||||
userEmail: teamMember.user.email,
|
||||
userImage: teamMember.user.image,
|
||||
role: teamMember.role,
|
||||
inputTokens,
|
||||
outputTokens,
|
||||
cacheReadTokens,
|
||||
totalTokens,
|
||||
cost: Math.round((cost + Number.EPSILON) * 1000000) / 1000000,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const aiUsageService = new AiUsageService()
|
||||
@@ -21,3 +21,4 @@ export * from './versionStack/versionStack'
|
||||
export * from './hyrumtoken'
|
||||
export * from './pagination'
|
||||
export * from './chat/chat'
|
||||
export * from './ai-usage/ai-usage'
|
||||
|
||||
@@ -127,6 +127,7 @@ describe('SearchService', () => {
|
||||
// String fields
|
||||
await createWithMeta('str-apple', { text: 'apple' })
|
||||
await createWithMeta('str-banana', { text: 'banana' })
|
||||
await createWithMeta('sku-1-2', { sku: '1-2' })
|
||||
|
||||
// Number fields
|
||||
await createWithMeta('num-10', { num: 10 })
|
||||
@@ -181,6 +182,7 @@ describe('SearchService', () => {
|
||||
val: 'str-apple',
|
||||
expected: [
|
||||
'str-banana',
|
||||
'sku-1-2',
|
||||
'num-10',
|
||||
'num-20',
|
||||
'bool-true',
|
||||
@@ -200,6 +202,7 @@ describe('SearchService', () => {
|
||||
val: 'apple',
|
||||
expected: [
|
||||
'str-banana',
|
||||
'sku-1-2',
|
||||
'num-10',
|
||||
'num-20',
|
||||
'bool-true',
|
||||
@@ -220,6 +223,7 @@ describe('SearchService', () => {
|
||||
expected: [
|
||||
'str-apple',
|
||||
'str-banana',
|
||||
'sku-1-2',
|
||||
'num-10',
|
||||
'num-20',
|
||||
'bool-true',
|
||||
@@ -235,12 +239,14 @@ describe('SearchService', () => {
|
||||
|
||||
// String Metadata
|
||||
{ field: 'text', op: 'eq', val: 'apple', expected: ['str-apple'] },
|
||||
{ field: 'sku', op: 'eq', val: '1-2', expected: ['sku-1-2'] },
|
||||
{
|
||||
field: 'text',
|
||||
op: 'neq',
|
||||
val: 'apple',
|
||||
expected: [
|
||||
'str-banana',
|
||||
'sku-1-2',
|
||||
'num-10',
|
||||
'num-20',
|
||||
'bool-true',
|
||||
@@ -258,6 +264,7 @@ describe('SearchService', () => {
|
||||
op: 'isEmpty',
|
||||
val: null,
|
||||
expected: [
|
||||
'sku-1-2',
|
||||
'num-10',
|
||||
'num-20',
|
||||
'bool-true',
|
||||
@@ -281,6 +288,7 @@ describe('SearchService', () => {
|
||||
expected: [
|
||||
'str-apple',
|
||||
'str-banana',
|
||||
'sku-1-2',
|
||||
'num-20',
|
||||
'bool-true',
|
||||
'bool-false',
|
||||
@@ -293,6 +301,7 @@ describe('SearchService', () => {
|
||||
],
|
||||
},
|
||||
{ field: 'num', op: 'gt', val: 15, expected: ['num-20'] },
|
||||
{ field: 'num', op: 'gt', val: 100, expected: [] },
|
||||
{ field: 'num', op: 'lt', val: 15, expected: ['num-10'] },
|
||||
{ field: 'num', op: 'gte', val: 20, expected: ['num-20'] },
|
||||
{ field: 'num', op: 'lte', val: 10, expected: ['num-10'] },
|
||||
@@ -314,6 +323,7 @@ describe('SearchService', () => {
|
||||
expected: [
|
||||
'str-apple',
|
||||
'str-banana',
|
||||
'sku-1-2',
|
||||
'num-10',
|
||||
'num-20',
|
||||
'bool-true',
|
||||
@@ -332,6 +342,7 @@ describe('SearchService', () => {
|
||||
expected: [
|
||||
'str-apple',
|
||||
'str-banana',
|
||||
'sku-1-2',
|
||||
'num-10',
|
||||
'num-20',
|
||||
'bool-true',
|
||||
@@ -346,6 +357,7 @@ describe('SearchService', () => {
|
||||
|
||||
// Date Metadata
|
||||
{ field: 'date', op: 'eq', val: 'today', expected: ['date-today'] },
|
||||
{ field: 'date', op: 'lte', val: 'today', expected: ['date-today', 'date-yesterday'] },
|
||||
{ field: 'date', op: 'isWithin', val: 'today', expected: ['date-today'] },
|
||||
{ field: 'date', op: 'lt', val: 'today', expected: ['date-yesterday'] },
|
||||
{ field: 'date', op: 'gt', val: 'yesterday', expected: ['date-today'] },
|
||||
@@ -358,6 +370,7 @@ describe('SearchService', () => {
|
||||
expected: [
|
||||
'str-apple',
|
||||
'str-banana',
|
||||
'sku-1-2',
|
||||
'num-10',
|
||||
'num-20',
|
||||
'bool-true',
|
||||
@@ -378,6 +391,47 @@ describe('SearchService', () => {
|
||||
expected: [
|
||||
'str-apple',
|
||||
'str-banana',
|
||||
'sku-1-2',
|
||||
'num-10',
|
||||
'num-20',
|
||||
'bool-true',
|
||||
'bool-false',
|
||||
'multi-a-b',
|
||||
'multi-b-c',
|
||||
'date-today',
|
||||
'date-yesterday',
|
||||
'name-contains-test',
|
||||
'nothing',
|
||||
],
|
||||
},
|
||||
{
|
||||
field: 'createdAt',
|
||||
op: 'eq',
|
||||
val: 'today',
|
||||
expected: [
|
||||
'str-apple',
|
||||
'str-banana',
|
||||
'sku-1-2',
|
||||
'num-10',
|
||||
'num-20',
|
||||
'bool-true',
|
||||
'bool-false',
|
||||
'multi-a-b',
|
||||
'multi-b-c',
|
||||
'date-today',
|
||||
'date-yesterday',
|
||||
'name-contains-test',
|
||||
'nothing',
|
||||
],
|
||||
},
|
||||
{
|
||||
field: 'createdAt',
|
||||
op: 'lte',
|
||||
val: 'today',
|
||||
expected: [
|
||||
'str-apple',
|
||||
'str-banana',
|
||||
'sku-1-2',
|
||||
'num-10',
|
||||
'num-20',
|
||||
'bool-true',
|
||||
|
||||
@@ -35,4 +35,76 @@ describe('SqlQueryBuilder', () => {
|
||||
const builder = new SqlQueryBuilder().select(Prisma.sql`id`)
|
||||
expect(() => builder.build()).toThrow('FROM clause is required')
|
||||
})
|
||||
|
||||
describe('Bug Reproduction Tests for buildSqlCondition', () => {
|
||||
it('Bug 1: createdAt eq date should match full day range (>= startOfDay AND <= endOfDay)', () => {
|
||||
const builder = new SqlQueryBuilder()
|
||||
.from(Prisma.sql`assets a`)
|
||||
.addSearchConditions('AND', [{ field: 'createdAt', operator: 'eq', value: '2026-07-22' }])
|
||||
|
||||
const query = builder.build()
|
||||
expect(query.text).toBe(
|
||||
'SELECT * FROM assets a WHERE (a."created_at" >= $1 AND a."created_at" <= $2)',
|
||||
)
|
||||
const startVal = query.values[0] as Date
|
||||
const endVal = query.values[1] as Date
|
||||
expect(startVal.getHours()).toBe(0)
|
||||
expect(startVal.getMinutes()).toBe(0)
|
||||
expect(startVal.getSeconds()).toBe(0)
|
||||
expect(endVal.getHours()).toBe(23)
|
||||
expect(endVal.getMinutes()).toBe(59)
|
||||
expect(endVal.getSeconds()).toBe(59)
|
||||
})
|
||||
|
||||
it('Bug 2: createdAt lte date should use end-of-day timestamp (23:59:59.999)', () => {
|
||||
const builder = new SqlQueryBuilder()
|
||||
.from(Prisma.sql`assets a`)
|
||||
.addSearchConditions('AND', [{ field: 'createdAt', operator: 'lte', value: '2026-07-22' }])
|
||||
|
||||
const query = builder.build()
|
||||
expect(query.text).toBe('SELECT * FROM assets a WHERE (a."created_at" <= $1)')
|
||||
const endVal = query.values[0] as Date
|
||||
expect(endVal.getHours()).toBe(23)
|
||||
expect(endVal.getMinutes()).toBe(59)
|
||||
expect(endVal.getSeconds()).toBe(59)
|
||||
})
|
||||
|
||||
it('Bug 3: custom metadata numeric query should ONLY query number_value', () => {
|
||||
const builder = new SqlQueryBuilder()
|
||||
.from(Prisma.sql`assets a`)
|
||||
.addSearchConditions('AND', [{ field: 'rating', operator: 'gt', value: 100 }])
|
||||
|
||||
const query = builder.build()
|
||||
expect(query.text).toBe(
|
||||
'SELECT * FROM assets a WHERE (a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = $1 AND number_value > $2))',
|
||||
)
|
||||
expect(query.values).toEqual(['rating', 100])
|
||||
})
|
||||
|
||||
it('Bug 4: isDate should not misclassify dash-separated non-date string values like "1-2"', () => {
|
||||
const builder = new SqlQueryBuilder()
|
||||
.from(Prisma.sql`assets a`)
|
||||
.addSearchConditions('AND', [{ field: 'sku', operator: 'eq', value: '1-2' }])
|
||||
|
||||
const query = builder.build()
|
||||
expect(query.text).toBe(
|
||||
'SELECT * FROM assets a WHERE (a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = $1 AND string_value = $2))',
|
||||
)
|
||||
expect(query.values).toEqual(['sku', '1-2'])
|
||||
})
|
||||
|
||||
it('Bug 5: custom field names with special characters are safely parameterized', () => {
|
||||
const builder = new SqlQueryBuilder()
|
||||
.from(Prisma.sql`assets a`)
|
||||
.addSearchConditions('AND', [
|
||||
{ field: 'custom_field"test', operator: 'eq', value: 'hello' },
|
||||
])
|
||||
|
||||
const query = builder.build()
|
||||
expect(query.text).toBe(
|
||||
'SELECT * FROM assets a WHERE (a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = $1 AND string_value = $2))',
|
||||
)
|
||||
expect(query.values).toEqual(['custom_field"test', 'hello'])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -101,7 +101,7 @@ export class SqlQueryBuilder {
|
||||
private isDate(value: unknown): boolean {
|
||||
if (value instanceof Date) return true
|
||||
if (typeof value !== 'string') return false
|
||||
const valStr = value.toLowerCase()
|
||||
const valStr = value.trim().toLowerCase()
|
||||
const relativeKeywords = [
|
||||
'today',
|
||||
'yesterday',
|
||||
@@ -111,11 +111,14 @@ export class SqlQueryBuilder {
|
||||
'one month ago',
|
||||
'one month from now',
|
||||
]
|
||||
if (relativeKeywords.includes(valStr) || valStr.match(/\d+\s+days?\s+(ago|from\s+now)/)) {
|
||||
if (relativeKeywords.includes(valStr) || valStr.match(/^\d+\s+days?\s+(ago|from\s+now)$/)) {
|
||||
return true
|
||||
}
|
||||
if (!valStr.match(/^\d{4}-\d{2}-\d{2}/)) {
|
||||
return false
|
||||
}
|
||||
const d = new Date(value)
|
||||
return !isNaN(d.getTime()) && value.includes('-')
|
||||
return !isNaN(d.getTime())
|
||||
}
|
||||
|
||||
private toDate(value: unknown): Date {
|
||||
@@ -123,12 +126,8 @@ export class SqlQueryBuilder {
|
||||
}
|
||||
|
||||
private toDateBound(value: unknown, bound: 'start' | 'end'): Date {
|
||||
const d = this.parseRelativeDate(value)
|
||||
if (d instanceof Date) return d
|
||||
if (d && 'gte' in d && 'lte' in d) {
|
||||
return bound === 'start' ? d.gte! : d.lte!
|
||||
}
|
||||
return new Date(value as string)
|
||||
const range = this.parseDateRange(value)
|
||||
return bound === 'start' ? range.start : range.end
|
||||
}
|
||||
|
||||
private parseDateRange(value: unknown): { start: Date; end: Date } {
|
||||
@@ -137,6 +136,11 @@ export class SqlQueryBuilder {
|
||||
return { start: d.gte!, end: d.lte! }
|
||||
}
|
||||
const date = d instanceof Date ? d : new Date(value as string)
|
||||
const valStr = typeof value === 'string' ? value : ''
|
||||
const hasTime = valStr.includes('T') || valStr.includes(':')
|
||||
if (hasTime) {
|
||||
return { start: date, end: date }
|
||||
}
|
||||
const start = new Date(date)
|
||||
start.setHours(0, 0, 0, 0)
|
||||
const end = new Date(date)
|
||||
@@ -239,18 +243,8 @@ export class SqlQueryBuilder {
|
||||
}
|
||||
|
||||
private buildSqlCondition(field: string, operator: string, value: unknown): Prisma.Sql | null {
|
||||
const colName =
|
||||
field === 'sizeByte' || field === 'size_byte'
|
||||
? 'size_byte'
|
||||
: field === 'createdAt' || field === 'created_at'
|
||||
? 'created_at'
|
||||
: field === 'updatedAt' || field === 'updated_at'
|
||||
? 'updated_at'
|
||||
: field
|
||||
|
||||
const dbCol = Prisma.raw(`a."${colName}"`)
|
||||
|
||||
if (field === 'name') {
|
||||
const dbCol = Prisma.raw(`a."name"`)
|
||||
const valStr = String(value)
|
||||
switch (operator) {
|
||||
case 'eq':
|
||||
@@ -271,6 +265,7 @@ export class SqlQueryBuilder {
|
||||
}
|
||||
|
||||
if (field === 'sizeByte' || field === 'size_byte') {
|
||||
const dbCol = Prisma.raw(`a."size_byte"`)
|
||||
const valNum = Number(value)
|
||||
switch (operator) {
|
||||
case 'eq':
|
||||
@@ -296,12 +291,17 @@ export class SqlQueryBuilder {
|
||||
field === 'created_at' ||
|
||||
field === 'updated_at'
|
||||
) {
|
||||
const valDate = this.toDate(value)
|
||||
const colName = field === 'createdAt' || field === 'created_at' ? 'created_at' : 'updated_at'
|
||||
const dbCol = Prisma.raw(`a."${colName}"`)
|
||||
switch (operator) {
|
||||
case 'eq':
|
||||
return Prisma.sql`${dbCol} = ${valDate}`
|
||||
case 'neq':
|
||||
return Prisma.sql`${dbCol} != ${valDate}`
|
||||
case 'eq': {
|
||||
const range = this.parseDateRange(value)
|
||||
return Prisma.sql`${dbCol} >= ${range.start} AND ${dbCol} <= ${range.end}`
|
||||
}
|
||||
case 'neq': {
|
||||
const range = this.parseDateRange(value)
|
||||
return Prisma.sql`(${dbCol} < ${range.start} OR ${dbCol} > ${range.end})`
|
||||
}
|
||||
case 'gt':
|
||||
return Prisma.sql`${dbCol} > ${this.toDateBound(value, 'end')}`
|
||||
case 'gte':
|
||||
@@ -333,14 +333,42 @@ export class SqlQueryBuilder {
|
||||
const matchSql = this.buildEavValueMatch(value)
|
||||
return Prisma.sql`a.id NOT IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${field}) OR a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${field} AND NOT (${matchSql}))`
|
||||
}
|
||||
case 'gt':
|
||||
return Prisma.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${field} AND (number_value > ${Number(value)} OR date_value > ${this.toDateBound(value, 'end')}))`
|
||||
case 'gte':
|
||||
return Prisma.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${field} AND (number_value >= ${Number(value)} OR date_value >= ${this.toDateBound(value, 'start')}))`
|
||||
case 'lt':
|
||||
return Prisma.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${field} AND (number_value < ${Number(value)} OR date_value < ${this.toDateBound(value, 'start')}))`
|
||||
case 'lte':
|
||||
return Prisma.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${field} AND (number_value <= ${Number(value)} OR date_value <= ${this.toDateBound(value, 'end')}))`
|
||||
case 'gt': {
|
||||
if (
|
||||
typeof value === 'number' ||
|
||||
(typeof value === 'string' && !isNaN(Number(value)) && !this.isDate(value))
|
||||
) {
|
||||
return Prisma.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${field} AND number_value > ${Number(value)})`
|
||||
}
|
||||
return Prisma.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${field} AND date_value > ${this.toDateBound(value, 'end')})`
|
||||
}
|
||||
case 'gte': {
|
||||
if (
|
||||
typeof value === 'number' ||
|
||||
(typeof value === 'string' && !isNaN(Number(value)) && !this.isDate(value))
|
||||
) {
|
||||
return Prisma.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${field} AND number_value >= ${Number(value)})`
|
||||
}
|
||||
return Prisma.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${field} AND date_value >= ${this.toDateBound(value, 'start')})`
|
||||
}
|
||||
case 'lt': {
|
||||
if (
|
||||
typeof value === 'number' ||
|
||||
(typeof value === 'string' && !isNaN(Number(value)) && !this.isDate(value))
|
||||
) {
|
||||
return Prisma.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${field} AND number_value < ${Number(value)})`
|
||||
}
|
||||
return Prisma.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${field} AND date_value < ${this.toDateBound(value, 'start')})`
|
||||
}
|
||||
case 'lte': {
|
||||
if (
|
||||
typeof value === 'number' ||
|
||||
(typeof value === 'string' && !isNaN(Number(value)) && !this.isDate(value))
|
||||
) {
|
||||
return Prisma.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${field} AND number_value <= ${Number(value)})`
|
||||
}
|
||||
return Prisma.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${field} AND date_value <= ${this.toDateBound(value, 'end')})`
|
||||
}
|
||||
case 'contains':
|
||||
return Prisma.sql`a.id IN (SELECT asset_id FROM asset_metadata_values WHERE field_key = ${field} AND string_value ILIKE ${'%' + String(value) + '%'})`
|
||||
case 'notContains':
|
||||
|
||||
@@ -3,6 +3,7 @@ import { transcodeService } from './transcode'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import * as path from 'path'
|
||||
import * as child_process from 'child_process'
|
||||
import { execFile } from 'child_process'
|
||||
import * as fs from 'fs'
|
||||
import { WorkflowTask } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db/test'
|
||||
@@ -24,6 +25,7 @@ vi.mock('child_process', () => ({
|
||||
vi.mock('sharp', () => {
|
||||
const mockSharp = {
|
||||
resize: vi.fn().mockReturnThis(),
|
||||
toColorspace: vi.fn().mockReturnThis(),
|
||||
webp: vi.fn().mockReturnThis(),
|
||||
composite: vi.fn().mockReturnThis(),
|
||||
toBuffer: vi.fn().mockResolvedValue(Buffer.from('fake-webp-buffer')),
|
||||
@@ -182,17 +184,62 @@ describe('TranscodeService', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('should use sharp for image transcoding', async () => {
|
||||
it('should use sharp for image transcoding with sRGB conversion', async () => {
|
||||
const outputFile = path.join(tempDir, 'output.webp')
|
||||
await transcodeService.transcodeImage('input.png', outputFile, 480, 80)
|
||||
|
||||
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.webp).toHaveBeenCalledWith({ quality: 80 })
|
||||
expect(mockSharp.toFile).toHaveBeenCalledWith(outputFile)
|
||||
})
|
||||
|
||||
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')
|
||||
await transcodeService.transcodeImage(psdBuffer, outputFile, 480, 80)
|
||||
|
||||
expect(execFile).toHaveBeenCalledWith(
|
||||
'magick',
|
||||
expect.arrayContaining([
|
||||
'-colorspace',
|
||||
'sRGB',
|
||||
expect.stringContaining('[0]'),
|
||||
'-quality',
|
||||
'80',
|
||||
]),
|
||||
expect.any(Function),
|
||||
)
|
||||
})
|
||||
|
||||
it('should get PSD image info using ImageMagick identify', async () => {
|
||||
const mockExecFile = vi.mocked(execFile)
|
||||
mockExecFile.mockImplementation((cmd: unknown, args: unknown, callback: unknown) => {
|
||||
const cb = callback as (
|
||||
err: Error | null,
|
||||
result: { stdout: string; stderr: string },
|
||||
extra: string,
|
||||
) => void
|
||||
const argsArr = args as string[] | undefined
|
||||
if (cmd === 'magick' && argsArr && argsArr[0] === 'identify') {
|
||||
cb(null, { stdout: '1920 1080\n', stderr: '' }, '')
|
||||
} else if (typeof cb === 'function') {
|
||||
cb(null, { stdout: '', stderr: '' }, '')
|
||||
}
|
||||
return {} as ReturnType<typeof execFile>
|
||||
})
|
||||
|
||||
const psdPath = path.join(tempDir, 'sample.psd')
|
||||
fs.writeFileSync(psdPath, '8BPS-sample')
|
||||
|
||||
const info = await transcodeService.getImageInfo(psdPath)
|
||||
expect(info.originalWidth).toBe(1920)
|
||||
expect(info.originalHeight).toBe(1080)
|
||||
expect(info.mimeType).toBe('psd')
|
||||
})
|
||||
|
||||
it('should fetch image if input is a URL', async () => {
|
||||
const mockBuffer = Buffer.from('fake-image-data')
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@@ -215,6 +262,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.webp).toHaveBeenCalledWith({ quality: 80 })
|
||||
expect(mockSharp.toFile).toHaveBeenCalledWith(outputFile)
|
||||
@@ -598,6 +646,97 @@ describe('TranscodeService', () => {
|
||||
expect(b).toBeLessThan(100)
|
||||
})
|
||||
|
||||
it('should snap commentTimestamp and overlay annotations when start/end has rounding mismatch', async () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
;(child_process.execFile as any).mockImplementation(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(file: string, args: string[], cb: any) => {
|
||||
if (file === 'ffmpeg') {
|
||||
const outPath = args[args.length - 1]
|
||||
fs.writeFileSync(outPath, 'fake-webp-image')
|
||||
}
|
||||
cb(null, { stdout: '', stderr: '' })
|
||||
},
|
||||
)
|
||||
|
||||
const overlaySpy = vi
|
||||
.spyOn(transcodeService, 'overlayAnnotationsOnBuffer')
|
||||
.mockResolvedValue(Buffer.from('composited-buffer'))
|
||||
|
||||
const annotations: PrismaJson.AnnotationList = [
|
||||
{
|
||||
type: 'box',
|
||||
color: '#ff0000',
|
||||
points: [
|
||||
[0.2, 0.2],
|
||||
[0.8, 0.8],
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const results = await transcodeService.takeScreenshots({
|
||||
assetKey: 'test/video.mp4',
|
||||
assetId: 'asset-123',
|
||||
start: 4.57,
|
||||
end: 4.57,
|
||||
count: 1,
|
||||
commentTimestamp: 4.566666666666667,
|
||||
annotations,
|
||||
})
|
||||
|
||||
expect(results).toHaveLength(1)
|
||||
expect(results[0].timestamp).toBe(4.566666666666667)
|
||||
expect(overlaySpy).toHaveBeenCalledWith(expect.any(Buffer), annotations)
|
||||
|
||||
overlaySpy.mockRestore()
|
||||
})
|
||||
|
||||
it('should overlay annotation on ONLY the single snapped frame in a multi-screenshot range', async () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
;(child_process.execFile as any).mockImplementation(
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
(file: string, args: string[], cb: any) => {
|
||||
if (file === 'ffmpeg') {
|
||||
const outPath = args[args.length - 1]
|
||||
fs.writeFileSync(outPath, 'fake-webp-image')
|
||||
}
|
||||
cb(null, { stdout: '', stderr: '' })
|
||||
},
|
||||
)
|
||||
|
||||
const overlaySpy = vi
|
||||
.spyOn(transcodeService, 'overlayAnnotationsOnBuffer')
|
||||
.mockResolvedValue(Buffer.from('composited-buffer'))
|
||||
|
||||
const annotations: PrismaJson.AnnotationList = [
|
||||
{
|
||||
type: 'box',
|
||||
color: '#ff0000',
|
||||
points: [
|
||||
[0.2, 0.2],
|
||||
[0.8, 0.8],
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const results = await transcodeService.takeScreenshots({
|
||||
assetKey: 'test/video.mp4',
|
||||
assetId: 'asset-123',
|
||||
start: 0,
|
||||
end: 1,
|
||||
count: 30,
|
||||
commentTimestamp: 0.566666666666667,
|
||||
annotations,
|
||||
})
|
||||
|
||||
expect(results).toHaveLength(30)
|
||||
// Exactly 1 overlay call for the snapped timestamp out of 30 frames
|
||||
expect(overlaySpy).toHaveBeenCalledTimes(1)
|
||||
expect(overlaySpy).toHaveBeenCalledWith(expect.any(Buffer), annotations)
|
||||
|
||||
overlaySpy.mockRestore()
|
||||
})
|
||||
|
||||
it('should generate PDF from text file including CJK characters', async () => {
|
||||
const txtFile = path.join(tempDir, 'test.txt')
|
||||
const pdfFile = path.join(tempDir, 'output.pdf')
|
||||
|
||||
@@ -120,9 +120,69 @@ export interface ExtractVideoFramesParams {
|
||||
isImage: boolean
|
||||
}
|
||||
|
||||
export function isPsdInput(input: string | Buffer): boolean {
|
||||
if (typeof input === 'string') {
|
||||
if (input.toLowerCase().endsWith('.psd')) return true
|
||||
if (fs.existsSync(input)) {
|
||||
try {
|
||||
const fd = fs.openSync(input, 'r')
|
||||
const buf = Buffer.alloc(4)
|
||||
fs.readSync(fd, buf, 0, 4, 0)
|
||||
fs.closeSync(fd)
|
||||
return buf.toString('ascii') === '8BPS'
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
return (
|
||||
input.length >= 4 &&
|
||||
input[0] === 0x38 &&
|
||||
input[1] === 0x42 &&
|
||||
input[2] === 0x50 &&
|
||||
input[3] === 0x53
|
||||
)
|
||||
}
|
||||
|
||||
export class TranscodeService {
|
||||
constructor(private readonly prismaClient: typeof prisma = prisma) {}
|
||||
|
||||
private async execImageMagick(args: string[]): Promise<{ stdout: string; stderr: string }> {
|
||||
try {
|
||||
return await execFileAsync('magick', args)
|
||||
} catch (err: unknown) {
|
||||
const code = (err as Record<string, unknown>)?.code
|
||||
if (code === 'ENOENT') {
|
||||
return await execFileAsync('convert', args)
|
||||
}
|
||||
throw err
|
||||
}
|
||||
}
|
||||
|
||||
private async execImageMagickIdentify(
|
||||
filePath: string,
|
||||
): Promise<{ width: number; height: number }> {
|
||||
const fileArg = `${filePath}[0]`
|
||||
let stdout: string
|
||||
try {
|
||||
const res = await execFileAsync('magick', ['identify', '-format', '%w %h', fileArg])
|
||||
stdout = res.stdout
|
||||
} catch (err: unknown) {
|
||||
const code = (err as Record<string, unknown>)?.code
|
||||
if (code === 'ENOENT') {
|
||||
const res = await execFileAsync('identify', ['-format', '%w %h', fileArg])
|
||||
stdout = res.stdout
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
const parts = stdout.trim().split(/\s+/)
|
||||
const width = parseInt(parts[0], 10) || 0
|
||||
const height = parseInt(parts[1], 10) || 0
|
||||
return { width, height }
|
||||
}
|
||||
|
||||
private resolveCodecName(stream: {
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
codec_name?: string
|
||||
@@ -222,6 +282,8 @@ export class TranscodeService {
|
||||
|
||||
async getImageInfo(inputFile: string): Promise<MediaMetadata> {
|
||||
let input: string | Buffer = inputFile
|
||||
let tempDirToCleanup: string | null = null
|
||||
|
||||
if (inputFile.startsWith('http')) {
|
||||
const resp = await fetch(inputFile)
|
||||
if (!resp.ok) {
|
||||
@@ -230,6 +292,38 @@ export class TranscodeService {
|
||||
input = Buffer.from(await resp.arrayBuffer())
|
||||
}
|
||||
|
||||
if (isPsdInput(input)) {
|
||||
let psdPath: string
|
||||
if (typeof input === 'string') {
|
||||
psdPath = input
|
||||
} else {
|
||||
tempDirToCleanup = this.createTempDir('psd-info-')
|
||||
psdPath = path.join(tempDirToCleanup, 'input.psd')
|
||||
fs.writeFileSync(psdPath, input)
|
||||
}
|
||||
|
||||
try {
|
||||
const { width, height } = await this.execImageMagickIdentify(psdPath)
|
||||
return {
|
||||
originalWidth: width,
|
||||
originalHeight: height,
|
||||
duration: 0,
|
||||
bitRate: 0,
|
||||
frameRate: 0,
|
||||
totalFrames: 0,
|
||||
startTimecode: undefined,
|
||||
hasAudio: false,
|
||||
mimeType: 'psd',
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('ImageMagick identify failed for PSD, falling back to sharp:', err)
|
||||
} finally {
|
||||
if (tempDirToCleanup) {
|
||||
this.removeDir(tempDirToCleanup)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const metadata = await sharp(input, { limitInputPixels: false }).metadata()
|
||||
return {
|
||||
originalWidth: metadata.width || 0,
|
||||
@@ -309,13 +403,48 @@ export class TranscodeService {
|
||||
input = Buffer.from(await resp.arrayBuffer())
|
||||
}
|
||||
|
||||
const sharpInstance = sharp(input, { limitInputPixels: false })
|
||||
|
||||
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
|
||||
|
||||
sharpInstance.resize(targetW, targetH, {
|
||||
if (isPsdInput(input)) {
|
||||
let psdPath: string
|
||||
let tempDirToCleanup: string | null = null
|
||||
if (typeof input === 'string') {
|
||||
psdPath = input
|
||||
} else {
|
||||
tempDirToCleanup = this.createTempDir('psd-transcode-')
|
||||
psdPath = path.join(tempDirToCleanup, 'input.psd')
|
||||
fs.writeFileSync(psdPath, input)
|
||||
}
|
||||
|
||||
try {
|
||||
const resizeGeometry =
|
||||
targetH < WEBP_MAX_DIMENSION
|
||||
? `${targetW}x${targetH}>`
|
||||
: `${targetW}x${WEBP_MAX_DIMENSION}>`
|
||||
|
||||
await this.execImageMagick([
|
||||
`${psdPath}[0]`,
|
||||
'-colorspace',
|
||||
'sRGB',
|
||||
'-resize',
|
||||
resizeGeometry,
|
||||
'-quality',
|
||||
quality.toString(),
|
||||
outputFile,
|
||||
])
|
||||
return
|
||||
} finally {
|
||||
if (tempDirToCleanup) {
|
||||
this.removeDir(tempDirToCleanup)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const sharpInstance = sharp(input, { limitInputPixels: false })
|
||||
|
||||
sharpInstance.toColorspace('srgb').resize(targetW, targetH, {
|
||||
withoutEnlargement: true,
|
||||
fit: 'inside',
|
||||
})
|
||||
@@ -430,6 +559,7 @@ export class TranscodeService {
|
||||
await execFileAsync('ffmpeg', ['-y', '-loglevel', 'warning', ...spriteArgs])
|
||||
|
||||
await sharp(firstPagePath, { limitInputPixels: false })
|
||||
.toColorspace('srgb')
|
||||
.resize(480, null, { withoutEnlargement: true, fit: 'inside' })
|
||||
.webp({ quality: 75 })
|
||||
.toFile(outputPoster)
|
||||
@@ -793,10 +923,13 @@ export class TranscodeService {
|
||||
timestamps = Array.from({ length: params.count }, (_, i) => params.start + i * step)
|
||||
}
|
||||
|
||||
// 3. Snap closest timestamp to commentTimestamp if within range
|
||||
// 3. Snap closest timestamp to commentTimestamp if within range (with 100ms tolerance)
|
||||
const commentTimestamp = params.commentTimestamp
|
||||
const EPSILON = 0.1
|
||||
if (commentTimestamp !== undefined && commentTimestamp !== null) {
|
||||
if (commentTimestamp >= params.start && commentTimestamp <= params.end) {
|
||||
const inRange =
|
||||
commentTimestamp >= params.start - EPSILON && commentTimestamp <= params.end + EPSILON
|
||||
if (inRange) {
|
||||
let closestIdx = 0
|
||||
let minDiff = Math.abs(timestamps[0] - commentTimestamp)
|
||||
for (let i = 1; i < timestamps.length; i++) {
|
||||
@@ -834,14 +967,13 @@ export class TranscodeService {
|
||||
]
|
||||
await execFileAsync('ffmpeg', ['-y', '-loglevel', 'warning', ...args])
|
||||
|
||||
// 5. Overlay annotations if timestamp matches commentTimestamp exactly
|
||||
if (
|
||||
const isMatch =
|
||||
commentTimestamp !== undefined &&
|
||||
commentTimestamp !== null &&
|
||||
t === commentTimestamp &&
|
||||
params.annotations &&
|
||||
params.annotations.length > 0
|
||||
) {
|
||||
Math.abs(t - commentTimestamp) < 1e-4
|
||||
|
||||
// 5. Overlay annotations if timestamp matches commentTimestamp (within float tolerance)
|
||||
if (isMatch && params.annotations && params.annotations.length > 0) {
|
||||
const shotBuffer = fs.readFileSync(localShotPath)
|
||||
const composited = await this.overlayAnnotationsOnBuffer(shotBuffer, params.annotations)
|
||||
fs.writeFileSync(localShotPath, composited)
|
||||
@@ -926,6 +1058,7 @@ export class TranscodeService {
|
||||
const webpName = `${stem}-page-${pageNum}-${ulid()}.webp`
|
||||
|
||||
let webpBuffer = await sharp(localPngPath, { limitInputPixels: false })
|
||||
.toColorspace('srgb')
|
||||
.resize(1920, 1080, { fit: 'inside', withoutEnlargement: false })
|
||||
.webp({ quality: 85 })
|
||||
.toBuffer()
|
||||
@@ -973,6 +1106,7 @@ export class TranscodeService {
|
||||
const svgStr = renderAnnotationsToSvg(width, height, annotations)
|
||||
return await sharp(imageBuffer, { limitInputPixels: false })
|
||||
.composite([{ input: Buffer.from(svgStr), top: 0, left: 0 }])
|
||||
.toColorspace('srgb')
|
||||
.resize(16383, 16383, { fit: 'inside', withoutEnlargement: true })
|
||||
.webp({ quality: 85 })
|
||||
.toBuffer()
|
||||
|
||||
@@ -27,6 +27,11 @@ describe('detectSupportedMimeType', () => {
|
||||
expect(detectSupportedMimeType(buffer)).toBe('image/webp')
|
||||
})
|
||||
|
||||
it('should detect PSD', () => {
|
||||
const buffer = new Uint8Array([0x38, 0x42, 0x50, 0x53, 0x00, 0x01])
|
||||
expect(detectSupportedMimeType(buffer)).toBe('image/vnd.adobe.photoshop')
|
||||
})
|
||||
|
||||
it('should detect MP4', () => {
|
||||
const buffer = new Uint8Array([
|
||||
0x00, 0x00, 0x00, 0x18, 0x66, 0x74, 0x79, 0x70, 0x69, 0x73, 0x6f, 0x6d,
|
||||
@@ -44,6 +49,8 @@ describe('getProxyType', () => {
|
||||
it('should detect image proxyType', () => {
|
||||
expect(getProxyType('image/png', 'test.png')).toBe('image')
|
||||
expect(getProxyType('image/jpeg', 'photo.jpg')).toBe('image')
|
||||
expect(getProxyType('image/vnd.adobe.photoshop', 'design.psd')).toBe('image')
|
||||
expect(getProxyType(null, 'design.psd')).toBe('image')
|
||||
})
|
||||
|
||||
it('should detect video proxyType', () => {
|
||||
|
||||
@@ -7,7 +7,7 @@ export function getProxyType(
|
||||
const lowerMediaType = mediaType?.toLowerCase() || ''
|
||||
const lowerFilename = filename?.toLowerCase() || ''
|
||||
|
||||
if (lowerMediaType.startsWith('image/')) return 'image'
|
||||
if (lowerMediaType.startsWith('image/') || lowerFilename.endsWith('.psd')) return 'image'
|
||||
if (lowerMediaType.startsWith('video/')) return 'video'
|
||||
if (lowerMediaType.startsWith('audio/')) return 'audio'
|
||||
|
||||
@@ -32,6 +32,9 @@ export function getProxyType(
|
||||
const PNG_SIGNATURE = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]
|
||||
|
||||
export function detectSupportedMimeType(buffer: Uint8Array): string | null {
|
||||
if (startsWithAscii(buffer, 0, '8BPS')) {
|
||||
return 'image/vnd.adobe.photoshop'
|
||||
}
|
||||
if (startsWith(buffer, [0xff, 0xd8, 0xff])) {
|
||||
return buffer[3] === 0xf7 ? null : 'image/jpeg'
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/db",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "ai_usages" (
|
||||
"id" TEXT NOT NULL,
|
||||
"team_id" TEXT NOT NULL,
|
||||
"user_id" TEXT,
|
||||
"period_start" TIMESTAMP(3) NOT NULL,
|
||||
"input_tokens" INTEGER NOT NULL DEFAULT 0,
|
||||
"output_tokens" INTEGER NOT NULL DEFAULT 0,
|
||||
"cache_read_tokens" INTEGER NOT NULL DEFAULT 0,
|
||||
"total_tokens" INTEGER NOT NULL DEFAULT 0,
|
||||
"cost" DOUBLE PRECISION NOT NULL DEFAULT 0,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_at" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "ai_usages_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "ai_usages_team_id_period_start_idx" ON "ai_usages"("team_id", "period_start");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "ai_usages_team_id_user_id_period_start_idx" ON "ai_usages"("team_id", "user_id", "period_start");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ai_usages" ADD CONSTRAINT "ai_usages_team_id_fkey" FOREIGN KEY ("team_id") REFERENCES "teams"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "ai_usages" ADD CONSTRAINT "ai_usages_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Warnings:
|
||||
|
||||
- A unique constraint covering the columns `[team_id,user_id,period_start]` on the table `ai_usages` will be added. If there are existing duplicate values, this will fail.
|
||||
|
||||
*/
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "ai_usages_team_id_user_id_period_start_key" ON "ai_usages"("team_id", "user_id", "period_start");
|
||||
@@ -155,6 +155,7 @@ model User {
|
||||
collections Collection[] @relation("UserToCollection")
|
||||
shareLinks ShareLink[] @relation("UserToShareLink")
|
||||
apiTokens ApiToken[] @relation("UserToApiToken")
|
||||
aiUsages AiUsage[] @relation("UserToAiUsage")
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
@@ -237,6 +238,7 @@ model Team {
|
||||
skills Skill[] @relation("TeamToSkill")
|
||||
sandbox Sandbox? @relation("TeamToSandbox")
|
||||
agents Agent[] @relation("TeamToAgent")
|
||||
aiUsages AiUsage[] @relation("TeamToAiUsage")
|
||||
|
||||
@@map("teams")
|
||||
}
|
||||
@@ -814,3 +816,26 @@ model ApiToken {
|
||||
|
||||
@@map("api_tokens")
|
||||
}
|
||||
|
||||
model AiUsage {
|
||||
id String @id @default(ulid())
|
||||
teamId String @map("team_id")
|
||||
userId String? @map("user_id")
|
||||
periodStart DateTime @map("period_start")
|
||||
inputTokens Int @default(0) @map("input_tokens")
|
||||
outputTokens Int @default(0) @map("output_tokens")
|
||||
cacheReadTokens Int @default(0) @map("cache_read_tokens")
|
||||
totalTokens Int @default(0) @map("total_tokens")
|
||||
cost Float @default(0) @map("cost")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
team Team @relation("TeamToAiUsage", fields: [teamId], references: [id], onDelete: Cascade)
|
||||
user User? @relation("UserToAiUsage", fields: [userId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@map("ai_usages")
|
||||
@@unique([teamId, userId, periodStart])
|
||||
@@index([teamId, periodStart])
|
||||
@@index([teamId, userId, periodStart])
|
||||
}
|
||||
|
||||
|
||||
+5
@@ -182,3 +182,8 @@ export type Collection = Prisma.CollectionModel
|
||||
*
|
||||
*/
|
||||
export type ApiToken = Prisma.ApiTokenModel
|
||||
/**
|
||||
* Model AiUsage
|
||||
*
|
||||
*/
|
||||
export type AiUsage = Prisma.AiUsageModel
|
||||
|
||||
+5
@@ -206,3 +206,8 @@ export type Collection = Prisma.CollectionModel
|
||||
*
|
||||
*/
|
||||
export type ApiToken = Prisma.ApiTokenModel
|
||||
/**
|
||||
* Model AiUsage
|
||||
*
|
||||
*/
|
||||
export type AiUsage = Prisma.AiUsageModel
|
||||
|
||||
@@ -643,6 +643,33 @@ export type EnumAgentSessionTypeWithAggregatesFilter<$PrismaModel = never> = {
|
||||
_max?: Prisma.NestedEnumAgentSessionTypeFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type FloatFilter<$PrismaModel = never> = {
|
||||
equals?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
in?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||
notIn?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||
lt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
lte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
gt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
gte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedFloatFilter<$PrismaModel> | number
|
||||
}
|
||||
|
||||
export type FloatWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
in?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||
notIn?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||
lt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
lte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
gt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
gte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedFloatWithAggregatesFilter<$PrismaModel> | number
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_avg?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||
_sum?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedStringFilter<$PrismaModel = never> = {
|
||||
equals?: string | Prisma.StringFieldRefInput<$PrismaModel>
|
||||
in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel>
|
||||
@@ -1218,4 +1245,20 @@ export type NestedEnumAgentSessionTypeWithAggregatesFilter<$PrismaModel = never>
|
||||
_max?: Prisma.NestedEnumAgentSessionTypeFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedFloatWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
in?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||
notIn?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||
lt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
lte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
gt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
gte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedFloatWithAggregatesFilter<$PrismaModel> | number
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_avg?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||
_sum?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
|
||||
|
||||
+14
-4
File diff suppressed because one or more lines are too long
+95
-2
@@ -416,7 +416,8 @@ export const ModelName = {
|
||||
Model: 'Model',
|
||||
Provider: 'Provider',
|
||||
Collection: 'Collection',
|
||||
ApiToken: 'ApiToken'
|
||||
ApiToken: 'ApiToken',
|
||||
AiUsage: 'AiUsage'
|
||||
} as const
|
||||
|
||||
export type ModelName = (typeof ModelName)[keyof typeof ModelName]
|
||||
@@ -432,7 +433,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"
|
||||
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"
|
||||
txIsolationLevel: TransactionIsolationLevel
|
||||
}
|
||||
model: {
|
||||
@@ -2878,6 +2879,80 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
||||
}
|
||||
}
|
||||
}
|
||||
AiUsage: {
|
||||
payload: Prisma.$AiUsagePayload<ExtArgs>
|
||||
fields: Prisma.AiUsageFieldRefs
|
||||
operations: {
|
||||
findUnique: {
|
||||
args: Prisma.AiUsageFindUniqueArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$AiUsagePayload> | null
|
||||
}
|
||||
findUniqueOrThrow: {
|
||||
args: Prisma.AiUsageFindUniqueOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$AiUsagePayload>
|
||||
}
|
||||
findFirst: {
|
||||
args: Prisma.AiUsageFindFirstArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$AiUsagePayload> | null
|
||||
}
|
||||
findFirstOrThrow: {
|
||||
args: Prisma.AiUsageFindFirstOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$AiUsagePayload>
|
||||
}
|
||||
findMany: {
|
||||
args: Prisma.AiUsageFindManyArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$AiUsagePayload>[]
|
||||
}
|
||||
create: {
|
||||
args: Prisma.AiUsageCreateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$AiUsagePayload>
|
||||
}
|
||||
createMany: {
|
||||
args: Prisma.AiUsageCreateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
createManyAndReturn: {
|
||||
args: Prisma.AiUsageCreateManyAndReturnArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$AiUsagePayload>[]
|
||||
}
|
||||
delete: {
|
||||
args: Prisma.AiUsageDeleteArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$AiUsagePayload>
|
||||
}
|
||||
update: {
|
||||
args: Prisma.AiUsageUpdateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$AiUsagePayload>
|
||||
}
|
||||
deleteMany: {
|
||||
args: Prisma.AiUsageDeleteManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateMany: {
|
||||
args: Prisma.AiUsageUpdateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateManyAndReturn: {
|
||||
args: Prisma.AiUsageUpdateManyAndReturnArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$AiUsagePayload>[]
|
||||
}
|
||||
upsert: {
|
||||
args: Prisma.AiUsageUpsertArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$AiUsagePayload>
|
||||
}
|
||||
aggregate: {
|
||||
args: Prisma.AiUsageAggregateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.AggregateAiUsage>
|
||||
}
|
||||
groupBy: {
|
||||
args: Prisma.AiUsageGroupByArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.AiUsageGroupByOutputType>[]
|
||||
}
|
||||
count: {
|
||||
args: Prisma.AiUsageCountArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.AiUsageCountAggregateOutputType> | number
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} & {
|
||||
other: {
|
||||
@@ -3392,6 +3467,23 @@ export const ApiTokenScalarFieldEnum = {
|
||||
export type ApiTokenScalarFieldEnum = (typeof ApiTokenScalarFieldEnum)[keyof typeof ApiTokenScalarFieldEnum]
|
||||
|
||||
|
||||
export const AiUsageScalarFieldEnum = {
|
||||
id: 'id',
|
||||
teamId: 'teamId',
|
||||
userId: 'userId',
|
||||
periodStart: 'periodStart',
|
||||
inputTokens: 'inputTokens',
|
||||
outputTokens: 'outputTokens',
|
||||
cacheReadTokens: 'cacheReadTokens',
|
||||
totalTokens: 'totalTokens',
|
||||
cost: 'cost',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt'
|
||||
} as const
|
||||
|
||||
export type AiUsageScalarFieldEnum = (typeof AiUsageScalarFieldEnum)[keyof typeof AiUsageScalarFieldEnum]
|
||||
|
||||
|
||||
export const SortOrder = {
|
||||
asc: 'asc',
|
||||
desc: 'desc'
|
||||
@@ -3889,6 +3981,7 @@ export type GlobalOmitConfig = {
|
||||
provider?: Prisma.ProviderOmit
|
||||
collection?: Prisma.CollectionOmit
|
||||
apiToken?: Prisma.ApiTokenOmit
|
||||
aiUsage?: Prisma.AiUsageOmit
|
||||
}
|
||||
|
||||
/* Types for Logging */
|
||||
|
||||
@@ -83,7 +83,8 @@ export const ModelName = {
|
||||
Model: 'Model',
|
||||
Provider: 'Provider',
|
||||
Collection: 'Collection',
|
||||
ApiToken: 'ApiToken'
|
||||
ApiToken: 'ApiToken',
|
||||
AiUsage: 'AiUsage'
|
||||
} as const
|
||||
|
||||
export type ModelName = (typeof ModelName)[keyof typeof ModelName]
|
||||
@@ -577,6 +578,23 @@ export const ApiTokenScalarFieldEnum = {
|
||||
export type ApiTokenScalarFieldEnum = (typeof ApiTokenScalarFieldEnum)[keyof typeof ApiTokenScalarFieldEnum]
|
||||
|
||||
|
||||
export const AiUsageScalarFieldEnum = {
|
||||
id: 'id',
|
||||
teamId: 'teamId',
|
||||
userId: 'userId',
|
||||
periodStart: 'periodStart',
|
||||
inputTokens: 'inputTokens',
|
||||
outputTokens: 'outputTokens',
|
||||
cacheReadTokens: 'cacheReadTokens',
|
||||
totalTokens: 'totalTokens',
|
||||
cost: 'cost',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt'
|
||||
} as const
|
||||
|
||||
export type AiUsageScalarFieldEnum = (typeof AiUsageScalarFieldEnum)[keyof typeof AiUsageScalarFieldEnum]
|
||||
|
||||
|
||||
export const SortOrder = {
|
||||
asc: 'asc',
|
||||
desc: 'desc'
|
||||
|
||||
+1
@@ -41,4 +41,5 @@ export type * from './models/Model.ts'
|
||||
export type * from './models/Provider.ts'
|
||||
export type * from './models/Collection.ts'
|
||||
export type * from './models/ApiToken.ts'
|
||||
export type * from './models/AiUsage.ts'
|
||||
export type * from './commonInputTypes.ts'
|
||||
+1815
File diff suppressed because it is too large
Load Diff
+194
@@ -199,6 +199,7 @@ export type TeamWhereInput = {
|
||||
skills?: Prisma.SkillListRelationFilter
|
||||
sandbox?: Prisma.XOR<Prisma.SandboxNullableScalarRelationFilter, Prisma.SandboxWhereInput> | null
|
||||
agents?: Prisma.AgentListRelationFilter
|
||||
aiUsages?: Prisma.AiUsageListRelationFilter
|
||||
}
|
||||
|
||||
export type TeamOrderByWithRelationInput = {
|
||||
@@ -219,6 +220,7 @@ export type TeamOrderByWithRelationInput = {
|
||||
skills?: Prisma.SkillOrderByRelationAggregateInput
|
||||
sandbox?: Prisma.SandboxOrderByWithRelationInput
|
||||
agents?: Prisma.AgentOrderByRelationAggregateInput
|
||||
aiUsages?: Prisma.AiUsageOrderByRelationAggregateInput
|
||||
}
|
||||
|
||||
export type TeamWhereUniqueInput = Prisma.AtLeast<{
|
||||
@@ -242,6 +244,7 @@ export type TeamWhereUniqueInput = Prisma.AtLeast<{
|
||||
skills?: Prisma.SkillListRelationFilter
|
||||
sandbox?: Prisma.XOR<Prisma.SandboxNullableScalarRelationFilter, Prisma.SandboxWhereInput> | null
|
||||
agents?: Prisma.AgentListRelationFilter
|
||||
aiUsages?: Prisma.AiUsageListRelationFilter
|
||||
}, "id" | "rootFolderId">
|
||||
|
||||
export type TeamOrderByWithAggregationInput = {
|
||||
@@ -285,6 +288,7 @@ export type TeamCreateInput = {
|
||||
skills?: Prisma.SkillCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateInput = {
|
||||
@@ -304,6 +308,7 @@ export type TeamUncheckedCreateInput = {
|
||||
skills?: Prisma.SkillUncheckedCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxUncheckedCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUpdateInput = {
|
||||
@@ -323,6 +328,7 @@ export type TeamUpdateInput = {
|
||||
skills?: Prisma.SkillUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateInput = {
|
||||
@@ -342,6 +348,7 @@ export type TeamUncheckedUpdateInput = {
|
||||
skills?: Prisma.SkillUncheckedUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUncheckedUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateManyInput = {
|
||||
@@ -579,6 +586,20 @@ export type TeamUpdateOneRequiredWithoutProvidersNestedInput = {
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.TeamUpdateToOneWithWhereWithoutProvidersInput, Prisma.TeamUpdateWithoutProvidersInput>, Prisma.TeamUncheckedUpdateWithoutProvidersInput>
|
||||
}
|
||||
|
||||
export type TeamCreateNestedOneWithoutAiUsagesInput = {
|
||||
create?: Prisma.XOR<Prisma.TeamCreateWithoutAiUsagesInput, Prisma.TeamUncheckedCreateWithoutAiUsagesInput>
|
||||
connectOrCreate?: Prisma.TeamCreateOrConnectWithoutAiUsagesInput
|
||||
connect?: Prisma.TeamWhereUniqueInput
|
||||
}
|
||||
|
||||
export type TeamUpdateOneRequiredWithoutAiUsagesNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.TeamCreateWithoutAiUsagesInput, Prisma.TeamUncheckedCreateWithoutAiUsagesInput>
|
||||
connectOrCreate?: Prisma.TeamCreateOrConnectWithoutAiUsagesInput
|
||||
upsert?: Prisma.TeamUpsertWithoutAiUsagesInput
|
||||
connect?: Prisma.TeamWhereUniqueInput
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.TeamUpdateToOneWithWhereWithoutAiUsagesInput, Prisma.TeamUpdateWithoutAiUsagesInput>, Prisma.TeamUncheckedUpdateWithoutAiUsagesInput>
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutSandboxInput = {
|
||||
id?: string
|
||||
name: string
|
||||
@@ -595,6 +616,7 @@ export type TeamCreateWithoutSandboxInput = {
|
||||
providers?: Prisma.ProviderCreateNestedManyWithoutTeamInput
|
||||
skills?: Prisma.SkillCreateNestedManyWithoutTeamInput
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutSandboxInput = {
|
||||
@@ -613,6 +635,7 @@ export type TeamUncheckedCreateWithoutSandboxInput = {
|
||||
providers?: Prisma.ProviderUncheckedCreateNestedManyWithoutTeamInput
|
||||
skills?: Prisma.SkillUncheckedCreateNestedManyWithoutTeamInput
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutSandboxInput = {
|
||||
@@ -647,6 +670,7 @@ export type TeamUpdateWithoutSandboxInput = {
|
||||
providers?: Prisma.ProviderUpdateManyWithoutTeamNestedInput
|
||||
skills?: Prisma.SkillUpdateManyWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutSandboxInput = {
|
||||
@@ -665,6 +689,7 @@ export type TeamUncheckedUpdateWithoutSandboxInput = {
|
||||
providers?: Prisma.ProviderUncheckedUpdateManyWithoutTeamNestedInput
|
||||
skills?: Prisma.SkillUncheckedUpdateManyWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutSkillsInput = {
|
||||
@@ -683,6 +708,7 @@ export type TeamCreateWithoutSkillsInput = {
|
||||
providers?: Prisma.ProviderCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutSkillsInput = {
|
||||
@@ -701,6 +727,7 @@ export type TeamUncheckedCreateWithoutSkillsInput = {
|
||||
providers?: Prisma.ProviderUncheckedCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxUncheckedCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutSkillsInput = {
|
||||
@@ -735,6 +762,7 @@ export type TeamUpdateWithoutSkillsInput = {
|
||||
providers?: Prisma.ProviderUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutSkillsInput = {
|
||||
@@ -753,6 +781,7 @@ export type TeamUncheckedUpdateWithoutSkillsInput = {
|
||||
providers?: Prisma.ProviderUncheckedUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUncheckedUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutMembersInput = {
|
||||
@@ -771,6 +800,7 @@ export type TeamCreateWithoutMembersInput = {
|
||||
skills?: Prisma.SkillCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutMembersInput = {
|
||||
@@ -789,6 +819,7 @@ export type TeamUncheckedCreateWithoutMembersInput = {
|
||||
skills?: Prisma.SkillUncheckedCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxUncheckedCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutMembersInput = {
|
||||
@@ -823,6 +854,7 @@ export type TeamUpdateWithoutMembersInput = {
|
||||
skills?: Prisma.SkillUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutMembersInput = {
|
||||
@@ -841,6 +873,7 @@ export type TeamUncheckedUpdateWithoutMembersInput = {
|
||||
skills?: Prisma.SkillUncheckedUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUncheckedUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutProjectsInput = {
|
||||
@@ -859,6 +892,7 @@ export type TeamCreateWithoutProjectsInput = {
|
||||
skills?: Prisma.SkillCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutProjectsInput = {
|
||||
@@ -877,6 +911,7 @@ export type TeamUncheckedCreateWithoutProjectsInput = {
|
||||
skills?: Prisma.SkillUncheckedCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxUncheckedCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutProjectsInput = {
|
||||
@@ -911,6 +946,7 @@ export type TeamUpdateWithoutProjectsInput = {
|
||||
skills?: Prisma.SkillUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutProjectsInput = {
|
||||
@@ -929,6 +965,7 @@ export type TeamUncheckedUpdateWithoutProjectsInput = {
|
||||
skills?: Prisma.SkillUncheckedUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUncheckedUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutRootFolderInput = {
|
||||
@@ -947,6 +984,7 @@ export type TeamCreateWithoutRootFolderInput = {
|
||||
skills?: Prisma.SkillCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutRootFolderInput = {
|
||||
@@ -965,6 +1003,7 @@ export type TeamUncheckedCreateWithoutRootFolderInput = {
|
||||
skills?: Prisma.SkillUncheckedCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxUncheckedCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutRootFolderInput = {
|
||||
@@ -999,6 +1038,7 @@ export type TeamUpdateWithoutRootFolderInput = {
|
||||
skills?: Prisma.SkillUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutRootFolderInput = {
|
||||
@@ -1017,6 +1057,7 @@ export type TeamUncheckedUpdateWithoutRootFolderInput = {
|
||||
skills?: Prisma.SkillUncheckedUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUncheckedUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutInvitesInput = {
|
||||
@@ -1035,6 +1076,7 @@ export type TeamCreateWithoutInvitesInput = {
|
||||
skills?: Prisma.SkillCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutInvitesInput = {
|
||||
@@ -1053,6 +1095,7 @@ export type TeamUncheckedCreateWithoutInvitesInput = {
|
||||
skills?: Prisma.SkillUncheckedCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxUncheckedCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutInvitesInput = {
|
||||
@@ -1087,6 +1130,7 @@ export type TeamUpdateWithoutInvitesInput = {
|
||||
skills?: Prisma.SkillUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutInvitesInput = {
|
||||
@@ -1105,6 +1149,7 @@ export type TeamUncheckedUpdateWithoutInvitesInput = {
|
||||
skills?: Prisma.SkillUncheckedUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUncheckedUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutMetadataFieldsInput = {
|
||||
@@ -1123,6 +1168,7 @@ export type TeamCreateWithoutMetadataFieldsInput = {
|
||||
skills?: Prisma.SkillCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutMetadataFieldsInput = {
|
||||
@@ -1141,6 +1187,7 @@ export type TeamUncheckedCreateWithoutMetadataFieldsInput = {
|
||||
skills?: Prisma.SkillUncheckedCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxUncheckedCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutMetadataFieldsInput = {
|
||||
@@ -1175,6 +1222,7 @@ export type TeamUpdateWithoutMetadataFieldsInput = {
|
||||
skills?: Prisma.SkillUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutMetadataFieldsInput = {
|
||||
@@ -1193,6 +1241,7 @@ export type TeamUncheckedUpdateWithoutMetadataFieldsInput = {
|
||||
skills?: Prisma.SkillUncheckedUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUncheckedUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutNotificationsInput = {
|
||||
@@ -1211,6 +1260,7 @@ export type TeamCreateWithoutNotificationsInput = {
|
||||
skills?: Prisma.SkillCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutNotificationsInput = {
|
||||
@@ -1229,6 +1279,7 @@ export type TeamUncheckedCreateWithoutNotificationsInput = {
|
||||
skills?: Prisma.SkillUncheckedCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxUncheckedCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutNotificationsInput = {
|
||||
@@ -1263,6 +1314,7 @@ export type TeamUpdateWithoutNotificationsInput = {
|
||||
skills?: Prisma.SkillUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutNotificationsInput = {
|
||||
@@ -1281,6 +1333,7 @@ export type TeamUncheckedUpdateWithoutNotificationsInput = {
|
||||
skills?: Prisma.SkillUncheckedUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUncheckedUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutAgentsInput = {
|
||||
@@ -1299,6 +1352,7 @@ export type TeamCreateWithoutAgentsInput = {
|
||||
providers?: Prisma.ProviderCreateNestedManyWithoutTeamInput
|
||||
skills?: Prisma.SkillCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxCreateNestedOneWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutAgentsInput = {
|
||||
@@ -1317,6 +1371,7 @@ export type TeamUncheckedCreateWithoutAgentsInput = {
|
||||
providers?: Prisma.ProviderUncheckedCreateNestedManyWithoutTeamInput
|
||||
skills?: Prisma.SkillUncheckedCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxUncheckedCreateNestedOneWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutAgentsInput = {
|
||||
@@ -1351,6 +1406,7 @@ export type TeamUpdateWithoutAgentsInput = {
|
||||
providers?: Prisma.ProviderUpdateManyWithoutTeamNestedInput
|
||||
skills?: Prisma.SkillUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUpdateOneWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutAgentsInput = {
|
||||
@@ -1369,6 +1425,7 @@ export type TeamUncheckedUpdateWithoutAgentsInput = {
|
||||
providers?: Prisma.ProviderUncheckedUpdateManyWithoutTeamNestedInput
|
||||
skills?: Prisma.SkillUncheckedUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUncheckedUpdateOneWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutUserMetadataInput = {
|
||||
@@ -1387,6 +1444,7 @@ export type TeamCreateWithoutUserMetadataInput = {
|
||||
skills?: Prisma.SkillCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutUserMetadataInput = {
|
||||
@@ -1405,6 +1463,7 @@ export type TeamUncheckedCreateWithoutUserMetadataInput = {
|
||||
skills?: Prisma.SkillUncheckedCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxUncheckedCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutUserMetadataInput = {
|
||||
@@ -1439,6 +1498,7 @@ export type TeamUpdateWithoutUserMetadataInput = {
|
||||
skills?: Prisma.SkillUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutUserMetadataInput = {
|
||||
@@ -1457,6 +1517,7 @@ export type TeamUncheckedUpdateWithoutUserMetadataInput = {
|
||||
skills?: Prisma.SkillUncheckedUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUncheckedUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutProvidersInput = {
|
||||
@@ -1475,6 +1536,7 @@ export type TeamCreateWithoutProvidersInput = {
|
||||
skills?: Prisma.SkillCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutProvidersInput = {
|
||||
@@ -1493,6 +1555,7 @@ export type TeamUncheckedCreateWithoutProvidersInput = {
|
||||
skills?: Prisma.SkillUncheckedCreateNestedManyWithoutTeamInput
|
||||
sandbox?: Prisma.SandboxUncheckedCreateNestedOneWithoutTeamInput
|
||||
agents?: Prisma.AgentUncheckedCreateNestedManyWithoutTeamInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutTeamInput
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutProvidersInput = {
|
||||
@@ -1527,6 +1590,7 @@ export type TeamUpdateWithoutProvidersInput = {
|
||||
skills?: Prisma.SkillUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutProvidersInput = {
|
||||
@@ -1545,6 +1609,99 @@ export type TeamUncheckedUpdateWithoutProvidersInput = {
|
||||
skills?: Prisma.SkillUncheckedUpdateManyWithoutTeamNestedInput
|
||||
sandbox?: Prisma.SandboxUncheckedUpdateOneWithoutTeamNestedInput
|
||||
agents?: Prisma.AgentUncheckedUpdateManyWithoutTeamNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutTeamNestedInput
|
||||
}
|
||||
|
||||
export type TeamCreateWithoutAiUsagesInput = {
|
||||
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
|
||||
}
|
||||
|
||||
export type TeamUncheckedCreateWithoutAiUsagesInput = {
|
||||
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
|
||||
}
|
||||
|
||||
export type TeamCreateOrConnectWithoutAiUsagesInput = {
|
||||
where: Prisma.TeamWhereUniqueInput
|
||||
create: Prisma.XOR<Prisma.TeamCreateWithoutAiUsagesInput, Prisma.TeamUncheckedCreateWithoutAiUsagesInput>
|
||||
}
|
||||
|
||||
export type TeamUpsertWithoutAiUsagesInput = {
|
||||
update: Prisma.XOR<Prisma.TeamUpdateWithoutAiUsagesInput, Prisma.TeamUncheckedUpdateWithoutAiUsagesInput>
|
||||
create: Prisma.XOR<Prisma.TeamCreateWithoutAiUsagesInput, Prisma.TeamUncheckedCreateWithoutAiUsagesInput>
|
||||
where?: Prisma.TeamWhereInput
|
||||
}
|
||||
|
||||
export type TeamUpdateToOneWithWhereWithoutAiUsagesInput = {
|
||||
where?: Prisma.TeamWhereInput
|
||||
data: Prisma.XOR<Prisma.TeamUpdateWithoutAiUsagesInput, Prisma.TeamUncheckedUpdateWithoutAiUsagesInput>
|
||||
}
|
||||
|
||||
export type TeamUpdateWithoutAiUsagesInput = {
|
||||
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
|
||||
}
|
||||
|
||||
export type TeamUncheckedUpdateWithoutAiUsagesInput = {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -1562,6 +1719,7 @@ export type TeamCountOutputType = {
|
||||
providers: number
|
||||
skills: number
|
||||
agents: number
|
||||
aiUsages: number
|
||||
}
|
||||
|
||||
export type TeamCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
@@ -1574,6 +1732,7 @@ export type TeamCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.I
|
||||
providers?: boolean | TeamCountOutputTypeCountProvidersArgs
|
||||
skills?: boolean | TeamCountOutputTypeCountSkillsArgs
|
||||
agents?: boolean | TeamCountOutputTypeCountAgentsArgs
|
||||
aiUsages?: boolean | TeamCountOutputTypeCountAiUsagesArgs
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1649,6 +1808,13 @@ export type TeamCountOutputTypeCountAgentsArgs<ExtArgs extends runtime.Types.Ext
|
||||
where?: Prisma.AgentWhereInput
|
||||
}
|
||||
|
||||
/**
|
||||
* TeamCountOutputType without action
|
||||
*/
|
||||
export type TeamCountOutputTypeCountAiUsagesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
where?: Prisma.AiUsageWhereInput
|
||||
}
|
||||
|
||||
|
||||
export type TeamSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
|
||||
id?: boolean
|
||||
@@ -1668,6 +1834,7 @@ export type TeamSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = r
|
||||
skills?: boolean | Prisma.Team$skillsArgs<ExtArgs>
|
||||
sandbox?: boolean | Prisma.Team$sandboxArgs<ExtArgs>
|
||||
agents?: boolean | Prisma.Team$agentsArgs<ExtArgs>
|
||||
aiUsages?: boolean | Prisma.Team$aiUsagesArgs<ExtArgs>
|
||||
_count?: boolean | Prisma.TeamCountOutputTypeDefaultArgs<ExtArgs>
|
||||
}, ExtArgs["result"]["team"]>
|
||||
|
||||
@@ -1713,6 +1880,7 @@ export type TeamInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs =
|
||||
skills?: boolean | Prisma.Team$skillsArgs<ExtArgs>
|
||||
sandbox?: boolean | Prisma.Team$sandboxArgs<ExtArgs>
|
||||
agents?: boolean | Prisma.Team$agentsArgs<ExtArgs>
|
||||
aiUsages?: boolean | Prisma.Team$aiUsagesArgs<ExtArgs>
|
||||
_count?: boolean | Prisma.TeamCountOutputTypeDefaultArgs<ExtArgs>
|
||||
}
|
||||
export type TeamIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
@@ -1736,6 +1904,7 @@ export type $TeamPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs =
|
||||
skills: Prisma.$SkillPayload<ExtArgs>[]
|
||||
sandbox: Prisma.$SandboxPayload<ExtArgs> | null
|
||||
agents: Prisma.$AgentPayload<ExtArgs>[]
|
||||
aiUsages: Prisma.$AiUsagePayload<ExtArgs>[]
|
||||
}
|
||||
scalars: runtime.Types.Extensions.GetPayloadResult<{
|
||||
id: string
|
||||
@@ -2152,6 +2321,7 @@ export interface Prisma__TeamClient<T, Null = never, ExtArgs extends runtime.Typ
|
||||
skills<T extends Prisma.Team$skillsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Team$skillsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$SkillPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
||||
sandbox<T extends Prisma.Team$sandboxArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.Team$sandboxArgs<ExtArgs>>): Prisma.Prisma__SandboxClient<runtime.Types.Result.GetResult<Prisma.$SandboxPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
|
||||
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>
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
@@ -2841,6 +3011,30 @@ export type Team$agentsArgs<ExtArgs extends runtime.Types.Extensions.InternalArg
|
||||
distinct?: Prisma.AgentScalarFieldEnum | Prisma.AgentScalarFieldEnum[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Team.aiUsages
|
||||
*/
|
||||
export type Team$aiUsagesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
/**
|
||||
* Select specific fields to fetch from the AiUsage
|
||||
*/
|
||||
select?: Prisma.AiUsageSelect<ExtArgs> | null
|
||||
/**
|
||||
* Omit specific fields from the AiUsage
|
||||
*/
|
||||
omit?: Prisma.AiUsageOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.AiUsageInclude<ExtArgs> | null
|
||||
where?: Prisma.AiUsageWhereInput
|
||||
orderBy?: Prisma.AiUsageOrderByWithRelationInput | Prisma.AiUsageOrderByWithRelationInput[]
|
||||
cursor?: Prisma.AiUsageWhereUniqueInput
|
||||
take?: number
|
||||
skip?: number
|
||||
distinct?: Prisma.AiUsageScalarFieldEnum | Prisma.AiUsageScalarFieldEnum[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Team without action
|
||||
*/
|
||||
|
||||
+268
@@ -245,6 +245,7 @@ export type UserWhereInput = {
|
||||
collections?: Prisma.CollectionListRelationFilter
|
||||
shareLinks?: Prisma.ShareLinkListRelationFilter
|
||||
apiTokens?: Prisma.ApiTokenListRelationFilter
|
||||
aiUsages?: Prisma.AiUsageListRelationFilter
|
||||
}
|
||||
|
||||
export type UserOrderByWithRelationInput = {
|
||||
@@ -276,6 +277,7 @@ export type UserOrderByWithRelationInput = {
|
||||
collections?: Prisma.CollectionOrderByRelationAggregateInput
|
||||
shareLinks?: Prisma.ShareLinkOrderByRelationAggregateInput
|
||||
apiTokens?: Prisma.ApiTokenOrderByRelationAggregateInput
|
||||
aiUsages?: Prisma.AiUsageOrderByRelationAggregateInput
|
||||
}
|
||||
|
||||
export type UserWhereUniqueInput = Prisma.AtLeast<{
|
||||
@@ -310,6 +312,7 @@ export type UserWhereUniqueInput = Prisma.AtLeast<{
|
||||
collections?: Prisma.CollectionListRelationFilter
|
||||
shareLinks?: Prisma.ShareLinkListRelationFilter
|
||||
apiTokens?: Prisma.ApiTokenListRelationFilter
|
||||
aiUsages?: Prisma.AiUsageListRelationFilter
|
||||
}, "id" | "email">
|
||||
|
||||
export type UserOrderByWithAggregationInput = {
|
||||
@@ -375,6 +378,7 @@ export type UserCreateInput = {
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateInput = {
|
||||
@@ -406,6 +410,7 @@ export type UserUncheckedCreateInput = {
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUpdateInput = {
|
||||
@@ -437,6 +442,7 @@ export type UserUpdateInput = {
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateInput = {
|
||||
@@ -468,6 +474,7 @@ export type UserUncheckedUpdateInput = {
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateManyInput = {
|
||||
@@ -838,6 +845,22 @@ export type UserUpdateOneRequiredWithoutApiTokensNestedInput = {
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.UserUpdateToOneWithWhereWithoutApiTokensInput, Prisma.UserUpdateWithoutApiTokensInput>, Prisma.UserUncheckedUpdateWithoutApiTokensInput>
|
||||
}
|
||||
|
||||
export type UserCreateNestedOneWithoutAiUsagesInput = {
|
||||
create?: Prisma.XOR<Prisma.UserCreateWithoutAiUsagesInput, Prisma.UserUncheckedCreateWithoutAiUsagesInput>
|
||||
connectOrCreate?: Prisma.UserCreateOrConnectWithoutAiUsagesInput
|
||||
connect?: Prisma.UserWhereUniqueInput
|
||||
}
|
||||
|
||||
export type UserUpdateOneWithoutAiUsagesNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.UserCreateWithoutAiUsagesInput, Prisma.UserUncheckedCreateWithoutAiUsagesInput>
|
||||
connectOrCreate?: Prisma.UserCreateOrConnectWithoutAiUsagesInput
|
||||
upsert?: Prisma.UserUpsertWithoutAiUsagesInput
|
||||
disconnect?: Prisma.UserWhereInput | boolean
|
||||
delete?: Prisma.UserWhereInput | boolean
|
||||
connect?: Prisma.UserWhereUniqueInput
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.UserUpdateToOneWithWhereWithoutAiUsagesInput, Prisma.UserUpdateWithoutAiUsagesInput>, Prisma.UserUncheckedUpdateWithoutAiUsagesInput>
|
||||
}
|
||||
|
||||
export type UserCreateWithoutSessionsInput = {
|
||||
id?: string
|
||||
type?: $Enums.UserType
|
||||
@@ -866,6 +889,7 @@ export type UserCreateWithoutSessionsInput = {
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutSessionsInput = {
|
||||
@@ -896,6 +920,7 @@ export type UserUncheckedCreateWithoutSessionsInput = {
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutSessionsInput = {
|
||||
@@ -942,6 +967,7 @@ export type UserUpdateWithoutSessionsInput = {
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutSessionsInput = {
|
||||
@@ -972,6 +998,7 @@ export type UserUncheckedUpdateWithoutSessionsInput = {
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutAccountsInput = {
|
||||
@@ -1002,6 +1029,7 @@ export type UserCreateWithoutAccountsInput = {
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutAccountsInput = {
|
||||
@@ -1032,6 +1060,7 @@ export type UserUncheckedCreateWithoutAccountsInput = {
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutAccountsInput = {
|
||||
@@ -1078,6 +1107,7 @@ export type UserUpdateWithoutAccountsInput = {
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutAccountsInput = {
|
||||
@@ -1108,6 +1138,7 @@ export type UserUncheckedUpdateWithoutAccountsInput = {
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutAuthTokensInput = {
|
||||
@@ -1138,6 +1169,7 @@ export type UserCreateWithoutAuthTokensInput = {
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutAuthTokensInput = {
|
||||
@@ -1168,6 +1200,7 @@ export type UserUncheckedCreateWithoutAuthTokensInput = {
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutAuthTokensInput = {
|
||||
@@ -1214,6 +1247,7 @@ export type UserUpdateWithoutAuthTokensInput = {
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutAuthTokensInput = {
|
||||
@@ -1244,6 +1278,7 @@ export type UserUncheckedUpdateWithoutAuthTokensInput = {
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutTeamMembersInput = {
|
||||
@@ -1274,6 +1309,7 @@ export type UserCreateWithoutTeamMembersInput = {
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutTeamMembersInput = {
|
||||
@@ -1304,6 +1340,7 @@ export type UserUncheckedCreateWithoutTeamMembersInput = {
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutTeamMembersInput = {
|
||||
@@ -1350,6 +1387,7 @@ export type UserUpdateWithoutTeamMembersInput = {
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutTeamMembersInput = {
|
||||
@@ -1380,6 +1418,7 @@ export type UserUncheckedUpdateWithoutTeamMembersInput = {
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutShareLinksInput = {
|
||||
@@ -1410,6 +1449,7 @@ export type UserCreateWithoutShareLinksInput = {
|
||||
userMetadata?: Prisma.UserMetadataCreateNestedManyWithoutUserInput
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutShareLinksInput = {
|
||||
@@ -1440,6 +1480,7 @@ export type UserUncheckedCreateWithoutShareLinksInput = {
|
||||
userMetadata?: Prisma.UserMetadataUncheckedCreateNestedManyWithoutUserInput
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutShareLinksInput = {
|
||||
@@ -1486,6 +1527,7 @@ export type UserUpdateWithoutShareLinksInput = {
|
||||
userMetadata?: Prisma.UserMetadataUpdateManyWithoutUserNestedInput
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutShareLinksInput = {
|
||||
@@ -1516,6 +1558,7 @@ export type UserUncheckedUpdateWithoutShareLinksInput = {
|
||||
userMetadata?: Prisma.UserMetadataUncheckedUpdateManyWithoutUserNestedInput
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutAssetsInput = {
|
||||
@@ -1546,6 +1589,7 @@ export type UserCreateWithoutAssetsInput = {
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutAssetsInput = {
|
||||
@@ -1576,6 +1620,7 @@ export type UserUncheckedCreateWithoutAssetsInput = {
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutAssetsInput = {
|
||||
@@ -1622,6 +1667,7 @@ export type UserUpdateWithoutAssetsInput = {
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutAssetsInput = {
|
||||
@@ -1652,6 +1698,7 @@ export type UserUncheckedUpdateWithoutAssetsInput = {
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutCommentsInput = {
|
||||
@@ -1682,6 +1729,7 @@ export type UserCreateWithoutCommentsInput = {
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutCommentsInput = {
|
||||
@@ -1712,6 +1760,7 @@ export type UserUncheckedCreateWithoutCommentsInput = {
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutCommentsInput = {
|
||||
@@ -1747,6 +1796,7 @@ export type UserCreateWithoutCompletionChangedCommentsInput = {
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutCompletionChangedCommentsInput = {
|
||||
@@ -1777,6 +1827,7 @@ export type UserUncheckedCreateWithoutCompletionChangedCommentsInput = {
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutCompletionChangedCommentsInput = {
|
||||
@@ -1823,6 +1874,7 @@ export type UserUpdateWithoutCommentsInput = {
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutCommentsInput = {
|
||||
@@ -1853,6 +1905,7 @@ export type UserUncheckedUpdateWithoutCommentsInput = {
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUpsertWithoutCompletionChangedCommentsInput = {
|
||||
@@ -1894,6 +1947,7 @@ export type UserUpdateWithoutCompletionChangedCommentsInput = {
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutCompletionChangedCommentsInput = {
|
||||
@@ -1924,6 +1978,7 @@ export type UserUncheckedUpdateWithoutCompletionChangedCommentsInput = {
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutCreatedInvitesInput = {
|
||||
@@ -1954,6 +2009,7 @@ export type UserCreateWithoutCreatedInvitesInput = {
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutCreatedInvitesInput = {
|
||||
@@ -1984,6 +2040,7 @@ export type UserUncheckedCreateWithoutCreatedInvitesInput = {
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutCreatedInvitesInput = {
|
||||
@@ -2030,6 +2087,7 @@ export type UserUpdateWithoutCreatedInvitesInput = {
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutCreatedInvitesInput = {
|
||||
@@ -2060,6 +2118,7 @@ export type UserUncheckedUpdateWithoutCreatedInvitesInput = {
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutCreatedNotificationsInput = {
|
||||
@@ -2090,6 +2149,7 @@ export type UserCreateWithoutCreatedNotificationsInput = {
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutCreatedNotificationsInput = {
|
||||
@@ -2120,6 +2180,7 @@ export type UserUncheckedCreateWithoutCreatedNotificationsInput = {
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutCreatedNotificationsInput = {
|
||||
@@ -2155,6 +2216,7 @@ export type UserCreateWithoutNotificationsInput = {
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutNotificationsInput = {
|
||||
@@ -2185,6 +2247,7 @@ export type UserUncheckedCreateWithoutNotificationsInput = {
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutNotificationsInput = {
|
||||
@@ -2231,6 +2294,7 @@ export type UserUpdateWithoutCreatedNotificationsInput = {
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutCreatedNotificationsInput = {
|
||||
@@ -2261,6 +2325,7 @@ export type UserUncheckedUpdateWithoutCreatedNotificationsInput = {
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUpsertWithoutNotificationsInput = {
|
||||
@@ -2302,6 +2367,7 @@ export type UserUpdateWithoutNotificationsInput = {
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutNotificationsInput = {
|
||||
@@ -2332,6 +2398,7 @@ export type UserUncheckedUpdateWithoutNotificationsInput = {
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutTasksInput = {
|
||||
@@ -2362,6 +2429,7 @@ export type UserCreateWithoutTasksInput = {
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutTasksInput = {
|
||||
@@ -2392,6 +2460,7 @@ export type UserUncheckedCreateWithoutTasksInput = {
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutTasksInput = {
|
||||
@@ -2438,6 +2507,7 @@ export type UserUpdateWithoutTasksInput = {
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutTasksInput = {
|
||||
@@ -2468,6 +2538,7 @@ export type UserUncheckedUpdateWithoutTasksInput = {
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutAgentInput = {
|
||||
@@ -2498,6 +2569,7 @@ export type UserCreateWithoutAgentInput = {
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutAgentInput = {
|
||||
@@ -2528,6 +2600,7 @@ export type UserUncheckedCreateWithoutAgentInput = {
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutAgentInput = {
|
||||
@@ -2574,6 +2647,7 @@ export type UserUpdateWithoutAgentInput = {
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutAgentInput = {
|
||||
@@ -2604,6 +2678,7 @@ export type UserUncheckedUpdateWithoutAgentInput = {
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutAgentSessionsInput = {
|
||||
@@ -2634,6 +2709,7 @@ export type UserCreateWithoutAgentSessionsInput = {
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutAgentSessionsInput = {
|
||||
@@ -2664,6 +2740,7 @@ export type UserUncheckedCreateWithoutAgentSessionsInput = {
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutAgentSessionsInput = {
|
||||
@@ -2710,6 +2787,7 @@ export type UserUpdateWithoutAgentSessionsInput = {
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutAgentSessionsInput = {
|
||||
@@ -2740,6 +2818,7 @@ export type UserUncheckedUpdateWithoutAgentSessionsInput = {
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutUserMetadataInput = {
|
||||
@@ -2770,6 +2849,7 @@ export type UserCreateWithoutUserMetadataInput = {
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutUserMetadataInput = {
|
||||
@@ -2800,6 +2880,7 @@ export type UserUncheckedCreateWithoutUserMetadataInput = {
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutUserMetadataInput = {
|
||||
@@ -2846,6 +2927,7 @@ export type UserUpdateWithoutUserMetadataInput = {
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutUserMetadataInput = {
|
||||
@@ -2876,6 +2958,7 @@ export type UserUncheckedUpdateWithoutUserMetadataInput = {
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutCollectionsInput = {
|
||||
@@ -2906,6 +2989,7 @@ export type UserCreateWithoutCollectionsInput = {
|
||||
userMetadata?: Prisma.UserMetadataCreateNestedManyWithoutUserInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutCollectionsInput = {
|
||||
@@ -2936,6 +3020,7 @@ export type UserUncheckedCreateWithoutCollectionsInput = {
|
||||
userMetadata?: Prisma.UserMetadataUncheckedCreateNestedManyWithoutUserInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutCollectionsInput = {
|
||||
@@ -2982,6 +3067,7 @@ export type UserUpdateWithoutCollectionsInput = {
|
||||
userMetadata?: Prisma.UserMetadataUpdateManyWithoutUserNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutCollectionsInput = {
|
||||
@@ -3012,6 +3098,7 @@ export type UserUncheckedUpdateWithoutCollectionsInput = {
|
||||
userMetadata?: Prisma.UserMetadataUncheckedUpdateManyWithoutUserNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutApiTokensInput = {
|
||||
@@ -3042,6 +3129,7 @@ export type UserCreateWithoutApiTokensInput = {
|
||||
userMetadata?: Prisma.UserMetadataCreateNestedManyWithoutUserInput
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
aiUsages?: Prisma.AiUsageCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutApiTokensInput = {
|
||||
@@ -3072,6 +3160,7 @@ export type UserUncheckedCreateWithoutApiTokensInput = {
|
||||
userMetadata?: Prisma.UserMetadataUncheckedCreateNestedManyWithoutUserInput
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutApiTokensInput = {
|
||||
@@ -3118,6 +3207,7 @@ export type UserUpdateWithoutApiTokensInput = {
|
||||
userMetadata?: Prisma.UserMetadataUpdateManyWithoutUserNestedInput
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
aiUsages?: Prisma.AiUsageUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutApiTokensInput = {
|
||||
@@ -3148,6 +3238,147 @@ export type UserUncheckedUpdateWithoutApiTokensInput = {
|
||||
userMetadata?: Prisma.UserMetadataUncheckedUpdateManyWithoutUserNestedInput
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
aiUsages?: Prisma.AiUsageUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserCreateWithoutAiUsagesInput = {
|
||||
id?: string
|
||||
type?: $Enums.UserType
|
||||
name: string
|
||||
email: string
|
||||
emailVerified?: boolean
|
||||
image?: string | null
|
||||
password?: string | null
|
||||
agentSettings?:PrismaJson.AgentSettings | Prisma.NullableJsonNullValueInput
|
||||
guestEmail?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
assets?: Prisma.AssetCreateNestedManyWithoutCreatorInput
|
||||
authTokens?: Prisma.AuthTokenCreateNestedManyWithoutUserInput
|
||||
tasks?: Prisma.TaskCreateNestedManyWithoutCreatorInput
|
||||
teamMembers?: Prisma.TeamMemberCreateNestedManyWithoutUserInput
|
||||
comments?: Prisma.AssetCommentCreateNestedManyWithoutCreatorInput
|
||||
completionChangedComments?: Prisma.AssetCommentCreateNestedManyWithoutCompletionLastChangedByInput
|
||||
createdInvites?: Prisma.InviteCreateNestedManyWithoutInviterInput
|
||||
createdNotifications?: Prisma.NotificationCreateNestedManyWithoutCreatorInput
|
||||
notifications?: Prisma.NotificationCreateNestedManyWithoutUserInput
|
||||
sessions?: Prisma.SessionCreateNestedManyWithoutUserInput
|
||||
accounts?: Prisma.AccountCreateNestedManyWithoutUserInput
|
||||
agent?: Prisma.AgentCreateNestedOneWithoutUserInput
|
||||
agentSessions?: Prisma.AgentSessionCreateNestedManyWithoutUserInput
|
||||
userMetadata?: Prisma.UserMetadataCreateNestedManyWithoutUserInput
|
||||
collections?: Prisma.CollectionCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserUncheckedCreateWithoutAiUsagesInput = {
|
||||
id?: string
|
||||
type?: $Enums.UserType
|
||||
name: string
|
||||
email: string
|
||||
emailVerified?: boolean
|
||||
image?: string | null
|
||||
password?: string | null
|
||||
agentSettings?:PrismaJson.AgentSettings | Prisma.NullableJsonNullValueInput
|
||||
guestEmail?: string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
assets?: Prisma.AssetUncheckedCreateNestedManyWithoutCreatorInput
|
||||
authTokens?: Prisma.AuthTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
tasks?: Prisma.TaskUncheckedCreateNestedManyWithoutCreatorInput
|
||||
teamMembers?: Prisma.TeamMemberUncheckedCreateNestedManyWithoutUserInput
|
||||
comments?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutCreatorInput
|
||||
completionChangedComments?: Prisma.AssetCommentUncheckedCreateNestedManyWithoutCompletionLastChangedByInput
|
||||
createdInvites?: Prisma.InviteUncheckedCreateNestedManyWithoutInviterInput
|
||||
createdNotifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutCreatorInput
|
||||
notifications?: Prisma.NotificationUncheckedCreateNestedManyWithoutUserInput
|
||||
sessions?: Prisma.SessionUncheckedCreateNestedManyWithoutUserInput
|
||||
accounts?: Prisma.AccountUncheckedCreateNestedManyWithoutUserInput
|
||||
agent?: Prisma.AgentUncheckedCreateNestedOneWithoutUserInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedCreateNestedManyWithoutUserInput
|
||||
userMetadata?: Prisma.UserMetadataUncheckedCreateNestedManyWithoutUserInput
|
||||
collections?: Prisma.CollectionUncheckedCreateNestedManyWithoutCreatorInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedCreateNestedManyWithoutCreatorInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedCreateNestedManyWithoutUserInput
|
||||
}
|
||||
|
||||
export type UserCreateOrConnectWithoutAiUsagesInput = {
|
||||
where: Prisma.UserWhereUniqueInput
|
||||
create: Prisma.XOR<Prisma.UserCreateWithoutAiUsagesInput, Prisma.UserUncheckedCreateWithoutAiUsagesInput>
|
||||
}
|
||||
|
||||
export type UserUpsertWithoutAiUsagesInput = {
|
||||
update: Prisma.XOR<Prisma.UserUpdateWithoutAiUsagesInput, Prisma.UserUncheckedUpdateWithoutAiUsagesInput>
|
||||
create: Prisma.XOR<Prisma.UserCreateWithoutAiUsagesInput, Prisma.UserUncheckedCreateWithoutAiUsagesInput>
|
||||
where?: Prisma.UserWhereInput
|
||||
}
|
||||
|
||||
export type UserUpdateToOneWithWhereWithoutAiUsagesInput = {
|
||||
where?: Prisma.UserWhereInput
|
||||
data: Prisma.XOR<Prisma.UserUpdateWithoutAiUsagesInput, Prisma.UserUncheckedUpdateWithoutAiUsagesInput>
|
||||
}
|
||||
|
||||
export type UserUpdateWithoutAiUsagesInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
type?: Prisma.EnumUserTypeFieldUpdateOperationsInput | $Enums.UserType
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
email?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
emailVerified?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
image?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
agentSettings?:PrismaJson.AgentSettings | Prisma.NullableJsonNullValueInput
|
||||
guestEmail?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assets?: Prisma.AssetUpdateManyWithoutCreatorNestedInput
|
||||
authTokens?: Prisma.AuthTokenUpdateManyWithoutUserNestedInput
|
||||
tasks?: Prisma.TaskUpdateManyWithoutCreatorNestedInput
|
||||
teamMembers?: Prisma.TeamMemberUpdateManyWithoutUserNestedInput
|
||||
comments?: Prisma.AssetCommentUpdateManyWithoutCreatorNestedInput
|
||||
completionChangedComments?: Prisma.AssetCommentUpdateManyWithoutCompletionLastChangedByNestedInput
|
||||
createdInvites?: Prisma.InviteUpdateManyWithoutInviterNestedInput
|
||||
createdNotifications?: Prisma.NotificationUpdateManyWithoutCreatorNestedInput
|
||||
notifications?: Prisma.NotificationUpdateManyWithoutUserNestedInput
|
||||
sessions?: Prisma.SessionUpdateManyWithoutUserNestedInput
|
||||
accounts?: Prisma.AccountUpdateManyWithoutUserNestedInput
|
||||
agent?: Prisma.AgentUpdateOneWithoutUserNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUpdateManyWithoutUserNestedInput
|
||||
userMetadata?: Prisma.UserMetadataUpdateManyWithoutUserNestedInput
|
||||
collections?: Prisma.CollectionUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
export type UserUncheckedUpdateWithoutAiUsagesInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
type?: Prisma.EnumUserTypeFieldUpdateOperationsInput | $Enums.UserType
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
email?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
emailVerified?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
image?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
agentSettings?:PrismaJson.AgentSettings | Prisma.NullableJsonNullValueInput
|
||||
guestEmail?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
assets?: Prisma.AssetUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
authTokens?: Prisma.AuthTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
tasks?: Prisma.TaskUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
teamMembers?: Prisma.TeamMemberUncheckedUpdateManyWithoutUserNestedInput
|
||||
comments?: Prisma.AssetCommentUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
completionChangedComments?: Prisma.AssetCommentUncheckedUpdateManyWithoutCompletionLastChangedByNestedInput
|
||||
createdInvites?: Prisma.InviteUncheckedUpdateManyWithoutInviterNestedInput
|
||||
createdNotifications?: Prisma.NotificationUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
notifications?: Prisma.NotificationUncheckedUpdateManyWithoutUserNestedInput
|
||||
sessions?: Prisma.SessionUncheckedUpdateManyWithoutUserNestedInput
|
||||
accounts?: Prisma.AccountUncheckedUpdateManyWithoutUserNestedInput
|
||||
agent?: Prisma.AgentUncheckedUpdateOneWithoutUserNestedInput
|
||||
agentSessions?: Prisma.AgentSessionUncheckedUpdateManyWithoutUserNestedInput
|
||||
userMetadata?: Prisma.UserMetadataUncheckedUpdateManyWithoutUserNestedInput
|
||||
collections?: Prisma.CollectionUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
shareLinks?: Prisma.ShareLinkUncheckedUpdateManyWithoutCreatorNestedInput
|
||||
apiTokens?: Prisma.ApiTokenUncheckedUpdateManyWithoutUserNestedInput
|
||||
}
|
||||
|
||||
|
||||
@@ -3172,6 +3403,7 @@ export type UserCountOutputType = {
|
||||
collections: number
|
||||
shareLinks: number
|
||||
apiTokens: number
|
||||
aiUsages: number
|
||||
}
|
||||
|
||||
export type UserCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
@@ -3191,6 +3423,7 @@ export type UserCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.I
|
||||
collections?: boolean | UserCountOutputTypeCountCollectionsArgs
|
||||
shareLinks?: boolean | UserCountOutputTypeCountShareLinksArgs
|
||||
apiTokens?: boolean | UserCountOutputTypeCountApiTokensArgs
|
||||
aiUsages?: boolean | UserCountOutputTypeCountAiUsagesArgs
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3315,6 +3548,13 @@ export type UserCountOutputTypeCountApiTokensArgs<ExtArgs extends runtime.Types.
|
||||
where?: Prisma.ApiTokenWhereInput
|
||||
}
|
||||
|
||||
/**
|
||||
* UserCountOutputType without action
|
||||
*/
|
||||
export type UserCountOutputTypeCountAiUsagesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
where?: Prisma.AiUsageWhereInput
|
||||
}
|
||||
|
||||
|
||||
export type UserSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
|
||||
id?: boolean
|
||||
@@ -3345,6 +3585,7 @@ export type UserSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = r
|
||||
collections?: boolean | Prisma.User$collectionsArgs<ExtArgs>
|
||||
shareLinks?: boolean | Prisma.User$shareLinksArgs<ExtArgs>
|
||||
apiTokens?: boolean | Prisma.User$apiTokensArgs<ExtArgs>
|
||||
aiUsages?: boolean | Prisma.User$aiUsagesArgs<ExtArgs>
|
||||
_count?: boolean | Prisma.UserCountOutputTypeDefaultArgs<ExtArgs>
|
||||
}, ExtArgs["result"]["user"]>
|
||||
|
||||
@@ -3409,6 +3650,7 @@ export type UserInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs =
|
||||
collections?: boolean | Prisma.User$collectionsArgs<ExtArgs>
|
||||
shareLinks?: boolean | Prisma.User$shareLinksArgs<ExtArgs>
|
||||
apiTokens?: boolean | Prisma.User$apiTokensArgs<ExtArgs>
|
||||
aiUsages?: boolean | Prisma.User$aiUsagesArgs<ExtArgs>
|
||||
_count?: boolean | Prisma.UserCountOutputTypeDefaultArgs<ExtArgs>
|
||||
}
|
||||
export type UserIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {}
|
||||
@@ -3434,6 +3676,7 @@ export type $UserPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs =
|
||||
collections: Prisma.$CollectionPayload<ExtArgs>[]
|
||||
shareLinks: Prisma.$ShareLinkPayload<ExtArgs>[]
|
||||
apiTokens: Prisma.$ApiTokenPayload<ExtArgs>[]
|
||||
aiUsages: Prisma.$AiUsagePayload<ExtArgs>[]
|
||||
}
|
||||
scalars: runtime.Types.Extensions.GetPayloadResult<{
|
||||
id: string
|
||||
@@ -3861,6 +4104,7 @@ export interface Prisma__UserClient<T, Null = never, ExtArgs extends runtime.Typ
|
||||
collections<T extends Prisma.User$collectionsArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.User$collectionsArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$CollectionPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
||||
shareLinks<T extends Prisma.User$shareLinksArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.User$shareLinksArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$ShareLinkPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
||||
apiTokens<T extends Prisma.User$apiTokensArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.User$apiTokensArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$ApiTokenPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
||||
aiUsages<T extends Prisma.User$aiUsagesArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.User$aiUsagesArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$AiUsagePayload<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.
|
||||
@@ -4696,6 +4940,30 @@ export type User$apiTokensArgs<ExtArgs extends runtime.Types.Extensions.Internal
|
||||
distinct?: Prisma.ApiTokenScalarFieldEnum | Prisma.ApiTokenScalarFieldEnum[]
|
||||
}
|
||||
|
||||
/**
|
||||
* User.aiUsages
|
||||
*/
|
||||
export type User$aiUsagesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
/**
|
||||
* Select specific fields to fetch from the AiUsage
|
||||
*/
|
||||
select?: Prisma.AiUsageSelect<ExtArgs> | null
|
||||
/**
|
||||
* Omit specific fields from the AiUsage
|
||||
*/
|
||||
omit?: Prisma.AiUsageOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.AiUsageInclude<ExtArgs> | null
|
||||
where?: Prisma.AiUsageWhereInput
|
||||
orderBy?: Prisma.AiUsageOrderByWithRelationInput | Prisma.AiUsageOrderByWithRelationInput[]
|
||||
cursor?: Prisma.AiUsageWhereUniqueInput
|
||||
take?: number
|
||||
skip?: number
|
||||
distinct?: Prisma.AiUsageScalarFieldEnum | Prisma.AiUsageScalarFieldEnum[]
|
||||
}
|
||||
|
||||
/**
|
||||
* User without action
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/dtos",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -14,3 +14,34 @@ export const aiProviderSettingsSchema = z.object({
|
||||
})
|
||||
|
||||
export type AiProviderSettings = z.infer<typeof aiProviderSettingsSchema>
|
||||
|
||||
export const timeframeSchema = z.enum(['1h', '24h', '7d', '30d'])
|
||||
export type Timeframe = z.infer<typeof timeframeSchema>
|
||||
|
||||
export const getTeamAiUsageQuerySchema = z.object({
|
||||
timeframe: timeframeSchema.default('30d'),
|
||||
userId: z.string().optional(),
|
||||
})
|
||||
export type GetTeamAiUsageQuery = z.infer<typeof getTeamAiUsageQuerySchema>
|
||||
|
||||
export interface AiUsageMetrics {
|
||||
inputTokens: number
|
||||
outputTokens: number
|
||||
cacheReadTokens: number
|
||||
totalTokens: number
|
||||
cost: number
|
||||
}
|
||||
|
||||
export interface MemberAiUsageMetrics extends AiUsageMetrics {
|
||||
userId: string
|
||||
userName: string
|
||||
userEmail: string
|
||||
userImage?: string | null
|
||||
role: string
|
||||
}
|
||||
|
||||
export interface TeamUsageStatsResponse {
|
||||
timeframe: Timeframe
|
||||
team?: AiUsageMetrics
|
||||
member?: MemberAiUsageMetrics
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,16 +1,17 @@
|
||||
{
|
||||
"name": "@shumai/e2e",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"@shumai/db": "workspace:*",
|
||||
"@shumai/core": "workspace:*",
|
||||
"@shumai/workflow-core": "workspace:*",
|
||||
"@shumai/agent": "workspace:*",
|
||||
"@shumai/transcode": "workspace:*",
|
||||
"@shumai/dtos": "workspace:*",
|
||||
"@earendil-works/pi-agent-core": "0.78.0",
|
||||
"@google/genai": "1.52.0"
|
||||
"@google/genai": "1.52.0",
|
||||
"@shumai/agent": "workspace:*",
|
||||
"@shumai/core": "workspace:*",
|
||||
"@shumai/db": "workspace:*",
|
||||
"@shumai/dtos": "workspace:*",
|
||||
"@shumai/transcode": "workspace:*",
|
||||
"@shumai/workflow-core": "workspace:*",
|
||||
"sharp": "0.35.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest'
|
||||
import { prisma } 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'
|
||||
|
||||
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 - overlayImageAnnotationWorkflow (executor: %s)',
|
||||
(mode) => {
|
||||
setupTestDbHooks()
|
||||
|
||||
let transcodeWorkerPromise: Promise<void> | null = null
|
||||
|
||||
beforeAll(async () => {
|
||||
process.env.S3_BUCKET = 'shumai-e2e-test-bucket-transcode'
|
||||
|
||||
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()
|
||||
}
|
||||
})
|
||||
|
||||
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 {
|
||||
console.log('Cleaning up local E2E storage files...')
|
||||
await s3Service.deletePrefix('shumai-e2e-test-bucket-transcode', '')
|
||||
} catch (err) {
|
||||
console.error('Failed to clean up E2E storage folder:', err)
|
||||
}
|
||||
})
|
||||
|
||||
it('should run transcodeMedia image annotation overlay successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Image Annotation Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Image Annotation Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/image-ann.png',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'image-ann.png',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'image/png',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from Fixture
|
||||
const pngPath = path.join(fixturesDir, 'small.png')
|
||||
const pngBuffer = fs.readFileSync(pngPath)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/image-ann.png',
|
||||
pngBuffer,
|
||||
pngBuffer.length,
|
||||
'image/png',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_image_annotation',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
imageAnnotation: {
|
||||
annotations: [
|
||||
{
|
||||
type: 'box',
|
||||
color: '#ff0000',
|
||||
points: [
|
||||
[0.1, 0.1],
|
||||
[0.9, 0.9],
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E Image Annotation Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
expect(completedTask.status).toBe('completed')
|
||||
|
||||
// Verify task output contains overlay image key
|
||||
const output = completedTask.output as unknown as { key: string }
|
||||
expect(output).toBeDefined()
|
||||
expect(output.key).toContain('annotations/')
|
||||
}, 50000)
|
||||
},
|
||||
)
|
||||
@@ -0,0 +1,126 @@
|
||||
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest'
|
||||
import { prisma } 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'
|
||||
|
||||
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 - renderPdfPagesWorkflow (executor: %s)',
|
||||
(mode) => {
|
||||
setupTestDbHooks()
|
||||
|
||||
let transcodeWorkerPromise: Promise<void> | null = null
|
||||
|
||||
beforeAll(async () => {
|
||||
process.env.S3_BUCKET = 'shumai-e2e-test-bucket-transcode'
|
||||
|
||||
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()
|
||||
}
|
||||
})
|
||||
|
||||
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 {
|
||||
console.log('Cleaning up local E2E storage files...')
|
||||
await s3Service.deletePrefix('shumai-e2e-test-bucket-transcode', '')
|
||||
} catch (err) {
|
||||
console.error('Failed to clean up E2E storage folder:', err)
|
||||
}
|
||||
})
|
||||
|
||||
it('should run renderPdfPages workflow for a PDF asset successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E PDF Pages Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E PDF Pages Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/test-pages.pdf',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'test-pages.pdf',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'application/pdf',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from fixture test.pdf
|
||||
const pdfPath = path.join(fixturesDir, 'test.pdf')
|
||||
const pdfBuffer = fs.readFileSync(pdfPath)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/test-pages.pdf',
|
||||
pdfBuffer,
|
||||
pdfBuffer.length,
|
||||
'application/pdf',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_pdf_pages',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
pdfPages: {
|
||||
start: 1,
|
||||
end: 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(`Submitted E2E PDF Pages Workflow Task. ID: ${task.id}. Awaiting completion...`)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
expect(completedTask.status).toBe('completed')
|
||||
|
||||
// Verify output contains rendered pages
|
||||
const output = completedTask.output as unknown as { pages: { key: string; page: number }[] }
|
||||
expect(output).toBeDefined()
|
||||
expect(output.pages).toBeDefined()
|
||||
expect(output.pages.length).toBeGreaterThan(0)
|
||||
}, 50000)
|
||||
},
|
||||
)
|
||||
@@ -0,0 +1,357 @@
|
||||
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest'
|
||||
import { prisma } 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 sharp from 'sharp'
|
||||
|
||||
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 - takeVideoScreenshotsWorkflow (executor: %s)',
|
||||
(mode) => {
|
||||
setupTestDbHooks()
|
||||
|
||||
let transcodeWorkerPromise: Promise<void> | null = null
|
||||
|
||||
beforeAll(async () => {
|
||||
process.env.S3_BUCKET = 'shumai-e2e-test-bucket-transcode'
|
||||
|
||||
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()
|
||||
}
|
||||
})
|
||||
|
||||
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 {
|
||||
console.log('Cleaning up local E2E storage files...')
|
||||
await s3Service.deletePrefix('shumai-e2e-test-bucket-transcode', '')
|
||||
} catch (err) {
|
||||
console.error('Failed to clean up E2E storage folder:', err)
|
||||
}
|
||||
})
|
||||
|
||||
it('should run transcodeMedia screenshot extraction successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Video Screenshot Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Video Screenshot Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/video-shot.mp4',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'video-shot.mp4',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'video/mp4',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from Fixture
|
||||
const mp4Path = path.join(fixturesDir, 'small.mp4')
|
||||
const mp4Buffer = fs.readFileSync(mp4Path)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/video-shot.mp4',
|
||||
mp4Buffer,
|
||||
mp4Buffer.length,
|
||||
'video/mp4',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_screenshot',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
screenshot: {
|
||||
start: 0,
|
||||
end: 1,
|
||||
count: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E Video Screenshot Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
expect(completedTask.status).toBe('completed')
|
||||
|
||||
// Verify task output contains list of screenshots
|
||||
const output = completedTask.output as unknown as { screenshots: { key: string }[] }
|
||||
expect(output).toBeDefined()
|
||||
expect(output.screenshots).toBeDefined()
|
||||
expect(output.screenshots.length).toBe(1)
|
||||
expect(output.screenshots[0].key).toContain('screenshots/')
|
||||
}, 50000)
|
||||
|
||||
it('should draw annotation box correctly for 5 random comment timestamps', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Video Screenshot Annotation Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Video Screenshot Annotation Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/video-shot-ann.mp4',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'video-shot-ann.mp4',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'video/mp4',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from Fixture
|
||||
const mp4Path = path.join(fixturesDir, 'small.mp4')
|
||||
const mp4Buffer = fs.readFileSync(mp4Path)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/video-shot-ann.mp4',
|
||||
mp4Buffer,
|
||||
mp4Buffer.length,
|
||||
'video/mp4',
|
||||
)
|
||||
|
||||
// 3. Generate 5 random comment timestamps between 0.05s and 0.95s
|
||||
const randomTimestamps: number[] = []
|
||||
for (let i = 0; i < 5; i++) {
|
||||
const randomTs = 0.05 + Math.random() * 0.9
|
||||
randomTimestamps.push(randomTs)
|
||||
}
|
||||
|
||||
console.log('Testing random timestamps:', randomTimestamps)
|
||||
|
||||
const boxAnnotation = [
|
||||
{
|
||||
type: 'box' as const,
|
||||
color: '#ff0000',
|
||||
points: [
|
||||
[0.2, 0.2],
|
||||
[0.8, 0.8],
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
for (const commentTimestamp of randomTimestamps) {
|
||||
// Create Workflow Task with commentTimestamp & annotations
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_screenshot',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
screenshot: {
|
||||
start: 0,
|
||||
end: 1,
|
||||
count: 5,
|
||||
commentTimestamp,
|
||||
annotations: boxAnnotation,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
expect(completedTask.status).toBe('completed')
|
||||
|
||||
const output = completedTask.output as unknown as {
|
||||
screenshots: { key: string; timestamp: number }[]
|
||||
}
|
||||
expect(output).toBeDefined()
|
||||
expect(output.screenshots).toBeDefined()
|
||||
|
||||
// Find the screenshot matching commentTimestamp
|
||||
const matchingShot = output.screenshots.find(
|
||||
(s) => Math.abs(s.timestamp - commentTimestamp) < 1e-6,
|
||||
)
|
||||
expect(matchingShot).toBeDefined()
|
||||
|
||||
// Download screenshot buffer from S3
|
||||
const s3Obj = await s3Service.getObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
matchingShot!.key,
|
||||
)
|
||||
const shotBuffer = s3Obj.buffer
|
||||
|
||||
// Verify pixel data using sharp to check if red box annotation was overlaid
|
||||
const { data, info } = await sharp(shotBuffer).raw().toBuffer({ resolveWithObject: true })
|
||||
|
||||
// Target pixel inside box (e.g. x = 50%, y = 20% near top edge of red box)
|
||||
const pixelX = Math.floor(info.width * 0.5)
|
||||
const pixelY = Math.floor(info.height * 0.2)
|
||||
const offset = (pixelY * info.width + pixelX) * info.channels
|
||||
|
||||
const r = data[offset]
|
||||
const g = data[offset + 1]
|
||||
const b = data[offset + 2]
|
||||
|
||||
// Red box color #ff0000 should result in high red channel and low green/blue channels
|
||||
expect(r).toBeGreaterThan(150)
|
||||
expect(g).toBeLessThan(120)
|
||||
expect(b).toBeLessThan(120)
|
||||
}
|
||||
}, 90000)
|
||||
|
||||
it('should overlay annotation when commentTimestamp has rounding mismatch with start/end', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Video Screenshot Rounding Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Video Screenshot Rounding Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/video-shot-rounding.mp4',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'video-shot-rounding.mp4',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'video/mp4',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from Fixture
|
||||
const mp4Path = path.join(fixturesDir, 'small.mp4')
|
||||
const mp4Buffer = fs.readFileSync(mp4Path)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/video-shot-rounding.mp4',
|
||||
mp4Buffer,
|
||||
mp4Buffer.length,
|
||||
'video/mp4',
|
||||
)
|
||||
|
||||
// Reproduce log scenario: exact timestamp is 0.566666666666667, Agent requested rounded 0.57
|
||||
const commentTimestamp = 0.566666666666667
|
||||
const start = 0.57
|
||||
const end = 0.57
|
||||
|
||||
const boxAnnotation = [
|
||||
{
|
||||
type: 'box' as const,
|
||||
color: '#ff0000',
|
||||
points: [
|
||||
[0.2, 0.2],
|
||||
[0.8, 0.8],
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_screenshot',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
screenshot: {
|
||||
start,
|
||||
end,
|
||||
count: 1,
|
||||
commentTimestamp,
|
||||
annotations: boxAnnotation,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
expect(completedTask.status).toBe('completed')
|
||||
|
||||
const output = completedTask.output as unknown as {
|
||||
screenshots: { key: string; timestamp: number }[]
|
||||
}
|
||||
expect(output).toBeDefined()
|
||||
expect(output.screenshots).toBeDefined()
|
||||
expect(output.screenshots.length).toBe(1)
|
||||
|
||||
const s3Obj = await s3Service.getObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
output.screenshots[0].key,
|
||||
)
|
||||
const shotBuffer = s3Obj.buffer
|
||||
|
||||
const { data, info } = await sharp(shotBuffer).raw().toBuffer({ resolveWithObject: true })
|
||||
|
||||
const pixelX = Math.floor(info.width * 0.5)
|
||||
const pixelY = Math.floor(info.height * 0.2)
|
||||
const offset = (pixelY * info.width + pixelX) * info.channels
|
||||
|
||||
const r = data[offset]
|
||||
const g = data[offset + 1]
|
||||
const b = data[offset + 2]
|
||||
|
||||
expect(r).toBeGreaterThan(150)
|
||||
expect(g).toBeLessThan(120)
|
||||
expect(b).toBeLessThan(120)
|
||||
}, 50000)
|
||||
},
|
||||
)
|
||||
@@ -0,0 +1,218 @@
|
||||
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'
|
||||
|
||||
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 - transcodeImageWorkflow (executor: %s)',
|
||||
(mode) => {
|
||||
setupTestDbHooks()
|
||||
|
||||
let transcodeWorkerPromise: Promise<void> | null = null
|
||||
|
||||
beforeAll(async () => {
|
||||
process.env.S3_BUCKET = 'shumai-e2e-test-bucket-transcode'
|
||||
|
||||
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()
|
||||
}
|
||||
})
|
||||
|
||||
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 {
|
||||
console.log('Cleaning up local E2E storage files...')
|
||||
await s3Service.deletePrefix('shumai-e2e-test-bucket-transcode', '')
|
||||
} catch (err) {
|
||||
console.error('Failed to clean up E2E storage folder:', err)
|
||||
}
|
||||
})
|
||||
|
||||
it('should run transcodeMedia workflow for an image asset successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Image Transcode Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Image Transcode Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/image-trans.png',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'image-trans.png',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'image/png',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from Fixture
|
||||
const pngPath = path.join(fixturesDir, 'small.png')
|
||||
const pngBuffer = fs.readFileSync(pngPath)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/image-trans.png',
|
||||
pngBuffer,
|
||||
pngBuffer.length,
|
||||
'image/png',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_image',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
transcode: {
|
||||
thumbnail: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E Image Transcode Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
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
|
||||
imageTranscodes: unknown[]
|
||||
thumbnail: unknown
|
||||
}
|
||||
expect(mediaInfo).toBeDefined()
|
||||
expect(mediaInfo.proxyType).toBe('image')
|
||||
expect(mediaInfo.imageTranscodes).toBeDefined()
|
||||
expect(mediaInfo.imageTranscodes.length).toBeGreaterThan(0)
|
||||
expect(mediaInfo.thumbnail).toBeDefined()
|
||||
}, 50000)
|
||||
|
||||
it('should run transcodeMedia workflow for a PSD image asset successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E PSD Transcode Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E PSD Transcode Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/test.psd',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'test.psd',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'image/vnd.adobe.photoshop',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from fixture test.psd
|
||||
const psdPath = path.join(fixturesDir, 'test.psd')
|
||||
const psdBuffer = fs.readFileSync(psdPath)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/test.psd',
|
||||
psdBuffer,
|
||||
psdBuffer.length,
|
||||
'image/vnd.adobe.photoshop',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_image',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
transcode: {
|
||||
thumbnail: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E PSD Image Transcode Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
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
|
||||
imageTranscodes: unknown[]
|
||||
thumbnail: unknown
|
||||
}
|
||||
expect(mediaInfo).toBeDefined()
|
||||
expect(mediaInfo.proxyType).toBe('image')
|
||||
expect(mediaInfo.imageTranscodes).toBeDefined()
|
||||
expect(mediaInfo.imageTranscodes.length).toBeGreaterThan(0)
|
||||
expect(mediaInfo.thumbnail).toBeDefined()
|
||||
}, 50000)
|
||||
},
|
||||
)
|
||||
@@ -0,0 +1,317 @@
|
||||
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'
|
||||
|
||||
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 - transcodePdfWorkflow (executor: %s)',
|
||||
(mode) => {
|
||||
setupTestDbHooks()
|
||||
|
||||
let transcodeWorkerPromise: Promise<void> | null = null
|
||||
|
||||
beforeAll(async () => {
|
||||
process.env.S3_BUCKET = 'shumai-e2e-test-bucket-transcode'
|
||||
|
||||
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()
|
||||
}
|
||||
})
|
||||
|
||||
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 {
|
||||
console.log('Cleaning up local E2E storage files...')
|
||||
await s3Service.deletePrefix('shumai-e2e-test-bucket-transcode', '')
|
||||
} catch (err) {
|
||||
console.error('Failed to clean up E2E storage folder:', err)
|
||||
}
|
||||
})
|
||||
|
||||
it('should run transcodeMedia workflow for a PDF asset successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E PDF Transcode Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E PDF Transcode Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/test.pdf',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'test.pdf',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'application/pdf',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from fixture test.pdf
|
||||
const pdfPath = path.join(fixturesDir, 'test.pdf')
|
||||
const pdfBuffer = fs.readFileSync(pdfPath)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/test.pdf',
|
||||
pdfBuffer,
|
||||
pdfBuffer.length,
|
||||
'application/pdf',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E PDF Transcode Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
expect(completedTask.status).toBe('completed')
|
||||
|
||||
// Verify Asset status is updated to processed
|
||||
const updatedAsset = await prisma.asset.findUnique({
|
||||
where: { id: asset.id },
|
||||
})
|
||||
expect(updatedAsset?.status).toBe(AssetStatus.processed)
|
||||
|
||||
// Verify media info contains pdf details, poster, sprite, and pageCount
|
||||
const mediaInfo = updatedAsset?.media as unknown as {
|
||||
proxyType: string
|
||||
poster: { key: string }
|
||||
sprite: { key: string }
|
||||
frames?: number
|
||||
pageCount?: number
|
||||
metadata?: { totalFrames?: number; pageCount?: number }
|
||||
}
|
||||
expect(mediaInfo).toBeDefined()
|
||||
expect(mediaInfo.proxyType).toBe('pdf')
|
||||
expect(mediaInfo.poster).toBeDefined()
|
||||
expect(mediaInfo.poster.key).toContain('poster.webp')
|
||||
expect(mediaInfo.sprite).toBeDefined()
|
||||
expect(mediaInfo.sprite.key).toContain('sprite.webp')
|
||||
expect(mediaInfo.frames ?? mediaInfo.metadata?.totalFrames).toBeGreaterThan(0)
|
||||
}, 50000)
|
||||
|
||||
it('should run transcodeMedia workflow for a TXT asset with CJK text to generate PDF proxy successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E CJK TXT Transcode Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E CJK TXT Transcode Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/cjk-test.txt',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'cjk-test.txt',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'text/plain',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage with CJK text
|
||||
const cjkText =
|
||||
'Hello World\n你好世界 (Chinese)\nこんにちは世界 (Japanese)\n안녕하세요世界 (Korean)\nLine 5 of random text.'
|
||||
const txtBuffer = Buffer.from(cjkText, 'utf-8')
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/cjk-test.txt',
|
||||
txtBuffer,
|
||||
txtBuffer.length,
|
||||
'text/plain',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E CJK TXT Transcode Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
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)
|
||||
}, 50000)
|
||||
|
||||
it('should process markdown (.md) transcode PDF task correctly', async () => {
|
||||
// 1. Create Team, Project, Asset & StorageKey
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E MD Transcode Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E MD Transcode Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/doc.md',
|
||||
status: 'active',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'doc.md',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'text/markdown',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage with Markdown text
|
||||
const mdText = '# Heading\n\nThis is a **markdown** document to be rendered to PDF proxy.'
|
||||
const mdBuffer = Buffer.from(mdText, 'utf-8')
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/doc.md',
|
||||
mdBuffer,
|
||||
mdBuffer.length,
|
||||
'text/markdown',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E MD Transcode Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
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)
|
||||
}, 50000)
|
||||
},
|
||||
)
|
||||
@@ -0,0 +1,225 @@
|
||||
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'
|
||||
|
||||
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 - transcodeVideoWorkflow (executor: %s)',
|
||||
(mode) => {
|
||||
setupTestDbHooks()
|
||||
|
||||
let transcodeWorkerPromise: Promise<void> | null = null
|
||||
|
||||
beforeAll(async () => {
|
||||
process.env.S3_BUCKET = 'shumai-e2e-test-bucket-transcode'
|
||||
|
||||
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()
|
||||
}
|
||||
})
|
||||
|
||||
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 {
|
||||
console.log('Cleaning up local E2E storage files...')
|
||||
await s3Service.deletePrefix('shumai-e2e-test-bucket-transcode', '')
|
||||
} catch (err) {
|
||||
console.error('Failed to clean up E2E storage folder:', err)
|
||||
}
|
||||
})
|
||||
|
||||
it('should run transcodeMedia workflow for a video asset successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Video Transcode Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Video Transcode Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/video-trans.mp4',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'video-trans.mp4',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'video/mp4',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from Fixture
|
||||
const mp4Path = path.join(fixturesDir, 'small.mp4')
|
||||
const mp4Buffer = fs.readFileSync(mp4Path)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/video-trans.mp4',
|
||||
mp4Buffer,
|
||||
mp4Buffer.length,
|
||||
'video/mp4',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_video',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
transcode: {
|
||||
videoStrategy: 'best_match',
|
||||
thumbnail: false,
|
||||
poster: true,
|
||||
sprite: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E Video Transcode Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
expect(completedTask.status).toBe('completed')
|
||||
|
||||
// Verify Asset status is updated to processed
|
||||
const updatedAsset = await prisma.asset.findUnique({
|
||||
where: { id: asset.id },
|
||||
})
|
||||
expect(updatedAsset?.status).toBe(AssetStatus.processed)
|
||||
|
||||
// Verify media info contains videoTranscodes, poster, sprite, and duration details
|
||||
const mediaInfo = updatedAsset?.media as unknown as {
|
||||
proxyType: string
|
||||
duration: number
|
||||
videoTranscodes: { key: string }[]
|
||||
poster: unknown
|
||||
sprite: unknown
|
||||
}
|
||||
expect(mediaInfo).toBeDefined()
|
||||
expect(mediaInfo.proxyType).toBe('video')
|
||||
expect(mediaInfo.duration).toBeCloseTo(1.0, 1)
|
||||
expect(mediaInfo.videoTranscodes).toBeDefined()
|
||||
expect(mediaInfo.videoTranscodes.length).toBeGreaterThan(0)
|
||||
expect(mediaInfo.poster).toBeDefined()
|
||||
expect(mediaInfo.sprite).toBeDefined()
|
||||
}, 50000)
|
||||
|
||||
it('should run transcodeMedia workflow for an audio asset successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Audio Transcode Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Audio Transcode Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/audio-trans.wav',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'audio-trans.wav',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'audio/wav',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from Fixture
|
||||
const wavPath = path.join(fixturesDir, 'small.wav')
|
||||
const wavBuffer = fs.readFileSync(wavPath)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/audio-trans.wav',
|
||||
wavBuffer,
|
||||
wavBuffer.length,
|
||||
'audio/wav',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_video',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
transcode: {},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E Audio Transcode Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
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
|
||||
videoTranscodes: { key: string }[]
|
||||
}
|
||||
expect(mediaInfo).toBeDefined()
|
||||
expect(mediaInfo.proxyType).toBe('audio')
|
||||
expect(mediaInfo.videoTranscodes).toBeDefined()
|
||||
expect(mediaInfo.videoTranscodes.length).toBeGreaterThan(0)
|
||||
// Audio proxy key should end with -audio-proxy.mp4
|
||||
expect(mediaInfo.videoTranscodes[0].key).toContain('-audio-proxy.mp4')
|
||||
}, 50000)
|
||||
},
|
||||
)
|
||||
@@ -1,790 +0,0 @@
|
||||
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'
|
||||
|
||||
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 - transcodeMedia (executor: %s)',
|
||||
(mode) => {
|
||||
setupTestDbHooks()
|
||||
|
||||
let transcodeWorkerPromise: Promise<void> | null = null
|
||||
|
||||
beforeAll(async () => {
|
||||
process.env.S3_BUCKET = 'shumai-e2e-test-bucket-transcode'
|
||||
|
||||
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()
|
||||
}
|
||||
})
|
||||
|
||||
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 {
|
||||
console.log('Cleaning up local E2E storage files...')
|
||||
await s3Service.deletePrefix('shumai-e2e-test-bucket-transcode', '')
|
||||
} catch (err) {
|
||||
console.error('Failed to clean up E2E storage folder:', err)
|
||||
}
|
||||
})
|
||||
|
||||
it('should run transcodeMedia workflow for a video asset successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Video Transcode Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Video Transcode Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/video-trans.mp4',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'video-trans.mp4',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'video/mp4',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from Fixture
|
||||
const mp4Path = path.join(fixturesDir, 'small.mp4')
|
||||
const mp4Buffer = fs.readFileSync(mp4Path)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/video-trans.mp4',
|
||||
mp4Buffer,
|
||||
mp4Buffer.length,
|
||||
'video/mp4',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_video',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
transcode: {
|
||||
videoStrategy: 'best_match',
|
||||
thumbnail: false,
|
||||
poster: true,
|
||||
sprite: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E Video Transcode Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
expect(completedTask.status).toBe('completed')
|
||||
|
||||
// Verify Asset status is updated to processed
|
||||
const updatedAsset = await prisma.asset.findUnique({
|
||||
where: { id: asset.id },
|
||||
})
|
||||
expect(updatedAsset?.status).toBe(AssetStatus.processed)
|
||||
|
||||
// Verify media info contains videoTranscodes, poster, sprite, and duration details
|
||||
const mediaInfo = updatedAsset?.media as unknown as {
|
||||
proxyType: string
|
||||
duration: number
|
||||
videoTranscodes: { key: string }[]
|
||||
poster: unknown
|
||||
sprite: unknown
|
||||
}
|
||||
expect(mediaInfo).toBeDefined()
|
||||
expect(mediaInfo.proxyType).toBe('video')
|
||||
expect(mediaInfo.duration).toBeCloseTo(1.0, 1)
|
||||
expect(mediaInfo.videoTranscodes).toBeDefined()
|
||||
expect(mediaInfo.videoTranscodes.length).toBeGreaterThan(0)
|
||||
expect(mediaInfo.poster).toBeDefined()
|
||||
expect(mediaInfo.sprite).toBeDefined()
|
||||
}, 50000)
|
||||
|
||||
it('should run transcodeMedia workflow for an image asset successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Image Transcode Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Image Transcode Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/image-trans.png',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'image-trans.png',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'image/png',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from Fixture
|
||||
const pngPath = path.join(fixturesDir, 'small.png')
|
||||
const pngBuffer = fs.readFileSync(pngPath)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/image-trans.png',
|
||||
pngBuffer,
|
||||
pngBuffer.length,
|
||||
'image/png',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_image',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
transcode: {
|
||||
thumbnail: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E Image Transcode Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
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
|
||||
imageTranscodes: unknown[]
|
||||
thumbnail: unknown
|
||||
}
|
||||
expect(mediaInfo).toBeDefined()
|
||||
expect(mediaInfo.proxyType).toBe('image')
|
||||
expect(mediaInfo.imageTranscodes).toBeDefined()
|
||||
expect(mediaInfo.imageTranscodes.length).toBeGreaterThan(0)
|
||||
expect(mediaInfo.thumbnail).toBeDefined()
|
||||
}, 50000)
|
||||
|
||||
it('should run transcodeMedia workflow for an audio asset successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Audio Transcode Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Audio Transcode Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/audio-trans.wav',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'audio-trans.wav',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'audio/wav',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from Fixture
|
||||
const wavPath = path.join(fixturesDir, 'small.wav')
|
||||
const wavBuffer = fs.readFileSync(wavPath)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/audio-trans.wav',
|
||||
wavBuffer,
|
||||
wavBuffer.length,
|
||||
'audio/wav',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_video',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
transcode: {},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E Audio Transcode Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
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
|
||||
videoTranscodes: { key: string }[]
|
||||
}
|
||||
expect(mediaInfo).toBeDefined()
|
||||
expect(mediaInfo.proxyType).toBe('audio')
|
||||
expect(mediaInfo.videoTranscodes).toBeDefined()
|
||||
expect(mediaInfo.videoTranscodes.length).toBeGreaterThan(0)
|
||||
// Audio proxy key should end with -audio-proxy.mp4
|
||||
expect(mediaInfo.videoTranscodes[0].key).toContain('-audio-proxy.mp4')
|
||||
}, 50000)
|
||||
|
||||
it('should run transcodeMedia screenshot extraction successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Video Screenshot Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Video Screenshot Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/video-shot.mp4',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'video-shot.mp4',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'video/mp4',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from Fixture
|
||||
const mp4Path = path.join(fixturesDir, 'small.mp4')
|
||||
const mp4Buffer = fs.readFileSync(mp4Path)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/video-shot.mp4',
|
||||
mp4Buffer,
|
||||
mp4Buffer.length,
|
||||
'video/mp4',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_screenshot',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
screenshot: {
|
||||
start: 0,
|
||||
end: 1,
|
||||
count: 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E Video Screenshot Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
expect(completedTask.status).toBe('completed')
|
||||
|
||||
// Verify task output contains list of screenshots
|
||||
const output = completedTask.output as unknown as { screenshots: { key: string }[] }
|
||||
expect(output).toBeDefined()
|
||||
expect(output.screenshots).toBeDefined()
|
||||
expect(output.screenshots.length).toBe(1)
|
||||
expect(output.screenshots[0].key).toContain('screenshots/')
|
||||
}, 50000)
|
||||
|
||||
it('should run transcodeMedia image annotation overlay successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E Image Annotation Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E Image Annotation Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/image-ann.png',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'image-ann.png',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'image/png',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from Fixture
|
||||
const pngPath = path.join(fixturesDir, 'small.png')
|
||||
const pngBuffer = fs.readFileSync(pngPath)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/image-ann.png',
|
||||
pngBuffer,
|
||||
pngBuffer.length,
|
||||
'image/png',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_image_annotation',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
imageAnnotation: {
|
||||
annotations: [
|
||||
{
|
||||
type: 'box',
|
||||
color: '#ff0000',
|
||||
points: [
|
||||
[0.1, 0.1],
|
||||
[0.9, 0.9],
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E Image Annotation Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
expect(completedTask.status).toBe('completed')
|
||||
|
||||
// Verify task output contains overlay image key
|
||||
const output = completedTask.output as unknown as { key: string }
|
||||
expect(output).toBeDefined()
|
||||
expect(output.key).toContain('annotations/')
|
||||
}, 50000)
|
||||
|
||||
it('should run transcodeMedia workflow for a PDF asset successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E PDF Transcode Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E PDF Transcode Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/test.pdf',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'test.pdf',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'application/pdf',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from fixture test.pdf
|
||||
const pdfPath = path.join(fixturesDir, 'test.pdf')
|
||||
const pdfBuffer = fs.readFileSync(pdfPath)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/test.pdf',
|
||||
pdfBuffer,
|
||||
pdfBuffer.length,
|
||||
'application/pdf',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E PDF Transcode Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
expect(completedTask.status).toBe('completed')
|
||||
|
||||
// Verify Asset status is updated to processed
|
||||
const updatedAsset = await prisma.asset.findUnique({
|
||||
where: { id: asset.id },
|
||||
})
|
||||
expect(updatedAsset?.status).toBe(AssetStatus.processed)
|
||||
|
||||
// Verify media info contains pdf details, poster, sprite, and pageCount
|
||||
const mediaInfo = updatedAsset?.media as unknown as {
|
||||
proxyType: string
|
||||
poster: { key: string }
|
||||
sprite: { key: string }
|
||||
frames?: number
|
||||
pageCount?: number
|
||||
metadata?: { totalFrames?: number; pageCount?: number }
|
||||
}
|
||||
expect(mediaInfo).toBeDefined()
|
||||
expect(mediaInfo.proxyType).toBe('pdf')
|
||||
expect(mediaInfo.poster).toBeDefined()
|
||||
expect(mediaInfo.poster.key).toContain('poster.webp')
|
||||
expect(mediaInfo.sprite).toBeDefined()
|
||||
expect(mediaInfo.sprite.key).toContain('sprite.webp')
|
||||
expect(mediaInfo.frames ?? mediaInfo.metadata?.totalFrames).toBeGreaterThan(0)
|
||||
}, 50000)
|
||||
|
||||
it('should run renderPdfPages workflow for a PDF asset successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E PDF Pages Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E PDF Pages Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/test-pages.pdf',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'test-pages.pdf',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'application/pdf',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage from fixture test.pdf
|
||||
const pdfPath = path.join(fixturesDir, 'test.pdf')
|
||||
const pdfBuffer = fs.readFileSync(pdfPath)
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/test-pages.pdf',
|
||||
pdfBuffer,
|
||||
pdfBuffer.length,
|
||||
'application/pdf',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
const task = await prisma.workflowTask.create({
|
||||
data: {
|
||||
type: 'transcode_pdf_pages',
|
||||
status: 'pending',
|
||||
assetId: asset.id,
|
||||
projectId: project.id,
|
||||
teamId: team.id,
|
||||
payload: {
|
||||
projectId: project.id,
|
||||
pdfPages: {
|
||||
start: 1,
|
||||
end: 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(`Submitted E2E PDF Pages Workflow Task. ID: ${task.id}. Awaiting completion...`)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
expect(completedTask.status).toBe('completed')
|
||||
|
||||
// Verify output contains rendered pages
|
||||
const output = completedTask.output as unknown as { pages: { key: string; page: number }[] }
|
||||
expect(output).toBeDefined()
|
||||
expect(output.pages).toBeDefined()
|
||||
expect(output.pages.length).toBeGreaterThan(0)
|
||||
}, 50000)
|
||||
|
||||
it('should run transcodeMedia workflow for a TXT asset with CJK text to generate PDF proxy successfully', async () => {
|
||||
// 1. Seed Database
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E CJK TXT Transcode Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E CJK TXT Transcode Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/cjk-test.txt',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'cjk-test.txt',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'text/plain',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage with CJK text
|
||||
const cjkText =
|
||||
'Hello World\n你好世界 (Chinese)\nこんにちは世界 (Japanese)\n안녕하세요世界 (Korean)\nLine 5 of random text.'
|
||||
const txtBuffer = Buffer.from(cjkText, 'utf-8')
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/cjk-test.txt',
|
||||
txtBuffer,
|
||||
txtBuffer.length,
|
||||
'text/plain',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E CJK TXT Transcode Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
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)
|
||||
}, 50000)
|
||||
|
||||
it('should process markdown (.md) transcode PDF task correctly', async () => {
|
||||
// 1. Create Team, Project, Asset & StorageKey
|
||||
const team = await prisma.team.create({
|
||||
data: { name: 'E2E MD Transcode Team' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'E2E MD Transcode Project', teamId: team.id },
|
||||
})
|
||||
|
||||
const storageKey = await prisma.storageKey.create({
|
||||
data: {
|
||||
key: 'projects/e2e/doc.md',
|
||||
status: 'active',
|
||||
},
|
||||
})
|
||||
|
||||
const asset = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'doc.md',
|
||||
type: 'file',
|
||||
status: 'uploaded',
|
||||
mediaType: 'text/markdown',
|
||||
projectId: project.id,
|
||||
storageKeyId: storageKey.id,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Seed S3 Storage with Markdown text
|
||||
const mdText = '# Heading\n\nThis is a **markdown** document to be rendered to PDF proxy.'
|
||||
const mdBuffer = Buffer.from(mdText, 'utf-8')
|
||||
await s3Service.putObject(
|
||||
'shumai-e2e-test-bucket-transcode',
|
||||
'projects/e2e/doc.md',
|
||||
mdBuffer,
|
||||
mdBuffer.length,
|
||||
'text/markdown',
|
||||
)
|
||||
|
||||
// 3. Create Workflow Task
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// 4. Wait for workflow to complete
|
||||
console.log(
|
||||
`Submitted E2E MD Transcode Workflow Task. ID: ${task.id}. Awaiting completion...`,
|
||||
)
|
||||
const completedTask = await workflowService.executeWait(task, 45000)
|
||||
|
||||
// 5. Verification
|
||||
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)
|
||||
}, 50000)
|
||||
},
|
||||
)
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/tableprinter",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/transcode",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -469,6 +469,21 @@ describe('Transcode Activities', () => {
|
||||
).rejects.toThrowError(/Image transcoding failed/)
|
||||
})
|
||||
|
||||
it('should throw non-retryable ApplicationFailure when transcodeImageActivity fails with ImageMagick error', async () => {
|
||||
vi.mocked(s3Service.headObject).mockRejectedValue(new Error('Not found'))
|
||||
vi.mocked(transcodeService.transcodeImage).mockRejectedValue(
|
||||
new Error('imagemagick convert failed'),
|
||||
)
|
||||
|
||||
await expect(
|
||||
transcodeImageActivity({
|
||||
assetKey: 'i.psd',
|
||||
filePath: '/tmp/i.psd',
|
||||
imageSpec: { width: 800, height: 600, quality: 90, format: 'webp' },
|
||||
}),
|
||||
).rejects.toThrowError(/Image transcoding failed/)
|
||||
})
|
||||
|
||||
it('should throw non-retryable ApplicationFailure when generateSpriteActivity fails with error', async () => {
|
||||
vi.mocked(s3Service.headObject).mockRejectedValue(new Error('Not found'))
|
||||
vi.mocked(transcodeService.generateSprite).mockRejectedValue(new Error('FFmpeg failed'))
|
||||
|
||||
@@ -389,6 +389,9 @@ export async function transcodeImageActivity(
|
||||
code === 'ENOENT' ||
|
||||
lowerMsg.includes('enoent') ||
|
||||
lowerMsg.includes('sharp') ||
|
||||
lowerMsg.includes('imagemagick') ||
|
||||
lowerMsg.includes('magick') ||
|
||||
lowerMsg.includes('convert') ||
|
||||
lowerMsg.includes('spawn') ||
|
||||
lowerMsg.includes('format')
|
||||
) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import { useChatbotStore } from '@/ui/stores/chatbot'
|
||||
import { useTeamContextStore } from '@/ui/stores/team-context'
|
||||
import { useDroppable } from '@dnd-kit/react'
|
||||
import type { ChatMessage } from '@shumai/dtos'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import {
|
||||
ArrowLeft,
|
||||
ArrowUp,
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
Trash2,
|
||||
Wrench,
|
||||
} from 'lucide-react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import Markdown from 'react-markdown'
|
||||
import { formatTimeAgo } from '../lib/time'
|
||||
|
||||
@@ -171,9 +171,20 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp
|
||||
}
|
||||
}, [isHistoryMode, fetchHistorySessions, teamId])
|
||||
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const handleAssetMutation = useCallback(() => {
|
||||
queryClient.invalidateQueries({ queryKey: ['search'] })
|
||||
queryClient.invalidateQueries({ queryKey: ['folders'] })
|
||||
queryClient.invalidateQueries({ queryKey: ['files'] })
|
||||
queryClient.invalidateQueries({ queryKey: ['file'] })
|
||||
queryClient.invalidateQueries({ queryKey: ['version_stacks'] })
|
||||
queryClient.invalidateQueries({ queryKey: ['projects'] })
|
||||
}, [queryClient])
|
||||
|
||||
const handleSend = () => {
|
||||
if (!inputText.trim() || isStreaming || !teamId) return
|
||||
sendMessage(teamId, inputText, projectId, contextAssetId)
|
||||
sendMessage(teamId, inputText, projectId, contextAssetId, handleAssetMutation)
|
||||
setInputText('')
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
import { useState } from 'react'
|
||||
import { useQuery, useQueries } from '@tanstack/react-query'
|
||||
import type { Timeframe } from '@shumai/dtos'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/ui/components/ui/card'
|
||||
import { ToggleGroup, ToggleGroupItem } from '@/ui/components/ui/toggle-group'
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from '@/ui/components/ui/table'
|
||||
import { Avatar, AvatarFallback, AvatarImage } from '@/ui/components/ui/avatar'
|
||||
import { Loader2 } from 'lucide-react'
|
||||
|
||||
interface AiUsageDashboardProps {
|
||||
teamId: string
|
||||
}
|
||||
|
||||
export function AiUsageDashboard({ teamId }: AiUsageDashboardProps) {
|
||||
const [viewMode, setViewMode] = useState<'team' | 'members'>('team')
|
||||
const [timeframe, setTimeframe] = useState<Timeframe>('1h')
|
||||
|
||||
// Query team-level usage
|
||||
const { data: teamUsageData, isLoading: isTeamLoading } = useQuery({
|
||||
queryKey: ['teams', teamId, 'ai-usage', timeframe, 'team'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId']['ai-usage'].$get({
|
||||
param: { teamId },
|
||||
query: { timeframe },
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch team AI usage')
|
||||
return await res.json()
|
||||
},
|
||||
enabled: !!teamId && viewMode === 'team',
|
||||
})
|
||||
|
||||
// Query member list for members view
|
||||
const { data: members, isLoading: isMembersListLoading } = useQuery({
|
||||
queryKey: ['teams', teamId, 'members'],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId'].members.$get({
|
||||
param: { teamId },
|
||||
query: {},
|
||||
})
|
||||
if (!res.ok) throw new Error('Failed to fetch team members')
|
||||
return await res.json()
|
||||
},
|
||||
enabled: !!teamId && viewMode === 'members',
|
||||
})
|
||||
|
||||
// Query each member's AI usage in parallel
|
||||
const memberUsageQueries = useQueries({
|
||||
queries: (members || []).map((member) => ({
|
||||
queryKey: ['teams', teamId, 'ai-usage', timeframe, member.id],
|
||||
queryFn: async () => {
|
||||
const res = await client.api.teams[':teamId']['ai-usage'].$get({
|
||||
param: { teamId },
|
||||
query: { timeframe, userId: member.id },
|
||||
})
|
||||
if (!res.ok) throw new Error(`Failed to fetch AI usage for member ${member.id}`)
|
||||
return await res.json()
|
||||
},
|
||||
enabled: !!teamId && viewMode === 'members',
|
||||
})),
|
||||
})
|
||||
|
||||
const isMembersLoading = isMembersListLoading || memberUsageQueries.some((q) => q.isLoading)
|
||||
|
||||
const getInitials = (name?: string) => {
|
||||
if (!name) return 'U'
|
||||
const names = name.split(' ')
|
||||
if (names.length > 1) {
|
||||
return `${names[0][0]}${names[names.length - 1][0]}`.toUpperCase()
|
||||
}
|
||||
return name.substring(0, 2).toUpperCase()
|
||||
}
|
||||
|
||||
const localizeRole = (role?: string) => {
|
||||
if (!role) return ''
|
||||
switch (role.toLowerCase()) {
|
||||
case 'owner':
|
||||
return m.owner()
|
||||
case 'editor':
|
||||
return m.editor()
|
||||
case 'reviewer':
|
||||
return m.reviewer()
|
||||
default:
|
||||
return role
|
||||
}
|
||||
}
|
||||
|
||||
const formatTokens = (val?: number) => (val ?? 0).toLocaleString()
|
||||
const formatCost = (val?: number) => `$${(val ?? 0).toFixed(6)}`
|
||||
|
||||
return (
|
||||
<Card className="border-border/60 shadow-sm">
|
||||
<CardHeader className="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between pb-6">
|
||||
<div>
|
||||
<CardTitle className="text-xl font-semibold tracking-tight">{m.ai_usage()}</CardTitle>
|
||||
<CardDescription className="text-sm text-muted-foreground mt-1">
|
||||
{m.ai_usage_description()}
|
||||
</CardDescription>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<ToggleGroup
|
||||
type="single"
|
||||
value={viewMode}
|
||||
onValueChange={(val) => {
|
||||
if (val) setViewMode(val as 'team' | 'members')
|
||||
}}
|
||||
className="border rounded-lg p-1 bg-muted/30"
|
||||
>
|
||||
<ToggleGroupItem value="team" className="px-3 py-1.5 text-xs font-medium">
|
||||
{m.team_view()}
|
||||
</ToggleGroupItem>
|
||||
<ToggleGroupItem value="members" className="px-3 py-1.5 text-xs font-medium">
|
||||
{m.members_view()}
|
||||
</ToggleGroupItem>
|
||||
</ToggleGroup>
|
||||
|
||||
<ToggleGroup
|
||||
type="single"
|
||||
value={timeframe}
|
||||
onValueChange={(val) => {
|
||||
if (val) setTimeframe(val as Timeframe)
|
||||
}}
|
||||
className="border rounded-lg p-1 bg-muted/30"
|
||||
>
|
||||
<ToggleGroupItem value="1h" className="px-2.5 py-1.5 text-xs font-medium">
|
||||
1h
|
||||
</ToggleGroupItem>
|
||||
<ToggleGroupItem value="24h" className="px-2.5 py-1.5 text-xs font-medium">
|
||||
24h
|
||||
</ToggleGroupItem>
|
||||
<ToggleGroupItem value="7d" className="px-2.5 py-1.5 text-xs font-medium">
|
||||
7d
|
||||
</ToggleGroupItem>
|
||||
<ToggleGroupItem value="30d" className="px-2.5 py-1.5 text-xs font-medium">
|
||||
30d
|
||||
</ToggleGroupItem>
|
||||
</ToggleGroup>
|
||||
</div>
|
||||
</CardHeader>
|
||||
|
||||
<CardContent>
|
||||
{viewMode === 'team' ? (
|
||||
isTeamLoading ? (
|
||||
<div className="flex h-48 items-center justify-center">
|
||||
<Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
) : (
|
||||
<div className="rounded-md border">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{m.team()}</TableHead>
|
||||
<TableHead className="text-right">{m.input_tokens()}</TableHead>
|
||||
<TableHead className="text-right">{m.output_tokens()}</TableHead>
|
||||
<TableHead className="text-right">{m.cache_read_tokens()}</TableHead>
|
||||
<TableHead className="text-right">{m.total_tokens()}</TableHead>
|
||||
<TableHead className="text-right">{m.cost()}</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<TableRow>
|
||||
<TableCell className="font-medium">{m.team()}</TableCell>
|
||||
<TableCell className="text-right">
|
||||
{formatTokens(teamUsageData?.team?.inputTokens)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
{formatTokens(teamUsageData?.team?.outputTokens)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
{formatTokens(teamUsageData?.team?.cacheReadTokens)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right font-medium">
|
||||
{formatTokens(teamUsageData?.team?.totalTokens)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right font-medium">
|
||||
{formatCost(teamUsageData?.team?.cost)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
)
|
||||
) : isMembersLoading ? (
|
||||
<div className="flex h-48 items-center justify-center">
|
||||
<Loader2 className="h-6 w-6 animate-spin text-muted-foreground" />
|
||||
</div>
|
||||
) : (
|
||||
<div className="rounded-md border">
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>{m.members()}</TableHead>
|
||||
<TableHead>{m.role()}</TableHead>
|
||||
<TableHead className="text-right">{m.input_tokens()}</TableHead>
|
||||
<TableHead className="text-right">{m.output_tokens()}</TableHead>
|
||||
<TableHead className="text-right">{m.cache_read_tokens()}</TableHead>
|
||||
<TableHead className="text-right">{m.total_tokens()}</TableHead>
|
||||
<TableHead className="text-right">{m.cost()}</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{(members || []).map((member, idx) => {
|
||||
const usageResult = memberUsageQueries[idx]?.data?.member
|
||||
return (
|
||||
<TableRow key={member.id}>
|
||||
<TableCell>
|
||||
<div className="flex items-center gap-3">
|
||||
<Avatar className="h-8 w-8 rounded-full">
|
||||
{member.image && (
|
||||
<AvatarImage
|
||||
src={member.image}
|
||||
alt={member.name}
|
||||
className="object-cover"
|
||||
/>
|
||||
)}
|
||||
<AvatarFallback className="bg-primary/20 text-xs">
|
||||
{getInitials(member.name)}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm font-medium leading-none">{member.name}</span>
|
||||
<span className="text-xs text-muted-foreground mt-0.5">
|
||||
{member.email}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell className="text-xs text-muted-foreground">
|
||||
{localizeRole(member.role)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
{formatTokens(usageResult?.inputTokens)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
{formatTokens(usageResult?.outputTokens)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right">
|
||||
{formatTokens(usageResult?.cacheReadTokens)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right font-medium">
|
||||
{formatTokens(usageResult?.totalTokens)}
|
||||
</TableCell>
|
||||
<TableCell className="text-right font-medium">
|
||||
{formatCost(usageResult?.cost)}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)
|
||||
})}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
}
|
||||
@@ -540,6 +540,9 @@ export function FileBrowser({
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['search', teamId, assetId],
|
||||
})
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['teams', teamId, 'upload', 'tasks'],
|
||||
})
|
||||
|
||||
// The RPC client returns an object that we cast to the expected type
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
@@ -547,6 +550,9 @@ export function FileBrowser({
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['search', teamId, assetId],
|
||||
})
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: ['teams', teamId, 'upload', 'tasks'],
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -223,8 +223,8 @@ export function FileCard({
|
||||
}
|
||||
}}
|
||||
className={cn(
|
||||
'group relative flex cursor-pointer select-none flex-col overflow-hidden rounded-xl border border-border bg-card transition-all hover:border-primary h-full m-1',
|
||||
isSelected && 'outline-1 outline-primary border-primary',
|
||||
'group relative flex cursor-pointer select-none flex-col overflow-hidden rounded-xl border border-border bg-card transition-all hover:border-primary h-full m-1 outline-none focus:outline-none focus-visible:outline-none',
|
||||
(isSelected || isChecked) && 'outline-1 outline-primary border-primary',
|
||||
showDropFeedback && 'border-primary outline-1 outline-primary',
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -183,12 +183,12 @@ export function FileListItem({
|
||||
e.preventDefault()
|
||||
}
|
||||
}}
|
||||
className="group cursor-pointer select-none transition-colors whitespace-nowrap flex w-full"
|
||||
className="group cursor-pointer select-none transition-colors whitespace-nowrap flex w-full outline-none focus:outline-none focus-visible:outline-none"
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
'px-4 py-2 sticky left-0 z-10 transition-colors border-r shrink-0',
|
||||
isSelected ? 'bg-muted' : 'bg-card group-hover:bg-muted',
|
||||
isSelected || isChecked ? 'bg-muted' : 'bg-card group-hover:bg-muted',
|
||||
)}
|
||||
style={{
|
||||
width: columnSizing?.['name'] || 300,
|
||||
|
||||
@@ -272,7 +272,7 @@ export function FolderCard({
|
||||
: undefined
|
||||
}
|
||||
className={cn(
|
||||
'group relative w-full max-w-[340px] select-none cursor-pointer isolate flex flex-col items-center h-full',
|
||||
'group relative w-full max-w-[340px] select-none cursor-pointer isolate flex flex-col items-center h-full outline-none focus:outline-none focus-visible:outline-none',
|
||||
)}
|
||||
>
|
||||
<div className="absolute inset-0 z-10 pointer-events-none">
|
||||
|
||||
@@ -139,7 +139,7 @@ function ListRow({
|
||||
: undefined
|
||||
}
|
||||
className={cn(
|
||||
'group border-b border-border transition-colors hover:bg-primary/20 absolute top-0 left-0 w-full flex flex-col',
|
||||
'group border-b border-border transition-colors hover:bg-primary/20 absolute top-0 left-0 w-full flex flex-col outline-none focus:outline-none focus-visible:outline-none',
|
||||
isSelected && 'bg-primary/10',
|
||||
showDropFeedback && 'bg-primary/10',
|
||||
isTopOver && 'border-t-2 border-t-primary',
|
||||
|
||||
@@ -19,11 +19,12 @@ import { useTopNavStore } from '@/ui/stores/top-nav'
|
||||
import { useUiStore } from '@/ui/stores/ui'
|
||||
import { useUserMetadataStore } from '@/ui/stores/user-metadata'
|
||||
import { Feedback, PointerActivationConstraints } from '@dnd-kit/dom'
|
||||
import { DragDropProvider, DragOverlay, KeyboardSensor, PointerSensor } from '@dnd-kit/react'
|
||||
import { DragDropProvider, DragOverlay, PointerSensor } from '@dnd-kit/react'
|
||||
import { useInfiniteQuery, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { cn } from '../lib/utils'
|
||||
import { getSelectedRangeIds } from '../lib/selection-utils'
|
||||
import { ChatbotSidebar } from './chatbot-sidebar'
|
||||
import { SnapToPointer } from './dnd-modifiers'
|
||||
import { FileBrowser } from './file-browser/file-browser'
|
||||
@@ -337,27 +338,18 @@ export default function FileSystemManager({
|
||||
const lastSelectedItem = allItems.find((i) => i.id === lastSelectedId)
|
||||
|
||||
if (lastSelectedItem) {
|
||||
if (lastSelectedItem.type === item.type) {
|
||||
// Only select range if they are the same type
|
||||
const typeItems = item.type === 'folder' ? folders : files
|
||||
const lastIndex = typeItems.findIndex((i) => i.id === lastSelectedId)
|
||||
const currentIndex = typeItems.findIndex((i) => i.id === item.id)
|
||||
const newSelectedIds = getSelectedRangeIds(
|
||||
lastSelectedItem,
|
||||
item,
|
||||
lastSelectedId,
|
||||
folders,
|
||||
files,
|
||||
selectedIds,
|
||||
)
|
||||
|
||||
if (lastIndex !== -1 && currentIndex !== -1) {
|
||||
const start = Math.min(lastIndex, currentIndex)
|
||||
const end = Math.max(lastIndex, currentIndex)
|
||||
const rangeItems = typeItems.slice(start, end + 1)
|
||||
|
||||
const newSelectedIds = new Set(selectedIds)
|
||||
rangeItems.forEach((rangeItem) => {
|
||||
newSelectedIds.add(rangeItem.id)
|
||||
})
|
||||
setSelectedIds(newSelectedIds)
|
||||
setSelectedItem(item)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// If types are different, do nothing (as requested by user)
|
||||
if (newSelectedIds) {
|
||||
setSelectedIds(newSelectedIds)
|
||||
setSelectedItem(item)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -426,7 +418,6 @@ export default function FileSystemManager({
|
||||
PointerSensor.configure({
|
||||
activationConstraints: [new PointerActivationConstraints.Distance({ value: 10 })],
|
||||
}),
|
||||
KeyboardSensor,
|
||||
]
|
||||
}
|
||||
onDragStart={handleDragStart}
|
||||
|
||||
@@ -380,8 +380,8 @@ export function SearchFilterDialog({
|
||||
</div>
|
||||
|
||||
{/* Results Body ported from Demo */}
|
||||
<ScrollArea className="flex-1 min-h-0 bg-background">
|
||||
<div className="p-4 md:p-5">
|
||||
<ScrollArea className="flex-1 min-h-0 bg-background [&>div>div]:block!">
|
||||
<div className="p-4 md:p-5 min-w-0">
|
||||
<div className="flex items-center justify-between mb-3 px-1">
|
||||
<span className="text-[11px] font-bold uppercase tracking-wider text-muted-foreground/60 font-mono">
|
||||
{m.search_results()}
|
||||
@@ -394,7 +394,7 @@ export function SearchFilterDialog({
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col border border-border rounded-xl divide-y divide-border overflow-hidden">
|
||||
<div className="flex flex-col border border-border rounded-xl divide-y divide-border overflow-hidden min-w-0">
|
||||
{!hasActiveCriteria ? (
|
||||
<div className="py-20 text-center flex flex-col items-center justify-center bg-muted/20 px-4">
|
||||
<Search className="w-10 h-10 text-muted-foreground/30 mb-2" />
|
||||
@@ -449,7 +449,7 @@ export function SearchFilterDialog({
|
||||
<div
|
||||
key={record.id}
|
||||
onClick={() => handleResultClick(record)}
|
||||
className="p-3.5 flex items-center gap-3 hover:bg-muted/40 transition-colors group/record cursor-pointer"
|
||||
className="p-3.5 flex items-center gap-3 hover:bg-muted/40 transition-colors group/record cursor-pointer min-w-0"
|
||||
>
|
||||
<div
|
||||
className={cn(
|
||||
@@ -471,8 +471,8 @@ export function SearchFilterDialog({
|
||||
</div>
|
||||
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="truncate">
|
||||
<div className="flex items-center justify-between gap-3 min-w-0">
|
||||
<div className="flex-1 min-w-0">
|
||||
<span className="font-medium text-sm text-foreground group-hover/record:text-primary transition-colors block truncate">
|
||||
{record.name}
|
||||
</span>
|
||||
@@ -485,7 +485,7 @@ export function SearchFilterDialog({
|
||||
record.startTime !== null &&
|
||||
record.endTime !== undefined &&
|
||||
record.endTime !== null && (
|
||||
<span className="text-[10px] font-semibold text-primary bg-primary/10 border border-primary/20 px-1.5 py-0.5 rounded mt-1 inline-block">
|
||||
<span className="text-[10px] font-semibold text-primary bg-primary/10 border border-primary/20 px-1.5 py-0.5 rounded mt-1 inline-block max-w-full truncate">
|
||||
{m.match_found_at()} {formatTimestamp(record.startTime)} -{' '}
|
||||
{formatTimestamp(record.endTime)}
|
||||
</span>
|
||||
|
||||
@@ -12,7 +12,7 @@ import { ShareSettingsSidebar } from './share-settings-sidebar'
|
||||
import { FolderTree } from './folder-tree'
|
||||
import { ResizeHandle } from './resize-handle'
|
||||
import { useFileSystemDnd } from './use-file-system-dnd'
|
||||
import { DragDropProvider, DragOverlay, KeyboardSensor, PointerSensor } from '@dnd-kit/react'
|
||||
import { DragDropProvider, DragOverlay, PointerSensor } from '@dnd-kit/react'
|
||||
import { PointerActivationConstraints } from '@dnd-kit/dom'
|
||||
import { SnapToPointer } from './dnd-modifiers'
|
||||
import { useUiStore } from '@/ui/stores/ui'
|
||||
@@ -268,7 +268,6 @@ export default function ShareManager({
|
||||
PointerSensor.configure({
|
||||
activationConstraints: [new PointerActivationConstraints.Distance({ value: 10 })],
|
||||
}),
|
||||
KeyboardSensor,
|
||||
]}
|
||||
onDragStart={handleDragStart}
|
||||
onDragEnd={handleDragEnd}
|
||||
|
||||
@@ -146,6 +146,19 @@ export function UserMenu() {
|
||||
</DropdownMenuPortal>
|
||||
</DropdownMenuSub>
|
||||
<DropdownMenuSeparator />
|
||||
{me?.role?.toLowerCase() === 'owner' && (
|
||||
<DropdownMenuItem
|
||||
onClick={() =>
|
||||
navigate({
|
||||
to: '/teams/$teamId/dashboard',
|
||||
params: { teamId: teamId! },
|
||||
})
|
||||
}
|
||||
disabled={!teamId}
|
||||
>
|
||||
{m.dashboard()}
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
<DropdownMenuItem
|
||||
onClick={() =>
|
||||
navigate({
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { getSelectedRangeIds } from './selection-utils'
|
||||
import type { AssetInfo } from '@shumai/dtos'
|
||||
|
||||
describe('getSelectedRangeIds', () => {
|
||||
const folders = [
|
||||
{ id: 'folder1', name: 'Folder 1', type: 'folder', status: 'processed' },
|
||||
{ id: 'folder2', name: 'Folder 2', type: 'folder', status: 'processed' },
|
||||
] as unknown as AssetInfo[]
|
||||
|
||||
const files = [
|
||||
{ id: 'stack1', name: 'Version Stack 1', type: 'version_stack', status: 'processed' },
|
||||
{ id: 'file1', name: 'Image 1.png', type: 'file', status: 'processed' },
|
||||
{ id: 'file2', name: 'Image 2.png', type: 'file', status: 'processed' },
|
||||
] as unknown as AssetInfo[]
|
||||
|
||||
it('selects range when starting with version_stack and ending with a regular file', () => {
|
||||
const lastSelectedItem = files[0] // version_stack
|
||||
const currentItem = files[2] // file2
|
||||
|
||||
const result = getSelectedRangeIds(
|
||||
lastSelectedItem,
|
||||
currentItem,
|
||||
'stack1',
|
||||
folders,
|
||||
files,
|
||||
new Set(['stack1']),
|
||||
)
|
||||
|
||||
expect(result).not.toBeNull()
|
||||
expect(result?.size).toBe(3)
|
||||
expect(result?.has('stack1')).toBe(true)
|
||||
expect(result?.has('file1')).toBe(true)
|
||||
expect(result?.has('file2')).toBe(true)
|
||||
})
|
||||
|
||||
it('selects range when starting with a regular file and ending with version_stack', () => {
|
||||
const lastSelectedItem = files[2] // file2
|
||||
const currentItem = files[0] // stack1
|
||||
|
||||
const result = getSelectedRangeIds(
|
||||
lastSelectedItem,
|
||||
currentItem,
|
||||
'file2',
|
||||
folders,
|
||||
files,
|
||||
new Set(['file2']),
|
||||
)
|
||||
|
||||
expect(result).not.toBeNull()
|
||||
expect(result?.size).toBe(3)
|
||||
expect(result?.has('stack1')).toBe(true)
|
||||
expect(result?.has('file1')).toBe(true)
|
||||
expect(result?.has('file2')).toBe(true)
|
||||
})
|
||||
|
||||
it('returns null when range selecting across folder and file', () => {
|
||||
const lastSelectedItem = folders[0] // folder1
|
||||
const currentItem = files[1] // file1
|
||||
|
||||
const result = getSelectedRangeIds(
|
||||
lastSelectedItem,
|
||||
currentItem,
|
||||
'folder1',
|
||||
folders,
|
||||
files,
|
||||
new Set(['folder1']),
|
||||
)
|
||||
|
||||
expect(result).toBeNull()
|
||||
})
|
||||
|
||||
it('selects range between folders', () => {
|
||||
const lastSelectedItem = folders[0] // folder1
|
||||
const currentItem = folders[1] // folder2
|
||||
|
||||
const result = getSelectedRangeIds(
|
||||
lastSelectedItem,
|
||||
currentItem,
|
||||
'folder1',
|
||||
folders,
|
||||
files,
|
||||
new Set(['folder1']),
|
||||
)
|
||||
|
||||
expect(result).not.toBeNull()
|
||||
expect(result?.size).toBe(2)
|
||||
expect(result?.has('folder1')).toBe(true)
|
||||
expect(result?.has('folder2')).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,38 @@
|
||||
import type { AssetInfo } from '@shumai/dtos'
|
||||
|
||||
export function getSelectedRangeIds(
|
||||
lastSelectedItem: AssetInfo,
|
||||
currentItem: AssetInfo,
|
||||
lastSelectedId: string,
|
||||
folders: AssetInfo[],
|
||||
files: AssetInfo[],
|
||||
currentSelectedIds: Set<string>,
|
||||
): Set<string> | null {
|
||||
const isLastFolder = lastSelectedItem.type === 'folder'
|
||||
const isCurrentFolder = currentItem.type === 'folder'
|
||||
|
||||
if (isLastFolder !== isCurrentFolder) {
|
||||
return null
|
||||
}
|
||||
|
||||
const typeItems = isCurrentFolder ? folders : files
|
||||
const lastIndex = typeItems.findIndex((i) => i.id === lastSelectedId)
|
||||
const currentIndex = typeItems.findIndex((i) => i.id === currentItem.id)
|
||||
|
||||
if (lastIndex === -1 || currentIndex === -1) {
|
||||
return null
|
||||
}
|
||||
|
||||
const start = Math.min(lastIndex, currentIndex)
|
||||
const end = Math.max(lastIndex, currentIndex)
|
||||
const rangeItems = typeItems.slice(start, end + 1)
|
||||
|
||||
const newSelectedIds = new Set(currentSelectedIds)
|
||||
rangeItems.forEach((rangeItem) => {
|
||||
if (rangeItem.id) {
|
||||
newSelectedIds.add(rangeItem.id)
|
||||
}
|
||||
})
|
||||
|
||||
return newSelectedIds
|
||||
}
|
||||
@@ -870,5 +870,18 @@
|
||||
"no_chat_agents_warning": "No chat agents found. Please create a Chat Agent below first.",
|
||||
"select_agent": "Select Agent",
|
||||
"delete_comment_confirm": "Delete Comment?",
|
||||
"delete_comment_description": "Are you sure you want to delete this comment? This action cannot be undone."
|
||||
"delete_comment_description": "Are you sure you want to delete this comment? This action cannot be undone.",
|
||||
"ai_usage": "AI Token Usage",
|
||||
"ai_usage_description": "Monitor AI token consumption and estimated costs for your team and members.",
|
||||
"usage": "Usage",
|
||||
"input_tokens": "Input Tokens",
|
||||
"output_tokens": "Output Tokens",
|
||||
"cache_read_tokens": "Cache Read Tokens",
|
||||
"total_tokens": "Total Tokens",
|
||||
"cost": "Cost",
|
||||
"team_view": "Team",
|
||||
"members_view": "Members",
|
||||
"access_denied": "Access Denied",
|
||||
"only_owner_dashboard": "Only team owners can access the dashboard.",
|
||||
"role": "Role"
|
||||
}
|
||||
|
||||
@@ -870,5 +870,18 @@
|
||||
"no_chat_agents_warning": "未找到聊天智能体。请先在下方创建聊天智能体。",
|
||||
"select_agent": "选择智能体",
|
||||
"delete_comment_confirm": "删除评论?",
|
||||
"delete_comment_description": "您确定要删除这条评论吗?此操作将无法撤回。"
|
||||
"delete_comment_description": "您确定要删除这条评论吗?此操作将无法撤回。",
|
||||
"ai_usage": "AI Token 用量",
|
||||
"ai_usage_description": "查看并监控团队及成员的 AI Token 消耗与预估费用。",
|
||||
"usage": "用量",
|
||||
"input_tokens": "输入 Token",
|
||||
"output_tokens": "输出 Token",
|
||||
"cache_read_tokens": "缓存读取 Token",
|
||||
"total_tokens": "总 Token",
|
||||
"cost": "费用",
|
||||
"team_view": "团队",
|
||||
"members_view": "成员",
|
||||
"access_denied": "访问被拒绝",
|
||||
"only_owner_dashboard": "只有团队所有者才能访问仪表盘。",
|
||||
"role": "角色"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@shumai/webui",
|
||||
"version": "0.2.1",
|
||||
"version": "0.2.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./index.html",
|
||||
|
||||
+13
@@ -817,4 +817,17 @@ export * from "./no_chat_agents_warning.js";
|
||||
export * from "./select_agent.js";
|
||||
export * from "./delete_comment_confirm.js";
|
||||
export * from "./delete_comment_description.js";
|
||||
export * from "./ai_usage.js";
|
||||
export * from "./ai_usage_description.js";
|
||||
export * from "./usage.js";
|
||||
export * from "./input_tokens.js";
|
||||
export * from "./output_tokens.js";
|
||||
export * from "./cache_read_tokens.js";
|
||||
export * from "./total_tokens.js";
|
||||
export * from "./cost.js";
|
||||
export * from "./team_view.js";
|
||||
export * from "./members_view.js";
|
||||
export * from "./access_denied.js";
|
||||
export * from "./only_owner_dashboard.js";
|
||||
export * from "./role.js";
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
|
||||
+14
-1
@@ -818,4 +818,17 @@ export * from './select_chatbot_agent.js'
|
||||
export * from './no_chat_agents_warning.js'
|
||||
export * from './select_agent.js'
|
||||
export * from './delete_comment_confirm.js'
|
||||
export * from './delete_comment_description.js'
|
||||
export * from './delete_comment_description.js'
|
||||
export * from './ai_usage.js'
|
||||
export * from './ai_usage_description.js'
|
||||
export * from './usage.js'
|
||||
export * from './input_tokens.js'
|
||||
export * from './output_tokens.js'
|
||||
export * from './cache_read_tokens.js'
|
||||
export * from './total_tokens.js'
|
||||
export * from './cost.js'
|
||||
export * from './team_view.js'
|
||||
export * from './members_view.js'
|
||||
export * from './access_denied.js'
|
||||
export * from './only_owner_dashboard.js'
|
||||
export * from './role.js'
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Access Denied" |
|
||||
*
|
||||
* @param {Access_DeniedInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const access_denied: ((inputs?: Access_DeniedInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Access_DeniedInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Access_DeniedInputs = {};
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Access_DeniedInputs */
|
||||
|
||||
const en_access_denied = /** @type {(inputs: Access_DeniedInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Access Denied`)
|
||||
};
|
||||
|
||||
const zh_access_denied = /** @type {(inputs: Access_DeniedInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`访问被拒绝`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Access Denied" |
|
||||
*
|
||||
* @param {Access_DeniedInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const access_denied = /** @type {((inputs?: Access_DeniedInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Access_DeniedInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_access_denied(inputs)
|
||||
return zh_access_denied(inputs)
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "AI Token Usage" |
|
||||
*
|
||||
* @param {Ai_UsageInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const ai_usage: ((inputs?: Ai_UsageInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Ai_UsageInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Ai_UsageInputs = {};
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Ai_UsageInputs */
|
||||
|
||||
const en_ai_usage = /** @type {(inputs: Ai_UsageInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`AI Token Usage`)
|
||||
};
|
||||
|
||||
const zh_ai_usage = /** @type {(inputs: Ai_UsageInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`AI Token 用量`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "AI Token Usage" |
|
||||
*
|
||||
* @param {Ai_UsageInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const ai_usage = /** @type {((inputs?: Ai_UsageInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Ai_UsageInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_ai_usage(inputs)
|
||||
return zh_ai_usage(inputs)
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Monitor AI token consumption and estimated costs for your team and members." |
|
||||
*
|
||||
* @param {Ai_Usage_DescriptionInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const ai_usage_description: ((inputs?: Ai_Usage_DescriptionInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Ai_Usage_DescriptionInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Ai_Usage_DescriptionInputs = {};
|
||||
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Ai_Usage_DescriptionInputs */
|
||||
|
||||
const en_ai_usage_description = /** @type {(inputs: Ai_Usage_DescriptionInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Monitor AI token consumption and estimated costs for your team and members.`)
|
||||
};
|
||||
|
||||
const zh_ai_usage_description = /** @type {(inputs: Ai_Usage_DescriptionInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`查看并监控团队及成员的 AI Token 消耗与预估费用。`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Monitor AI token consumption and estimated costs for your team and members." |
|
||||
*
|
||||
* @param {Ai_Usage_DescriptionInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const ai_usage_description = /** @type {((inputs?: Ai_Usage_DescriptionInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Ai_Usage_DescriptionInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_ai_usage_description(inputs)
|
||||
return zh_ai_usage_description(inputs)
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Cache Read Tokens" |
|
||||
*
|
||||
* @param {Cache_Read_TokensInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const cache_read_tokens: ((inputs?: Cache_Read_TokensInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Cache_Read_TokensInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Cache_Read_TokensInputs = {};
|
||||
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Cache_Read_TokensInputs */
|
||||
|
||||
const en_cache_read_tokens = /** @type {(inputs: Cache_Read_TokensInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Cache Read Tokens`)
|
||||
};
|
||||
|
||||
const zh_cache_read_tokens = /** @type {(inputs: Cache_Read_TokensInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`缓存读取 Token`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Cache Read Tokens" |
|
||||
*
|
||||
* @param {Cache_Read_TokensInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const cache_read_tokens = /** @type {((inputs?: Cache_Read_TokensInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Cache_Read_TokensInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_cache_read_tokens(inputs)
|
||||
return zh_cache_read_tokens(inputs)
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Cost" |
|
||||
*
|
||||
* @param {CostInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const cost: ((inputs?: CostInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<CostInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type CostInputs = {};
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} CostInputs */
|
||||
|
||||
const en_cost = /** @type {(inputs: CostInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Cost`)
|
||||
};
|
||||
|
||||
const zh_cost = /** @type {(inputs: CostInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`费用`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Cost" |
|
||||
*
|
||||
* @param {CostInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const cost = /** @type {((inputs?: CostInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<CostInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_cost(inputs)
|
||||
return zh_cost(inputs)
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Input Tokens" |
|
||||
*
|
||||
* @param {Input_TokensInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const input_tokens: ((inputs?: Input_TokensInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Input_TokensInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Input_TokensInputs = {};
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Input_TokensInputs */
|
||||
|
||||
const en_input_tokens = /** @type {(inputs: Input_TokensInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Input Tokens`)
|
||||
};
|
||||
|
||||
const zh_input_tokens = /** @type {(inputs: Input_TokensInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`输入 Token`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Input Tokens" |
|
||||
*
|
||||
* @param {Input_TokensInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const input_tokens = /** @type {((inputs?: Input_TokensInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Input_TokensInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_input_tokens(inputs)
|
||||
return zh_input_tokens(inputs)
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Members" |
|
||||
*
|
||||
* @param {Members_ViewInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const members_view: ((inputs?: Members_ViewInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Members_ViewInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Members_ViewInputs = {};
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Members_ViewInputs */
|
||||
|
||||
const en_members_view = /** @type {(inputs: Members_ViewInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Members`)
|
||||
};
|
||||
|
||||
const zh_members_view = /** @type {(inputs: Members_ViewInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`成员`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Members" |
|
||||
*
|
||||
* @param {Members_ViewInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const members_view = /** @type {((inputs?: Members_ViewInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Members_ViewInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_members_view(inputs)
|
||||
return zh_members_view(inputs)
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Only team owners can access the dashboard." |
|
||||
*
|
||||
* @param {Only_Owner_DashboardInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const only_owner_dashboard: ((inputs?: Only_Owner_DashboardInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Only_Owner_DashboardInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Only_Owner_DashboardInputs = {};
|
||||
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Only_Owner_DashboardInputs */
|
||||
|
||||
const en_only_owner_dashboard = /** @type {(inputs: Only_Owner_DashboardInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Only team owners can access the dashboard.`)
|
||||
};
|
||||
|
||||
const zh_only_owner_dashboard = /** @type {(inputs: Only_Owner_DashboardInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`只有团队所有者才能访问仪表盘。`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Only team owners can access the dashboard." |
|
||||
*
|
||||
* @param {Only_Owner_DashboardInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const only_owner_dashboard = /** @type {((inputs?: Only_Owner_DashboardInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Only_Owner_DashboardInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_only_owner_dashboard(inputs)
|
||||
return zh_only_owner_dashboard(inputs)
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Output Tokens" |
|
||||
*
|
||||
* @param {Output_TokensInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const output_tokens: ((inputs?: Output_TokensInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Output_TokensInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Output_TokensInputs = {};
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Output_TokensInputs */
|
||||
|
||||
const en_output_tokens = /** @type {(inputs: Output_TokensInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Output Tokens`)
|
||||
};
|
||||
|
||||
const zh_output_tokens = /** @type {(inputs: Output_TokensInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`输出 Token`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Output Tokens" |
|
||||
*
|
||||
* @param {Output_TokensInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const output_tokens = /** @type {((inputs?: Output_TokensInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Output_TokensInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_output_tokens(inputs)
|
||||
return zh_output_tokens(inputs)
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Role" |
|
||||
*
|
||||
* @param {RoleInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const role: ((inputs?: RoleInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<RoleInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type RoleInputs = {};
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} RoleInputs */
|
||||
|
||||
const en_role = /** @type {(inputs: RoleInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Role`)
|
||||
};
|
||||
|
||||
const zh_role = /** @type {(inputs: RoleInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`角色`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Role" |
|
||||
*
|
||||
* @param {RoleInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const role = /** @type {((inputs?: RoleInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<RoleInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_role(inputs)
|
||||
return zh_role(inputs)
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Team" |
|
||||
*
|
||||
* @param {Team_ViewInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const team_view: ((inputs?: Team_ViewInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Team_ViewInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Team_ViewInputs = {};
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Team_ViewInputs */
|
||||
|
||||
const en_team_view = /** @type {(inputs: Team_ViewInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Team`)
|
||||
};
|
||||
|
||||
const zh_team_view = /** @type {(inputs: Team_ViewInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`团队`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Team" |
|
||||
*
|
||||
* @param {Team_ViewInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const team_view = /** @type {((inputs?: Team_ViewInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Team_ViewInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_team_view(inputs)
|
||||
return zh_team_view(inputs)
|
||||
});
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Total Tokens" |
|
||||
*
|
||||
* @param {Total_TokensInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const total_tokens: ((inputs?: Total_TokensInputs, options?: {
|
||||
locale?: "en" | "zh";
|
||||
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Total_TokensInputs, {
|
||||
locale?: "en" | "zh";
|
||||
}, {}>;
|
||||
export type LocalizedString = import("../runtime.js").LocalizedString;
|
||||
export type Total_TokensInputs = {};
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable */
|
||||
import { getLocale, experimentalStaticLocale } from '../runtime.js';
|
||||
|
||||
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
|
||||
|
||||
/** @typedef {{}} Total_TokensInputs */
|
||||
|
||||
const en_total_tokens = /** @type {(inputs: Total_TokensInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`Total Tokens`)
|
||||
};
|
||||
|
||||
const zh_total_tokens = /** @type {(inputs: Total_TokensInputs) => LocalizedString} */ () => {
|
||||
return /** @type {LocalizedString} */ (`总 Token`)
|
||||
};
|
||||
|
||||
/**
|
||||
* | output |
|
||||
* | --- |
|
||||
* | "Total Tokens" |
|
||||
*
|
||||
* @param {Total_TokensInputs} inputs
|
||||
* @param {{ locale?: "en" | "zh" }} options
|
||||
* @returns {LocalizedString}
|
||||
*/
|
||||
export const total_tokens = /** @type {((inputs?: Total_TokensInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Total_TokensInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
|
||||
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
|
||||
if (locale === "en") return en_total_tokens(inputs)
|
||||
return zh_total_tokens(inputs)
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user