mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 15:09:20 +00:00
Merge branch 'main' into feat/virtualize-file-list
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Yiling-J
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -111,8 +111,6 @@
|
||||
"name": "@shumai/core",
|
||||
"version": "0.1.0",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.1031.0",
|
||||
"@aws-sdk/s3-request-presigner": "^3.1031.0",
|
||||
"@shumai/db": "workspace:*",
|
||||
"@shumai/dtos": "workspace:*",
|
||||
"@sinclair/typebox": "^0.34.49",
|
||||
@@ -294,10 +292,6 @@
|
||||
|
||||
"@aws-crypto/crc32": ["@aws-crypto/crc32@5.2.0", "", { "dependencies": { "@aws-crypto/util": "^5.2.0", "@aws-sdk/types": "^3.222.0", "tslib": "^2.6.2" } }, "sha512-nLbCWqQNgUiwwtFsen1AdzAtvuLRsQS8rYgMuxCrdKf9kOssamGLuPwyTY9wyYblNr9+1XM8v6zoDTPPSIeANg=="],
|
||||
|
||||
"@aws-crypto/crc32c": ["@aws-crypto/crc32c@5.2.0", "", { "dependencies": { "@aws-crypto/util": "^5.2.0", "@aws-sdk/types": "^3.222.0", "tslib": "^2.6.2" } }, "sha512-+iWb8qaHLYKrNvGRbiYRHSdKRWhto5XlZUEBwDjYNf+ly5SVYG6zEoYIdxvf5R3zyeP16w4PLBn3rH1xc74Rag=="],
|
||||
|
||||
"@aws-crypto/sha1-browser": ["@aws-crypto/sha1-browser@5.2.0", "", { "dependencies": { "@aws-crypto/supports-web-crypto": "^5.2.0", "@aws-crypto/util": "^5.2.0", "@aws-sdk/types": "^3.222.0", "@aws-sdk/util-locate-window": "^3.0.0", "@smithy/util-utf8": "^2.0.0", "tslib": "^2.6.2" } }, "sha512-OH6lveCFfcDjX4dbAvCFSYUjJZjDr/3XJ3xHtjn3Oj5b9RjojQo8npoLeA/bNwkOkrSQ0wgrHzXk4tDRxGKJeg=="],
|
||||
|
||||
"@aws-crypto/sha256-browser": ["@aws-crypto/sha256-browser@5.2.0", "", { "dependencies": { "@aws-crypto/sha256-js": "^5.2.0", "@aws-crypto/supports-web-crypto": "^5.2.0", "@aws-crypto/util": "^5.2.0", "@aws-sdk/types": "^3.222.0", "@aws-sdk/util-locate-window": "^3.0.0", "@smithy/util-utf8": "^2.0.0", "tslib": "^2.6.2" } }, "sha512-AXfN/lGotSQwu6HNcEsIASo7kWXZ5HYWvfOmSNKDsEqC4OashTp8alTmaz+F7TC2L083SFv5RdB+qU3Vs1kZqw=="],
|
||||
|
||||
"@aws-crypto/sha256-js": ["@aws-crypto/sha256-js@5.2.0", "", { "dependencies": { "@aws-crypto/util": "^5.2.0", "@aws-sdk/types": "^3.222.0", "tslib": "^2.6.2" } }, "sha512-FFQQyu7edu4ufvIZ+OadFpHHOt+eSTBaYaki44c+akjg7qZg9oOQeLlk77F6tSYqjDAFClrHJk9tMf0HdVyOvA=="],
|
||||
@@ -308,12 +302,8 @@
|
||||
|
||||
"@aws-sdk/client-bedrock-runtime": ["@aws-sdk/client-bedrock-runtime@3.1048.0", "", { "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "^3.974.11", "@aws-sdk/credential-provider-node": "^3.972.42", "@aws-sdk/eventstream-handler-node": "^3.972.16", "@aws-sdk/middleware-eventstream": "^3.972.12", "@aws-sdk/middleware-websocket": "^3.972.19", "@aws-sdk/token-providers": "3.1048.0", "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/fetch-http-handler": "^5.4.2", "@smithy/node-http-handler": "^4.7.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-u+NT61JZEkRFtpL0CAw1N1dwxnaLgwVXQl/zjJxTGgLyS/jTIdg2SdoEoCTHxgDyCnqa1HEi9QOoE9/pYRNpOQ=="],
|
||||
|
||||
"@aws-sdk/client-s3": ["@aws-sdk/client-s3@3.1058.0", "", { "dependencies": { "@aws-crypto/sha1-browser": "5.2.0", "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "^3.974.15", "@aws-sdk/credential-provider-node": "^3.972.48", "@aws-sdk/middleware-bucket-endpoint": "^3.972.17", "@aws-sdk/middleware-expect-continue": "^3.972.14", "@aws-sdk/middleware-flexible-checksums": "^3.974.23", "@aws-sdk/middleware-location-constraint": "^3.972.11", "@aws-sdk/middleware-sdk-s3": "^3.972.44", "@aws-sdk/middleware-ssec": "^3.972.11", "@aws-sdk/signature-v4-multi-region": "^3.996.30", "@aws-sdk/types": "^3.973.9", "@smithy/core": "^3.24.5", "@smithy/fetch-http-handler": "^5.4.5", "@smithy/node-http-handler": "^4.7.5", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-AfED3hhaBZ121NuiBImgnlF98kQRMk6hGPMGfj/Oo1hSaoMFRzM+N4nlICCasUSM2R8QaIRZRYGpZ3fy0ilGZQ=="],
|
||||
|
||||
"@aws-sdk/core": ["@aws-sdk/core@3.974.15", "", { "dependencies": { "@aws-sdk/types": "^3.973.9", "@aws-sdk/xml-builder": "^3.972.26", "@aws/lambda-invoke-store": "^0.2.2", "@smithy/core": "^3.24.5", "@smithy/signature-v4": "^5.4.5", "@smithy/types": "^4.14.2", "bowser": "^2.11.0", "tslib": "^2.6.2" } }, "sha512-UpA0rTGW/tHGITcCqHisbuuEPraYg9GG+mWmXjY5+RxZBMLGe6aL9oe0ix50LztwAcPIkGZLH0yWdMIkCM10hw=="],
|
||||
|
||||
"@aws-sdk/crc64-nvme": ["@aws-sdk/crc64-nvme@3.972.9", "", { "dependencies": { "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-P+QGozmXn2mZZI7sDgk+aUm+RTI61MPSFB+Ir2vjEjEbEsE4e7hYtzrDvAUxZy9ko81h53e11+F/GYlvwDkaOQ=="],
|
||||
|
||||
"@aws-sdk/credential-provider-env": ["@aws-sdk/credential-provider-env@3.972.41", "", { "dependencies": { "@aws-sdk/core": "^3.974.15", "@aws-sdk/types": "^3.973.9", "@smithy/core": "^3.24.5", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-n1EbJ98yvPWWdHZZv8bRBMqqDQJrtgtxyJ4xLy2Uqrh25BCOZQ7nnS1CsFXvuH8r0b0KVHDZEGEH5FxmEMP8jg=="],
|
||||
|
||||
"@aws-sdk/credential-provider-http": ["@aws-sdk/credential-provider-http@3.972.43", "", { "dependencies": { "@aws-sdk/core": "^3.974.15", "@aws-sdk/types": "^3.973.9", "@smithy/core": "^3.24.5", "@smithy/fetch-http-handler": "^5.4.5", "@smithy/node-http-handler": "^4.7.5", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-TT76RN1NkI9WoyZqCNxOw6/WBMF7pYOTJcXbMokNFU+euSG40Kaf/t/FhDACVZWP+43wEM6ZynIPIkzS1wR1iA=="],
|
||||
@@ -332,26 +322,12 @@
|
||||
|
||||
"@aws-sdk/eventstream-handler-node": ["@aws-sdk/eventstream-handler-node@3.972.18", "", { "dependencies": { "@aws-sdk/types": "^3.973.9", "@smithy/core": "^3.24.5", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-QPQhwY/fstR8fMZFWrsJRNoTP6D1RjRPHGRX7u9/VkF3opCsvD0oXPz6qzkX94SchzvuS5vyFZbJbPcMEs2Jeg=="],
|
||||
|
||||
"@aws-sdk/middleware-bucket-endpoint": ["@aws-sdk/middleware-bucket-endpoint@3.972.17", "", { "dependencies": { "@aws-sdk/core": "^3.974.15", "@aws-sdk/types": "^3.973.9", "@smithy/core": "^3.24.5", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-lbDmWuHenc+kiwCNrxz4MyN6nkxCWyTXPIWuspJN0ibziu+8CXci7vI1bK9MAkwy8cwJOEXNu0gBM5S0uTGRIg=="],
|
||||
|
||||
"@aws-sdk/middleware-eventstream": ["@aws-sdk/middleware-eventstream@3.972.14", "", { "dependencies": { "@aws-sdk/types": "^3.973.9", "@smithy/core": "^3.24.5", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-DoZ4djVj/74XQ6M/IwxuKh543tTvLCL7u1Dx+VDHMgW9yGNrFSJJ1l0LrUQRaekic5CB12wUiiOoHL0VI6H0gg=="],
|
||||
|
||||
"@aws-sdk/middleware-expect-continue": ["@aws-sdk/middleware-expect-continue@3.972.14", "", { "dependencies": { "@aws-sdk/types": "^3.973.9", "@smithy/core": "^3.24.5", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-3TNFEVGO4sWZj9TEXOCZLzGEctXHnaO4fk2EQ8KVaboTbwHmEPEQrm17Xb9koImUIXEw0sgi2xtHjg7LuTS3rA=="],
|
||||
|
||||
"@aws-sdk/middleware-flexible-checksums": ["@aws-sdk/middleware-flexible-checksums@3.974.23", "", { "dependencies": { "@aws-crypto/crc32": "5.2.0", "@aws-crypto/crc32c": "5.2.0", "@aws-crypto/util": "5.2.0", "@aws-sdk/core": "^3.974.15", "@aws-sdk/crc64-nvme": "^3.972.9", "@aws-sdk/types": "^3.973.9", "@smithy/core": "^3.24.5", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-4nPKARo2lfKvQGUt2fPA5NlS/mEohckdxpuC9ecbjVfj7B7NFFYHeTg+Bf5BEQwdn3yRfUIzFiEkPp8Yuaw3wA=="],
|
||||
|
||||
"@aws-sdk/middleware-location-constraint": ["@aws-sdk/middleware-location-constraint@3.972.11", "", { "dependencies": { "@aws-sdk/types": "^3.973.9", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-hkfspNUP4criAH6ton6BGKgnm5dZx+7bUOy1YqlTfejDeUPAM23D81q/IX+hdlS3KUsfwGz5ADTqZWKBEUpf4A=="],
|
||||
|
||||
"@aws-sdk/middleware-sdk-s3": ["@aws-sdk/middleware-sdk-s3@3.972.44", "", { "dependencies": { "@aws-sdk/core": "^3.974.15", "@aws-sdk/signature-v4-multi-region": "^3.996.30", "@aws-sdk/types": "^3.973.9", "@smithy/core": "^3.24.5", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-8HQsRg1NpX8vR4vNl1E8pyLnqZroq9VSL2vZQVSgBqp6wv6365LzYD08/c9FFh/9FTg7YRc7aTtEmXF0ir/pqg=="],
|
||||
|
||||
"@aws-sdk/middleware-ssec": ["@aws-sdk/middleware-ssec@3.972.11", "", { "dependencies": { "@aws-sdk/types": "^3.973.9", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-7PQvGNhtveKlvVqNahqWx5yrwxP7ecwAoB1dYBf8eKwfo2tzzCbNnW+q2nO3N066ktQaB4iBQbDRWtizm+amoQ=="],
|
||||
|
||||
"@aws-sdk/middleware-websocket": ["@aws-sdk/middleware-websocket@3.972.23", "", { "dependencies": { "@aws-sdk/core": "^3.974.15", "@aws-sdk/types": "^3.973.9", "@smithy/core": "^3.24.5", "@smithy/fetch-http-handler": "^5.4.5", "@smithy/signature-v4": "^5.4.5", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-F0d4A9pJFiwljyKgSwU1Z5n+CXSv8bp+V5SthbS2rftB8wBN9z1K2Yyv3xbeK0AM2T0g4q6Ptf0shFF+oQZyiA=="],
|
||||
|
||||
"@aws-sdk/nested-clients": ["@aws-sdk/nested-clients@3.997.13", "", { "dependencies": { "@aws-crypto/sha256-browser": "5.2.0", "@aws-crypto/sha256-js": "5.2.0", "@aws-sdk/core": "^3.974.15", "@aws-sdk/signature-v4-multi-region": "^3.996.30", "@aws-sdk/types": "^3.973.9", "@smithy/core": "^3.24.5", "@smithy/fetch-http-handler": "^5.4.5", "@smithy/node-http-handler": "^4.7.5", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-2pA6eyb5nSo/ZD2cayhOTEMoGQYgspq0RI05GDLkzQ3ajZ6isS6waV6E92Am/hz4LIlLUTrbwPLurJ/fuiHvkg=="],
|
||||
|
||||
"@aws-sdk/s3-request-presigner": ["@aws-sdk/s3-request-presigner@3.1058.0", "", { "dependencies": { "@aws-sdk/core": "^3.974.15", "@aws-sdk/signature-v4-multi-region": "^3.996.30", "@aws-sdk/types": "^3.973.9", "@smithy/core": "^3.24.5", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-IRgNfn8U3zfsZ0JkpmwjS59R/XyHMHxpuwW6HVuJhik+FsbClhNkujEO0w1WqJvXrF4FX+7qIAwUrvlwNvaZ7Q=="],
|
||||
|
||||
"@aws-sdk/signature-v4-multi-region": ["@aws-sdk/signature-v4-multi-region@3.996.30", "", { "dependencies": { "@aws-sdk/types": "^3.973.9", "@smithy/signature-v4": "^5.4.5", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-HULDLMVzkmTSEv6//7kx2kRevp/VYUpm8hJNNFbmhxDn0fUiGTxVcM9yg31TukvTq8nyOBDUN2gH0o5IRbKjdw=="],
|
||||
|
||||
"@aws-sdk/token-providers": ["@aws-sdk/token-providers@3.1048.0", "", { "dependencies": { "@aws-sdk/core": "^3.974.11", "@aws-sdk/nested-clients": "^3.997.9", "@aws-sdk/types": "^3.973.8", "@smithy/core": "^3.24.2", "@smithy/types": "^4.14.1", "tslib": "^2.6.2" } }, "sha512-k0y/GcuesuSfWyUM0WamrGyeZmltRYaPbHO82UDA6mZ/doB+FOHKutikPAtSXMn/hDz970cF+iRuuiYO9VEbAA=="],
|
||||
@@ -1016,7 +992,7 @@
|
||||
|
||||
"@smithy/is-array-buffer": ["@smithy/is-array-buffer@2.2.0", "", { "dependencies": { "tslib": "^2.6.2" } }, "sha512-GGP3O9QFD24uGeAXYUjwSTXARoqpZykHadOmA8G5vfJPK0/DC67qa//0qvqrJzL1xc8WQWX7/yc7fwudjPHPhA=="],
|
||||
|
||||
"@smithy/node-http-handler": ["@smithy/node-http-handler@4.7.6", "", { "dependencies": { "@smithy/core": "^3.24.6", "@smithy/types": "^4.14.3", "tslib": "^2.6.2" } }, "sha512-3fya8i7GrJilQouk4cZJKdy5k8MWQBpjfXrRNaXDedH8r779tr0jcxyH3+yoTmsluc2+vF4S343yFbnvu8ExDQ=="],
|
||||
"@smithy/node-http-handler": ["@smithy/node-http-handler@4.7.3", "", { "dependencies": { "@smithy/core": "^3.24.3", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-/jPhevcTFPMVl6KNjbaI47iOg1zxC7IsnX4PQDGVZKMFceOXtB8IEYaB7a9VvkP/3oC60WzTeKocvSI7vLT0vA=="],
|
||||
|
||||
"@smithy/signature-v4": ["@smithy/signature-v4@5.4.6", "", { "dependencies": { "@smithy/core": "^3.24.6", "@smithy/types": "^4.14.3", "tslib": "^2.6.2" } }, "sha512-Ojg4B6oIDlIr1R86xCDJt1zJWnYa0VINmqdjfe9qxWjdRivHalZ3iSlQgVqYbW0MdpFOC5XfHEWsnbmdnpIILQ=="],
|
||||
|
||||
@@ -2680,8 +2656,14 @@
|
||||
|
||||
"@anthropic-ai/sandbox-runtime/zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
|
||||
|
||||
"@aws-sdk/client-bedrock-runtime/@smithy/node-http-handler": ["@smithy/node-http-handler@4.7.6", "", { "dependencies": { "@smithy/core": "^3.24.6", "@smithy/types": "^4.14.3", "tslib": "^2.6.2" } }, "sha512-3fya8i7GrJilQouk4cZJKdy5k8MWQBpjfXrRNaXDedH8r779tr0jcxyH3+yoTmsluc2+vF4S343yFbnvu8ExDQ=="],
|
||||
|
||||
"@aws-sdk/credential-provider-http/@smithy/node-http-handler": ["@smithy/node-http-handler@4.7.6", "", { "dependencies": { "@smithy/core": "^3.24.6", "@smithy/types": "^4.14.3", "tslib": "^2.6.2" } }, "sha512-3fya8i7GrJilQouk4cZJKdy5k8MWQBpjfXrRNaXDedH8r779tr0jcxyH3+yoTmsluc2+vF4S343yFbnvu8ExDQ=="],
|
||||
|
||||
"@aws-sdk/credential-provider-sso/@aws-sdk/token-providers": ["@aws-sdk/token-providers@3.1056.0", "", { "dependencies": { "@aws-sdk/core": "^3.974.15", "@aws-sdk/nested-clients": "^3.997.13", "@aws-sdk/types": "^3.973.9", "@smithy/core": "^3.24.5", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-81duvlltQlsfn5K+o8zILcystBRdbT1G2JJYVCML5NZHBz4CL/zf+sAemCtBh/uh6RQUMyInGeZLQ7/8igZhbA=="],
|
||||
|
||||
"@aws-sdk/nested-clients/@smithy/node-http-handler": ["@smithy/node-http-handler@4.7.6", "", { "dependencies": { "@smithy/core": "^3.24.6", "@smithy/types": "^4.14.3", "tslib": "^2.6.2" } }, "sha512-3fya8i7GrJilQouk4cZJKdy5k8MWQBpjfXrRNaXDedH8r779tr0jcxyH3+yoTmsluc2+vF4S343yFbnvu8ExDQ=="],
|
||||
|
||||
"@earendil-works/pi-agent-core/@earendil-works/pi-ai": ["@earendil-works/pi-ai@0.78.0", "", { "dependencies": { "@anthropic-ai/sdk": "0.91.1", "@aws-sdk/client-bedrock-runtime": "3.1048.0", "@google/genai": "1.52.0", "@mistralai/mistralai": "2.2.1", "@smithy/node-http-handler": "4.7.3", "http-proxy-agent": "7.0.2", "https-proxy-agent": "7.0.6", "openai": "6.26.0", "partial-json": "0.1.7", "typebox": "1.1.38" }, "bin": { "pi-ai": "dist/cli.js" } }, "sha512-q0hUrvT6ngT6cgBX0oIbzfQfmzztgdkZobP8OTL+sCOOBlnG6+1YRt8g7zO9CC/4NdeYEqa7uGqWdQhH0fjCLA=="],
|
||||
|
||||
"@earendil-works/pi-agent-core/ignore": ["ignore@7.0.5", "", {}, "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg=="],
|
||||
@@ -3092,8 +3074,6 @@
|
||||
|
||||
"yauzl/buffer-crc32": ["buffer-crc32@0.2.13", "", {}, "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ=="],
|
||||
|
||||
"@earendil-works/pi-agent-core/@earendil-works/pi-ai/@smithy/node-http-handler": ["@smithy/node-http-handler@4.7.3", "", { "dependencies": { "@smithy/core": "^3.24.3", "@smithy/types": "^4.14.2", "tslib": "^2.6.2" } }, "sha512-/jPhevcTFPMVl6KNjbaI47iOg1zxC7IsnX4PQDGVZKMFceOXtB8IEYaB7a9VvkP/3oC60WzTeKocvSI7vLT0vA=="],
|
||||
|
||||
"@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=="],
|
||||
|
||||
@@ -866,12 +866,6 @@ export async function executeAgentToolActivity(params: ExecuteAgentToolParams):
|
||||
creatorId: userId,
|
||||
})
|
||||
|
||||
// Increment fileCount of parent folder
|
||||
await prisma.asset.update({
|
||||
where: { id: parent },
|
||||
data: { fileCount: { increment: 1 } },
|
||||
})
|
||||
|
||||
return {
|
||||
id: newFolder.id,
|
||||
name: newFolder.name,
|
||||
@@ -930,12 +924,8 @@ export async function executeAgentToolActivity(params: ExecuteAgentToolParams):
|
||||
creatorId: userId,
|
||||
})
|
||||
|
||||
// Increment fileCount of parent and update ancestor size
|
||||
// Increment update ancestor size
|
||||
await prisma.$transaction(async (tx) => {
|
||||
await tx.asset.update({
|
||||
where: { id: parent },
|
||||
data: { fileCount: { increment: 1 } },
|
||||
})
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
await assetService.updateAncestorsSize(tx as any, parent, fileSize)
|
||||
|
||||
@@ -1026,11 +1016,10 @@ export async function executeAgentToolActivity(params: ExecuteAgentToolParams):
|
||||
where: { id: newFile.id },
|
||||
data: { sortIndex: newSortIndex },
|
||||
})
|
||||
// Increment stack's fileCount and size
|
||||
// Increment stack's size (fileCount is incremented by createAsset already)
|
||||
const updatedStack = await tx.asset.update({
|
||||
where: { id: stackId },
|
||||
data: {
|
||||
fileCount: { increment: 1 },
|
||||
sizeByte: { increment: fileSize },
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { Hono } from 'hono'
|
||||
|
||||
const { mockServeStatic } = vi.hoisted(() => ({
|
||||
@@ -14,6 +13,7 @@ vi.mock('hono/bun', () => ({
|
||||
describe('S3 API', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
vi.resetModules()
|
||||
})
|
||||
|
||||
it('GET /files/* calls serveStatic with correct options', async () => {
|
||||
@@ -39,10 +39,49 @@ describe('S3 API', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it('GET /files/* with filename query parameter sets Content-Disposition header', async () => {
|
||||
// We need to capture the onFound callback from serveStatic options
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
let onFoundCallback: ((path: string, c: any) => void) | undefined
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
mockServeStatic.mockImplementationOnce((options: any) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
onFoundCallback = (options as any).onFound
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return (c: any) => c.text('static-file')
|
||||
})
|
||||
|
||||
const { default: route } = await import('./s3')
|
||||
const app = new Hono().route('/files', route)
|
||||
|
||||
// First, verify onFound is called through the mock
|
||||
await app.request('/files/b1/test.webp?filename=my-file.txt')
|
||||
|
||||
expect(onFoundCallback).toBeDefined()
|
||||
|
||||
// Test the callback directly
|
||||
const mockContext = {
|
||||
req: {
|
||||
query: (key: string) => (key === 'filename' ? 'my-file.txt' : undefined),
|
||||
},
|
||||
header: vi.fn(),
|
||||
}
|
||||
|
||||
if (onFoundCallback) {
|
||||
onFoundCallback('/files/b1/test.webp', mockContext)
|
||||
expect(mockContext.header).toHaveBeenCalledWith(
|
||||
'Content-Disposition',
|
||||
'attachment; filename="my-file.txt"',
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it('PUT /files/:bucket/:key calls s3Service.putObject', async () => {
|
||||
const { s3Service: service } = await import('@shumai/core/src/s3/s3')
|
||||
const mockPut = vi.spyOn(service, 'putObject').mockResolvedValue(undefined)
|
||||
|
||||
const { default: route } = await import('./s3')
|
||||
const app = new Hono().route('/files', route)
|
||||
const mockPut = vi.spyOn(s3Service, 'putObject').mockResolvedValue(undefined)
|
||||
const body = new TextEncoder().encode('test-data')
|
||||
|
||||
const res = await app.request('/files/b1/test.webp', {
|
||||
|
||||
@@ -8,6 +8,13 @@ const route = new Hono()
|
||||
serveStatic({
|
||||
root: './data',
|
||||
rewriteRequestPath: (path) => path.replace(/^\/files\//, ''),
|
||||
onFound: (_path, c) => {
|
||||
const filename = c.req.query('filename')
|
||||
if (filename) {
|
||||
const safeFilename = filename.replace(/["\r\n]/g, '_')
|
||||
c.header('Content-Disposition', `attachment; filename="${safeFilename}"`)
|
||||
}
|
||||
},
|
||||
}),
|
||||
)
|
||||
.put('/:bucket/:key{.+}', async (c) => {
|
||||
|
||||
@@ -175,7 +175,11 @@ describe('team api', () => {
|
||||
permission: Permission.Read,
|
||||
}),
|
||||
)
|
||||
expect(mockGetTeamMembers).toHaveBeenCalledWith({ teamId: 't1', includeAgents: false })
|
||||
expect(mockGetTeamMembers).toHaveBeenCalledWith({
|
||||
teamId: 't1',
|
||||
userId: 'user1',
|
||||
includeAgents: false,
|
||||
})
|
||||
})
|
||||
|
||||
it('GET /teams/:teamId/settings returns settings', async () => {
|
||||
|
||||
@@ -108,6 +108,7 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
|
||||
const members = await teamService.getTeamMembers({
|
||||
teamId,
|
||||
userId: user.id,
|
||||
includeAgents: includeAgents,
|
||||
})
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
"dependencies": {
|
||||
"@shumai/db": "workspace:*",
|
||||
"@shumai/dtos": "workspace:*",
|
||||
"@aws-sdk/client-s3": "^3.1031.0",
|
||||
"@aws-sdk/s3-request-presigner": "^3.1031.0",
|
||||
"@sinclair/typebox": "^0.34.49",
|
||||
"adm-zip": "^0.5.17",
|
||||
"better-auth": "1.6.11",
|
||||
|
||||
@@ -559,6 +559,63 @@ describe('AssetService', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('fileCount verification', () => {
|
||||
it('createAsset should increment parent fileCount', async () => {
|
||||
const { user, assets, project } = await setupBasicAssets()
|
||||
|
||||
const parent = assets.folderA
|
||||
const initialCount = parent.fileCount // should be 2 from setup (fileA1, fileA2)
|
||||
|
||||
// Create a new folder inside folderA
|
||||
await assetService.createAsset({
|
||||
name: 'newFolder',
|
||||
type: 'folder',
|
||||
parentId: parent.id,
|
||||
projectId: project.id,
|
||||
creatorId: user.id,
|
||||
})
|
||||
|
||||
const updatedParent = await prisma.asset.findUnique({ where: { id: parent.id } })
|
||||
expect(updatedParent?.fileCount).toBe(initialCount + 1)
|
||||
|
||||
// Create a new file inside folderA
|
||||
await assetService.createAsset({
|
||||
name: 'newFile',
|
||||
type: 'file',
|
||||
parentId: parent.id,
|
||||
projectId: project.id,
|
||||
creatorId: user.id,
|
||||
})
|
||||
|
||||
const updatedParent2 = await prisma.asset.findUnique({ where: { id: parent.id } })
|
||||
expect(updatedParent2?.fileCount).toBe(initialCount + 2)
|
||||
})
|
||||
|
||||
it('reparentAssets should update fileCount when moving folders', async () => {
|
||||
const { user, assets } = await setupBasicAssets()
|
||||
|
||||
const sourceParent = assets.root
|
||||
const targetParent = assets.folderB
|
||||
const folderToMove = assets.folderA
|
||||
|
||||
// folderA is a child of root.
|
||||
// root children: folderA, folderB, fileRoot1. count=3.
|
||||
// folderB children: stackB, fileB2. count=2.
|
||||
|
||||
await assetService.reparentAssets({
|
||||
assetIds: [folderToMove.id],
|
||||
newParentId: targetParent.id,
|
||||
creatorId: user.id,
|
||||
})
|
||||
|
||||
const updatedSourceParent = await prisma.asset.findUnique({ where: { id: sourceParent.id } })
|
||||
expect(updatedSourceParent?.fileCount).toBe(2)
|
||||
|
||||
const updatedTargetParent = await prisma.asset.findUnique({ where: { id: targetParent.id } })
|
||||
expect(updatedTargetParent?.fileCount).toBe(3)
|
||||
})
|
||||
})
|
||||
|
||||
it('handles reparenting - Version Stack: dissolve with 1 remaining', async () => {
|
||||
const { user, assets } = await setupBasicAssets()
|
||||
await assetService.reparentAssets({
|
||||
|
||||
@@ -172,8 +172,8 @@ export class AssetService {
|
||||
}
|
||||
}
|
||||
|
||||
async reparentAssets(req: ReparentAssetsRequest): Promise<void> {
|
||||
await this.prismaClient.$transaction(async (tx) => {
|
||||
async reparentAssets(req: ReparentAssetsRequest, tx?: Prisma.TransactionClient): Promise<void> {
|
||||
const runInTx = async (tx: Prisma.TransactionClient) => {
|
||||
const newParent = await tx.asset.findUnique({
|
||||
where: { id: req.newParentId },
|
||||
include: { project: { include: { team: true } } },
|
||||
@@ -269,7 +269,13 @@ export class AssetService {
|
||||
if (oldParent) {
|
||||
await this.dissolveStackIfEmpty(tx, oldParent)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (tx) {
|
||||
await runInTx(tx)
|
||||
} else {
|
||||
await this.prismaClient.$transaction(runInTx)
|
||||
}
|
||||
}
|
||||
|
||||
async copyAssets(req: CopyAssetsRequest): Promise<void> {
|
||||
@@ -722,30 +728,41 @@ export class AssetService {
|
||||
if (req.contentType) data.mediaType = req.contentType
|
||||
if (req.creatorId) data.creator = { connect: { id: req.creatorId } }
|
||||
|
||||
const asset = await this.prismaClient.asset.create({
|
||||
data,
|
||||
include: {
|
||||
creator: true,
|
||||
metadataValues: true,
|
||||
storageKey: true,
|
||||
target: {
|
||||
include: {
|
||||
creator: true,
|
||||
metadataValues: true,
|
||||
storageKey: true,
|
||||
children: {
|
||||
include: { creator: true, metadataValues: true, storageKey: true },
|
||||
take: 3,
|
||||
orderBy: { sortIndex: 'asc' },
|
||||
const asset = await this.prismaClient.$transaction(async (tx) => {
|
||||
const createdAsset = await tx.asset.create({
|
||||
data,
|
||||
include: {
|
||||
creator: true,
|
||||
metadataValues: true,
|
||||
storageKey: true,
|
||||
target: {
|
||||
include: {
|
||||
creator: true,
|
||||
metadataValues: true,
|
||||
storageKey: true,
|
||||
children: {
|
||||
include: { creator: true, metadataValues: true, storageKey: true },
|
||||
take: 3,
|
||||
orderBy: { sortIndex: 'asc' },
|
||||
},
|
||||
},
|
||||
},
|
||||
children: {
|
||||
include: { creator: true, metadataValues: true, storageKey: true },
|
||||
take: 3,
|
||||
orderBy: { sortIndex: 'asc' },
|
||||
},
|
||||
},
|
||||
children: {
|
||||
include: { creator: true, metadataValues: true, storageKey: true },
|
||||
take: 3,
|
||||
orderBy: { sortIndex: 'asc' },
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
if (parent) {
|
||||
await tx.asset.update({
|
||||
where: { id: parent.id },
|
||||
data: { fileCount: { increment: 1 } },
|
||||
})
|
||||
}
|
||||
|
||||
return createdAsset
|
||||
})
|
||||
|
||||
const infos = await this.toAssetInfos([asset])
|
||||
@@ -824,6 +841,7 @@ export class AssetService {
|
||||
process.env.S3_BUCKET || 'shumai',
|
||||
info.media.original.key,
|
||||
'GET',
|
||||
a.name,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1548,9 +1566,18 @@ export class AssetService {
|
||||
|
||||
const key = latestVersion.storageKey?.key
|
||||
if (media && key) {
|
||||
const fileName =
|
||||
a.type === AssetType.version_stack && (a.name === '' || !a.name)
|
||||
? latestVersion.name
|
||||
: a.name
|
||||
media.original = {
|
||||
key,
|
||||
downloadUrl: await s3Service.presign(process.env.S3_BUCKET || 'shumai', key, 'GET'),
|
||||
downloadUrl: await s3Service.presign(
|
||||
process.env.S3_BUCKET || 'shumai',
|
||||
key,
|
||||
'GET',
|
||||
fileName,
|
||||
),
|
||||
filesizeInBytes: latestVersion.sizeByte,
|
||||
codec: '', // TODO: extract from metadata if needed
|
||||
}
|
||||
|
||||
@@ -225,6 +225,7 @@ export class ProjectService {
|
||||
name: pm.teamMember.user.name,
|
||||
role: pm.role,
|
||||
image: await getAvatarUrl(pm.teamMember.user.image),
|
||||
scope: pm.teamMember.scope,
|
||||
})),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,36 +3,41 @@ import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import { LocalStorageService, S3StorageService } from './s3'
|
||||
|
||||
// Mock the AWS SDK
|
||||
// Mock Bun S3Client
|
||||
const s3ClientConstructorSpy = vi.fn()
|
||||
vi.mock('@aws-sdk/client-s3', () => {
|
||||
const s3FileSpy = vi.fn()
|
||||
const s3WriteSpy = vi.fn()
|
||||
const s3DeleteSpy = vi.fn()
|
||||
const s3ListSpy = vi.fn()
|
||||
const s3ExistsSpy = vi.fn()
|
||||
const s3PresignSpy = vi.fn()
|
||||
|
||||
vi.mock('bun', () => {
|
||||
return {
|
||||
S3Client: class {
|
||||
constructor(params: unknown) {
|
||||
s3ClientConstructorSpy(params)
|
||||
}
|
||||
send = vi.fn().mockResolvedValue({})
|
||||
file = s3FileSpy.mockReturnValue({
|
||||
size: Promise.resolve(123),
|
||||
exists: vi.fn().mockResolvedValue(true),
|
||||
arrayBuffer: vi.fn().mockResolvedValue(new ArrayBuffer(10)),
|
||||
type: 'text/plain',
|
||||
})
|
||||
write = s3WriteSpy.mockResolvedValue({})
|
||||
delete = s3DeleteSpy.mockResolvedValue({})
|
||||
list = s3ListSpy.mockResolvedValue({ contents: [], isTruncated: false })
|
||||
exists = s3ExistsSpy.mockResolvedValue(true)
|
||||
presign = s3PresignSpy.mockReturnValue('http://presigned-url')
|
||||
},
|
||||
HeadObjectCommand: class {},
|
||||
PutObjectCommand: class {},
|
||||
GetObjectCommand: class {},
|
||||
ListObjectsV2Command: class {},
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('@aws-sdk/s3-request-presigner', () => {
|
||||
return {
|
||||
getSignedUrl: vi.fn().mockResolvedValue('http://presigned-url'),
|
||||
}
|
||||
})
|
||||
|
||||
describe('S3Service implementations', () => {
|
||||
beforeEach(async () => {
|
||||
const { getSignedUrl } = await import('@aws-sdk/s3-request-presigner')
|
||||
vi.mocked(getSignedUrl).mockReset()
|
||||
vi.mocked(getSignedUrl).mockResolvedValue('http://presigned-url')
|
||||
vi.clearAllMocks()
|
||||
delete process.env.PRESIGNED_URL_EXPIRES_IN
|
||||
s3PresignSpy.mockReturnValue('http://presigned-url')
|
||||
})
|
||||
|
||||
describe('S3StorageService', () => {
|
||||
@@ -64,56 +69,65 @@ describe('S3Service implementations', () => {
|
||||
const s3 = new S3StorageService('localhost:9000', 'key', 'secret', 'test-bucket', false)
|
||||
const url = await s3.presign('bucket', 'key', 'GET')
|
||||
expect(url).toBe('http://presigned-url')
|
||||
expect(s3PresignSpy).toHaveBeenCalledWith('key', expect.objectContaining({ method: 'GET' }))
|
||||
})
|
||||
|
||||
it('should cache GET presign URLs', async () => {
|
||||
const s3 = new S3StorageService('localhost:9000', 'key', 'secret', 'test-bucket', false)
|
||||
const { getSignedUrl } = await import('@aws-sdk/s3-request-presigner')
|
||||
|
||||
vi.mocked(getSignedUrl).mockClear()
|
||||
vi.mocked(getSignedUrl).mockResolvedValueOnce('http://presigned-url-1')
|
||||
vi.mocked(getSignedUrl).mockResolvedValueOnce('http://presigned-url-2')
|
||||
s3PresignSpy.mockClear()
|
||||
s3PresignSpy.mockReturnValueOnce('http://presigned-url-1')
|
||||
s3PresignSpy.mockReturnValueOnce('http://presigned-url-2')
|
||||
|
||||
const url1 = await s3.presign('bucket', 'key', 'GET')
|
||||
const url2 = await s3.presign('bucket', 'key', 'GET')
|
||||
|
||||
expect(url1).toBe('http://presigned-url-1')
|
||||
expect(url2).toBe('http://presigned-url-1')
|
||||
expect(vi.mocked(getSignedUrl)).toHaveBeenCalledTimes(1)
|
||||
expect(s3PresignSpy).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('should NOT cache PUT presign URLs', async () => {
|
||||
const s3 = new S3StorageService('localhost:9000', 'key', 'secret', 'test-bucket', false)
|
||||
const { getSignedUrl } = await import('@aws-sdk/s3-request-presigner')
|
||||
|
||||
vi.mocked(getSignedUrl).mockClear()
|
||||
vi.mocked(getSignedUrl).mockResolvedValueOnce('http://put-url-1')
|
||||
vi.mocked(getSignedUrl).mockResolvedValueOnce('http://put-url-2')
|
||||
s3PresignSpy.mockReset()
|
||||
s3PresignSpy.mockReturnValueOnce('http://unique-put-url-1')
|
||||
s3PresignSpy.mockReturnValueOnce('http://unique-put-url-2')
|
||||
|
||||
const url1 = await s3.presign('bucket', 'key', 'PUT')
|
||||
const url2 = await s3.presign('bucket', 'key', 'PUT')
|
||||
|
||||
expect(url1).toBe('http://put-url-1')
|
||||
expect(url2).toBe('http://put-url-2')
|
||||
expect(vi.mocked(getSignedUrl)).toHaveBeenCalledTimes(2)
|
||||
expect(url1).toBe('http://unique-put-url-1')
|
||||
expect(url2).toBe('http://unique-put-url-2')
|
||||
expect(s3PresignSpy).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
it('should respect PRESIGNED_URL_EXPIRES_IN env', async () => {
|
||||
process.env.PRESIGNED_URL_EXPIRES_IN = '10'
|
||||
const s3 = new S3StorageService('localhost:9000', 'key', 'secret', 'test-bucket', false)
|
||||
const { getSignedUrl } = await import('@aws-sdk/s3-request-presigner')
|
||||
|
||||
vi.mocked(getSignedUrl).mockClear()
|
||||
s3PresignSpy.mockClear()
|
||||
await s3.presign('bucket', 'key', 'GET')
|
||||
|
||||
expect(vi.mocked(getSignedUrl)).toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
expect.anything(),
|
||||
expect(s3PresignSpy).toHaveBeenCalledWith(
|
||||
'key',
|
||||
expect.objectContaining({ expiresIn: 10 * 3600 }),
|
||||
)
|
||||
|
||||
delete process.env.PRESIGNED_URL_EXPIRES_IN
|
||||
})
|
||||
|
||||
it('should pass filename to presign', async () => {
|
||||
const s3 = new S3StorageService('localhost:9000', 'key', 'secret', 'test-bucket', false)
|
||||
await s3.presign('bucket', 'key', 'GET', 'test.txt')
|
||||
|
||||
expect(s3PresignSpy).toHaveBeenCalledWith(
|
||||
'key',
|
||||
expect.objectContaining({
|
||||
contentDisposition: 'attachment; filename="test.txt"',
|
||||
}),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('LocalStorageService', () => {
|
||||
@@ -168,6 +182,11 @@ describe('S3Service implementations', () => {
|
||||
expect(url).toBe('http://localhost:3000/files/my-bucket/dir/file.txt')
|
||||
})
|
||||
|
||||
it('should generate a local presign URL with filename', async () => {
|
||||
const url = await localS3.presign('my-bucket', 'dir/file.txt', 'GET', 'original.txt')
|
||||
expect(url).toBe('http://localhost:3000/files/my-bucket/dir/file.txt?filename=original.txt')
|
||||
})
|
||||
|
||||
it('should throw an error for unsupported presign methods', async () => {
|
||||
await expect(localS3.presign('b', 'k', 'POST')).rejects.toThrow()
|
||||
})
|
||||
|
||||
+64
-130
@@ -1,17 +1,7 @@
|
||||
import { ObjectInfo } from '@shumai/dtos'
|
||||
import {
|
||||
CopyObjectCommand,
|
||||
DeleteObjectCommand,
|
||||
GetObjectCommand,
|
||||
HeadObjectCommand,
|
||||
ListObjectsV2Command,
|
||||
PutObjectCommand,
|
||||
S3Client,
|
||||
} from '@aws-sdk/client-s3'
|
||||
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'
|
||||
import { S3Client } from 'bun'
|
||||
import * as crypto from 'crypto'
|
||||
import * as fs from 'fs'
|
||||
import { readFileSync, statSync } from 'fs'
|
||||
import * as path from 'path'
|
||||
import { ulid } from 'ulid'
|
||||
import { LruTtlCache } from '../cache/lru-ttl-cache'
|
||||
@@ -64,7 +54,7 @@ export interface S3Service {
|
||||
listObjects(bucket: string, prefix: string): Promise<string[]>
|
||||
uploadFile(filePath: string, contentType: string): Promise<string>
|
||||
uploadFileToKey(filePath: string, key: string, contentType: string): Promise<void>
|
||||
presign(bucket: string, key: string, method: string): Promise<string>
|
||||
presign(bucket: string, key: string, method: string, filename?: string): Promise<string>
|
||||
}
|
||||
|
||||
export class S3StorageService implements S3Service {
|
||||
@@ -89,54 +79,36 @@ export class S3StorageService implements S3Service {
|
||||
this.client = new S3Client({
|
||||
region,
|
||||
endpoint: fullEndpoint,
|
||||
credentials: {
|
||||
accessKeyId,
|
||||
secretAccessKey,
|
||||
},
|
||||
forcePathStyle: false,
|
||||
accessKeyId,
|
||||
secretAccessKey,
|
||||
bucket,
|
||||
})
|
||||
this.bucket = bucket
|
||||
}
|
||||
|
||||
async getObjectSize(bucket: string, key: string): Promise<number> {
|
||||
const command = new HeadObjectCommand({
|
||||
Bucket: bucket,
|
||||
Key: key,
|
||||
})
|
||||
const response = await this.client.send(command)
|
||||
return response.ContentLength || 0
|
||||
return await this.client.size(key, { bucket })
|
||||
}
|
||||
|
||||
async putObject(
|
||||
bucket: string,
|
||||
key: string,
|
||||
body: Buffer | Uint8Array | string,
|
||||
size: number,
|
||||
_size: number,
|
||||
contentType?: string,
|
||||
): Promise<void> {
|
||||
const command = new PutObjectCommand({
|
||||
Bucket: bucket,
|
||||
Key: key,
|
||||
Body: body,
|
||||
ContentLength: size,
|
||||
ContentType: contentType,
|
||||
await this.client.write(key, body, {
|
||||
bucket,
|
||||
type: contentType,
|
||||
})
|
||||
await this.client.send(command)
|
||||
}
|
||||
|
||||
async getObject(bucket: string, key: string): Promise<S3Object> {
|
||||
const command = new GetObjectCommand({
|
||||
Bucket: bucket,
|
||||
Key: key,
|
||||
})
|
||||
const response = await this.client.send(command)
|
||||
if (!response.Body) {
|
||||
throw new Error('Empty response body')
|
||||
}
|
||||
const byteArray = await response.Body.transformToByteArray()
|
||||
const file = this.client.file(key, { bucket })
|
||||
const arrayBuffer = await file.arrayBuffer()
|
||||
return {
|
||||
buffer: Buffer.from(byteArray),
|
||||
contentType: response.ContentType || 'application/octet-stream',
|
||||
buffer: Buffer.from(arrayBuffer),
|
||||
contentType: file.type || 'application/octet-stream',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,54 +118,22 @@ export class S3StorageService implements S3Service {
|
||||
destBucket: string,
|
||||
destKey: string,
|
||||
): Promise<void> {
|
||||
const command = new CopyObjectCommand({
|
||||
Bucket: destBucket,
|
||||
Key: destKey,
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
CopySource: `${sourceBucket}/${sourceKey}`,
|
||||
})
|
||||
await this.client.send(command)
|
||||
const sourceFile = this.client.file(sourceKey, { bucket: sourceBucket })
|
||||
await this.client.write(destKey, sourceFile, { bucket: destBucket })
|
||||
}
|
||||
|
||||
async downloadToFile(bucket: string, key: string, filePath: string): Promise<void> {
|
||||
const command = new GetObjectCommand({
|
||||
Bucket: bucket,
|
||||
Key: key,
|
||||
})
|
||||
const response = await this.client.send(command)
|
||||
if (!response.Body) {
|
||||
throw new Error('Empty response body')
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const stream = response.Body as any
|
||||
const writeStream = fs.createWriteStream(filePath)
|
||||
|
||||
await new Promise((resolve, reject) => {
|
||||
stream
|
||||
.pipe(writeStream)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
.on('error', (err: any) => {
|
||||
writeStream.close()
|
||||
reject(err)
|
||||
})
|
||||
.on('finish', () => {
|
||||
writeStream.close()
|
||||
resolve(null)
|
||||
})
|
||||
})
|
||||
const file = this.client.file(key, { bucket })
|
||||
await Bun.write(filePath, file)
|
||||
}
|
||||
|
||||
async deleteObject(bucket: string, key: string): Promise<number> {
|
||||
const command = new DeleteObjectCommand({
|
||||
Bucket: bucket,
|
||||
Key: key,
|
||||
})
|
||||
try {
|
||||
await this.client.send(command)
|
||||
const exists = await this.client.exists(key, { bucket })
|
||||
if (!exists) return 0
|
||||
await this.client.delete(key, { bucket })
|
||||
return 1
|
||||
} catch {
|
||||
// If object doesn't exist, we return 0
|
||||
return 0
|
||||
}
|
||||
}
|
||||
@@ -207,17 +147,20 @@ export class S3StorageService implements S3Service {
|
||||
}
|
||||
|
||||
async headObject(bucket: string, key: string): Promise<ObjectInfo> {
|
||||
const command = new HeadObjectCommand({
|
||||
Bucket: bucket,
|
||||
Key: key,
|
||||
})
|
||||
const response = await this.client.send(command)
|
||||
const file = this.client.file(key, { bucket })
|
||||
const exists = await file.exists()
|
||||
if (!exists) {
|
||||
throw new Error(`NoSuchKey: The specified key does not exist.`)
|
||||
}
|
||||
|
||||
// Bun.S3File doesn't expose lastModified or eTag directly in a way that matches ObjectInfo easily
|
||||
// but we can try to get them if available. For now, using defaults for fields not provided.
|
||||
return {
|
||||
key,
|
||||
size: response.ContentLength || 0,
|
||||
lastModified: response.LastModified || new Date(),
|
||||
contentType: response.ContentType || 'application/octet-stream',
|
||||
eTag: response.ETag || '',
|
||||
size: await file.size,
|
||||
lastModified: new Date(), // Bun doesn't expose this yet via S3File
|
||||
contentType: file.type || 'application/octet-stream',
|
||||
eTag: '',
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,23 +170,21 @@ export class S3StorageService implements S3Service {
|
||||
let continuationToken: string | undefined = undefined
|
||||
|
||||
while (isTruncated) {
|
||||
const command: ListObjectsV2Command = new ListObjectsV2Command({
|
||||
Bucket: bucket,
|
||||
Prefix: prefix,
|
||||
ContinuationToken: continuationToken,
|
||||
const response = await this.client.list({
|
||||
prefix,
|
||||
continuationToken,
|
||||
})
|
||||
const response = await this.client.send(command)
|
||||
|
||||
if (response.Contents) {
|
||||
for (const item of response.Contents) {
|
||||
if (item.Key) {
|
||||
keys.push(item.Key)
|
||||
if (response.contents) {
|
||||
for (const item of response.contents) {
|
||||
if (item.key) {
|
||||
keys.push(item.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
isTruncated = response.IsTruncated || false
|
||||
continuationToken = response.NextContinuationToken
|
||||
isTruncated = response.isTruncated || false
|
||||
continuationToken = response.nextContinuationToken
|
||||
}
|
||||
|
||||
return keys
|
||||
@@ -256,50 +197,39 @@ export class S3StorageService implements S3Service {
|
||||
}
|
||||
|
||||
async uploadFileToKey(filePath: string, key: string, contentType: string): Promise<void> {
|
||||
const fileStats = statSync(filePath)
|
||||
const fileContent = readFileSync(filePath)
|
||||
|
||||
const command = new PutObjectCommand({
|
||||
Bucket: this.bucket,
|
||||
Key: key,
|
||||
Body: fileContent,
|
||||
ContentLength: fileStats.size,
|
||||
ContentType: contentType,
|
||||
await this.client.write(key, Bun.file(filePath), {
|
||||
bucket: this.bucket,
|
||||
type: contentType,
|
||||
})
|
||||
|
||||
await this.client.send(command)
|
||||
}
|
||||
|
||||
async presign(bucket: string, key: string, method: string): Promise<string> {
|
||||
async presign(bucket: string, key: string, method: string, filename?: string): Promise<string> {
|
||||
const expireHours = parseInt(process.env.PRESIGNED_URL_EXPIRES_IN || '5', 10)
|
||||
const expiresInSeconds = expireHours * 3600
|
||||
// Cache time is 2/3 of expire time, rounded to minute
|
||||
const cacheMinutes = Math.round((expireHours * 60 * 2) / 3)
|
||||
const cacheTtlMs = cacheMinutes * 60 * 1000
|
||||
|
||||
const cacheKey = `${bucket}:${key}`
|
||||
const cacheKey = `${bucket}:${key}:${filename || ''}`
|
||||
|
||||
if (method === 'GET') {
|
||||
const cached = this.presignCache.get(cacheKey)
|
||||
if (cached) return cached
|
||||
}
|
||||
|
||||
let command: GetObjectCommand | PutObjectCommand
|
||||
if (method === 'GET') {
|
||||
command = new GetObjectCommand({
|
||||
Bucket: bucket,
|
||||
Key: key,
|
||||
})
|
||||
} else if (method === 'PUT') {
|
||||
command = new PutObjectCommand({
|
||||
Bucket: bucket,
|
||||
Key: key,
|
||||
})
|
||||
} else {
|
||||
throw new Error(`Invalid method: ${method}`)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const options: any = {
|
||||
bucket,
|
||||
expiresIn: expiresInSeconds,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
method: method as any,
|
||||
}
|
||||
|
||||
const url = await getSignedUrl(this.client, command, { expiresIn: expiresInSeconds })
|
||||
if (filename) {
|
||||
options.contentDisposition = `attachment; filename="${filename}"`
|
||||
}
|
||||
|
||||
const url = this.client.presign(key, options)
|
||||
|
||||
if (method === 'GET') {
|
||||
this.presignCache.set(cacheKey, url, cacheTtlMs)
|
||||
@@ -505,14 +435,18 @@ export class LocalStorageService implements S3Service {
|
||||
await fs.promises.copyFile(filePath, destPath)
|
||||
}
|
||||
|
||||
async presign(bucket: string, key: string, method: string): Promise<string> {
|
||||
async presign(bucket: string, key: string, method: string, filename?: string): Promise<string> {
|
||||
if (method !== 'GET' && method !== 'PUT') {
|
||||
throw new Error(`Invalid method: ${method}`)
|
||||
}
|
||||
if (method === 'PUT') {
|
||||
return `${this.endpoint}${signLocalUrl(bucket, key)}`
|
||||
}
|
||||
return `${this.endpoint}/files/${bucket}/${key}`
|
||||
let url = `${this.endpoint}/files/${bucket}/${key}`
|
||||
if (filename) {
|
||||
url += `?filename=${encodeURIComponent(filename)}`
|
||||
}
|
||||
return url
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -127,6 +127,7 @@ describe('TeamService', () => {
|
||||
|
||||
const members = await teamService.getTeamMembers({
|
||||
teamId: team.id,
|
||||
userId: user1.id,
|
||||
})
|
||||
|
||||
expect(members).toHaveLength(2)
|
||||
@@ -169,6 +170,7 @@ describe('TeamService', () => {
|
||||
// Should hide bots by default
|
||||
const members = await teamService.getTeamMembers({
|
||||
teamId: team.id,
|
||||
userId: user.id,
|
||||
})
|
||||
expect(members).toHaveLength(1)
|
||||
expect(members[0].id).toBe(user.id)
|
||||
@@ -176,11 +178,73 @@ describe('TeamService', () => {
|
||||
// Should include bots if requested
|
||||
const allMembers = await teamService.getTeamMembers({
|
||||
teamId: team.id,
|
||||
userId: user.id,
|
||||
includeAgents: true,
|
||||
})
|
||||
expect(allMembers).toHaveLength(2)
|
||||
})
|
||||
|
||||
it('should filter members for project-scoped members', async () => {
|
||||
const owner = await prisma.user.create({
|
||||
data: { name: 'Owner', email: `owner-${Date.now()}@example.com`, password: 'pw' },
|
||||
})
|
||||
const team = await teamService.createTeam(owner, { name: 'Test Team' })
|
||||
|
||||
const teamMember = await prisma.user.create({
|
||||
data: { name: 'Team Member', email: `tm-${Date.now()}@example.com`, password: 'pw' },
|
||||
})
|
||||
await teamService.joinTeam({ teamId: team.id, userId: teamMember.id })
|
||||
|
||||
const projectMember1 = await prisma.user.create({
|
||||
data: { name: 'Proj Member 1', email: `pm1-${Date.now()}@example.com`, password: 'pw' },
|
||||
})
|
||||
const tm1 = await prisma.teamMember.create({
|
||||
data: { teamId: team.id, userId: projectMember1.id, scope: 'project', role: 'editor' },
|
||||
})
|
||||
|
||||
const projectMember2 = await prisma.user.create({
|
||||
data: { name: 'Proj Member 2', email: `pm2-${Date.now()}@example.com`, password: 'pw' },
|
||||
})
|
||||
const tm2 = await prisma.teamMember.create({
|
||||
data: { teamId: team.id, userId: projectMember2.id, scope: 'project', role: 'editor' },
|
||||
})
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: { name: 'Shared Project', teamId: team.id },
|
||||
})
|
||||
|
||||
await prisma.projectMember.createMany({
|
||||
data: [
|
||||
{ projectId: project.id, teamMemberId: tm1.id, role: 'editor' },
|
||||
{ projectId: project.id, teamMemberId: tm2.id, role: 'editor' },
|
||||
],
|
||||
})
|
||||
|
||||
const projectMember3 = await prisma.user.create({
|
||||
data: { name: 'Proj Member 3', email: `pm3-${Date.now()}@example.com`, password: 'pw' },
|
||||
})
|
||||
await prisma.teamMember.create({
|
||||
data: { teamId: team.id, userId: projectMember3.id, scope: 'project', role: 'editor' },
|
||||
})
|
||||
|
||||
// Owner (team scope) should see everyone (4 users)
|
||||
const ownerView = await teamService.getTeamMembers({ teamId: team.id, userId: owner.id })
|
||||
expect(ownerView).toHaveLength(5) // Owner, Team Member, PM1, PM2, PM3
|
||||
|
||||
// PM1 (project scope) should see: Owner, Team Member, PM2 (shares project), but NOT PM3
|
||||
const pm1View = await teamService.getTeamMembers({ teamId: team.id, userId: projectMember1.id })
|
||||
const pm1ViewIds = pm1View.map((m) => m.id)
|
||||
expect(pm1View).toHaveLength(4)
|
||||
expect(pm1ViewIds).toContain(owner.id)
|
||||
expect(pm1ViewIds).toContain(teamMember.id)
|
||||
expect(pm1ViewIds).toContain(projectMember2.id)
|
||||
expect(pm1ViewIds).not.toContain(projectMember3.id)
|
||||
|
||||
// Check scopes are returned
|
||||
expect(pm1View.find((m) => m.id === owner.id)?.scope).toBe('team')
|
||||
expect(pm1View.find((m) => m.id === projectMember2.id)?.scope).toBe('project')
|
||||
})
|
||||
|
||||
it('should get and update settings', async () => {
|
||||
const user = await prisma.user.create({
|
||||
data: { name: 'Test User', email: `test-${Date.now()}@example.com`, password: 'pw' },
|
||||
|
||||
@@ -174,6 +174,19 @@ export class TeamService {
|
||||
}
|
||||
|
||||
async getTeamMembers(req: ServiceGetTeamMembersRequest): Promise<UserInfo[]> {
|
||||
const requester = await prisma.teamMember.findUnique({
|
||||
where: {
|
||||
teamIdUserId: {
|
||||
teamId: req.teamId,
|
||||
userId: req.userId,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
if (!requester) {
|
||||
throw new HTTPException(403, { message: 'Requester is not a team member' })
|
||||
}
|
||||
|
||||
const members = await prisma.teamMember.findMany({
|
||||
where: {
|
||||
teamId: req.teamId,
|
||||
@@ -194,17 +207,39 @@ export class TeamService {
|
||||
}
|
||||
: { user: { type: { not: 'agent' } } }),
|
||||
},
|
||||
include: { user: true },
|
||||
include: {
|
||||
user: true,
|
||||
projectMembers: true,
|
||||
},
|
||||
})
|
||||
|
||||
let filteredMembers = members
|
||||
|
||||
if (requester.scope === 'project') {
|
||||
const requesterProjectIds = await prisma.projectMember
|
||||
.findMany({
|
||||
where: { teamMemberId: requester.id },
|
||||
select: { projectId: true },
|
||||
})
|
||||
.then((pms) => pms.map((pm) => pm.projectId))
|
||||
|
||||
filteredMembers = members.filter((m) => {
|
||||
// Team-scoped members are always visible
|
||||
if (m.scope === 'team') return true
|
||||
// Project-scoped members are visible if they share a project
|
||||
return m.projectMembers.some((pm) => requesterProjectIds.includes(pm.projectId))
|
||||
})
|
||||
}
|
||||
|
||||
return Promise.all(
|
||||
members.map(async (m) => ({
|
||||
filteredMembers.map(async (m) => ({
|
||||
id: m.user.id,
|
||||
name: m.user.name,
|
||||
email: undefined,
|
||||
role: m.role,
|
||||
type: m.user.type || undefined,
|
||||
image: await getAvatarUrl(m.user.image),
|
||||
scope: m.scope,
|
||||
})),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -93,6 +93,67 @@ describe('UploadService', () => {
|
||||
expect(hidden).toBeNull()
|
||||
})
|
||||
|
||||
it('should correctly increment fileCount for parent folders when uploading folders', async () => {
|
||||
const req = {
|
||||
parentId: parentId,
|
||||
files: [
|
||||
{
|
||||
name: 'folder1',
|
||||
id: '1',
|
||||
type: 'folder' as const,
|
||||
size: 0,
|
||||
children: [
|
||||
{
|
||||
name: 'folder2',
|
||||
id: '2',
|
||||
type: 'folder' as const,
|
||||
size: 0,
|
||||
children: [],
|
||||
},
|
||||
{
|
||||
name: 'file1.txt',
|
||||
id: '3',
|
||||
type: 'file' as const,
|
||||
size: 100,
|
||||
mediaType: 'text/plain',
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
await uploadService.createUploadTask(userId, req)
|
||||
|
||||
// parentId folder should have folder1 as a direct child
|
||||
const parent = await prisma.asset.findUnique({ where: { id: parentId } })
|
||||
expect(parent?.fileCount).toBe(1)
|
||||
|
||||
// folder1 should have folder2 and file1.txt as direct children
|
||||
// folder2 is a folder, so it is counted immediately.
|
||||
// file1.txt is a file, so it is counted after confirmFileUpload.
|
||||
const folder1 = await prisma.asset.findFirst({ where: { name: 'folder1' } })
|
||||
expect(folder1?.parentId).toBe(parentId)
|
||||
expect(folder1?.fileCount).toBe(1)
|
||||
|
||||
const folder2 = await prisma.asset.findFirst({ where: { name: 'folder2' } })
|
||||
expect(folder2?.parentId).toBe(folder1?.id)
|
||||
expect(folder2?.fileCount).toBe(0)
|
||||
|
||||
const file1 = await prisma.asset.findFirst({ where: { name: 'file1.txt' } })
|
||||
expect(file1?.parentId).toBe(folder1?.id)
|
||||
expect(file1?.status).toBe(AssetStatus.uploading)
|
||||
|
||||
// Confirm upload for file1.txt
|
||||
const task = await prisma.task.findFirst({ where: { total: 1 } })
|
||||
await uploadService.confirmFileUpload(userId, task!.id, {
|
||||
fileId: file1!.id,
|
||||
})
|
||||
|
||||
const folder1After = await prisma.asset.findUnique({ where: { id: folder1!.id } })
|
||||
expect(folder1After?.fileCount).toBe(2)
|
||||
})
|
||||
|
||||
it('should confirm file upload and create transcode tasks for video', async () => {
|
||||
const task = await prisma.task.create({
|
||||
data: { creatorId: userId, total: 1, uploaded: 0, type: 'upload' },
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
import { prisma } from '@shumai/db'
|
||||
import { ulid } from 'ulid'
|
||||
import { generateKeyBetween } from 'jittered-fractional-indexing'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { assetService } from '@shumai/core/src/asset/asset'
|
||||
import { PaginatedData, PaginationParams, paginateQuery } from '@shumai/core/src/pagination'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import {
|
||||
AssetStatus,
|
||||
AssetType,
|
||||
Prisma,
|
||||
TaskStatus,
|
||||
WorkflowTaskStatus,
|
||||
WorkflowTaskType,
|
||||
prisma,
|
||||
} from '@shumai/db'
|
||||
import {
|
||||
ConfirmFileUploadRequest,
|
||||
CreateUploadTaskRequest,
|
||||
@@ -11,16 +18,9 @@ import {
|
||||
PresignedUrl,
|
||||
TaskInfo,
|
||||
} from '@shumai/dtos'
|
||||
import {
|
||||
AssetStatus,
|
||||
AssetType,
|
||||
Prisma,
|
||||
TaskStatus,
|
||||
WorkflowTaskStatus,
|
||||
WorkflowTaskType,
|
||||
} from '@shumai/db'
|
||||
import { PaginationParams, paginateQuery, PaginatedData } from '@shumai/core/src/pagination'
|
||||
import { VideoTranscoder, ImageTranscoder } from '@shumai/transcode'
|
||||
import { ImageTranscoder, VideoTranscoder } from '@shumai/transcode'
|
||||
import { generateKeyBetween } from 'jittered-fractional-indexing'
|
||||
import { ulid } from 'ulid'
|
||||
|
||||
export class UploadService {
|
||||
constructor(private readonly prismaClient: typeof prisma = prisma) {}
|
||||
@@ -67,24 +67,32 @@ export class UploadService {
|
||||
const isParentFile = parentAsset.type === AssetType.file
|
||||
const targetParentId = isParentFile ? parentAsset.parentId! : parentAsset.id
|
||||
|
||||
const createdAssetIds = await this.createAssetsRecursively(
|
||||
userId,
|
||||
task.id,
|
||||
parentAsset.projectId,
|
||||
targetParentId,
|
||||
req.files,
|
||||
presignedUrls,
|
||||
)
|
||||
await this.prismaClient.$transaction(async (tx) => {
|
||||
const ids = await this.createAssetsRecursively(
|
||||
tx,
|
||||
userId,
|
||||
task.id,
|
||||
parentAsset.projectId!,
|
||||
targetParentId,
|
||||
req.files,
|
||||
presignedUrls,
|
||||
)
|
||||
|
||||
if (isParentFile && createdAssetIds.length > 0) {
|
||||
for (const assetId of createdAssetIds) {
|
||||
await assetService.reparentAssets({
|
||||
assetIds: [assetId],
|
||||
newParentId: parentAsset.id,
|
||||
creatorId: userId,
|
||||
})
|
||||
if (isParentFile && ids.length > 0) {
|
||||
for (const assetId of ids) {
|
||||
await assetService.reparentAssets(
|
||||
{
|
||||
assetIds: [assetId],
|
||||
newParentId: parentAsset.id,
|
||||
creatorId: userId,
|
||||
},
|
||||
tx,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ids
|
||||
})
|
||||
|
||||
return {
|
||||
taskId: task.id,
|
||||
@@ -93,6 +101,7 @@ export class UploadService {
|
||||
}
|
||||
|
||||
private async createAssetsRecursively(
|
||||
tx: Prisma.TransactionClient,
|
||||
userId: string,
|
||||
taskId: string,
|
||||
projectId: string,
|
||||
@@ -100,7 +109,7 @@ export class UploadService {
|
||||
files: FileNode[],
|
||||
presignedUrls: PresignedUrl[],
|
||||
): Promise<string[]> {
|
||||
const firstFile = await this.prismaClient.asset.findFirst({
|
||||
const firstFile = await tx.asset.findFirst({
|
||||
where: { parentId },
|
||||
orderBy: { sortIndex: 'asc' },
|
||||
})
|
||||
@@ -119,14 +128,14 @@ export class UploadService {
|
||||
key = `files/${ulid()}/raw`
|
||||
}
|
||||
|
||||
const newAsset = await this.prismaClient.asset.create({
|
||||
const newAsset = await tx.asset.create({
|
||||
data: {
|
||||
name: file.name,
|
||||
type: assetType,
|
||||
storageKey: key ? { create: { key } } : undefined,
|
||||
sortIndex: newSortIndex,
|
||||
mediaType: file.mediaType,
|
||||
status: AssetStatus.uploading,
|
||||
status: assetType === AssetType.folder ? AssetStatus.uploaded : AssetStatus.uploading,
|
||||
sizeByte: file.size,
|
||||
creator: userId ? { connect: { id: userId } } : undefined,
|
||||
parent: parentId ? { connect: { id: parentId } } : undefined,
|
||||
@@ -136,8 +145,16 @@ export class UploadService {
|
||||
})
|
||||
createdIds.push(newAsset.id)
|
||||
|
||||
if (assetType === AssetType.folder && parentId) {
|
||||
await tx.asset.update({
|
||||
where: { id: parentId },
|
||||
data: { fileCount: { increment: 1 } },
|
||||
})
|
||||
}
|
||||
|
||||
if (file.children && file.children.length > 0) {
|
||||
await this.createAssetsRecursively(
|
||||
tx,
|
||||
userId,
|
||||
taskId,
|
||||
projectId,
|
||||
@@ -212,9 +229,8 @@ export class UploadService {
|
||||
where: { id: asset.parentId },
|
||||
data: { fileCount: { increment: 1 } },
|
||||
})
|
||||
// The transaction context is compatible with the asset service's requirements
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
await assetService.updateAncestorsSize(tx as any, asset.parentId, updatedAsset.sizeByte)
|
||||
|
||||
await assetService.updateAncestorsSize(tx, asset.parentId, updatedAsset.sizeByte)
|
||||
}
|
||||
|
||||
// Update task
|
||||
|
||||
@@ -46,8 +46,9 @@ export type GetProjectTeamResponse = z.infer<typeof getProjectTeamResponseSchema
|
||||
export const projectUserInfoSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
role: z.string(),
|
||||
role: z.enum(['owner', 'editor', 'reviewer', 'bot', 'unknown']),
|
||||
image: z.string().optional(),
|
||||
scope: z.enum(['team', 'project']).optional(),
|
||||
})
|
||||
export type ProjectUserInfo = z.infer<typeof projectUserInfoSchema>
|
||||
|
||||
@@ -96,7 +97,7 @@ export interface ServiceListProjectsRequest {
|
||||
export interface ServiceAddProjectMemberRequest {
|
||||
projectId: string
|
||||
userId: string
|
||||
role: string
|
||||
role: 'owner' | 'editor' | 'reviewer' | 'bot' | 'unknown'
|
||||
}
|
||||
|
||||
export interface ServiceListProjectMembersRequest {
|
||||
|
||||
@@ -33,7 +33,7 @@ export const getMeResponseSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
email: z.string().optional(),
|
||||
role: z.string(),
|
||||
role: z.enum(['owner', 'editor', 'reviewer', 'bot', 'unknown']),
|
||||
image: z.string().optional(),
|
||||
unreadNotificationCount: z.number().optional(),
|
||||
})
|
||||
@@ -48,10 +48,11 @@ export type UpdateMeRequest = z.infer<typeof updateMeRequestSchema>
|
||||
export const userInfoSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
role: z.string(),
|
||||
role: z.enum(['owner', 'editor', 'reviewer', 'bot', 'unknown']),
|
||||
email: z.string().optional(),
|
||||
type: z.enum(['human', 'agent']).optional(),
|
||||
image: z.string().optional(),
|
||||
scope: z.enum(['team', 'project']).optional(),
|
||||
})
|
||||
export type UserInfo = z.infer<typeof userInfoSchema>
|
||||
|
||||
@@ -112,6 +113,7 @@ export interface ServiceGetMeRequest {
|
||||
|
||||
export interface ServiceGetTeamMembersRequest {
|
||||
teamId: string
|
||||
userId: string
|
||||
includeAgents?: boolean
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ describe('TranscodeService', () => {
|
||||
expect(info.originalHeight).toBe(600)
|
||||
expect(info.mimeType).toBe('png')
|
||||
expect(info.duration).toBe(0)
|
||||
expect(sharp).toHaveBeenCalledWith('test.png')
|
||||
expect(sharp).toHaveBeenCalledWith('test.png', { limitInputPixels: false })
|
||||
})
|
||||
|
||||
it('should construct correct ffmpeg arguments for video transcoding', async () => {
|
||||
@@ -147,9 +147,9 @@ describe('TranscodeService', () => {
|
||||
const outputFile = path.join(tempDir, 'output.webp')
|
||||
await transcodeService.transcodeImage('input.png', outputFile, 480, 80)
|
||||
|
||||
expect(sharp).toHaveBeenCalledWith('input.png')
|
||||
expect(sharp).toHaveBeenCalledWith('input.png', { limitInputPixels: false })
|
||||
const mockSharp = vi.mocked(sharp).mock.results[0].value
|
||||
expect(mockSharp.resize).toHaveBeenCalledWith(480, null, expect.any(Object))
|
||||
expect(mockSharp.resize).toHaveBeenCalledWith(480, 7680, expect.any(Object))
|
||||
expect(mockSharp.webp).toHaveBeenCalledWith({ quality: 80 })
|
||||
expect(mockSharp.toFile).toHaveBeenCalledWith(outputFile)
|
||||
})
|
||||
@@ -166,7 +166,7 @@ describe('TranscodeService', () => {
|
||||
await transcodeService.transcodeImage('http://example.com/image.png', outputFile, 480, 80)
|
||||
|
||||
expect(global.fetch).toHaveBeenCalledWith('http://example.com/image.png')
|
||||
expect(sharp).toHaveBeenCalledWith(expect.any(Buffer))
|
||||
expect(sharp).toHaveBeenCalledWith(expect.any(Buffer), { limitInputPixels: false })
|
||||
})
|
||||
|
||||
it('should support Buffer as input for image transcoding', async () => {
|
||||
@@ -174,9 +174,9 @@ describe('TranscodeService', () => {
|
||||
const outputFile = path.join(tempDir, 'output-buffer.webp')
|
||||
await transcodeService.transcodeImage(inputBuffer, outputFile, 480, 80)
|
||||
|
||||
expect(sharp).toHaveBeenCalledWith(inputBuffer)
|
||||
expect(sharp).toHaveBeenCalledWith(inputBuffer, { limitInputPixels: false })
|
||||
const mockSharp = vi.mocked(sharp).mock.results[vi.mocked(sharp).mock.results.length - 1].value
|
||||
expect(mockSharp.resize).toHaveBeenCalledWith(480, null, expect.any(Object))
|
||||
expect(mockSharp.resize).toHaveBeenCalledWith(480, 7680, expect.any(Object))
|
||||
expect(mockSharp.webp).toHaveBeenCalledWith({ quality: 80 })
|
||||
expect(mockSharp.toFile).toHaveBeenCalledWith(outputFile)
|
||||
})
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
import { prisma } from '@shumai/db'
|
||||
import { WorkflowTaskStatus, WorkflowTaskType } from '@shumai/db'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { prisma, WorkflowTaskStatus, WorkflowTaskType } from '@shumai/db'
|
||||
import '@shumai/db/src/prisma-json-types'
|
||||
import { execFile } from 'child_process'
|
||||
import * as fs from 'fs'
|
||||
import * as os from 'os'
|
||||
import * as path from 'path'
|
||||
import sharp from 'sharp'
|
||||
import { promisify } from 'util'
|
||||
import { s3Service } from '@shumai/core/src/s3/s3'
|
||||
import { ulid } from 'ulid'
|
||||
import { promisify } from 'util'
|
||||
|
||||
const execFileAsync = promisify(execFile)
|
||||
|
||||
@@ -237,7 +236,7 @@ export class TranscodeService {
|
||||
input = Buffer.from(await resp.arrayBuffer())
|
||||
}
|
||||
|
||||
const metadata = await sharp(input).metadata()
|
||||
const metadata = await sharp(input, { limitInputPixels: false }).metadata()
|
||||
return {
|
||||
originalWidth: metadata.width || 0,
|
||||
originalHeight: metadata.height || 0,
|
||||
@@ -289,17 +288,16 @@ export class TranscodeService {
|
||||
input = Buffer.from(await resp.arrayBuffer())
|
||||
}
|
||||
|
||||
const sharpInstance = sharp(input)
|
||||
const sharpInstance = sharp(input, { limitInputPixels: false })
|
||||
|
||||
const w = width > 0 ? width : null
|
||||
const h = height && height > 0 ? height : null
|
||||
const WEBP_MAX_DIMENSION = 7680
|
||||
const targetW = width > 0 ? Math.min(width, WEBP_MAX_DIMENSION) : WEBP_MAX_DIMENSION
|
||||
const targetH = height && height > 0 ? Math.min(height, WEBP_MAX_DIMENSION) : WEBP_MAX_DIMENSION
|
||||
|
||||
if (w || h) {
|
||||
sharpInstance.resize(w, h, {
|
||||
withoutEnlargement: true,
|
||||
fit: 'inside',
|
||||
})
|
||||
}
|
||||
sharpInstance.resize(targetW, targetH, {
|
||||
withoutEnlargement: true,
|
||||
fit: 'inside',
|
||||
})
|
||||
|
||||
await sharpInstance.webp({ quality }).toFile(outputFile)
|
||||
}
|
||||
@@ -497,14 +495,14 @@ export class TranscodeService {
|
||||
params.annotations &&
|
||||
params.annotations.length > 0
|
||||
) {
|
||||
const meta = await sharp(localShotPath).metadata()
|
||||
const meta = await sharp(localShotPath, { limitInputPixels: false }).metadata()
|
||||
const width = meta.width || 1280
|
||||
const height = meta.height || 720
|
||||
|
||||
const svgStr = renderAnnotationsToSvg(width, height, params.annotations)
|
||||
const tempCompositedPath = path.join(tmpDir, `composite-${outName}`)
|
||||
|
||||
await sharp(localShotPath)
|
||||
await sharp(localShotPath, { limitInputPixels: false })
|
||||
.composite([{ input: Buffer.from(svgStr), top: 0, left: 0 }])
|
||||
.toFile(tempCompositedPath)
|
||||
|
||||
@@ -539,7 +537,7 @@ export class TranscodeService {
|
||||
await s3Service.downloadToFile(bucket, params.assetKey, imgPath)
|
||||
|
||||
// 2. Read dimensions
|
||||
const meta = await sharp(imgPath).metadata()
|
||||
const meta = await sharp(imgPath, { limitInputPixels: false }).metadata()
|
||||
const width = meta.width || 1920
|
||||
const height = meta.height || 1080
|
||||
|
||||
@@ -550,8 +548,9 @@ export class TranscodeService {
|
||||
const outName = `annotation-${ulid()}.webp`
|
||||
const localOutPath = path.join(tmpDir, outName)
|
||||
|
||||
await sharp(imgPath)
|
||||
await sharp(imgPath, { limitInputPixels: false })
|
||||
.composite([{ input: Buffer.from(svgStr), top: 0, left: 0 }])
|
||||
.resize(16383, 16383, { fit: 'inside', withoutEnlargement: true })
|
||||
.webp({ quality: 90 })
|
||||
.toFile(localOutPath)
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ const customFetch = async (input: RequestInfo | URL, init?: RequestInit) => {
|
||||
// Don't redirect if we are already on login page, it's an auth request, or we are on a public share page
|
||||
if (
|
||||
!window.location.pathname.includes('/login') &&
|
||||
!window.location.pathname.includes('/signup') &&
|
||||
!window.location.pathname.startsWith('/share/') &&
|
||||
!url.includes('/api/authn')
|
||||
) {
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import { ShumaiLogo } from '@/ui/components/ui/icons'
|
||||
import { CheckCircle2 } from 'lucide-react'
|
||||
import { ReactNode } from 'react'
|
||||
|
||||
export function AuthLayout({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<div className="min-h-screen w-full flex items-center justify-center p-4 md:p-8 bg-zinc-100/80 dark:bg-black font-sans overflow-hidden relative">
|
||||
{/* Drifting Background Mesh Blobs */}
|
||||
<div className="bg-rose-500/10 dark:bg-rose-600/5 w-[600px] h-[600px] rounded-full blur-[140px] absolute top-[-10%] left-[-10%] animate-drift-slow" />
|
||||
<div className="bg-orange-500/10 dark:bg-orange-600/5 w-[600px] h-[600px] rounded-full blur-[140px] absolute bottom-[-10%] right-[-10%] animate-drift-medium" />
|
||||
|
||||
{/* Main Glassmorphic Split-Pane Card */}
|
||||
<div className="relative max-w-4xl w-full flex flex-col md:flex-row rounded-3xl border border-zinc-200 dark:border-zinc-800 shadow-2xl bg-white dark:bg-zinc-900 overflow-hidden min-h-[580px] z-10 transition-all duration-300 hover:shadow-rose-500/5">
|
||||
{/* Left Pane (Brand Showcase) */}
|
||||
<div className="hidden md:flex flex-col w-full md:w-1/2 bg-gradient-to-br from-rose-500/15 via-orange-500/10 to-amber-500/5 dark:from-rose-950/30 dark:via-orange-950/15 dark:to-zinc-900/40 p-8 md:p-12 justify-between border-r border-zinc-200 dark:border-zinc-800 relative overflow-hidden">
|
||||
{/* Subtle Grid Overlay */}
|
||||
<div className="absolute inset-0 bg-[linear-gradient(to_right,#8080800a_1px,transparent_1px),linear-gradient(to_bottom,#8080800a_1px,transparent_1px)] bg-[size:14px_24px] [mask-image:radial-gradient(ellipse_60%_50%_at_50%_0%,#000_70%,transparent_100%)] pointer-events-none" />
|
||||
|
||||
{/* Logo & Brand */}
|
||||
<div className="relative flex items-center gap-3">
|
||||
<ShumaiLogo className="h-12 w-12 shadow-lg shadow-rose-500/10 rounded-2xl transition-transform duration-500 hover:scale-105" />
|
||||
<span className="text-xl font-extrabold tracking-tight bg-gradient-to-r from-rose-500 via-orange-500 to-amber-500 bg-clip-text text-transparent">
|
||||
Shumai
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Marketing Copy / Feature Points */}
|
||||
<div className="relative my-8 md:my-0 space-y-6">
|
||||
<h2 className="text-3xl font-extrabold tracking-tight leading-tight text-zinc-900 dark:text-zinc-50">
|
||||
One workspace
|
||||
<br />
|
||||
for all your
|
||||
<br />
|
||||
<span className="bg-gradient-to-r from-rose-500 to-orange-500 bg-clip-text text-transparent">
|
||||
creative assets.
|
||||
</span>
|
||||
</h2>
|
||||
<p className="text-zinc-600 dark:text-zinc-400 text-sm leading-relaxed max-w-sm">
|
||||
Upload and index your files, enrich them with custom metadata schemas, draw
|
||||
annotations directly on media, and gather instant feedback — all in one modern
|
||||
workspace built for creators.
|
||||
</p>
|
||||
|
||||
<ul className="space-y-3.5 pt-4">
|
||||
{[
|
||||
'Instant asset uploads & high-fidelity media players',
|
||||
'Custom metadata schemas & drawing canvas reviews',
|
||||
'Frictionless team workspaces & secure sharing',
|
||||
].map((text, i) => (
|
||||
<li
|
||||
key={i}
|
||||
className="flex items-center gap-3 text-sm text-zinc-700 dark:text-zinc-300 font-medium"
|
||||
>
|
||||
<CheckCircle2 className="w-5 h-5 text-rose-500 flex-shrink-0" />
|
||||
<span>{text}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{/* Footer Label */}
|
||||
<div className="relative pt-4 border-t border-zinc-200/30 dark:border-zinc-800/30">
|
||||
<p className="text-xs text-zinc-500 dark:text-zinc-400 font-medium">
|
||||
Join our community of developers and designers.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right Pane (Form Container) */}
|
||||
<div className="w-full md:w-1/2 p-8 md:p-12 flex flex-col justify-center">{children}</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -530,6 +530,10 @@ export function FileBrowser({
|
||||
const selectedFiles = Array.from(selectedIds).filter((id) =>
|
||||
displayedFiles.find((item) => item.id === id),
|
||||
).length
|
||||
const selectedSize = Array.from(selectedIds).reduce((acc, id) => {
|
||||
const item = folders.find((f) => f.id === id) || displayedFiles.find((f) => f.id === id)
|
||||
return acc + (item?.sizeByte || 0)
|
||||
}, 0)
|
||||
|
||||
const handleUploadFilesClick = () => {
|
||||
fileInputRef.current?.click()
|
||||
@@ -876,20 +880,20 @@ export function FileBrowser({
|
||||
<div className="text-sm text-muted-foreground">
|
||||
{selectedFolders > 0 && selectedFiles > 0 && (
|
||||
<span>
|
||||
{selectedFolders} folder
|
||||
{selectedFolders !== 1 ? 's' : ''}, {selectedFiles} file
|
||||
{selectedFiles !== 1 ? 's' : ''} selected
|
||||
{selectedCount} Item{selectedCount !== 1 ? 's' : ''} selected •{' '}
|
||||
{formatSize(selectedSize)}
|
||||
</span>
|
||||
)}
|
||||
{selectedFolders > 0 && selectedFiles === 0 && (
|
||||
<span>
|
||||
{selectedFolders} folder
|
||||
{selectedFolders !== 1 ? 's' : ''} selected
|
||||
{selectedFolders} folder{selectedFolders !== 1 ? 's' : ''} selected •{' '}
|
||||
{formatSize(selectedSize)}
|
||||
</span>
|
||||
)}
|
||||
{selectedFolders === 0 && selectedFiles > 0 && (
|
||||
<span>
|
||||
{selectedFiles} file{selectedFiles !== 1 ? 's' : ''} selected
|
||||
{selectedFiles} file{selectedFiles !== 1 ? 's' : ''} selected •{' '}
|
||||
{formatSize(selectedSize)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -531,7 +531,7 @@ export function FolderTree({
|
||||
{!hideShares && (
|
||||
<div
|
||||
className={cn(
|
||||
'flex flex-col overflow-hidden transition-all duration-300 ease-in-out border-b border-border pb-4',
|
||||
'flex flex-col overflow-hidden transition-all duration-300 ease-in-out',
|
||||
isSharesExpanded ? 'flex-1 min-h-0 h-full' : 'flex-none h-[44px] max-h-[44px]',
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -28,6 +28,7 @@ export interface Member {
|
||||
name?: string
|
||||
role?: string
|
||||
image?: string
|
||||
scope?: 'team' | 'project'
|
||||
}
|
||||
|
||||
interface MembersDialogProps {
|
||||
@@ -154,7 +155,19 @@ export function MembersDialog({
|
||||
</Avatar>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm font-medium">{member.name}</span>
|
||||
<span className="text-xs text-muted-foreground capitalize">{member.role}</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs text-muted-foreground capitalize">
|
||||
{member.role}
|
||||
</span>
|
||||
{member.scope && (
|
||||
<>
|
||||
<span className="text-[10px] text-muted-foreground/50">•</span>
|
||||
<span className="text-[10px] bg-muted px-1.5 py-0.5 rounded-full font-medium text-muted-foreground uppercase tracking-wider">
|
||||
{member.scope === 'team' ? 'Team Member' : 'Project Member'}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import { TopNav } from '@/ui/components/top-nav'
|
||||
import { HomeIcon, NotificationFillIcon, UploadCloudIcon } from '@/ui/components/ui/icons'
|
||||
import { Toaster } from '@/ui/components/ui/sonner'
|
||||
import { UploadTasks } from '@/ui/components/upload-tasks'
|
||||
import { usePermissions } from '@/ui/hooks/use-permissions'
|
||||
import { useAuthStore } from '@/ui/stores/auth'
|
||||
import { useTeamContextStore } from '@/ui/stores/team-context'
|
||||
import { useUploadStore } from '@/ui/stores/upload'
|
||||
@@ -21,7 +20,6 @@ import { useEffect } from 'react'
|
||||
function RootComponent() {
|
||||
const user = useAuthStore((state) => state.user)
|
||||
const { uploading } = useUploadStore()
|
||||
const { canEdit } = usePermissions()
|
||||
const pathname = useRouterState({ select: (s) => s.location.pathname })
|
||||
const navigate = useNavigate()
|
||||
|
||||
@@ -90,19 +88,17 @@ function RootComponent() {
|
||||
<DualSidebarItem icon={<NotificationFillIcon />} label="Notifications" badge={badge}>
|
||||
<NotificationList />
|
||||
</DualSidebarItem>
|
||||
{canEdit && (
|
||||
<DualSidebarItem
|
||||
icon={
|
||||
<UploadCloudIcon
|
||||
uploading={uploading > 0}
|
||||
className={uploading > 0 ? 'text-blue-500' : ''}
|
||||
/>
|
||||
}
|
||||
label="Uploads"
|
||||
>
|
||||
<UploadTasks />
|
||||
</DualSidebarItem>
|
||||
)}
|
||||
<DualSidebarItem
|
||||
icon={
|
||||
<UploadCloudIcon
|
||||
uploading={uploading > 0}
|
||||
className={uploading > 0 ? 'text-blue-500' : ''}
|
||||
/>
|
||||
}
|
||||
label="Uploads"
|
||||
>
|
||||
<UploadTasks />
|
||||
</DualSidebarItem>
|
||||
</DualSidebar>
|
||||
<div className="flex flex-col flex-1 md:pl-16 overflow-hidden relative">
|
||||
<TopNav />
|
||||
|
||||
+95
-159
@@ -10,8 +10,9 @@ import { useEffect, useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { z } from 'zod'
|
||||
import { signIn } from '@/ui/lib/auth-client'
|
||||
import { Loader2, Mail, Lock, ArrowRight, LogIn, CheckCircle2 } from 'lucide-react'
|
||||
import { Loader2, Mail, Lock, ArrowRight, LogIn } from 'lucide-react'
|
||||
import { ShumaiLogo } from '@/ui/components/ui/icons'
|
||||
import { AuthLayout } from '@/ui/components/auth-layout'
|
||||
|
||||
const loginSchema = z.object({
|
||||
email: z.string().email('Invalid email address'),
|
||||
@@ -77,165 +78,100 @@ function LoginPage() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen w-full flex items-center justify-center p-4 md:p-8 bg-zinc-100/80 dark:bg-black font-sans overflow-hidden relative font-sans">
|
||||
{/* Drifting Background Mesh Blobs */}
|
||||
<div className="bg-rose-500/10 dark:bg-rose-600/5 w-[600px] h-[600px] rounded-full blur-[140px] absolute top-[-10%] left-[-10%] animate-drift-slow" />
|
||||
<div className="bg-orange-500/10 dark:bg-orange-600/5 w-[600px] h-[600px] rounded-full blur-[140px] absolute bottom-[-10%] right-[-10%] animate-drift-medium" />
|
||||
|
||||
{/* Main Glassmorphic Split-Pane Card */}
|
||||
<div className="relative max-w-4xl w-full flex flex-col md:flex-row rounded-3xl border border-zinc-200 dark:border-zinc-800 shadow-2xl bg-white dark:bg-zinc-900 overflow-hidden min-h-[580px] z-10 transition-all duration-300 hover:shadow-rose-500/5">
|
||||
{/* Left Pane (Brand Showcase) */}
|
||||
<div className="w-full md:w-1/2 bg-gradient-to-br from-rose-500/15 via-orange-500/10 to-amber-500/5 dark:from-rose-950/30 dark:via-orange-950/15 dark:to-zinc-900/40 p-8 md:p-12 flex flex-col justify-between border-b md:border-b-0 md:border-r border-zinc-200 dark:border-zinc-800 relative overflow-hidden">
|
||||
{/* Subtle Grid Overlay */}
|
||||
<div className="absolute inset-0 bg-[linear-gradient(to_right,#8080800a_1px,transparent_1px),linear-gradient(to_bottom,#8080800a_1px,transparent_1px)] bg-[size:14px_24px] [mask-image:radial-gradient(ellipse_60%_50%_at_50%_0%,#000_70%,transparent_100%)] pointer-events-none" />
|
||||
|
||||
{/* Logo & Brand */}
|
||||
<div className="relative flex items-center gap-3">
|
||||
<ShumaiLogo className="h-12 w-12 shadow-lg shadow-rose-500/10 rounded-2xl transition-transform duration-500 hover:scale-105" />
|
||||
<span className="text-xl font-extrabold tracking-tight bg-gradient-to-r from-rose-500 via-orange-500 to-amber-500 bg-clip-text text-transparent">
|
||||
Shumai
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Marketing Copy / Feature Points */}
|
||||
<div className="relative my-8 md:my-0 space-y-6">
|
||||
<h2 className="text-3xl font-extrabold tracking-tight leading-tight text-zinc-900 dark:text-zinc-50">
|
||||
One workspace
|
||||
<br />
|
||||
for all your
|
||||
<br />
|
||||
<span className="bg-gradient-to-r from-rose-500 to-orange-500 bg-clip-text text-transparent">
|
||||
creative assets.
|
||||
</span>
|
||||
</h2>
|
||||
<p className="text-zinc-600 dark:text-zinc-400 text-sm leading-relaxed max-w-sm">
|
||||
Upload and index your files, enrich them with custom metadata schemas, draw
|
||||
annotations directly on media, and gather instant feedback — all in one modern
|
||||
workspace built for creators.
|
||||
</p>
|
||||
|
||||
<ul className="space-y-3.5 pt-4">
|
||||
{[
|
||||
'Instant asset uploads & high-fidelity media players',
|
||||
'Custom metadata schemas & drawing canvas reviews',
|
||||
'Frictionless team workspaces & secure sharing',
|
||||
].map((text, i) => (
|
||||
<li
|
||||
key={i}
|
||||
className="flex items-center gap-3 text-sm text-zinc-700 dark:text-zinc-300 font-medium"
|
||||
>
|
||||
<CheckCircle2 className="w-5 h-5 text-rose-500 flex-shrink-0" />
|
||||
<span>{text}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{/* Footer Label */}
|
||||
<div className="relative pt-4 border-t border-zinc-200/30 dark:border-zinc-800/30">
|
||||
<p className="text-xs text-zinc-500 dark:text-zinc-400 font-medium">
|
||||
Join our community of developers and designers.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right Pane (Form Container) */}
|
||||
<div className="w-full md:w-1/2 p-8 md:p-12 flex flex-col justify-center">
|
||||
<div className="mb-8">
|
||||
<h1 className="text-2xl font-bold tracking-tight text-zinc-900 dark:text-zinc-50">
|
||||
Welcome Back
|
||||
</h1>
|
||||
<p className="text-zinc-500 dark:text-zinc-400 text-sm mt-1">
|
||||
Enter your credentials to access your account.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div className="mb-6 p-3 bg-red-500/10 border border-red-500/20 text-red-600 dark:text-red-400 rounded-xl text-sm text-center font-medium">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-5">
|
||||
<div className="space-y-2">
|
||||
<Label
|
||||
htmlFor="email"
|
||||
className="text-xs font-semibold text-zinc-600 dark:text-zinc-400 tracking-wide uppercase"
|
||||
>
|
||||
Email Address
|
||||
</Label>
|
||||
<div className="relative group">
|
||||
<Mail className="absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400 dark:text-zinc-600 transition-colors group-focus-within:text-rose-500" />
|
||||
<Input
|
||||
id="email"
|
||||
{...form.register('email')}
|
||||
placeholder="you@example.com"
|
||||
type="email"
|
||||
className="pl-10.5 h-11 border-zinc-200 dark:border-zinc-800 focus-visible:ring-rose-500/50 focus-visible:border-rose-500 rounded-xl transition-all shadow-sm"
|
||||
/>
|
||||
</div>
|
||||
{form.formState.errors.email && (
|
||||
<p className="text-red-500 text-xs font-medium">
|
||||
{form.formState.errors.email.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label
|
||||
htmlFor="password"
|
||||
className="text-xs font-semibold text-zinc-600 dark:text-zinc-400 tracking-wide uppercase"
|
||||
>
|
||||
Password
|
||||
</Label>
|
||||
<div className="relative group">
|
||||
<Lock className="absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400 dark:text-zinc-600 transition-colors group-focus-within:text-rose-500" />
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
{...form.register('password')}
|
||||
placeholder="Your password"
|
||||
className="pl-10.5 h-11 border-zinc-200 dark:border-zinc-800 focus-visible:ring-rose-500/50 focus-visible:border-rose-500 rounded-xl transition-all shadow-sm"
|
||||
/>
|
||||
</div>
|
||||
{form.formState.errors.password && (
|
||||
<p className="text-red-500 text-xs font-medium">
|
||||
{form.formState.errors.password.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
className="w-full h-11 bg-gradient-to-r from-rose-500 to-orange-500 hover:from-rose-600 hover:to-orange-600 text-white font-semibold rounded-xl shadow-md shadow-rose-500/10 hover:shadow-rose-500/20 active:scale-[0.98] transition-all flex items-center justify-center gap-2 border-0"
|
||||
disabled={loading}
|
||||
>
|
||||
{loading ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
Logging in...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<LogIn className="w-4 h-4" />
|
||||
Login
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<div className="mt-8 pt-6 border-t border-zinc-200/30 dark:border-zinc-800/30 text-center text-sm">
|
||||
<span className="text-zinc-500 dark:text-zinc-400">Don't have an account? </span>
|
||||
<a
|
||||
href="/signup"
|
||||
className="font-semibold text-rose-500 hover:text-rose-600 dark:text-rose-400 dark:hover:text-rose-300 transition-colors hover:underline inline-flex items-center gap-0.5"
|
||||
>
|
||||
Sign up <ArrowRight className="w-3.5 h-3.5" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<AuthLayout>
|
||||
<div className="mb-8">
|
||||
<h1 className="text-2xl font-bold tracking-tight text-zinc-900 dark:text-zinc-50">
|
||||
Welcome Back
|
||||
</h1>
|
||||
<p className="text-zinc-500 dark:text-zinc-400 text-sm mt-1">
|
||||
Enter your credentials to access your account.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div className="mb-6 p-3 bg-red-500/10 border border-red-500/20 text-red-600 dark:text-red-400 rounded-xl text-sm text-center font-medium">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-5">
|
||||
<div className="space-y-2">
|
||||
<Label
|
||||
htmlFor="email"
|
||||
className="text-xs font-semibold text-zinc-600 dark:text-zinc-400 tracking-wide uppercase"
|
||||
>
|
||||
Email Address
|
||||
</Label>
|
||||
<div className="relative group">
|
||||
<Mail className="absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400 dark:text-zinc-600 transition-colors group-focus-within:text-rose-500" />
|
||||
<Input
|
||||
id="email"
|
||||
{...form.register('email')}
|
||||
placeholder="you@example.com"
|
||||
type="email"
|
||||
className="pl-10.5 h-11 border-zinc-200 dark:border-zinc-800 focus-visible:ring-rose-500/50 focus-visible:border-rose-500 rounded-xl transition-all shadow-sm"
|
||||
/>
|
||||
</div>
|
||||
{form.formState.errors.email && (
|
||||
<p className="text-red-500 text-xs font-medium">
|
||||
{form.formState.errors.email.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label
|
||||
htmlFor="password"
|
||||
className="text-xs font-semibold text-zinc-600 dark:text-zinc-400 tracking-wide uppercase"
|
||||
>
|
||||
Password
|
||||
</Label>
|
||||
<div className="relative group">
|
||||
<Lock className="absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400 dark:text-zinc-600 transition-colors group-focus-within:text-rose-500" />
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
{...form.register('password')}
|
||||
placeholder="Your password"
|
||||
className="pl-10.5 h-11 border-zinc-200 dark:border-zinc-800 focus-visible:ring-rose-500/50 focus-visible:border-rose-500 rounded-xl transition-all shadow-sm"
|
||||
/>
|
||||
</div>
|
||||
{form.formState.errors.password && (
|
||||
<p className="text-red-500 text-xs font-medium">
|
||||
{form.formState.errors.password.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
className="w-full h-11 bg-gradient-to-r from-rose-500 to-orange-500 hover:from-rose-600 hover:to-orange-600 text-white font-semibold rounded-xl shadow-md shadow-rose-500/10 hover:shadow-rose-500/20 active:scale-[0.98] transition-all flex items-center justify-center gap-2 border-0"
|
||||
disabled={loading}
|
||||
>
|
||||
{loading ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
Logging in...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<LogIn className="w-4 h-4" />
|
||||
Login
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<div className="mt-8 pt-6 border-t border-zinc-200/30 dark:border-zinc-800/30 text-center text-sm">
|
||||
<span className="text-zinc-500 dark:text-zinc-400">Don't have an account? </span>
|
||||
<a
|
||||
href="/signup"
|
||||
className="font-semibold text-rose-500 hover:text-rose-600 dark:text-rose-400 dark:hover:text-rose-300 transition-colors hover:underline inline-flex items-center gap-0.5"
|
||||
>
|
||||
Sign up <ArrowRight className="w-3.5 h-3.5" />
|
||||
</a>
|
||||
</div>
|
||||
</AuthLayout>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+110
-174
@@ -4,7 +4,7 @@ import { Button } from '@/ui/components/ui/button'
|
||||
import { Card, CardDescription, CardFooter, CardHeader, CardTitle } from '@/ui/components/ui/card'
|
||||
import { Input } from '@/ui/components/ui/input'
|
||||
import { Label } from '@/ui/components/ui/label'
|
||||
import { Loader2, Mail, Lock, CheckCircle2, ArrowRight, UserPlus } from 'lucide-react'
|
||||
import { Loader2, Mail, Lock, ArrowRight, UserPlus } from 'lucide-react'
|
||||
import { useAuthStore } from '@/ui/stores/auth'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { createFileRoute, redirect, useNavigate } from '@tanstack/react-router'
|
||||
@@ -13,6 +13,7 @@ import { z } from 'zod'
|
||||
import { signUp } from '@/ui/lib/auth-client'
|
||||
import { useState } from 'react'
|
||||
import { ShumaiLogo } from '@/ui/components/ui/icons'
|
||||
import { AuthLayout } from '@/ui/components/auth-layout'
|
||||
|
||||
const signupSchema = z.object({
|
||||
email: z.string().email('Invalid email address'),
|
||||
@@ -135,183 +136,118 @@ function SignupPage() {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen w-full flex items-center justify-center p-4 md:p-8 bg-zinc-100/80 dark:bg-black font-sans overflow-hidden relative">
|
||||
{/* Drifting Background Mesh Blobs */}
|
||||
<div className="bg-rose-500/10 dark:bg-rose-600/5 w-[600px] h-[600px] rounded-full blur-[140px] absolute top-[-10%] left-[-10%] animate-drift-slow" />
|
||||
<div className="bg-orange-500/10 dark:bg-orange-600/5 w-[600px] h-[600px] rounded-full blur-[140px] absolute bottom-[-10%] right-[-10%] animate-drift-medium" />
|
||||
<AuthLayout>
|
||||
<div className="mb-8">
|
||||
<h1 className="text-2xl font-bold tracking-tight text-zinc-900 dark:text-zinc-50">
|
||||
Create Account
|
||||
</h1>
|
||||
<p className="text-zinc-500 dark:text-zinc-400 text-sm mt-1 mb-4">
|
||||
Start building and organizing your space.
|
||||
</p>
|
||||
|
||||
{/* Main Glassmorphic Split-Pane Card */}
|
||||
<div className="relative max-w-4xl w-full flex flex-col md:flex-row rounded-3xl border border-zinc-200 dark:border-zinc-800 shadow-2xl bg-white dark:bg-zinc-900 overflow-hidden min-h-[580px] z-10 transition-all duration-300 hover:shadow-rose-500/5">
|
||||
{/* Left Pane (Brand Showcase) */}
|
||||
<div className="w-full md:w-1/2 bg-gradient-to-br from-rose-500/15 via-orange-500/10 to-amber-500/5 dark:from-rose-950/30 dark:via-orange-950/15 dark:to-zinc-900/40 p-8 md:p-12 flex flex-col justify-between border-b md:border-b-0 md:border-r border-zinc-200 dark:border-zinc-800 relative overflow-hidden">
|
||||
{/* Subtle Grid Overlay */}
|
||||
<div className="absolute inset-0 bg-[linear-gradient(to_right,#8080800a_1px,transparent_1px),linear-gradient(to_bottom,#8080800a_1px,transparent_1px)] bg-[size:14px_24px] [mask-image:radial-gradient(ellipse_60%_50%_at_50%_0%,#000_70%,transparent_100%)] pointer-events-none" />
|
||||
|
||||
{/* Logo & Brand */}
|
||||
<div className="relative flex items-center gap-3">
|
||||
<ShumaiLogo className="h-12 w-12 shadow-lg shadow-rose-500/10 rounded-2xl transition-transform duration-500 hover:scale-105" />
|
||||
<span className="text-xl font-extrabold tracking-tight bg-gradient-to-r from-rose-500 via-orange-500 to-amber-500 bg-clip-text text-transparent">
|
||||
Shumai
|
||||
{/* Context Banners (First User / Invite Info) */}
|
||||
{isFirstUser && (
|
||||
<div className="flex items-start gap-3 p-3 bg-amber-500/10 border border-amber-500/20 text-amber-800 dark:text-amber-300 rounded-2xl text-xs leading-relaxed font-medium">
|
||||
<span>🎉</span>
|
||||
<span>You will be the owner of the default workspace as the first user!</span>
|
||||
</div>
|
||||
)}
|
||||
{inviteInfo && !('error' in inviteInfo) && (
|
||||
<div className="flex items-start gap-3 p-3 bg-rose-500/10 border border-rose-500/20 text-rose-800 dark:text-rose-300 rounded-2xl text-xs leading-relaxed font-medium mt-3">
|
||||
<span>👋</span>
|
||||
<span>
|
||||
<strong>{inviteInfo.inviterName}</strong> invited you to join{' '}
|
||||
<strong>{inviteInfo.projectName || inviteInfo.teamName}</strong> as a{' '}
|
||||
<strong>{inviteInfo.role}</strong>.
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Marketing Copy / Feature Points */}
|
||||
<div className="relative my-8 md:my-0 space-y-6">
|
||||
<h2 className="text-3xl font-extrabold tracking-tight leading-tight text-zinc-900 dark:text-zinc-50">
|
||||
One workspace
|
||||
<br />
|
||||
for all your
|
||||
<br />
|
||||
<span className="bg-gradient-to-r from-rose-500 to-orange-500 bg-clip-text text-transparent">
|
||||
creative assets.
|
||||
</span>
|
||||
</h2>
|
||||
<p className="text-zinc-600 dark:text-zinc-400 text-sm leading-relaxed max-w-sm">
|
||||
Upload and index your files, enrich them with custom metadata schemas, draw
|
||||
annotations directly on media, and gather instant feedback — all in one modern
|
||||
workspace built for creators.
|
||||
</p>
|
||||
|
||||
<ul className="space-y-3.5 pt-4">
|
||||
{[
|
||||
'Instant asset uploads & high-fidelity media players',
|
||||
'Custom metadata schemas & drawing canvas reviews',
|
||||
'Frictionless team workspaces & secure sharing',
|
||||
].map((text, i) => (
|
||||
<li
|
||||
key={i}
|
||||
className="flex items-center gap-3 text-sm text-zinc-700 dark:text-zinc-300 font-medium"
|
||||
>
|
||||
<CheckCircle2 className="w-5 h-5 text-rose-500 flex-shrink-0" />
|
||||
<span>{text}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{/* Context Banners (First User / Invite Info) */}
|
||||
<div className="relative pt-4 border-t border-zinc-200/30 dark:border-zinc-800/30">
|
||||
{isFirstUser && (
|
||||
<div className="flex items-start gap-3 p-3 bg-amber-500/10 border border-amber-500/20 text-amber-800 dark:text-amber-300 rounded-2xl text-xs leading-relaxed font-medium">
|
||||
<span>🎉</span>
|
||||
<span>You will be the owner of the default workspace as the first user!</span>
|
||||
</div>
|
||||
)}
|
||||
{inviteInfo && !('error' in inviteInfo) && (
|
||||
<div className="flex items-start gap-3 p-3 bg-rose-500/10 border border-rose-500/20 text-rose-800 dark:text-rose-300 rounded-2xl text-xs leading-relaxed font-medium">
|
||||
<span>👋</span>
|
||||
<span>
|
||||
<strong>{inviteInfo.inviterName}</strong> invited you to join{' '}
|
||||
<strong>{inviteInfo.teamName || inviteInfo.projectName}</strong> as a{' '}
|
||||
<strong>{inviteInfo.role}</strong>.
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{!isFirstUser && !inviteInfo && (
|
||||
<p className="text-xs text-zinc-500 dark:text-zinc-400 font-medium">
|
||||
Join our community of developers and designers.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right Pane (Form Container) */}
|
||||
<div className="w-full md:w-1/2 p-8 md:p-12 flex flex-col justify-center">
|
||||
<div className="mb-8">
|
||||
<h1 className="text-2xl font-bold tracking-tight text-zinc-900 dark:text-zinc-50">
|
||||
Create Account
|
||||
</h1>
|
||||
<p className="text-zinc-500 dark:text-zinc-400 text-sm mt-1">
|
||||
Start building and organizing your space.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div className="mb-6 p-3 bg-red-500/10 border border-red-500/20 text-red-600 dark:text-red-400 rounded-xl text-sm text-center font-medium">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-5">
|
||||
<div className="space-y-2">
|
||||
<Label
|
||||
htmlFor="email"
|
||||
className="text-xs font-semibold text-zinc-600 dark:text-zinc-400 tracking-wide uppercase"
|
||||
>
|
||||
Email Address
|
||||
</Label>
|
||||
<div className="relative group">
|
||||
<Mail className="absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400 dark:text-zinc-600 transition-colors group-focus-within:text-rose-500" />
|
||||
<Input
|
||||
id="email"
|
||||
{...form.register('email')}
|
||||
placeholder="you@example.com"
|
||||
type="email"
|
||||
className="pl-10.5 h-11 border-zinc-200 dark:border-zinc-800 focus-visible:ring-rose-500/50 focus-visible:border-rose-500 rounded-xl transition-all shadow-sm"
|
||||
/>
|
||||
</div>
|
||||
{form.formState.errors.email && (
|
||||
<p className="text-red-500 text-xs font-medium">
|
||||
{form.formState.errors.email.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label
|
||||
htmlFor="password"
|
||||
className="text-xs font-semibold text-zinc-600 dark:text-zinc-400 tracking-wide uppercase"
|
||||
>
|
||||
Password
|
||||
</Label>
|
||||
<div className="relative group">
|
||||
<Lock className="absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400 dark:text-zinc-600 transition-colors group-focus-within:text-rose-500" />
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
{...form.register('password')}
|
||||
placeholder="At least 3 characters"
|
||||
className="pl-10.5 h-11 border-zinc-200 dark:border-zinc-800 focus-visible:ring-rose-500/50 focus-visible:border-rose-500 rounded-xl transition-all shadow-sm"
|
||||
/>
|
||||
</div>
|
||||
{form.formState.errors.password && (
|
||||
<p className="text-red-500 text-xs font-medium">
|
||||
{form.formState.errors.password.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
className="w-full h-11 bg-gradient-to-r from-rose-500 to-orange-500 hover:from-rose-600 hover:to-orange-600 text-white font-semibold rounded-xl shadow-md shadow-rose-500/10 hover:shadow-rose-500/20 active:scale-[0.98] transition-all flex items-center justify-center gap-2 border-0"
|
||||
disabled={loading}
|
||||
>
|
||||
{loading ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
Creating account...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<UserPlus className="w-4 h-4" />
|
||||
Sign Up
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<div className="mt-8 pt-6 border-t border-zinc-200/30 dark:border-zinc-800/30 text-center text-sm">
|
||||
<span className="text-zinc-500 dark:text-zinc-400">Already have an account? </span>
|
||||
<a
|
||||
href="/login"
|
||||
className="font-semibold text-rose-500 hover:text-rose-600 dark:text-rose-400 dark:hover:text-rose-300 transition-colors hover:underline inline-flex items-center gap-0.5"
|
||||
>
|
||||
Login <ArrowRight className="w-3.5 h-3.5" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div className="mb-6 p-3 bg-red-500/10 border border-red-500/20 text-red-600 dark:text-red-400 rounded-xl text-sm text-center font-medium">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-5">
|
||||
<div className="space-y-2">
|
||||
<Label
|
||||
htmlFor="email"
|
||||
className="text-xs font-semibold text-zinc-600 dark:text-zinc-400 tracking-wide uppercase"
|
||||
>
|
||||
Email Address
|
||||
</Label>
|
||||
<div className="relative group">
|
||||
<Mail className="absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400 dark:text-zinc-600 transition-colors group-focus-within:text-rose-500" />
|
||||
<Input
|
||||
id="email"
|
||||
{...form.register('email')}
|
||||
placeholder="you@example.com"
|
||||
type="email"
|
||||
className="pl-10.5 h-11 border-zinc-200 dark:border-zinc-800 focus-visible:ring-rose-500/50 focus-visible:border-rose-500 rounded-xl transition-all shadow-sm"
|
||||
/>
|
||||
</div>
|
||||
{form.formState.errors.email && (
|
||||
<p className="text-red-500 text-xs font-medium">
|
||||
{form.formState.errors.email.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label
|
||||
htmlFor="password"
|
||||
className="text-xs font-semibold text-zinc-600 dark:text-zinc-400 tracking-wide uppercase"
|
||||
>
|
||||
Password
|
||||
</Label>
|
||||
<div className="relative group">
|
||||
<Lock className="absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400 dark:text-zinc-600 transition-colors group-focus-within:text-rose-500" />
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
{...form.register('password')}
|
||||
placeholder="At least 3 characters"
|
||||
className="pl-10.5 h-11 border-zinc-200 dark:border-zinc-800 focus-visible:ring-rose-500/50 focus-visible:border-rose-500 rounded-xl transition-all shadow-sm"
|
||||
/>
|
||||
</div>
|
||||
{form.formState.errors.password && (
|
||||
<p className="text-red-500 text-xs font-medium">
|
||||
{form.formState.errors.password.message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
type="submit"
|
||||
className="w-full h-11 bg-gradient-to-r from-rose-500 to-orange-500 hover:from-rose-600 hover:to-orange-600 text-white font-semibold rounded-xl shadow-md shadow-rose-500/10 hover:shadow-rose-500/20 active:scale-[0.98] transition-all flex items-center justify-center gap-2 border-0"
|
||||
disabled={loading}
|
||||
>
|
||||
{loading ? (
|
||||
<>
|
||||
<Loader2 className="h-4 w-4 animate-spin" />
|
||||
Creating account...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<UserPlus className="w-4 h-4" />
|
||||
Sign Up
|
||||
</>
|
||||
)}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<div className="mt-8 pt-6 border-t border-zinc-200/30 dark:border-zinc-800/30 text-center text-sm">
|
||||
<span className="text-zinc-500 dark:text-zinc-400">Already have an account? </span>
|
||||
<a
|
||||
href="/login"
|
||||
className="font-semibold text-rose-500 hover:text-rose-600 dark:text-rose-400 dark:hover:text-rose-300 transition-colors hover:underline inline-flex items-center gap-0.5"
|
||||
>
|
||||
Login <ArrowRight className="w-3.5 h-3.5" />
|
||||
</a>
|
||||
</div>
|
||||
</AuthLayout>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -233,21 +233,23 @@ function TeamSettingsPage() {
|
||||
)}
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => setActiveTab('transcode')}
|
||||
className={cn(
|
||||
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
|
||||
activeTab === 'transcode'
|
||||
? 'bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border'
|
||||
: 'text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
|
||||
)}
|
||||
>
|
||||
<Film className="w-5 h-5" />
|
||||
Media Processing
|
||||
{activeTab === 'transcode' && (
|
||||
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary" />
|
||||
)}
|
||||
</button>
|
||||
{me?.role === 'owner' && (
|
||||
<button
|
||||
onClick={() => setActiveTab('transcode')}
|
||||
className={cn(
|
||||
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
|
||||
activeTab === 'transcode'
|
||||
? 'bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border'
|
||||
: 'text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
|
||||
)}
|
||||
>
|
||||
<Film className="w-5 h-5" />
|
||||
Media Processing
|
||||
{activeTab === 'transcode' && (
|
||||
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary" />
|
||||
)}
|
||||
</button>
|
||||
)}
|
||||
|
||||
<button
|
||||
onClick={() => setActiveTab('notifications')}
|
||||
@@ -265,73 +267,77 @@ function TeamSettingsPage() {
|
||||
)}
|
||||
</button>
|
||||
|
||||
<div className="mt-6 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border">
|
||||
AI
|
||||
</div>
|
||||
{me?.role === 'owner' && (
|
||||
<>
|
||||
<div className="mt-6 mb-2 px-4 text-xs font-semibold text-sidebar-foreground/60 uppercase tracking-wider pt-4 border-t border-sidebar-border">
|
||||
AI
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={() => setActiveTab('providers')}
|
||||
className={cn(
|
||||
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
|
||||
activeTab === 'providers'
|
||||
? 'bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border'
|
||||
: 'text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
|
||||
)}
|
||||
>
|
||||
<Cpu className="w-5 h-5" />
|
||||
Providers
|
||||
{activeTab === 'providers' && (
|
||||
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary" />
|
||||
)}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setActiveTab('providers')}
|
||||
className={cn(
|
||||
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
|
||||
activeTab === 'providers'
|
||||
? 'bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border'
|
||||
: 'text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
|
||||
)}
|
||||
>
|
||||
<Cpu className="w-5 h-5" />
|
||||
Providers
|
||||
{activeTab === 'providers' && (
|
||||
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary" />
|
||||
)}
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => setActiveTab('skills')}
|
||||
className={cn(
|
||||
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
|
||||
activeTab === 'skills'
|
||||
? 'bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border'
|
||||
: 'text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
|
||||
)}
|
||||
>
|
||||
<Puzzle className="w-5 h-5" />
|
||||
Skills
|
||||
{activeTab === 'skills' && (
|
||||
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary" />
|
||||
)}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setActiveTab('skills')}
|
||||
className={cn(
|
||||
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
|
||||
activeTab === 'skills'
|
||||
? 'bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border'
|
||||
: 'text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
|
||||
)}
|
||||
>
|
||||
<Puzzle className="w-5 h-5" />
|
||||
Skills
|
||||
{activeTab === 'skills' && (
|
||||
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary" />
|
||||
)}
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => setActiveTab('agents')}
|
||||
className={cn(
|
||||
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
|
||||
activeTab === 'agents'
|
||||
? 'bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border'
|
||||
: 'text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
|
||||
)}
|
||||
>
|
||||
<Bot className="w-5 h-5" />
|
||||
Agents
|
||||
{activeTab === 'agents' && (
|
||||
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary" />
|
||||
)}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setActiveTab('agents')}
|
||||
className={cn(
|
||||
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
|
||||
activeTab === 'agents'
|
||||
? 'bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border'
|
||||
: 'text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
|
||||
)}
|
||||
>
|
||||
<Bot className="w-5 h-5" />
|
||||
Agents
|
||||
{activeTab === 'agents' && (
|
||||
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary" />
|
||||
)}
|
||||
</button>
|
||||
|
||||
<button
|
||||
onClick={() => setActiveTab('sandbox')}
|
||||
className={cn(
|
||||
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
|
||||
activeTab === 'sandbox'
|
||||
? 'bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border'
|
||||
: 'text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
|
||||
)}
|
||||
>
|
||||
<Shield className="w-5 h-5" />
|
||||
Agent Sandbox
|
||||
{activeTab === 'sandbox' && (
|
||||
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary" />
|
||||
)}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setActiveTab('sandbox')}
|
||||
className={cn(
|
||||
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
|
||||
activeTab === 'sandbox'
|
||||
? 'bg-sidebar-accent text-sidebar-accent-foreground ring-1 ring-sidebar-border'
|
||||
: 'text-sidebar-foreground/75 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground',
|
||||
)}
|
||||
>
|
||||
<Shield className="w-5 h-5" />
|
||||
Agent Sandbox
|
||||
{activeTab === 'sandbox' && (
|
||||
<div className="ml-auto w-1.5 h-1.5 rounded-full bg-sidebar-primary" />
|
||||
)}
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user