mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 02:39:27 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72654e84b2 | ||
|
|
cec3821d00 | ||
|
|
dc3dbcb73e | ||
|
|
6226090fd1 | ||
|
|
d052c56d39 | ||
|
|
bd13fa7774 | ||
|
|
5e462cc7b1 | ||
|
|
73c11af9a3 | ||
|
|
adb73b56a2 | ||
|
|
e5dcf02b26 | ||
|
|
684f88a406 | ||
|
|
8ec970e2bf | ||
|
|
3eb7894df9 | ||
|
|
464167ec83 |
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shumai/agent-app",
|
"name": "@shumai/agent-app",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shumai/cli",
|
"name": "@shumai/cli",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shumai/transcode-app",
|
"name": "@shumai/transcode-app",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shumai/web-app",
|
"name": "@shumai/web-app",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
},
|
},
|
||||||
"apps/agent": {
|
"apps/agent": {
|
||||||
"name": "@shumai/agent-app",
|
"name": "@shumai/agent-app",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
"bin": {
|
"bin": {
|
||||||
"shumai-agent": "./src/index.ts",
|
"shumai-agent": "./src/index.ts",
|
||||||
},
|
},
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
},
|
},
|
||||||
"apps/cli": {
|
"apps/cli": {
|
||||||
"name": "@shumai/cli",
|
"name": "@shumai/cli",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
"bin": {
|
"bin": {
|
||||||
"shumai-cli": "./src/index.ts",
|
"shumai-cli": "./src/index.ts",
|
||||||
},
|
},
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
},
|
},
|
||||||
"apps/transcode": {
|
"apps/transcode": {
|
||||||
"name": "@shumai/transcode-app",
|
"name": "@shumai/transcode-app",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
"bin": {
|
"bin": {
|
||||||
"shumai-transcode": "./src/index.ts",
|
"shumai-transcode": "./src/index.ts",
|
||||||
},
|
},
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
},
|
},
|
||||||
"apps/web": {
|
"apps/web": {
|
||||||
"name": "@shumai/web-app",
|
"name": "@shumai/web-app",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shumai/agent": "workspace:*",
|
"@shumai/agent": "workspace:*",
|
||||||
"@shumai/api": "workspace:*",
|
"@shumai/api": "workspace:*",
|
||||||
@@ -92,7 +92,7 @@
|
|||||||
},
|
},
|
||||||
"packages/agent": {
|
"packages/agent": {
|
||||||
"name": "@shumai/agent",
|
"name": "@shumai/agent",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@anthropic-ai/sandbox-runtime": "0.0.52",
|
"@anthropic-ai/sandbox-runtime": "0.0.52",
|
||||||
"@earendil-works/pi-agent-core": "0.78.0",
|
"@earendil-works/pi-agent-core": "0.78.0",
|
||||||
@@ -117,7 +117,7 @@
|
|||||||
},
|
},
|
||||||
"packages/api": {
|
"packages/api": {
|
||||||
"name": "@shumai/api",
|
"name": "@shumai/api",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hono/zod-validator": "0.7.6",
|
"@hono/zod-validator": "0.7.6",
|
||||||
"@shumai/core": "workspace:*",
|
"@shumai/core": "workspace:*",
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
},
|
},
|
||||||
"packages/core": {
|
"packages/core": {
|
||||||
"name": "@shumai/core",
|
"name": "@shumai/core",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@earendil-works/pi-agent-core": "0.78.0",
|
"@earendil-works/pi-agent-core": "0.78.0",
|
||||||
"@shumai/db": "workspace:*",
|
"@shumai/db": "workspace:*",
|
||||||
@@ -162,7 +162,7 @@
|
|||||||
},
|
},
|
||||||
"packages/db": {
|
"packages/db": {
|
||||||
"name": "@shumai/db",
|
"name": "@shumai/db",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@earendil-works/pi-agent-core": "0.78.0",
|
"@earendil-works/pi-agent-core": "0.78.0",
|
||||||
"@prisma/adapter-pg": "7.8.0",
|
"@prisma/adapter-pg": "7.8.0",
|
||||||
@@ -178,7 +178,7 @@
|
|||||||
},
|
},
|
||||||
"packages/dtos": {
|
"packages/dtos": {
|
||||||
"name": "@shumai/dtos",
|
"name": "@shumai/dtos",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@earendil-works/pi-agent-core": "0.78.0",
|
"@earendil-works/pi-agent-core": "0.78.0",
|
||||||
"zod": "4.4.3",
|
"zod": "4.4.3",
|
||||||
@@ -186,7 +186,7 @@
|
|||||||
},
|
},
|
||||||
"packages/e2e": {
|
"packages/e2e": {
|
||||||
"name": "@shumai/e2e",
|
"name": "@shumai/e2e",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@earendil-works/pi-agent-core": "0.78.0",
|
"@earendil-works/pi-agent-core": "0.78.0",
|
||||||
"@google/genai": "1.52.0",
|
"@google/genai": "1.52.0",
|
||||||
@@ -196,15 +196,16 @@
|
|||||||
"@shumai/dtos": "workspace:*",
|
"@shumai/dtos": "workspace:*",
|
||||||
"@shumai/transcode": "workspace:*",
|
"@shumai/transcode": "workspace:*",
|
||||||
"@shumai/workflow-core": "workspace:*",
|
"@shumai/workflow-core": "workspace:*",
|
||||||
|
"sharp": "0.35.3",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"packages/tableprinter": {
|
"packages/tableprinter": {
|
||||||
"name": "@shumai/tableprinter",
|
"name": "@shumai/tableprinter",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
},
|
},
|
||||||
"packages/transcode": {
|
"packages/transcode": {
|
||||||
"name": "@shumai/transcode",
|
"name": "@shumai/transcode",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shumai/core": "workspace:*",
|
"@shumai/core": "workspace:*",
|
||||||
"@shumai/db": "workspace:*",
|
"@shumai/db": "workspace:*",
|
||||||
@@ -218,7 +219,7 @@
|
|||||||
},
|
},
|
||||||
"packages/webui": {
|
"packages/webui": {
|
||||||
"name": "@shumai/webui",
|
"name": "@shumai/webui",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@base-ui/react": "1.5.0",
|
"@base-ui/react": "1.5.0",
|
||||||
"@dnd-kit/abstract": "0.4.0",
|
"@dnd-kit/abstract": "0.4.0",
|
||||||
@@ -316,7 +317,7 @@
|
|||||||
},
|
},
|
||||||
"packages/workflow-core": {
|
"packages/workflow-core": {
|
||||||
"name": "@shumai/workflow-core",
|
"name": "@shumai/workflow-core",
|
||||||
"version": "0.2.0",
|
"version": "0.2.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@shumai/core": "workspace:*",
|
"@shumai/core": "workspace:*",
|
||||||
"@shumai/db": "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-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-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=="],
|
"@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-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-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=="],
|
"@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=="],
|
"@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/@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=="],
|
"@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=="],
|
"@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/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=="],
|
"@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=="],
|
"@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/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=="],
|
"@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=="],
|
"@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=="],
|
"@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=="],
|
"@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",
|
"name": "shumai",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shumai/agent",
|
"name": "@shumai/agent",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./src/index.ts",
|
"main": "./src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shumai/api",
|
"name": "@shumai/api",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./src/index.ts",
|
"main": "./src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shumai/core",
|
"name": "@shumai/core",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./src/index.ts",
|
"main": "./src/index.ts",
|
||||||
|
|||||||
@@ -646,6 +646,97 @@ describe('TranscodeService', () => {
|
|||||||
expect(b).toBeLessThan(100)
|
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 () => {
|
it('should generate PDF from text file including CJK characters', async () => {
|
||||||
const txtFile = path.join(tempDir, 'test.txt')
|
const txtFile = path.join(tempDir, 'test.txt')
|
||||||
const pdfFile = path.join(tempDir, 'output.pdf')
|
const pdfFile = path.join(tempDir, 'output.pdf')
|
||||||
|
|||||||
@@ -923,10 +923,13 @@ export class TranscodeService {
|
|||||||
timestamps = Array.from({ length: params.count }, (_, i) => params.start + i * step)
|
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 commentTimestamp = params.commentTimestamp
|
||||||
|
const EPSILON = 0.1
|
||||||
if (commentTimestamp !== undefined && commentTimestamp !== null) {
|
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 closestIdx = 0
|
||||||
let minDiff = Math.abs(timestamps[0] - commentTimestamp)
|
let minDiff = Math.abs(timestamps[0] - commentTimestamp)
|
||||||
for (let i = 1; i < timestamps.length; i++) {
|
for (let i = 1; i < timestamps.length; i++) {
|
||||||
@@ -964,14 +967,13 @@ export class TranscodeService {
|
|||||||
]
|
]
|
||||||
await execFileAsync('ffmpeg', ['-y', '-loglevel', 'warning', ...args])
|
await execFileAsync('ffmpeg', ['-y', '-loglevel', 'warning', ...args])
|
||||||
|
|
||||||
// 5. Overlay annotations if timestamp matches commentTimestamp exactly
|
const isMatch =
|
||||||
if (
|
|
||||||
commentTimestamp !== undefined &&
|
commentTimestamp !== undefined &&
|
||||||
commentTimestamp !== null &&
|
commentTimestamp !== null &&
|
||||||
t === commentTimestamp &&
|
Math.abs(t - commentTimestamp) < 1e-4
|
||||||
params.annotations &&
|
|
||||||
params.annotations.length > 0
|
// 5. Overlay annotations if timestamp matches commentTimestamp (within float tolerance)
|
||||||
) {
|
if (isMatch && params.annotations && params.annotations.length > 0) {
|
||||||
const shotBuffer = fs.readFileSync(localShotPath)
|
const shotBuffer = fs.readFileSync(localShotPath)
|
||||||
const composited = await this.overlayAnnotationsOnBuffer(shotBuffer, params.annotations)
|
const composited = await this.overlayAnnotationsOnBuffer(shotBuffer, params.annotations)
|
||||||
fs.writeFileSync(localShotPath, composited)
|
fs.writeFileSync(localShotPath, composited)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shumai/db",
|
"name": "@shumai/db",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./src/index.ts",
|
"main": "./src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shumai/dtos",
|
"name": "@shumai/dtos",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./src/index.ts",
|
"main": "./src/index.ts",
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "@shumai/e2e",
|
"name": "@shumai/e2e",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"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",
|
"@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,871 +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 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)
|
|
||||||
|
|
||||||
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",
|
"name": "@shumai/tableprinter",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./src/index.ts",
|
"main": "./src/index.ts",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shumai/transcode",
|
"name": "@shumai/transcode",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./src/index.ts",
|
"main": "./src/index.ts",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { useChatbotStore } from '@/ui/stores/chatbot'
|
|||||||
import { useTeamContextStore } from '@/ui/stores/team-context'
|
import { useTeamContextStore } from '@/ui/stores/team-context'
|
||||||
import { useDroppable } from '@dnd-kit/react'
|
import { useDroppable } from '@dnd-kit/react'
|
||||||
import type { ChatMessage } from '@shumai/dtos'
|
import type { ChatMessage } from '@shumai/dtos'
|
||||||
import { useQuery } from '@tanstack/react-query'
|
import { useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
import {
|
import {
|
||||||
ArrowLeft,
|
ArrowLeft,
|
||||||
ArrowUp,
|
ArrowUp,
|
||||||
@@ -26,7 +26,7 @@ import {
|
|||||||
Trash2,
|
Trash2,
|
||||||
Wrench,
|
Wrench,
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { useEffect, useRef, useState } from 'react'
|
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||||
import Markdown from 'react-markdown'
|
import Markdown from 'react-markdown'
|
||||||
import { formatTimeAgo } from '../lib/time'
|
import { formatTimeAgo } from '../lib/time'
|
||||||
|
|
||||||
@@ -171,9 +171,20 @@ export function ChatbotSidebar({ projectId, contextAssetId }: ChatbotSidebarProp
|
|||||||
}
|
}
|
||||||
}, [isHistoryMode, fetchHistorySessions, teamId])
|
}, [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 = () => {
|
const handleSend = () => {
|
||||||
if (!inputText.trim() || isStreaming || !teamId) return
|
if (!inputText.trim() || isStreaming || !teamId) return
|
||||||
sendMessage(teamId, inputText, projectId, contextAssetId)
|
sendMessage(teamId, inputText, projectId, contextAssetId, handleAssetMutation)
|
||||||
setInputText('')
|
setInputText('')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -223,8 +223,8 @@ export function FileCard({
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
className={cn(
|
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',
|
'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 && 'outline-1 outline-primary border-primary',
|
(isSelected || isChecked) && 'outline-1 outline-primary border-primary',
|
||||||
showDropFeedback && 'border-primary outline-1 outline-primary',
|
showDropFeedback && 'border-primary outline-1 outline-primary',
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -183,12 +183,12 @@ export function FileListItem({
|
|||||||
e.preventDefault()
|
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
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'px-4 py-2 sticky left-0 z-10 transition-colors border-r shrink-0',
|
'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={{
|
style={{
|
||||||
width: columnSizing?.['name'] || 300,
|
width: columnSizing?.['name'] || 300,
|
||||||
|
|||||||
@@ -272,7 +272,7 @@ export function FolderCard({
|
|||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
className={cn(
|
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">
|
<div className="absolute inset-0 z-10 pointer-events-none">
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ function ListRow({
|
|||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
className={cn(
|
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',
|
isSelected && 'bg-primary/10',
|
||||||
showDropFeedback && 'bg-primary/10',
|
showDropFeedback && 'bg-primary/10',
|
||||||
isTopOver && 'border-t-2 border-t-primary',
|
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 { useUiStore } from '@/ui/stores/ui'
|
||||||
import { useUserMetadataStore } from '@/ui/stores/user-metadata'
|
import { useUserMetadataStore } from '@/ui/stores/user-metadata'
|
||||||
import { Feedback, PointerActivationConstraints } from '@dnd-kit/dom'
|
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 { useInfiniteQuery, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||||
import { useNavigate } from '@tanstack/react-router'
|
import { useNavigate } from '@tanstack/react-router'
|
||||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||||
import { cn } from '../lib/utils'
|
import { cn } from '../lib/utils'
|
||||||
|
import { getSelectedRangeIds } from '../lib/selection-utils'
|
||||||
import { ChatbotSidebar } from './chatbot-sidebar'
|
import { ChatbotSidebar } from './chatbot-sidebar'
|
||||||
import { SnapToPointer } from './dnd-modifiers'
|
import { SnapToPointer } from './dnd-modifiers'
|
||||||
import { FileBrowser } from './file-browser/file-browser'
|
import { FileBrowser } from './file-browser/file-browser'
|
||||||
@@ -337,27 +338,18 @@ export default function FileSystemManager({
|
|||||||
const lastSelectedItem = allItems.find((i) => i.id === lastSelectedId)
|
const lastSelectedItem = allItems.find((i) => i.id === lastSelectedId)
|
||||||
|
|
||||||
if (lastSelectedItem) {
|
if (lastSelectedItem) {
|
||||||
if (lastSelectedItem.type === item.type) {
|
const newSelectedIds = getSelectedRangeIds(
|
||||||
// Only select range if they are the same type
|
lastSelectedItem,
|
||||||
const typeItems = item.type === 'folder' ? folders : files
|
item,
|
||||||
const lastIndex = typeItems.findIndex((i) => i.id === lastSelectedId)
|
lastSelectedId,
|
||||||
const currentIndex = typeItems.findIndex((i) => i.id === item.id)
|
folders,
|
||||||
|
files,
|
||||||
|
selectedIds,
|
||||||
|
)
|
||||||
|
|
||||||
if (lastIndex !== -1 && currentIndex !== -1) {
|
if (newSelectedIds) {
|
||||||
const start = Math.min(lastIndex, currentIndex)
|
setSelectedIds(newSelectedIds)
|
||||||
const end = Math.max(lastIndex, currentIndex)
|
setSelectedItem(item)
|
||||||
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)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -426,7 +418,6 @@ export default function FileSystemManager({
|
|||||||
PointerSensor.configure({
|
PointerSensor.configure({
|
||||||
activationConstraints: [new PointerActivationConstraints.Distance({ value: 10 })],
|
activationConstraints: [new PointerActivationConstraints.Distance({ value: 10 })],
|
||||||
}),
|
}),
|
||||||
KeyboardSensor,
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
onDragStart={handleDragStart}
|
onDragStart={handleDragStart}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { ShareSettingsSidebar } from './share-settings-sidebar'
|
|||||||
import { FolderTree } from './folder-tree'
|
import { FolderTree } from './folder-tree'
|
||||||
import { ResizeHandle } from './resize-handle'
|
import { ResizeHandle } from './resize-handle'
|
||||||
import { useFileSystemDnd } from './use-file-system-dnd'
|
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 { PointerActivationConstraints } from '@dnd-kit/dom'
|
||||||
import { SnapToPointer } from './dnd-modifiers'
|
import { SnapToPointer } from './dnd-modifiers'
|
||||||
import { useUiStore } from '@/ui/stores/ui'
|
import { useUiStore } from '@/ui/stores/ui'
|
||||||
@@ -268,7 +268,6 @@ export default function ShareManager({
|
|||||||
PointerSensor.configure({
|
PointerSensor.configure({
|
||||||
activationConstraints: [new PointerActivationConstraints.Distance({ value: 10 })],
|
activationConstraints: [new PointerActivationConstraints.Distance({ value: 10 })],
|
||||||
}),
|
}),
|
||||||
KeyboardSensor,
|
|
||||||
]}
|
]}
|
||||||
onDragStart={handleDragStart}
|
onDragStart={handleDragStart}
|
||||||
onDragEnd={handleDragEnd}
|
onDragEnd={handleDragEnd}
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shumai/webui",
|
"name": "@shumai/webui",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./index.html",
|
"main": "./index.html",
|
||||||
|
|||||||
@@ -259,4 +259,44 @@ describe('useChatbotStore', () => {
|
|||||||
expect(finalState.messages[0].id).toBe('context-display-ulid')
|
expect(finalState.messages[0].id).toBe('context-display-ulid')
|
||||||
expect(finalState.messages[1].id).toBe('user-msg-ulid')
|
expect(finalState.messages[1].id).toBe('user-msg-ulid')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should invoke onAssetMutation callback when asset creation tool result arrives', async () => {
|
||||||
|
const mockEvents = [
|
||||||
|
'data: {"type":"session","sessionId":"sess-123"}\n\n',
|
||||||
|
'data: {"type":"entry","entry":{"id":"user-msg-ulid","role":"user","content":[{"type":"text","text":"create a file"}],"timestamp":123}}\n\n',
|
||||||
|
'data: {"type":"entry","entry":{"id":"tool-res-ulid","role":"toolResult","toolName":"create_file","isError":false,"content":"File created","timestamp":124}}\n\n',
|
||||||
|
'data: {"type":"done","status":"completed"}\n\n',
|
||||||
|
]
|
||||||
|
|
||||||
|
let eventIdx = 0
|
||||||
|
const mockReader = {
|
||||||
|
read: vi.fn(async () => {
|
||||||
|
if (eventIdx < mockEvents.length) {
|
||||||
|
const value = new TextEncoder().encode(mockEvents[eventIdx++])
|
||||||
|
return { done: false, value }
|
||||||
|
}
|
||||||
|
return { done: true, value: undefined }
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
|
||||||
|
const mockResponse = {
|
||||||
|
ok: true,
|
||||||
|
headers: {
|
||||||
|
get: vi.fn(() => 'sess-123'),
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
getReader: () => mockReader,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
vi.mocked(client.api.teams[':teamId'].chat.$post).mockResolvedValue(mockResponse as any)
|
||||||
|
|
||||||
|
const onAssetMutation = vi.fn()
|
||||||
|
await useChatbotStore
|
||||||
|
.getState()
|
||||||
|
.sendMessage('team-123', 'create a file', 'proj-123', undefined, onAssetMutation)
|
||||||
|
|
||||||
|
expect(onAssetMutation).toHaveBeenCalledTimes(1)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ interface ChatbotState {
|
|||||||
text: string,
|
text: string,
|
||||||
projectId: string,
|
projectId: string,
|
||||||
contextAssetId?: string,
|
contextAssetId?: string,
|
||||||
|
onAssetMutation?: () => void,
|
||||||
) => Promise<void>
|
) => Promise<void>
|
||||||
abortActiveSession: (teamId: string) => Promise<void>
|
abortActiveSession: (teamId: string) => Promise<void>
|
||||||
}
|
}
|
||||||
@@ -151,7 +152,7 @@ export const useChatbotStore = create<ChatbotState>((set) => ({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
sendMessage: async (teamId, text, projectId, contextAssetId) => {
|
sendMessage: async (teamId, text, projectId, contextAssetId, onAssetMutation) => {
|
||||||
const state = useChatbotStore.getState()
|
const state = useChatbotStore.getState()
|
||||||
if (state.isStreaming) return
|
if (state.isStreaming) return
|
||||||
|
|
||||||
@@ -251,6 +252,16 @@ export const useChatbotStore = create<ChatbotState>((set) => ({
|
|||||||
}
|
}
|
||||||
} else if (data.type === 'entry') {
|
} else if (data.type === 'entry') {
|
||||||
const entry = data.entry as ChatMessage
|
const entry = data.entry as ChatMessage
|
||||||
|
const entryObj = entry as unknown as Record<string, unknown>
|
||||||
|
if (
|
||||||
|
entryObj.role === 'toolResult' &&
|
||||||
|
typeof entryObj.toolName === 'string' &&
|
||||||
|
['create_file', 'create_folder', 'create_version'].includes(entryObj.toolName) &&
|
||||||
|
!entryObj.isError
|
||||||
|
) {
|
||||||
|
onAssetMutation?.()
|
||||||
|
}
|
||||||
|
|
||||||
set((s) => {
|
set((s) => {
|
||||||
const isExisting = s.messages.some((m) => m.id === entry.id)
|
const isExisting = s.messages.some((m) => m.id === entry.id)
|
||||||
// Replace temp/optimistic message when the real counterpart streams back
|
// Replace temp/optimistic message when the real counterpart streams back
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export const useUiStore = create<UiState>()(
|
|||||||
setFileViewLeftSidebarCollapsed: (collapsed) =>
|
setFileViewLeftSidebarCollapsed: (collapsed) =>
|
||||||
set({ fileViewLeftSidebarCollapsed: collapsed }),
|
set({ fileViewLeftSidebarCollapsed: collapsed }),
|
||||||
|
|
||||||
fileViewRightSidebarCollapsed: true,
|
fileViewRightSidebarCollapsed: false,
|
||||||
setFileViewRightSidebarCollapsed: (collapsed) =>
|
setFileViewRightSidebarCollapsed: (collapsed) =>
|
||||||
set({ fileViewRightSidebarCollapsed: collapsed }),
|
set({ fileViewRightSidebarCollapsed: collapsed }),
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export const APP_VERSION = '0.2.2'
|
export const APP_VERSION = '0.2.3'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@shumai/workflow-core",
|
"name": "@shumai/workflow-core",
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./src/index.ts",
|
"main": "./src/index.ts",
|
||||||
|
|||||||
Reference in New Issue
Block a user