mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 10:55:27 +00:00
feat(share): record and display share activity (#549)
* feat(share): record and display share activity * style(share): remove activity entry borders * docs(share): explain share link activity
This commit is contained in:
@@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||
|
||||
### Added
|
||||
|
||||
- **share**: See view counts, last viewed times, and activity for public share links, including file and folder views, downloads, and comments.
|
||||
|
||||
- **share**: Add options to create a share link or add to existing share links directly from the media view dropdown menu, and open a quick share dialog with inline renaming, one-click link copying, and security settings upon creation.
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -80,6 +80,9 @@ apps/web/e2e/
|
||||
| Owner creates a share link from a file context menu, edits it in the quick dialog, and opens advanced settings | `tests/project/create-share-link.spec.ts` |
|
||||
| Owner creates a share link and adds to an existing share link from media view | `tests/project/create-share-link.spec.ts` |
|
||||
| Owner protects a share with a password; guests must enter it to view | `tests/project/share-password.spec.ts` |
|
||||
| Public page views and share activity appear in both management sidebars | `tests/project/share-activity.spec.ts` |
|
||||
| Opening a direct historical version link records the selected version | `tests/project/share-activity.spec.ts` |
|
||||
| Concurrent public opens count every view and deduplicate matching activity | `tests/project/share-activity.spec.ts` |
|
||||
| Owner creates a collection from the sidebar; the collection shows project files | `tests/project/create-collection.spec.ts` |
|
||||
| Owner invites a member to a project; the member only sees the invited project | `tests/project/invite-member.spec.ts` |
|
||||
| Owner changes a project member role in the members dialog and permissions update | `tests/project/change-member-role.spec.ts` |
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
import { expect, test } from '../../fixtures'
|
||||
import { apiAddAssetsToShare, apiCreateShare, fileCard } from '../../helpers/files'
|
||||
|
||||
test('counts public page views and shows activity in both share management sidebars', async ({
|
||||
file,
|
||||
browser,
|
||||
prisma,
|
||||
}) => {
|
||||
const { context, page, projectId, rootFolderId, fileId, fileName } = file
|
||||
const folder = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'Review Folder',
|
||||
projectId,
|
||||
parentId: rootFolderId,
|
||||
type: 'folder',
|
||||
status: 'processed',
|
||||
},
|
||||
})
|
||||
await prisma.asset.update({ where: { id: fileId }, data: { parentId: folder.id } })
|
||||
const share = await apiCreateShare(context.request, projectId, 'Client Review')
|
||||
await apiAddAssetsToShare(context.request, share.id, [folder.id])
|
||||
const password = 'review-password'
|
||||
const lock = await context.request.put(`/api/shares/${share.id}`, { data: { password } })
|
||||
expect(lock.ok()).toBe(true)
|
||||
const readShare = () => prisma.shareLink.findUniqueOrThrow({ where: { id: share.id } })
|
||||
|
||||
await page.goto(`/projects/${projectId}/shares`)
|
||||
await expect(page.getByText('Never viewed')).toBeVisible()
|
||||
|
||||
const guest = await browser.newContext()
|
||||
try {
|
||||
const guestPage = await guest.newPage()
|
||||
await guestPage.goto(`/share/${share.id}`)
|
||||
await guestPage.getByPlaceholder('Enter password').fill(password)
|
||||
await guestPage.getByRole('button', { name: 'Access Share' }).click()
|
||||
await expect(fileCard(guestPage, folder.name)).toBeVisible()
|
||||
await expect.poll(async () => (await readShare()).views).toBe(1)
|
||||
await fileCard(guestPage, folder.name).click()
|
||||
await expect(fileCard(guestPage, fileName)).toBeVisible()
|
||||
await expect.poll(async () => (await readShare()).views).toBe(2)
|
||||
await fileCard(guestPage, fileName).click()
|
||||
await expect.poll(async () => (await readShare()).views).toBe(3)
|
||||
const beforeReload = (await readShare()).lastViewedAt
|
||||
await guestPage.reload()
|
||||
await expect.poll(async () => (await readShare()).views).toBe(4)
|
||||
expect((await readShare()).lastViewedAt!.getTime()).toBeGreaterThan(beforeReload!.getTime())
|
||||
|
||||
const downloadResponse = guestPage.waitForResponse((response) =>
|
||||
response.url().endsWith('/download-url'),
|
||||
)
|
||||
await guestPage.getByTestId('default-viewer-download-button').click()
|
||||
const download = await downloadResponse
|
||||
expect(download.status()).toBe(200)
|
||||
|
||||
const comment = await context.request.post(`/api/shares/${share.id}/files/${fileId}/comments`, {
|
||||
headers: { 'x-share-password': password },
|
||||
data: { message: 'Ready for review', attachmentIds: [] },
|
||||
})
|
||||
expect(comment.status()).toBe(201)
|
||||
} finally {
|
||||
await guest.close()
|
||||
}
|
||||
|
||||
await page.reload()
|
||||
const row = page.getByRole('row').filter({ hasText: share.name })
|
||||
await expect(row.getByRole('cell', { name: '4', exact: true })).toBeVisible()
|
||||
await expect(row.locator('time')).toContainText('Today')
|
||||
await row.getByRole('button', { name: 'View Activity' }).click()
|
||||
const sidebar = page.getByRole('dialog', { name: 'Activity' })
|
||||
await expect(sidebar.getByText('Opened Share Link')).toHaveCount(1)
|
||||
await expect(sidebar.getByText('Viewed Asset')).toHaveCount(2)
|
||||
await expect(sidebar.getByText(folder.name)).toBeVisible()
|
||||
await expect(sidebar.getByText('Downloaded')).toBeVisible()
|
||||
await expect(sidebar.getByText('Commented')).toBeVisible()
|
||||
await expect(sidebar.getByText('Someone').first()).toBeVisible()
|
||||
|
||||
await page.goto(`/projects/${projectId}/shares/${share.id}`)
|
||||
await expect(page.getByRole('tab', { name: 'Settings' })).toHaveAttribute('aria-selected', 'true')
|
||||
await page.getByRole('tab', { name: 'Activity' }).click()
|
||||
const tab = page.getByRole('tabpanel', { name: 'Activity' })
|
||||
await expect(tab.getByText('Opened Share Link')).toHaveCount(1)
|
||||
await expect(tab.getByText('Viewed Asset')).toHaveCount(2)
|
||||
await expect(tab.getByText('Commented')).toBeVisible()
|
||||
})
|
||||
|
||||
test('a direct historical version link records the version as the viewed asset', async ({
|
||||
file,
|
||||
browser,
|
||||
prisma,
|
||||
}) => {
|
||||
const { context, projectId, rootFolderId, fileId } = file
|
||||
const stack = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'Review Versions',
|
||||
projectId,
|
||||
parentId: rootFolderId,
|
||||
type: 'version_stack',
|
||||
status: 'processed',
|
||||
},
|
||||
})
|
||||
await prisma.asset.update({
|
||||
where: { id: fileId },
|
||||
data: { parentId: stack.id, sortIndex: 'a' },
|
||||
})
|
||||
const oldVersion = await prisma.asset.create({
|
||||
data: {
|
||||
name: 'Earlier Cut',
|
||||
projectId,
|
||||
parentId: stack.id,
|
||||
sortIndex: 'b',
|
||||
type: 'file',
|
||||
status: 'processed',
|
||||
},
|
||||
})
|
||||
const share = await apiCreateShare(context.request, projectId, 'Version Review')
|
||||
await apiAddAssetsToShare(context.request, share.id, [stack.id])
|
||||
const guest = await browser.newContext()
|
||||
try {
|
||||
const page = await guest.newPage()
|
||||
await page.goto(`/share/${share.id}/files/${stack.id}?version=${oldVersion.id}`)
|
||||
await expect
|
||||
.poll(() => prisma.shareActivity.count({ where: { shareLinkId: share.id } }))
|
||||
.toBe(2)
|
||||
const activities = await prisma.shareActivity.findMany({ where: { shareLinkId: share.id } })
|
||||
expect(activities).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ kind: 'share_viewed', assetId: null }),
|
||||
expect.objectContaining({ kind: 'asset_viewed', assetId: oldVersion.id }),
|
||||
]),
|
||||
)
|
||||
const link = await prisma.shareLink.findUniqueOrThrow({ where: { id: share.id } })
|
||||
expect(link.views).toBe(1)
|
||||
} finally {
|
||||
await guest.close()
|
||||
}
|
||||
})
|
||||
|
||||
test('concurrent authorized page opens add every view and one matching activity', async ({
|
||||
project,
|
||||
browser,
|
||||
prisma,
|
||||
}) => {
|
||||
const share = await apiCreateShare(
|
||||
project.context.request,
|
||||
project.projectId,
|
||||
'Concurrent Review',
|
||||
)
|
||||
const guest = await browser.newContext()
|
||||
try {
|
||||
const responses = await Promise.all(
|
||||
Array.from({ length: 8 }, () =>
|
||||
guest.request.post(`/api/shares/${share.id}/views`, { data: {} }),
|
||||
),
|
||||
)
|
||||
expect(responses.map((response) => response.status())).toEqual(Array(8).fill(204))
|
||||
const link = await prisma.shareLink.findUniqueOrThrow({ where: { id: share.id } })
|
||||
expect(link).toMatchObject({ views: 8, lastViewedAt: expect.any(Date) })
|
||||
const activities = await prisma.shareActivity.findMany({ where: { shareLinkId: share.id } })
|
||||
expect(activities).toMatchObject([{ kind: 'share_viewed', userId: null, assetId: null }])
|
||||
} finally {
|
||||
await guest.close()
|
||||
}
|
||||
})
|
||||
@@ -11,7 +11,7 @@ Shumai allows you to collaborate with external stakeholders who do not have acco
|
||||
|
||||
1. Select the files or folders you want to share, then right-click and choose **Create New Share Link**.
|
||||
2. Click the newly created **Share Link** in the project sidebar to open its settings page.
|
||||
3. Configure the share link in the right sidebar. You can:
|
||||
3. Use the **Settings** tab in the right sidebar to configure the share link.
|
||||
- Add password protection
|
||||
- Set an expiration date
|
||||
- Allow or disallow downloads
|
||||
@@ -33,6 +33,16 @@ Once a share link is created, you can easily add more files or folders to it wit
|
||||
|
||||
---
|
||||
|
||||
## Viewing Share Activity
|
||||
|
||||
Open **All Share Links** in the project sidebar to see **Views** and **Last Viewed** for each link. Click **View Activity** on a link’s row to open its history, or select the **Activity** tab on that link’s settings page.
|
||||
|
||||
The history groups share opens, file and folder views, downloads, and comments by day. It shows the visitor’s name when available and **Someone** for anonymous activity. A download entry appears when a visitor starts an authorized download.
|
||||
|
||||
Every successful open of the share, a shared folder, or a shared file adds one view and updates **Last Viewed**, including reloads. The history shows matching actions once within 30 minutes. A match uses the share link, action, visitor, and asset when there is one. For this check, all anonymous visitors are treated as the same visitor. For example, if a visitor opens the same file twice in ten minutes, **Views** increases by two and the history shows one **Viewed Asset** entry.
|
||||
|
||||
---
|
||||
|
||||
## Security and Settings
|
||||
|
||||
### Expiration Date
|
||||
|
||||
@@ -11,7 +11,7 @@ Shumai 支持与未注册工作区账号的外部利益相关者协作。借助*
|
||||
|
||||
1. 选中要分享的文件或文件夹,右键单击并选择**创建新分享链接**。
|
||||
2. 在项目侧边栏中点击刚创建的**分享链接**,进入其配置页面。
|
||||
3. 在右侧边栏中配置分享链接参数:
|
||||
3. 在右侧边栏的**设置**选项卡中配置分享链接。
|
||||
- 添加密码保护
|
||||
- 设置过期时间
|
||||
- 开启或禁止文件下载
|
||||
@@ -33,6 +33,16 @@ Shumai 支持与未注册工作区账号的外部利益相关者协作。借助*
|
||||
|
||||
---
|
||||
|
||||
## 查看分享活动
|
||||
|
||||
在项目侧边栏打开**所有分享链接**,即可看到每条链接的**浏览次数**和**最近浏览**时间。点击对应行的**查看活动**,或在该链接的配置页面切换到**活动**选项卡,即可查看活动记录。
|
||||
|
||||
活动按天分组,包括打开分享链接、浏览文件和文件夹、下载以及发表评论。可以识别访客时显示其姓名,匿名活动显示为**有人**。访客开始下载且通过权限验证后,系统会记录下载活动。
|
||||
|
||||
每次成功打开分享页面、共享文件夹或共享文件(包括刷新页面)都会增加一次**浏览次数**,并更新**最近浏览**时间。系统根据分享链接、操作、访客和相关资产(如有)判断活动是否重复,30 分钟内的重复活动只显示一次。判断时,所有匿名访客视为同一位访客。例如,同一位访客在十分钟内两次打开同一文件,**浏览次数**会增加两次,活动列表显示一条**浏览了素材**的记录。
|
||||
|
||||
---
|
||||
|
||||
## 安全与权限配置
|
||||
|
||||
### 有效期
|
||||
|
||||
@@ -3,9 +3,14 @@ import type { Context } from 'hono'
|
||||
import { getCookie } from 'hono/cookie'
|
||||
import { zValidator } from '@hono/zod-validator'
|
||||
import { shareService } from '@shumai/core/src/share/share'
|
||||
import { shareActivityService } from '@shumai/core/src/share/share-activity'
|
||||
import { assetService } from '@shumai/core/src/asset/asset'
|
||||
import { watermarkService } from '@shumai/core/src/watermark/watermark'
|
||||
import { paginationParamsSchema, assetTypeFilterSchema } from '@shumai/dtos'
|
||||
import {
|
||||
paginationParamsSchema,
|
||||
assetTypeFilterSchema,
|
||||
recordShareViewRequestSchema,
|
||||
} from '@shumai/dtos'
|
||||
import { z } from 'zod'
|
||||
import { metadataService } from '@shumai/core/src/metadata/metadata'
|
||||
import { FieldInfo } from '@shumai/dtos'
|
||||
@@ -156,7 +161,36 @@ const sharedChildrenRequestSchema = paginationParamsSchema.extend({
|
||||
assetType: assetTypeFilterSchema.optional().default('file'),
|
||||
})
|
||||
|
||||
async function getPublicShareUserId(c: Context, shareId: string) {
|
||||
const session = await auth.api.getSession({ headers: c.req.raw.headers })
|
||||
if (session?.user) return session.user.id
|
||||
|
||||
const token = getCookie(c, `shumai_guest_${shareId}`) || getCookie(c, 'shumai_guest')
|
||||
const verified = token && verifyGuestToken(token, shareId)
|
||||
if (!verified) return undefined
|
||||
|
||||
const guestUser = await userService.getUserById(verified.userId)
|
||||
return guestUser?.guestEmail ? guestUser.id : undefined
|
||||
}
|
||||
|
||||
const route = app
|
||||
.post('/shares/:shareId/views', zValidator('json', recordShareViewRequestSchema), async (c) => {
|
||||
const shareId = c.req.param('shareId')
|
||||
const password = c.req.header('x-share-password')
|
||||
const { assetId, isShareEntry } = c.req.valid('json')
|
||||
try {
|
||||
const share = await shareService.verifyPublicAccess(shareId, assetId, password)
|
||||
const targetId =
|
||||
assetId && assetId !== share.rootFolderId
|
||||
? await assetService.resolveLatestVersionId(assetId)
|
||||
: undefined
|
||||
const userId = await getPublicShareUserId(c, shareId)
|
||||
await shareActivityService.recordView(shareId, { assetId: targetId, isShareEntry, userId })
|
||||
return c.body(null, 204)
|
||||
} catch (err) {
|
||||
return handlePublicShareError(c, err)
|
||||
}
|
||||
})
|
||||
.get('/shares/:shareId/info', async (c) => {
|
||||
const shareId = c.req.param('shareId')
|
||||
const password = c.req.header('x-share-password')
|
||||
@@ -305,12 +339,18 @@ const route = app
|
||||
})
|
||||
.post(
|
||||
'/shares/:shareId/files/:fileId/download-url',
|
||||
zValidator('json', z.object({ key: z.string().min(1) })),
|
||||
zValidator(
|
||||
'json',
|
||||
z.object({
|
||||
key: z.string().min(1),
|
||||
purpose: z.enum(['download', 'prepare', 'clipboard']).default('download'),
|
||||
}),
|
||||
),
|
||||
async (c) => {
|
||||
const shareId = c.req.param('shareId')
|
||||
const fileId = c.req.param('fileId')
|
||||
const password = c.req.header('x-share-password')
|
||||
const { key } = c.req.valid('json')
|
||||
const { key, purpose } = c.req.valid('json')
|
||||
|
||||
try {
|
||||
const shareLink = await shareService.verifyPublicAccess(shareId, fileId, password)
|
||||
@@ -323,7 +363,16 @@ const route = app
|
||||
return c.json({ error: 'Invalid key' }, 400)
|
||||
}
|
||||
|
||||
const url = await assetService.getDownloadUrl(fileId, key)
|
||||
const { url, assetId } = await assetService.getDownloadUrlWithAsset(fileId, key)
|
||||
if (assetId !== fileId) await shareService.verifyPublicAccess(shareId, assetId, password)
|
||||
if (purpose === 'download') {
|
||||
const userId = await getPublicShareUserId(c, shareId)
|
||||
await shareActivityService.recordEvent(shareId, {
|
||||
kind: 'asset_downloaded',
|
||||
assetId,
|
||||
userId,
|
||||
})
|
||||
}
|
||||
return c.json({ url })
|
||||
} catch (err) {
|
||||
return handlePublicShareError(c, err)
|
||||
@@ -343,25 +392,7 @@ const route = app
|
||||
await shareService.verifyPublicAccess(shareId, fileId, password)
|
||||
|
||||
const targetFileId = await assetService.resolveTargetAssetId(fileId)
|
||||
let userId: string | undefined
|
||||
const session = await auth.api.getSession({
|
||||
headers: c.req.raw.headers,
|
||||
})
|
||||
if (session?.user) {
|
||||
userId = session.user.id
|
||||
} else {
|
||||
const cookieName = `shumai_guest_${shareId}`
|
||||
const token = getCookie(c, cookieName) || getCookie(c, 'shumai_guest')
|
||||
if (token) {
|
||||
const verified = verifyGuestToken(token, shareId)
|
||||
if (verified) {
|
||||
const guestUser = await userService.getUserById(verified.userId)
|
||||
if (guestUser && guestUser.guestEmail) {
|
||||
userId = guestUser.id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const userId = await getPublicShareUserId(c, shareId)
|
||||
const res = await assetService.listComments(targetFileId, req, userId)
|
||||
return c.json(res)
|
||||
} catch (err) {
|
||||
@@ -383,48 +414,30 @@ const route = app
|
||||
}
|
||||
|
||||
try {
|
||||
const shareLink = await shareService.getShareLink(shareId)
|
||||
await shareService.verifyPublicAccess(shareId, fileId, password)
|
||||
const shareLink = await shareService.verifyPublicAccess(shareId, fileId, password)
|
||||
|
||||
const targetFileId = await assetService.resolveTargetAssetId(fileId)
|
||||
|
||||
const teamId = await projectService.getProjectTeam(shareLink.projectId)
|
||||
|
||||
// Identify user
|
||||
let userId: string | null = null
|
||||
const session = await auth.api.getSession({
|
||||
headers: c.req.raw.headers,
|
||||
})
|
||||
|
||||
if (session?.user) {
|
||||
userId = session.user.id
|
||||
} else {
|
||||
const cookieName = `shumai_guest_${shareId}`
|
||||
const token = getCookie(c, cookieName) || getCookie(c, 'shumai_guest')
|
||||
if (token) {
|
||||
const verified = verifyGuestToken(token, shareId)
|
||||
if (verified) {
|
||||
const guestUser = await userService.getUserById(verified.userId)
|
||||
if (guestUser && guestUser.guestEmail) {
|
||||
userId = guestUser.id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const userId = await getPublicShareUserId(c, shareId)
|
||||
|
||||
if (!userId) {
|
||||
return c.json({ error: 'Unauthorized' }, 401)
|
||||
}
|
||||
|
||||
const comment = await assetService.createComment({
|
||||
assetId: targetFileId,
|
||||
userId: userId,
|
||||
replyToId: req.replyToId,
|
||||
message: req.message,
|
||||
annotations: req.annotations,
|
||||
second: req.second,
|
||||
attachmentIds: req.attachmentIds,
|
||||
})
|
||||
const comment = await assetService.createComment(
|
||||
{
|
||||
assetId: targetFileId,
|
||||
userId,
|
||||
replyToId: req.replyToId,
|
||||
message: req.message,
|
||||
annotations: req.annotations,
|
||||
second: req.second,
|
||||
attachmentIds: req.attachmentIds,
|
||||
},
|
||||
{ shareLinkId: shareId },
|
||||
)
|
||||
|
||||
const notifType = req.replyToId ? 'reply_created' : 'comment_created'
|
||||
|
||||
|
||||
@@ -4,9 +4,15 @@ import shareRoute from './share'
|
||||
import publicShareRoute from './public-share'
|
||||
import { authMiddleware } from './middleware/auth'
|
||||
import { shareService } from '@shumai/core/src/share/share'
|
||||
import { shareActivityService } from '@shumai/core/src/share/share-activity'
|
||||
import { HTTPException } from 'hono/http-exception'
|
||||
import { assetService } from '@shumai/core/src/asset/asset'
|
||||
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
||||
import { ShareLinkPasswordInvalidError, ShareLinkExpiredError } from '@shumai/core/src/share/errors'
|
||||
import {
|
||||
ShareLinkPasswordInvalidError,
|
||||
ShareLinkExpiredError,
|
||||
ShareLinkNotFoundError,
|
||||
} from '@shumai/core/src/share/errors'
|
||||
import { createGuestToken } from '@shumai/core/src/auth/guest-token'
|
||||
import { userService } from '@shumai/core/src/user/user'
|
||||
import { notificationService } from '@shumai/core/src/notification/notification'
|
||||
@@ -93,6 +99,82 @@ describe('Share API', () => {
|
||||
})
|
||||
|
||||
// Public Routes
|
||||
describe('POST /shares/:shareId/views', () => {
|
||||
test('attributes an authorized asset view to a verified guest', async () => {
|
||||
vi.spyOn(shareService, 'verifyPublicAccess').mockResolvedValue({
|
||||
rootFolderId: 'folder1',
|
||||
} as Awaited<ReturnType<typeof shareService.verifyPublicAccess>>)
|
||||
vi.spyOn(assetService, 'resolveLatestVersionId').mockResolvedValue('asset1')
|
||||
vi.spyOn(userService, 'getUserById').mockResolvedValue({
|
||||
id: 'guest1',
|
||||
guestEmail: 'alice@example.com',
|
||||
} as Awaited<ReturnType<typeof userService.getUserById>>)
|
||||
const record = vi.spyOn(shareActivityService, 'recordView').mockResolvedValue(undefined)
|
||||
const token = createGuestToken({ userId: 'guest1', shareId: 'share1' })
|
||||
|
||||
const res = await app.request('/shares/share1/views', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'x-share-password': 'pass',
|
||||
Cookie: `shumai_guest_share1=${token}`,
|
||||
},
|
||||
body: JSON.stringify({ assetId: 'alias1', isShareEntry: true }),
|
||||
})
|
||||
|
||||
expect(res.status).toBe(204)
|
||||
expect(shareService.verifyPublicAccess).toHaveBeenCalledWith('share1', 'alias1', 'pass')
|
||||
expect(record).toHaveBeenCalledWith('share1', {
|
||||
assetId: 'asset1',
|
||||
isShareEntry: true,
|
||||
userId: 'guest1',
|
||||
})
|
||||
})
|
||||
|
||||
test('a rejected view leaves the counter and history alone', async () => {
|
||||
vi.spyOn(shareService, 'verifyPublicAccess').mockRejectedValue(
|
||||
new ShareLinkPasswordInvalidError('Incorrect password'),
|
||||
)
|
||||
const record = vi.spyOn(shareActivityService, 'recordView').mockResolvedValue(undefined)
|
||||
const res = await app.request('/shares/share1/views', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: '{}',
|
||||
})
|
||||
|
||||
expect(res.status).toBe(401)
|
||||
expect(record).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe('GET /shares/:shareId/activities', () => {
|
||||
test('returns the requested page to a share reader', async () => {
|
||||
const list = vi.spyOn(shareActivityService, 'list').mockResolvedValue({
|
||||
data: [],
|
||||
pageInfo: { total: 0 },
|
||||
})
|
||||
const res = await app.request('/shares/share1/activities?first=20')
|
||||
expect(res.status).toBe(200)
|
||||
expect(await res.json()).toEqual({ data: [], pageInfo: { total: 0 } })
|
||||
expect(authzService.hasPermission).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
id: 'share1',
|
||||
permission: Permission.Read,
|
||||
type: ResourceType.Share,
|
||||
}),
|
||||
)
|
||||
expect(list).toHaveBeenCalledWith('share1', { first: 20 })
|
||||
})
|
||||
|
||||
test('denies access to activity without share read permission', async () => {
|
||||
vi.mocked(authzService.hasPermission).mockRejectedValueOnce(new HTTPException(403))
|
||||
const list = vi.spyOn(shareActivityService, 'list')
|
||||
const res = await app.request('/shares/share1/activities')
|
||||
expect(res.status).toBe(403)
|
||||
expect(list).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe('GET /shares/:shareId/info', () => {
|
||||
test('Success', async () => {
|
||||
vi.spyOn(shareService, 'getShareLink').mockResolvedValue({
|
||||
@@ -101,6 +183,8 @@ describe('Share API', () => {
|
||||
isDisabled: false,
|
||||
allowDownload: false,
|
||||
isExpired: false,
|
||||
views: 0,
|
||||
lastViewedAt: null,
|
||||
hasPassword: true,
|
||||
rootFolderId: 'folder1',
|
||||
projectId: 'project1',
|
||||
@@ -134,6 +218,8 @@ describe('Share API', () => {
|
||||
isDisabled: false,
|
||||
allowDownload: false,
|
||||
isExpired: false,
|
||||
views: 0,
|
||||
lastViewedAt: null,
|
||||
hasPassword: true,
|
||||
rootFolderId: 'folder1',
|
||||
projectId: 'project1',
|
||||
@@ -161,6 +247,8 @@ describe('Share API', () => {
|
||||
isDisabled: false,
|
||||
allowDownload: false,
|
||||
isExpired: false,
|
||||
views: 0,
|
||||
lastViewedAt: null,
|
||||
hasPassword: true,
|
||||
rootFolderId: 'folder1',
|
||||
projectId: 'project1',
|
||||
@@ -712,6 +800,8 @@ describe('Share API', () => {
|
||||
rootFolderId: 'root1',
|
||||
projectId: 'project1',
|
||||
isExpired: false,
|
||||
views: 0,
|
||||
lastViewedAt: null,
|
||||
hasPassword: false,
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
@@ -756,6 +846,8 @@ describe('Share API', () => {
|
||||
rootFolderId: 'root1',
|
||||
projectId: 'project1',
|
||||
isExpired: false,
|
||||
views: 0,
|
||||
lastViewedAt: null,
|
||||
hasPassword: false,
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
@@ -813,6 +905,8 @@ describe('Share API', () => {
|
||||
rootFolderId: 'root1',
|
||||
projectId: 'project1',
|
||||
isExpired: false,
|
||||
views: 0,
|
||||
lastViewedAt: null,
|
||||
hasPassword: false,
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
@@ -844,6 +938,8 @@ describe('Share API', () => {
|
||||
rootFolderId: 'root1',
|
||||
projectId: 'project1',
|
||||
isExpired: false,
|
||||
views: 0,
|
||||
lastViewedAt: null,
|
||||
hasPassword: false,
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
@@ -888,6 +984,8 @@ describe('Share API', () => {
|
||||
rootFolderId: 'root1',
|
||||
projectId: 'project1',
|
||||
isExpired: false,
|
||||
views: 0,
|
||||
lastViewedAt: null,
|
||||
hasPassword: false,
|
||||
watermarkStatus: 'processing',
|
||||
watermarkConfigId: 'cfg1',
|
||||
@@ -976,12 +1074,60 @@ describe('Share API', () => {
|
||||
})
|
||||
|
||||
describe('POST /shares/:shareId/files/:fileId/download-url', () => {
|
||||
test('requires share access to the concrete asset selected for download', async () => {
|
||||
vi.spyOn(shareService, 'verifyPublicAccess')
|
||||
.mockResolvedValueOnce({
|
||||
allowDownload: true,
|
||||
} as Awaited<ReturnType<typeof shareService.verifyPublicAccess>>)
|
||||
.mockRejectedValueOnce(new ShareLinkNotFoundError('Asset is not shared'))
|
||||
vi.spyOn(assetService, 'getDownloadUrlWithAsset').mockResolvedValue({
|
||||
url: 'https://s3.example.com/download',
|
||||
assetId: 'unshared',
|
||||
})
|
||||
const record = vi.spyOn(shareActivityService, 'recordEvent').mockResolvedValue(undefined)
|
||||
const res = await app.request('/shares/share1/files/file1/download-url', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ key: 'files/download.png' }),
|
||||
})
|
||||
|
||||
expect(res.status).toBe(404)
|
||||
expect(await res.json()).toEqual({ error: 'Asset is not shared' })
|
||||
expect(record).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test.each(['prepare', 'clipboard'])(
|
||||
'does not count a URL requested for %s',
|
||||
async (purpose) => {
|
||||
vi.spyOn(shareService, 'verifyPublicAccess').mockResolvedValue({
|
||||
allowDownload: true,
|
||||
} as Awaited<ReturnType<typeof shareService.verifyPublicAccess>>)
|
||||
vi.spyOn(assetService, 'getDownloadUrlWithAsset').mockResolvedValue({
|
||||
url: 'https://s3.example.com/download',
|
||||
assetId: 'target1',
|
||||
})
|
||||
const record = vi.spyOn(shareActivityService, 'recordEvent').mockResolvedValue(undefined)
|
||||
const res = await app.request('/shares/share1/files/symlink1/download-url', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ key: 'files/target1/fly.png', purpose }),
|
||||
})
|
||||
|
||||
expect(res.status).toBe(200)
|
||||
expect(record).not.toHaveBeenCalled()
|
||||
},
|
||||
)
|
||||
|
||||
test('Success for symlink asset in share', async () => {
|
||||
vi.spyOn(shareService, 'verifyPublicAccess').mockResolvedValue({
|
||||
allowDownload: true,
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any)
|
||||
vi.spyOn(assetService, 'getDownloadUrl').mockResolvedValue('https://s3.example.com/download')
|
||||
vi.spyOn(assetService, 'getDownloadUrlWithAsset').mockResolvedValue({
|
||||
url: 'https://s3.example.com/download',
|
||||
assetId: 'target1',
|
||||
})
|
||||
const record = vi.spyOn(shareActivityService, 'recordEvent').mockResolvedValue(undefined)
|
||||
|
||||
const res = await app.request('/shares/share1/files/symlink1/download-url', {
|
||||
method: 'POST',
|
||||
@@ -993,7 +1139,15 @@ describe('Share API', () => {
|
||||
const body = await res.json()
|
||||
expect(body.url).toBe('https://s3.example.com/download')
|
||||
expect(shareService.verifyPublicAccess).toHaveBeenCalledWith('share1', 'symlink1', undefined)
|
||||
expect(assetService.getDownloadUrl).toHaveBeenCalledWith('symlink1', 'files/target1/fly.png')
|
||||
expect(assetService.getDownloadUrlWithAsset).toHaveBeenCalledWith(
|
||||
'symlink1',
|
||||
'files/target1/fly.png',
|
||||
)
|
||||
expect(record).toHaveBeenCalledWith('share1', {
|
||||
kind: 'asset_downloaded',
|
||||
assetId: 'target1',
|
||||
userId: undefined,
|
||||
})
|
||||
})
|
||||
|
||||
test('Rejects when allowDownload is disabled', async () => {
|
||||
@@ -1004,8 +1158,8 @@ describe('Share API', () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} as any)
|
||||
const getDownloadUrlSpy = vi
|
||||
.spyOn(assetService, 'getDownloadUrl')
|
||||
.mockResolvedValue('https://s3.example.com/download')
|
||||
.spyOn(assetService, 'getDownloadUrlWithAsset')
|
||||
.mockResolvedValue({ url: 'https://s3.example.com/download', assetId: 'target1' })
|
||||
|
||||
const res = await app.request('/shares/share1/files/symlink1/download-url', {
|
||||
method: 'POST',
|
||||
@@ -1173,6 +1327,7 @@ describe('Share API', () => {
|
||||
userId: 'guest1',
|
||||
message: 'hello from alice',
|
||||
}),
|
||||
{ shareLinkId: 'share1' },
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -2,11 +2,13 @@ import { Hono } from 'hono'
|
||||
import { zValidator } from '@hono/zod-validator'
|
||||
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
|
||||
import { shareService } from '@shumai/core/src/share/share'
|
||||
import { shareActivityService } from '@shumai/core/src/share/share-activity'
|
||||
import { projectService } from '@shumai/core/src/project/project'
|
||||
import {
|
||||
createShareLinkRequestSchema,
|
||||
updateShareLinkRequestSchema,
|
||||
listShareLinksRequestSchema,
|
||||
paginationParamsSchema,
|
||||
addAssetToShareRequestSchema,
|
||||
updateShareLinkWatermarkRequestSchema,
|
||||
AuditAction,
|
||||
@@ -90,6 +92,16 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
const shareLink = await shareService.getShareLink(shareId)
|
||||
return c.json(shareLink)
|
||||
})
|
||||
.get('/shares/:shareId/activities', zValidator('query', paginationParamsSchema), async (c) => {
|
||||
const shareId = c.req.param('shareId')
|
||||
await authzService.hasPermission({
|
||||
user: c.get('user'),
|
||||
permission: Permission.Read,
|
||||
type: ResourceType.Share,
|
||||
id: shareId,
|
||||
})
|
||||
return c.json(await shareActivityService.list(shareId, c.req.valid('query')))
|
||||
})
|
||||
.put('/shares/:shareId', zValidator('json', updateShareLinkRequestSchema), async (c) => {
|
||||
const shareId = c.req.param('shareId')
|
||||
const user = c.get('user')
|
||||
|
||||
@@ -61,6 +61,7 @@ import { dedupeSymlinksToTarget } from './symlink'
|
||||
import { watermarkService } from '@shumai/core/src/watermark/watermark'
|
||||
import { generateKeyBetween } from 'jittered-fractional-indexing'
|
||||
import { getAvatarUrl } from '@shumai/core/src/user/avatar'
|
||||
import { shareActivityService } from '@shumai/core/src/share/share-activity'
|
||||
import { getAgentRequiredLevel, getRoleLevel } from '@shumai/core/src/agent/permissions'
|
||||
import { resolveEffectiveRole } from '@shumai/core/src/authz/authz'
|
||||
import { metadataService } from '@shumai/core/src/metadata/metadata'
|
||||
@@ -1964,7 +1965,7 @@ export class AssetService {
|
||||
*/
|
||||
async createComment(
|
||||
req: CreateCommentRequest,
|
||||
options: { triggerAgents?: boolean } = {},
|
||||
options: { triggerAgents?: boolean; shareLinkId?: string } = {},
|
||||
): Promise<CommentInfo> {
|
||||
const triggerAgents = options.triggerAgents ?? true
|
||||
let commentId = ''
|
||||
@@ -2020,6 +2021,14 @@ export class AssetService {
|
||||
}
|
||||
}
|
||||
|
||||
if (options.shareLinkId) {
|
||||
await shareActivityService.recordEvent(
|
||||
options.shareLinkId,
|
||||
{ kind: 'comment_created', assetId: a.id, userId: req.userId },
|
||||
tx,
|
||||
)
|
||||
}
|
||||
|
||||
if (!triggerAgents) return
|
||||
|
||||
// Parse bot mentions
|
||||
@@ -3080,6 +3089,10 @@ export class AssetService {
|
||||
* that belong to an asset they have access to.
|
||||
*/
|
||||
async getDownloadUrl(assetId: string, key: string): Promise<string> {
|
||||
return (await this.getDownloadUrlWithAsset(assetId, key)).url
|
||||
}
|
||||
|
||||
async getDownloadUrlWithAsset(assetId: string, key: string) {
|
||||
const targetAssetId = await this.resolveLatestVersionId(assetId)
|
||||
const asset = await this.prismaClient.asset.findUnique({
|
||||
where: { id: targetAssetId },
|
||||
@@ -3100,6 +3113,7 @@ export class AssetService {
|
||||
throw new Error('Key does not belong to this asset')
|
||||
}
|
||||
|
||||
let signedAssetId = asset.id
|
||||
let storageKey = asset.storageKey.key
|
||||
let assetDir = storageKey.substring(0, storageKey.lastIndexOf('/') + 1)
|
||||
let targetName = asset.name
|
||||
@@ -3115,12 +3129,14 @@ export class AssetService {
|
||||
storageKey: { key: { startsWith: key.substring(0, key.lastIndexOf('/') + 1) } },
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
status: true,
|
||||
storageKey: { select: { key: true, isArchived: true } },
|
||||
},
|
||||
})
|
||||
if (sibling?.storageKey?.key) {
|
||||
signedAssetId = sibling.id
|
||||
storageKey = sibling.storageKey.key
|
||||
assetDir = storageKey.substring(0, storageKey.lastIndexOf('/') + 1)
|
||||
targetStatus = sibling.status
|
||||
@@ -3176,7 +3192,14 @@ export class AssetService {
|
||||
}
|
||||
}
|
||||
|
||||
return s3Service.presign(process.env.S3_BUCKET || 'shumai', key, 'GET', true, downloadFilename)
|
||||
const url = await s3Service.presign(
|
||||
process.env.S3_BUCKET || 'shumai',
|
||||
key,
|
||||
'GET',
|
||||
true,
|
||||
downloadFilename,
|
||||
)
|
||||
return { url, assetId: signedAssetId }
|
||||
}
|
||||
|
||||
async archiveAssets(
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
import { prisma } from '@shumai/db'
|
||||
import { setupTestDbHooks } from '@shumai/db/test'
|
||||
import { assetService } from '@shumai/core/src/asset/asset'
|
||||
import { shareActivityService } from './share-activity'
|
||||
import { shareService } from './share'
|
||||
|
||||
describe('Share activity', () => {
|
||||
setupTestDbHooks()
|
||||
|
||||
let shareId: string
|
||||
let projectId: string
|
||||
let assetId: string
|
||||
let userId: string
|
||||
|
||||
beforeEach(async () => {
|
||||
const user = await prisma.user.create({
|
||||
data: {
|
||||
name: 'Reviewer',
|
||||
email: 'reviewer@example.com',
|
||||
image: 'https://example.com/avatar',
|
||||
},
|
||||
})
|
||||
const team = await prisma.team.create({ data: { name: 'Team' } })
|
||||
const project = await prisma.project.create({ data: { name: 'Project', teamId: team.id } })
|
||||
const asset = await prisma.asset.create({
|
||||
data: { name: 'Review Cut', projectId: project.id, type: 'file', status: 'processed' },
|
||||
})
|
||||
const share = await shareService.createShareLink(project.id, { name: 'Review' }, user.id)
|
||||
shareId = share.id
|
||||
projectId = project.id
|
||||
assetId = asset.id
|
||||
userId = user.id
|
||||
})
|
||||
|
||||
it('sets the last view and counts every visit, including a duplicate deep-link visit', async () => {
|
||||
expect(await shareService.getShareLink(shareId)).toMatchObject({ views: 0, lastViewedAt: null })
|
||||
await shareActivityService.recordView(shareId, { assetId, isShareEntry: true })
|
||||
const first = await prisma.shareLink.findUniqueOrThrow({ where: { id: shareId } })
|
||||
expect(first).toMatchObject({ views: 1, lastViewedAt: expect.any(Date) })
|
||||
|
||||
const prior = new Date('2020-01-01T00:00:00Z')
|
||||
await prisma.shareLink.update({ where: { id: shareId }, data: { lastViewedAt: prior } })
|
||||
await shareActivityService.recordView(shareId, { assetId, isShareEntry: true })
|
||||
|
||||
const share = await prisma.shareLink.findUniqueOrThrow({ where: { id: shareId } })
|
||||
expect(share.views).toBe(2)
|
||||
expect(share.lastViewedAt!.getTime()).toBeGreaterThan(prior.getTime())
|
||||
expect(await prisma.shareActivity.findMany({ where: { shareLinkId: shareId } })).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({ kind: 'share_viewed', userId: null, assetId: null }),
|
||||
expect.objectContaining({ kind: 'asset_viewed', userId: null, assetId }),
|
||||
]),
|
||||
)
|
||||
expect(await prisma.shareActivity.count({ where: { shareLinkId: shareId } })).toBe(2)
|
||||
})
|
||||
|
||||
it('uses a rolling window from the last recorded event and permits a match after 30 minutes', async () => {
|
||||
const event = { kind: 'asset_downloaded', userId, assetId } as const
|
||||
const record = await prisma.shareActivity.create({
|
||||
data: {
|
||||
...event,
|
||||
shareLinkId: shareId,
|
||||
createdAt: new Date(Date.now() - 29 * 60_000),
|
||||
},
|
||||
})
|
||||
await shareActivityService.recordEvent(shareId, event)
|
||||
expect(await prisma.shareActivity.count({ where: { shareLinkId: shareId } })).toBe(1)
|
||||
expect(await prisma.shareActivity.findUnique({ where: { id: record.id } })).toEqual(record)
|
||||
|
||||
await prisma.shareActivity.update({
|
||||
where: { id: record.id },
|
||||
data: { createdAt: new Date(Date.now() - 30 * 60_000) },
|
||||
})
|
||||
await shareActivityService.recordEvent(shareId, event)
|
||||
expect(await prisma.shareActivity.count({ where: { shareLinkId: shareId } })).toBe(2)
|
||||
})
|
||||
|
||||
it('scopes the deduplication identity to the share, event kind, user and asset', async () => {
|
||||
const otherShare = await shareService.createShareLink(projectId, { name: 'Other' })
|
||||
const otherAsset = await prisma.asset.create({
|
||||
data: { name: 'Other Cut', projectId, type: 'file', status: 'processed' },
|
||||
})
|
||||
await shareActivityService.recordView(shareId, { assetId })
|
||||
await shareActivityService.recordView(shareId, { assetId, userId })
|
||||
await shareActivityService.recordView(shareId, { assetId: otherAsset.id, userId })
|
||||
await shareActivityService.recordView(otherShare.id, { assetId, userId })
|
||||
await shareActivityService.recordEvent(shareId, { kind: 'asset_downloaded', assetId, userId })
|
||||
|
||||
expect(await prisma.shareActivity.count({ where: { shareLinkId: shareId } })).toBe(4)
|
||||
expect(await prisma.shareActivity.count({ where: { shareLinkId: otherShare.id } })).toBe(1)
|
||||
expect(await shareService.getShareLink(shareId)).toMatchObject({ views: 3 })
|
||||
})
|
||||
|
||||
it('records a share comment in its transaction while preserving every comment', async () => {
|
||||
const comment = { assetId, userId, message: 'Looks good', attachmentIds: [] }
|
||||
await assetService.createComment(comment, { shareLinkId: shareId })
|
||||
await assetService.createComment({ ...comment, message: 'Ready' }, { shareLinkId: shareId })
|
||||
await assetService.createComment({ ...comment, message: 'Workspace comment' })
|
||||
expect(await prisma.assetComment.count({ where: { assetId } })).toBe(3)
|
||||
const events = await prisma.shareActivity.findMany({ where: { shareLinkId: shareId } })
|
||||
expect(events).toMatchObject([{ kind: 'comment_created', assetId, userId }])
|
||||
|
||||
await expect(assetService.createComment(comment, { shareLinkId: 'missing' })).rejects.toThrow(
|
||||
'Share link not found',
|
||||
)
|
||||
expect(await prisma.assetComment.count({ where: { assetId } })).toBe(3)
|
||||
})
|
||||
|
||||
it('paginates the feed and resolves current names and missing assets', async () => {
|
||||
await shareActivityService.recordView(shareId, { assetId, userId, isShareEntry: true })
|
||||
await prisma.asset.update({ where: { id: assetId }, data: { name: 'Renamed Cut' } })
|
||||
const first = await shareActivityService.list(shareId, { first: 1 })
|
||||
expect(first.pageInfo).toMatchObject({ total: 2, cursor: expect.any(String) })
|
||||
const second = await shareActivityService.list(shareId, {
|
||||
first: 1,
|
||||
after: first.pageInfo.cursor,
|
||||
})
|
||||
expect(first.data).toHaveLength(1)
|
||||
expect(second.data).toHaveLength(1)
|
||||
expect(first.data[0].id > second.data[0].id).toBe(true)
|
||||
expect([...first.data, ...second.data]).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
kind: 'asset_viewed',
|
||||
user: { name: 'Reviewer', image: 'https://example.com/avatar' },
|
||||
asset: { id: assetId, name: 'Renamed Cut' },
|
||||
}),
|
||||
expect.objectContaining({ kind: 'share_viewed', asset: null }),
|
||||
]),
|
||||
)
|
||||
|
||||
await prisma.asset.update({ where: { id: assetId }, data: { isDeleted: true } })
|
||||
const getAssetEvent = async () =>
|
||||
(await shareActivityService.list(shareId, {})).data.find(
|
||||
(event) => event.kind === 'asset_viewed',
|
||||
)
|
||||
expect((await getAssetEvent())?.asset).toEqual({ id: assetId, name: null })
|
||||
await prisma.asset.delete({ where: { id: assetId } })
|
||||
expect((await getAssetEvent())?.asset).toEqual({ id: assetId, name: null })
|
||||
await shareService.deleteShareLink(shareId)
|
||||
expect(await prisma.shareActivity.count({ where: { shareLinkId: shareId } })).toBe(0)
|
||||
})
|
||||
|
||||
it('checks that a share root is accessible before accepting a root view', async () => {
|
||||
const share = await shareService.getShareLink(shareId)
|
||||
await expect(shareService.verifyPublicAccess(shareId, undefined)).resolves.toMatchObject({
|
||||
id: shareId,
|
||||
})
|
||||
await prisma.asset.update({
|
||||
where: { id: share.rootFolderId },
|
||||
data: { isDeleted: true },
|
||||
})
|
||||
await expect(shareService.verifyPublicAccess(shareId, undefined)).rejects.toThrow(
|
||||
'Asset is not shared',
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,129 @@
|
||||
import { prisma, type Prisma } from '@shumai/db'
|
||||
import type { ShareActivityInfo, ShareActivityKind } from '@shumai/dtos'
|
||||
import { paginateQuery, type PaginationParams } from '@shumai/core/src/pagination'
|
||||
import { getAvatarUrl } from '@shumai/core/src/user/avatar'
|
||||
import { ShareLinkNotFoundError } from './errors'
|
||||
|
||||
const deduplicationWindowMs = 30 * 60 * 1000
|
||||
|
||||
type Activity = {
|
||||
kind: ShareActivityKind
|
||||
userId?: string
|
||||
assetId?: string
|
||||
}
|
||||
|
||||
class ShareActivityService {
|
||||
async recordView(
|
||||
shareLinkId: string,
|
||||
view: { userId?: string; assetId?: string; isShareEntry?: boolean },
|
||||
): Promise<void> {
|
||||
const events: Activity[] = []
|
||||
if (!view.assetId || view.isShareEntry) {
|
||||
events.push({ kind: 'share_viewed', userId: view.userId })
|
||||
}
|
||||
if (view.assetId) {
|
||||
events.push({ kind: 'asset_viewed', userId: view.userId, assetId: view.assetId })
|
||||
}
|
||||
|
||||
await prisma.$transaction(async (tx) => {
|
||||
const now = await this.lockShare(tx, shareLinkId)
|
||||
// A visit updates the counters independently of whether its events are duplicates.
|
||||
await tx.$executeRaw`
|
||||
UPDATE share_links
|
||||
SET views = views + 1,
|
||||
last_viewed_at = GREATEST(last_viewed_at, ${now.toISOString()}::timestamptz AT TIME ZONE 'UTC')
|
||||
WHERE id = ${shareLinkId}
|
||||
`
|
||||
for (const event of events) {
|
||||
await this.insertIfNew(tx, shareLinkId, event, now)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async recordEvent(
|
||||
shareLinkId: string,
|
||||
event: Activity,
|
||||
tx?: Prisma.TransactionClient,
|
||||
): Promise<void> {
|
||||
if (!tx) {
|
||||
await prisma.$transaction((client) => this.recordEvent(shareLinkId, event, client))
|
||||
return
|
||||
}
|
||||
|
||||
const now = await this.lockShare(tx, shareLinkId)
|
||||
await this.insertIfNew(tx, shareLinkId, event, now)
|
||||
}
|
||||
|
||||
async list(shareLinkId: string, params: PaginationParams) {
|
||||
const where = { shareLinkId }
|
||||
const page = await paginateQuery(
|
||||
(skip, take) => prisma.shareActivity.findMany({ where, orderBy: { id: 'desc' }, skip, take }),
|
||||
() => prisma.shareActivity.count({ where }),
|
||||
params,
|
||||
)
|
||||
const userIds = page.data.flatMap(({ userId }) => (userId ? [userId] : []))
|
||||
const assetIds = page.data.flatMap(({ assetId }) => (assetId ? [assetId] : []))
|
||||
const [users, assets] = await Promise.all([
|
||||
prisma.user.findMany({
|
||||
where: { id: { in: userIds } },
|
||||
select: { id: true, name: true, image: true },
|
||||
}),
|
||||
prisma.asset.findMany({
|
||||
where: { id: { in: assetIds }, isDeleted: false },
|
||||
select: { id: true, name: true },
|
||||
}),
|
||||
])
|
||||
const usersById = new Map(
|
||||
await Promise.all(
|
||||
users.map(
|
||||
async ({ id, name, image }) => [id, { name, image: await getAvatarUrl(image) }] as const,
|
||||
),
|
||||
),
|
||||
)
|
||||
const namesById = new Map(assets.map(({ id, name }) => [id, name]))
|
||||
const data: ShareActivityInfo[] = page.data.map((event) => ({
|
||||
id: event.id,
|
||||
kind: event.kind,
|
||||
createdAt: event.createdAt.toISOString(),
|
||||
user: event.userId ? (usersById.get(event.userId) ?? null) : null,
|
||||
asset: event.assetId
|
||||
? { id: event.assetId, name: namesById.get(event.assetId) ?? null }
|
||||
: null,
|
||||
}))
|
||||
return { data, pageInfo: page.pageInfo }
|
||||
}
|
||||
|
||||
private async lockShare(tx: Prisma.TransactionClient, shareLinkId: string) {
|
||||
const rows = await tx.$queryRaw<{ id: string }[]>`
|
||||
SELECT id FROM share_links WHERE id = ${shareLinkId} FOR UPDATE
|
||||
`
|
||||
if (rows.length === 0) throw new ShareLinkNotFoundError('Share link not found')
|
||||
// Read time after acquiring the lock so a queued request uses its actual write time.
|
||||
const [clock] = await tx.$queryRaw<{ now: Date }[]>`SELECT clock_timestamp() AS now`
|
||||
return clock.now
|
||||
}
|
||||
|
||||
private async insertIfNew(
|
||||
tx: Prisma.TransactionClient,
|
||||
shareLinkId: string,
|
||||
event: Activity,
|
||||
now: Date,
|
||||
) {
|
||||
const identity = {
|
||||
shareLinkId,
|
||||
kind: event.kind,
|
||||
userId: event.userId ?? null,
|
||||
assetId: event.assetId ?? null,
|
||||
}
|
||||
const recent = await tx.shareActivity.findFirst({
|
||||
where: {
|
||||
...identity,
|
||||
createdAt: { gt: new Date(now.getTime() - deduplicationWindowMs) },
|
||||
},
|
||||
select: { id: true },
|
||||
})
|
||||
if (!recent) await tx.shareActivity.create({ data: { ...identity, createdAt: now } })
|
||||
}
|
||||
}
|
||||
|
||||
export const shareActivityService = new ShareActivityService()
|
||||
@@ -250,7 +250,7 @@ export class ShareService {
|
||||
|
||||
async verifyPublicAccess(
|
||||
shareLinkId: string,
|
||||
assetId: string,
|
||||
assetId: string | undefined,
|
||||
providedPassword?: string,
|
||||
): Promise<Prisma.ShareLinkGetPayload<true>> {
|
||||
const shareLink = await prisma.shareLink.findUnique({
|
||||
@@ -273,11 +273,13 @@ export class ShareService {
|
||||
throw new ShareLinkPasswordInvalidError('Invalid password for share link')
|
||||
}
|
||||
|
||||
const targetId = assetId ?? shareLink.rootFolderId
|
||||
|
||||
const rows = await prisma.$queryRaw<{ id: string }[]>`
|
||||
WITH RECURSIVE
|
||||
-- Trace ancestors in the real asset tree
|
||||
real_ancestors AS (
|
||||
SELECT id, parent_id, type::text, target_id FROM assets WHERE id = ${assetId} AND is_deleted = false
|
||||
SELECT id, parent_id, type::text, target_id FROM assets WHERE id = ${targetId} AND is_deleted = false
|
||||
UNION ALL
|
||||
SELECT a.id, a.parent_id, a.type::text, a.target_id FROM assets a
|
||||
INNER JOIN real_ancestors ra ON ra.parent_id = a.id
|
||||
@@ -339,6 +341,8 @@ export class ShareService {
|
||||
rootFolderId: l.rootFolderId,
|
||||
projectId: l.projectId,
|
||||
isExpired,
|
||||
views: l.views,
|
||||
lastViewedAt: l.lastViewedAt?.toISOString() ?? null,
|
||||
watermarkConfigId: l.watermarkConfigId,
|
||||
watermarkStatus: l.watermarkStatus || 'disabled',
|
||||
watermarkConfig: watermarkConfig
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "ShareActivityKind" AS ENUM ('share_viewed', 'asset_viewed', 'asset_downloaded', 'comment_created');
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "share_links" ADD COLUMN "last_viewed_at" TIMESTAMP(3),
|
||||
ADD COLUMN "views" INTEGER NOT NULL DEFAULT 0;
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "share_activities" (
|
||||
"id" TEXT NOT NULL,
|
||||
"share_link_id" TEXT NOT NULL,
|
||||
"kind" "ShareActivityKind" NOT NULL,
|
||||
"user_id" TEXT,
|
||||
"asset_id" TEXT,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "share_activities_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "share_activities_dedup_idx" ON "share_activities"("share_link_id", "kind", "user_id", "asset_id", "created_at" DESC);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "share_activities_share_link_id_id_idx" ON "share_activities"("share_link_id", "id" DESC);
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "share_activities" ADD CONSTRAINT "share_activities_share_link_id_fkey" FOREIGN KEY ("share_link_id") REFERENCES "share_links"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -479,6 +479,8 @@ model ShareLink {
|
||||
viewMode String? @map("view_mode")
|
||||
/// [ShareLinkFieldVisibility]
|
||||
fieldVisibility Json? @map("field_visibility")
|
||||
views Int @default(0)
|
||||
lastViewedAt DateTime? @map("last_viewed_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@ -495,9 +497,33 @@ model ShareLink {
|
||||
watermarkStatus WatermarkStatus @default(disabled) @map("watermark_status")
|
||||
watermarkConfig WatermarkConfig? @relation(fields: [watermarkConfigId], references: [id], onDelete: SetNull)
|
||||
|
||||
activities ShareActivity[]
|
||||
|
||||
@@map("share_links")
|
||||
}
|
||||
|
||||
enum ShareActivityKind {
|
||||
share_viewed
|
||||
asset_viewed
|
||||
asset_downloaded
|
||||
comment_created
|
||||
}
|
||||
|
||||
model ShareActivity {
|
||||
id String @id @default(ulid())
|
||||
shareLinkId String @map("share_link_id")
|
||||
shareLink ShareLink @relation(fields: [shareLinkId], references: [id], onDelete: Cascade)
|
||||
kind ShareActivityKind
|
||||
// Historical references retained when the user or asset is deleted.
|
||||
userId String? @map("user_id")
|
||||
assetId String? @map("asset_id")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
@@index([shareLinkId, kind, userId, assetId, createdAt(sort: Desc)], map: "share_activities_dedup_idx")
|
||||
@@index([shareLinkId, id(sort: Desc)])
|
||||
@@map("share_activities")
|
||||
}
|
||||
|
||||
model WatermarkConfig {
|
||||
id String @id @default(ulid())
|
||||
/// [WatermarkConfigSpec]
|
||||
|
||||
+5
@@ -77,6 +77,11 @@ export type ProjectMember = Prisma.ProjectMemberModel
|
||||
*
|
||||
*/
|
||||
export type ShareLink = Prisma.ShareLinkModel
|
||||
/**
|
||||
* Model ShareActivity
|
||||
*
|
||||
*/
|
||||
export type ShareActivity = Prisma.ShareActivityModel
|
||||
/**
|
||||
* Model WatermarkConfig
|
||||
*
|
||||
|
||||
+5
@@ -101,6 +101,11 @@ export type ProjectMember = Prisma.ProjectMemberModel
|
||||
*
|
||||
*/
|
||||
export type ShareLink = Prisma.ShareLinkModel
|
||||
/**
|
||||
* Model ShareActivity
|
||||
*
|
||||
*/
|
||||
export type ShareActivity = Prisma.ShareActivityModel
|
||||
/**
|
||||
* Model WatermarkConfig
|
||||
*
|
||||
|
||||
+88
-54
@@ -267,6 +267,17 @@ export type EnumProjectMemberRoleWithAggregatesFilter<$PrismaModel = never> = {
|
||||
_max?: Prisma.NestedEnumProjectMemberRoleFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type IntFilter<$PrismaModel = never> = {
|
||||
equals?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||
notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||
lt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
lte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
gt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
gte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedIntFilter<$PrismaModel> | number
|
||||
}
|
||||
|
||||
export type EnumWatermarkStatusFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.WatermarkStatus | Prisma.EnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.WatermarkStatus[] | Prisma.ListEnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
@@ -274,6 +285,22 @@ export type EnumWatermarkStatusFilter<$PrismaModel = never> = {
|
||||
not?: Prisma.NestedEnumWatermarkStatusFilter<$PrismaModel> | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type IntWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||
notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||
lt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
lte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
gt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
gte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedIntWithAggregatesFilter<$PrismaModel> | number
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_avg?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||
_sum?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type EnumWatermarkStatusWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.WatermarkStatus | Prisma.EnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.WatermarkStatus[] | Prisma.ListEnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
@@ -284,6 +311,23 @@ export type EnumWatermarkStatusWithAggregatesFilter<$PrismaModel = never> = {
|
||||
_max?: Prisma.NestedEnumWatermarkStatusFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type EnumShareActivityKindFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.ShareActivityKind | Prisma.EnumShareActivityKindFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.ShareActivityKind[] | Prisma.ListEnumShareActivityKindFieldRefInput<$PrismaModel>
|
||||
notIn?: $Enums.ShareActivityKind[] | Prisma.ListEnumShareActivityKindFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedEnumShareActivityKindFilter<$PrismaModel> | $Enums.ShareActivityKind
|
||||
}
|
||||
|
||||
export type EnumShareActivityKindWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.ShareActivityKind | Prisma.EnumShareActivityKindFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.ShareActivityKind[] | Prisma.ListEnumShareActivityKindFieldRefInput<$PrismaModel>
|
||||
notIn?: $Enums.ShareActivityKind[] | Prisma.ListEnumShareActivityKindFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedEnumShareActivityKindWithAggregatesFilter<$PrismaModel> | $Enums.ShareActivityKind
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedEnumShareActivityKindFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedEnumShareActivityKindFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type JsonFilter<$PrismaModel = never> =
|
||||
| Prisma.PatchUndefined<
|
||||
Prisma.Either<Required<JsonFilterBase<$PrismaModel>>, Exclude<keyof Required<JsonFilterBase<$PrismaModel>>, 'path'>>,
|
||||
@@ -359,17 +403,6 @@ export type EnumAssetTypeFilter<$PrismaModel = never> = {
|
||||
not?: Prisma.NestedEnumAssetTypeFilter<$PrismaModel> | $Enums.AssetType
|
||||
}
|
||||
|
||||
export type IntFilter<$PrismaModel = never> = {
|
||||
equals?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||
notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||
lt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
lte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
gt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
gte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedIntFilter<$PrismaModel> | number
|
||||
}
|
||||
|
||||
export type BigIntFilter<$PrismaModel = never> = {
|
||||
equals?: bigint | number | Prisma.BigIntFieldRefInput<$PrismaModel>
|
||||
in?: bigint[] | number[] | Prisma.ListBigIntFieldRefInput<$PrismaModel>
|
||||
@@ -398,22 +431,6 @@ export type EnumAssetTypeWithAggregatesFilter<$PrismaModel = never> = {
|
||||
_max?: Prisma.NestedEnumAssetTypeFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type IntWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||
notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||
lt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
lte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
gt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
gte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedIntWithAggregatesFilter<$PrismaModel> | number
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_avg?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||
_sum?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type BigIntWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: bigint | number | Prisma.BigIntFieldRefInput<$PrismaModel>
|
||||
in?: bigint[] | number[] | Prisma.ListBigIntFieldRefInput<$PrismaModel>
|
||||
@@ -1147,6 +1164,33 @@ export type NestedEnumWatermarkStatusFilter<$PrismaModel = never> = {
|
||||
not?: Prisma.NestedEnumWatermarkStatusFilter<$PrismaModel> | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type NestedIntWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||
notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||
lt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
lte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
gt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
gte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedIntWithAggregatesFilter<$PrismaModel> | number
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_avg?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||
_sum?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedFloatFilter<$PrismaModel = never> = {
|
||||
equals?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
in?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||
notIn?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||
lt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
lte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
gt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
gte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedFloatFilter<$PrismaModel> | number
|
||||
}
|
||||
|
||||
export type NestedEnumWatermarkStatusWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.WatermarkStatus | Prisma.EnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.WatermarkStatus[] | Prisma.ListEnumWatermarkStatusFieldRefInput<$PrismaModel>
|
||||
@@ -1157,6 +1201,23 @@ export type NestedEnumWatermarkStatusWithAggregatesFilter<$PrismaModel = never>
|
||||
_max?: Prisma.NestedEnumWatermarkStatusFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedEnumShareActivityKindFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.ShareActivityKind | Prisma.EnumShareActivityKindFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.ShareActivityKind[] | Prisma.ListEnumShareActivityKindFieldRefInput<$PrismaModel>
|
||||
notIn?: $Enums.ShareActivityKind[] | Prisma.ListEnumShareActivityKindFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedEnumShareActivityKindFilter<$PrismaModel> | $Enums.ShareActivityKind
|
||||
}
|
||||
|
||||
export type NestedEnumShareActivityKindWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: $Enums.ShareActivityKind | Prisma.EnumShareActivityKindFieldRefInput<$PrismaModel>
|
||||
in?: $Enums.ShareActivityKind[] | Prisma.ListEnumShareActivityKindFieldRefInput<$PrismaModel>
|
||||
notIn?: $Enums.ShareActivityKind[] | Prisma.ListEnumShareActivityKindFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedEnumShareActivityKindWithAggregatesFilter<$PrismaModel> | $Enums.ShareActivityKind
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedEnumShareActivityKindFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedEnumShareActivityKindFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedJsonFilter<$PrismaModel = never> =
|
||||
| Prisma.PatchUndefined<
|
||||
Prisma.Either<Required<NestedJsonFilterBase<$PrismaModel>>, Exclude<keyof Required<NestedJsonFilterBase<$PrismaModel>>, 'path'>>,
|
||||
@@ -1233,33 +1294,6 @@ export type NestedEnumAssetTypeWithAggregatesFilter<$PrismaModel = never> = {
|
||||
_max?: Prisma.NestedEnumAssetTypeFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedIntWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||
notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel>
|
||||
lt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
lte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
gt?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
gte?: number | Prisma.IntFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedIntWithAggregatesFilter<$PrismaModel> | number
|
||||
_count?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_avg?: Prisma.NestedFloatFilter<$PrismaModel>
|
||||
_sum?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_min?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
_max?: Prisma.NestedIntFilter<$PrismaModel>
|
||||
}
|
||||
|
||||
export type NestedFloatFilter<$PrismaModel = never> = {
|
||||
equals?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
in?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||
notIn?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel>
|
||||
lt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
lte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
gt?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
gte?: number | Prisma.FloatFieldRefInput<$PrismaModel>
|
||||
not?: Prisma.NestedFloatFilter<$PrismaModel> | number
|
||||
}
|
||||
|
||||
export type NestedBigIntWithAggregatesFilter<$PrismaModel = never> = {
|
||||
equals?: bigint | number | Prisma.BigIntFieldRefInput<$PrismaModel>
|
||||
in?: bigint[] | number[] | Prisma.ListBigIntFieldRefInput<$PrismaModel>
|
||||
|
||||
+10
@@ -268,6 +268,16 @@ export const KanbanTaskEventType = {
|
||||
export type KanbanTaskEventType = (typeof KanbanTaskEventType)[keyof typeof KanbanTaskEventType]
|
||||
|
||||
|
||||
export const ShareActivityKind = {
|
||||
share_viewed: 'share_viewed',
|
||||
asset_viewed: 'asset_viewed',
|
||||
asset_downloaded: 'asset_downloaded',
|
||||
comment_created: 'comment_created'
|
||||
} as const
|
||||
|
||||
export type ShareActivityKind = (typeof ShareActivityKind)[keyof typeof ShareActivityKind]
|
||||
|
||||
|
||||
export const AgentType = {
|
||||
chat: 'chat',
|
||||
autofill: 'autofill',
|
||||
|
||||
+14
-4
File diff suppressed because one or more lines are too long
+119
-15
@@ -409,6 +409,7 @@ export const ModelName = {
|
||||
Project: 'Project',
|
||||
ProjectMember: 'ProjectMember',
|
||||
ShareLink: 'ShareLink',
|
||||
ShareActivity: 'ShareActivity',
|
||||
WatermarkConfig: 'WatermarkConfig',
|
||||
WatermarkTemplate: 'WatermarkTemplate',
|
||||
WatermarkFile: 'WatermarkFile',
|
||||
@@ -473,7 +474,7 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
||||
omit: GlobalOmitOptions
|
||||
}
|
||||
meta: {
|
||||
modelProps: "user" | "session" | "account" | "verification" | "authToken" | "team" | "runner" | "skill" | "teamMember" | "project" | "projectMember" | "shareLink" | "watermarkConfig" | "watermarkTemplate" | "watermarkFile" | "asset" | "storageKey" | "assetMetadataValue" | "assetAgentMd" | "assetComment" | "assetCommentAttachment" | "assetCommentReaction" | "assetEmbedding" | "invite" | "metadataField" | "notification" | "systemSettings" | "task" | "workflowTask" | "agent" | "agentSkill" | "mcpServer" | "agentMcpServer" | "mcpServerCredential" | "agentSession" | "agentSessionCommit" | "agentSessionEntry" | "userMetadata" | "model" | "provider" | "collection" | "apiToken" | "aiUsage" | "auditLog" | "quotaRule" | "quotaRecord" | "kanbanGoal" | "kanbanTask" | "kanbanTaskLink" | "kanbanTaskAsset" | "kanbanTaskComment" | "kanbanTaskEvent" | "recentFileItem" | "jwks" | "oauthClient" | "oauthResource" | "oauthClientResource" | "oauthRefreshToken" | "oauthAccessToken" | "oauthConsent" | "oauthClientAssertion"
|
||||
modelProps: "user" | "session" | "account" | "verification" | "authToken" | "team" | "runner" | "skill" | "teamMember" | "project" | "projectMember" | "shareLink" | "shareActivity" | "watermarkConfig" | "watermarkTemplate" | "watermarkFile" | "asset" | "storageKey" | "assetMetadataValue" | "assetAgentMd" | "assetComment" | "assetCommentAttachment" | "assetCommentReaction" | "assetEmbedding" | "invite" | "metadataField" | "notification" | "systemSettings" | "task" | "workflowTask" | "agent" | "agentSkill" | "mcpServer" | "agentMcpServer" | "mcpServerCredential" | "agentSession" | "agentSessionCommit" | "agentSessionEntry" | "userMetadata" | "model" | "provider" | "collection" | "apiToken" | "aiUsage" | "auditLog" | "quotaRule" | "quotaRecord" | "kanbanGoal" | "kanbanTask" | "kanbanTaskLink" | "kanbanTaskAsset" | "kanbanTaskComment" | "kanbanTaskEvent" | "recentFileItem" | "jwks" | "oauthClient" | "oauthResource" | "oauthClientResource" | "oauthRefreshToken" | "oauthAccessToken" | "oauthConsent" | "oauthClientAssertion"
|
||||
txIsolationLevel: TransactionIsolationLevel
|
||||
}
|
||||
model: {
|
||||
@@ -1365,6 +1366,80 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
||||
}
|
||||
}
|
||||
}
|
||||
ShareActivity: {
|
||||
payload: Prisma.$ShareActivityPayload<ExtArgs>
|
||||
fields: Prisma.ShareActivityFieldRefs
|
||||
operations: {
|
||||
findUnique: {
|
||||
args: Prisma.ShareActivityFindUniqueArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ShareActivityPayload> | null
|
||||
}
|
||||
findUniqueOrThrow: {
|
||||
args: Prisma.ShareActivityFindUniqueOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ShareActivityPayload>
|
||||
}
|
||||
findFirst: {
|
||||
args: Prisma.ShareActivityFindFirstArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ShareActivityPayload> | null
|
||||
}
|
||||
findFirstOrThrow: {
|
||||
args: Prisma.ShareActivityFindFirstOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ShareActivityPayload>
|
||||
}
|
||||
findMany: {
|
||||
args: Prisma.ShareActivityFindManyArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ShareActivityPayload>[]
|
||||
}
|
||||
create: {
|
||||
args: Prisma.ShareActivityCreateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ShareActivityPayload>
|
||||
}
|
||||
createMany: {
|
||||
args: Prisma.ShareActivityCreateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
createManyAndReturn: {
|
||||
args: Prisma.ShareActivityCreateManyAndReturnArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ShareActivityPayload>[]
|
||||
}
|
||||
delete: {
|
||||
args: Prisma.ShareActivityDeleteArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ShareActivityPayload>
|
||||
}
|
||||
update: {
|
||||
args: Prisma.ShareActivityUpdateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ShareActivityPayload>
|
||||
}
|
||||
deleteMany: {
|
||||
args: Prisma.ShareActivityDeleteManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateMany: {
|
||||
args: Prisma.ShareActivityUpdateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateManyAndReturn: {
|
||||
args: Prisma.ShareActivityUpdateManyAndReturnArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ShareActivityPayload>[]
|
||||
}
|
||||
upsert: {
|
||||
args: Prisma.ShareActivityUpsertArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ShareActivityPayload>
|
||||
}
|
||||
aggregate: {
|
||||
args: Prisma.ShareActivityAggregateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.AggregateShareActivity>
|
||||
}
|
||||
groupBy: {
|
||||
args: Prisma.ShareActivityGroupByArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.ShareActivityGroupByOutputType>[]
|
||||
}
|
||||
count: {
|
||||
args: Prisma.ShareActivityCountArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.ShareActivityCountAggregateOutputType> | number
|
||||
}
|
||||
}
|
||||
}
|
||||
WatermarkConfig: {
|
||||
payload: Prisma.$WatermarkConfigPayload<ExtArgs>
|
||||
fields: Prisma.WatermarkConfigFieldRefs
|
||||
@@ -5198,6 +5273,8 @@ export const ShareLinkScalarFieldEnum = {
|
||||
defaultSortOrder: 'defaultSortOrder',
|
||||
viewMode: 'viewMode',
|
||||
fieldVisibility: 'fieldVisibility',
|
||||
views: 'views',
|
||||
lastViewedAt: 'lastViewedAt',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt',
|
||||
projectId: 'projectId',
|
||||
@@ -5210,6 +5287,18 @@ export const ShareLinkScalarFieldEnum = {
|
||||
export type ShareLinkScalarFieldEnum = (typeof ShareLinkScalarFieldEnum)[keyof typeof ShareLinkScalarFieldEnum]
|
||||
|
||||
|
||||
export const ShareActivityScalarFieldEnum = {
|
||||
id: 'id',
|
||||
shareLinkId: 'shareLinkId',
|
||||
kind: 'kind',
|
||||
userId: 'userId',
|
||||
assetId: 'assetId',
|
||||
createdAt: 'createdAt'
|
||||
} as const
|
||||
|
||||
export type ShareActivityScalarFieldEnum = (typeof ShareActivityScalarFieldEnum)[keyof typeof ShareActivityScalarFieldEnum]
|
||||
|
||||
|
||||
export const WatermarkConfigScalarFieldEnum = {
|
||||
id: 'id',
|
||||
config: 'config',
|
||||
@@ -6119,6 +6208,20 @@ export type ListEnumProjectMemberRoleFieldRefInput<$PrismaModel> = FieldRefInput
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'Int'
|
||||
*/
|
||||
export type IntFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Int'>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'Int[]'
|
||||
*/
|
||||
export type ListIntFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Int[]'>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'WatermarkStatus'
|
||||
*/
|
||||
@@ -6133,6 +6236,20 @@ export type ListEnumWatermarkStatusFieldRefInput<$PrismaModel> = FieldRefInputTy
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'ShareActivityKind'
|
||||
*/
|
||||
export type EnumShareActivityKindFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'ShareActivityKind'>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'ShareActivityKind[]'
|
||||
*/
|
||||
export type ListEnumShareActivityKindFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'ShareActivityKind[]'>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'WatermarkFileStatus'
|
||||
*/
|
||||
@@ -6161,20 +6278,6 @@ export type ListEnumAssetTypeFieldRefInput<$PrismaModel> = FieldRefInputType<$Pr
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'Int'
|
||||
*/
|
||||
export type IntFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Int'>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'Int[]'
|
||||
*/
|
||||
export type ListIntFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Int[]'>
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reference to a field of type 'BigInt'
|
||||
*/
|
||||
@@ -6631,6 +6734,7 @@ export type GlobalOmitConfig = {
|
||||
project?: Prisma.ProjectOmit
|
||||
projectMember?: Prisma.ProjectMemberOmit
|
||||
shareLink?: Prisma.ShareLinkOmit
|
||||
shareActivity?: Prisma.ShareActivityOmit
|
||||
watermarkConfig?: Prisma.WatermarkConfigOmit
|
||||
watermarkTemplate?: Prisma.WatermarkTemplateOmit
|
||||
watermarkFile?: Prisma.WatermarkFileOmit
|
||||
|
||||
@@ -63,6 +63,7 @@ export const ModelName = {
|
||||
Project: 'Project',
|
||||
ProjectMember: 'ProjectMember',
|
||||
ShareLink: 'ShareLink',
|
||||
ShareActivity: 'ShareActivity',
|
||||
WatermarkConfig: 'WatermarkConfig',
|
||||
WatermarkTemplate: 'WatermarkTemplate',
|
||||
WatermarkFile: 'WatermarkFile',
|
||||
@@ -298,6 +299,8 @@ export const ShareLinkScalarFieldEnum = {
|
||||
defaultSortOrder: 'defaultSortOrder',
|
||||
viewMode: 'viewMode',
|
||||
fieldVisibility: 'fieldVisibility',
|
||||
views: 'views',
|
||||
lastViewedAt: 'lastViewedAt',
|
||||
createdAt: 'createdAt',
|
||||
updatedAt: 'updatedAt',
|
||||
projectId: 'projectId',
|
||||
@@ -310,6 +313,18 @@ export const ShareLinkScalarFieldEnum = {
|
||||
export type ShareLinkScalarFieldEnum = (typeof ShareLinkScalarFieldEnum)[keyof typeof ShareLinkScalarFieldEnum]
|
||||
|
||||
|
||||
export const ShareActivityScalarFieldEnum = {
|
||||
id: 'id',
|
||||
shareLinkId: 'shareLinkId',
|
||||
kind: 'kind',
|
||||
userId: 'userId',
|
||||
assetId: 'assetId',
|
||||
createdAt: 'createdAt'
|
||||
} as const
|
||||
|
||||
export type ShareActivityScalarFieldEnum = (typeof ShareActivityScalarFieldEnum)[keyof typeof ShareActivityScalarFieldEnum]
|
||||
|
||||
|
||||
export const WatermarkConfigScalarFieldEnum = {
|
||||
id: 'id',
|
||||
config: 'config',
|
||||
|
||||
+1
@@ -20,6 +20,7 @@ export type * from './models/TeamMember.ts'
|
||||
export type * from './models/Project.ts'
|
||||
export type * from './models/ProjectMember.ts'
|
||||
export type * from './models/ShareLink.ts'
|
||||
export type * from './models/ShareActivity.ts'
|
||||
export type * from './models/WatermarkConfig.ts'
|
||||
export type * from './models/WatermarkTemplate.ts'
|
||||
export type * from './models/WatermarkFile.ts'
|
||||
|
||||
@@ -1143,14 +1143,6 @@ export type EnumAssetTypeFieldUpdateOperationsInput = {
|
||||
set?: $Enums.AssetType
|
||||
}
|
||||
|
||||
export type IntFieldUpdateOperationsInput = {
|
||||
set?: number
|
||||
increment?: number
|
||||
decrement?: number
|
||||
multiply?: number
|
||||
divide?: number
|
||||
}
|
||||
|
||||
export type BigIntFieldUpdateOperationsInput = {
|
||||
set?: bigint | number
|
||||
increment?: bigint | number
|
||||
|
||||
+1386
File diff suppressed because it is too large
Load Diff
+356
-1
@@ -22,10 +22,20 @@ export type ShareLinkModel = runtime.Types.Result.DefaultSelection<Prisma.$Share
|
||||
|
||||
export type AggregateShareLink = {
|
||||
_count: ShareLinkCountAggregateOutputType | null
|
||||
_avg: ShareLinkAvgAggregateOutputType | null
|
||||
_sum: ShareLinkSumAggregateOutputType | null
|
||||
_min: ShareLinkMinAggregateOutputType | null
|
||||
_max: ShareLinkMaxAggregateOutputType | null
|
||||
}
|
||||
|
||||
export type ShareLinkAvgAggregateOutputType = {
|
||||
views: number | null
|
||||
}
|
||||
|
||||
export type ShareLinkSumAggregateOutputType = {
|
||||
views: number | null
|
||||
}
|
||||
|
||||
export type ShareLinkMinAggregateOutputType = {
|
||||
id: string | null
|
||||
name: string | null
|
||||
@@ -35,6 +45,8 @@ export type ShareLinkMinAggregateOutputType = {
|
||||
allowDownload: boolean | null
|
||||
defaultSortOrder: string | null
|
||||
viewMode: string | null
|
||||
views: number | null
|
||||
lastViewedAt: Date | null
|
||||
createdAt: Date | null
|
||||
updatedAt: Date | null
|
||||
projectId: string | null
|
||||
@@ -53,6 +65,8 @@ export type ShareLinkMaxAggregateOutputType = {
|
||||
allowDownload: boolean | null
|
||||
defaultSortOrder: string | null
|
||||
viewMode: string | null
|
||||
views: number | null
|
||||
lastViewedAt: Date | null
|
||||
createdAt: Date | null
|
||||
updatedAt: Date | null
|
||||
projectId: string | null
|
||||
@@ -72,6 +86,8 @@ export type ShareLinkCountAggregateOutputType = {
|
||||
defaultSortOrder: number
|
||||
viewMode: number
|
||||
fieldVisibility: number
|
||||
views: number
|
||||
lastViewedAt: number
|
||||
createdAt: number
|
||||
updatedAt: number
|
||||
projectId: number
|
||||
@@ -83,6 +99,14 @@ export type ShareLinkCountAggregateOutputType = {
|
||||
}
|
||||
|
||||
|
||||
export type ShareLinkAvgAggregateInputType = {
|
||||
views?: true
|
||||
}
|
||||
|
||||
export type ShareLinkSumAggregateInputType = {
|
||||
views?: true
|
||||
}
|
||||
|
||||
export type ShareLinkMinAggregateInputType = {
|
||||
id?: true
|
||||
name?: true
|
||||
@@ -92,6 +116,8 @@ export type ShareLinkMinAggregateInputType = {
|
||||
allowDownload?: true
|
||||
defaultSortOrder?: true
|
||||
viewMode?: true
|
||||
views?: true
|
||||
lastViewedAt?: true
|
||||
createdAt?: true
|
||||
updatedAt?: true
|
||||
projectId?: true
|
||||
@@ -110,6 +136,8 @@ export type ShareLinkMaxAggregateInputType = {
|
||||
allowDownload?: true
|
||||
defaultSortOrder?: true
|
||||
viewMode?: true
|
||||
views?: true
|
||||
lastViewedAt?: true
|
||||
createdAt?: true
|
||||
updatedAt?: true
|
||||
projectId?: true
|
||||
@@ -129,6 +157,8 @@ export type ShareLinkCountAggregateInputType = {
|
||||
defaultSortOrder?: true
|
||||
viewMode?: true
|
||||
fieldVisibility?: true
|
||||
views?: true
|
||||
lastViewedAt?: true
|
||||
createdAt?: true
|
||||
updatedAt?: true
|
||||
projectId?: true
|
||||
@@ -174,6 +204,18 @@ export type ShareLinkAggregateArgs<ExtArgs extends runtime.Types.Extensions.Inte
|
||||
* Count returned ShareLinks
|
||||
**/
|
||||
_count?: true | ShareLinkCountAggregateInputType
|
||||
/**
|
||||
* {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs}
|
||||
*
|
||||
* Select which fields to average
|
||||
**/
|
||||
_avg?: ShareLinkAvgAggregateInputType
|
||||
/**
|
||||
* {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs}
|
||||
*
|
||||
* Select which fields to sum
|
||||
**/
|
||||
_sum?: ShareLinkSumAggregateInputType
|
||||
/**
|
||||
* {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs}
|
||||
*
|
||||
@@ -207,6 +249,8 @@ export type ShareLinkGroupByArgs<ExtArgs extends runtime.Types.Extensions.Intern
|
||||
take?: number
|
||||
skip?: number
|
||||
_count?: ShareLinkCountAggregateInputType | true
|
||||
_avg?: ShareLinkAvgAggregateInputType
|
||||
_sum?: ShareLinkSumAggregateInputType
|
||||
_min?: ShareLinkMinAggregateInputType
|
||||
_max?: ShareLinkMaxAggregateInputType
|
||||
}
|
||||
@@ -221,6 +265,8 @@ export type ShareLinkGroupByOutputType = {
|
||||
defaultSortOrder: string | null
|
||||
viewMode: string | null
|
||||
fieldVisibility:PrismaJson.ShareLinkFieldVisibility | null
|
||||
views: number
|
||||
lastViewedAt: Date | null
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
projectId: string
|
||||
@@ -229,6 +275,8 @@ export type ShareLinkGroupByOutputType = {
|
||||
watermarkConfigId: string | null
|
||||
watermarkStatus: $Enums.WatermarkStatus
|
||||
_count: ShareLinkCountAggregateOutputType | null
|
||||
_avg: ShareLinkAvgAggregateOutputType | null
|
||||
_sum: ShareLinkSumAggregateOutputType | null
|
||||
_min: ShareLinkMinAggregateOutputType | null
|
||||
_max: ShareLinkMaxAggregateOutputType | null
|
||||
}
|
||||
@@ -261,6 +309,8 @@ export type ShareLinkWhereInput = {
|
||||
defaultSortOrder?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
viewMode?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
fieldVisibility?: Prisma.JsonNullableFilter<"ShareLink">
|
||||
views?: Prisma.IntFilter<"ShareLink"> | number
|
||||
lastViewedAt?: Prisma.DateTimeNullableFilter<"ShareLink"> | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFilter<"ShareLink"> | Date | string
|
||||
updatedAt?: Prisma.DateTimeFilter<"ShareLink"> | Date | string
|
||||
projectId?: Prisma.StringFilter<"ShareLink"> | string
|
||||
@@ -272,6 +322,7 @@ export type ShareLinkWhereInput = {
|
||||
rootFolder?: Prisma.XOR<Prisma.AssetScalarRelationFilter, Prisma.AssetWhereInput>
|
||||
creator?: Prisma.XOR<Prisma.UserNullableScalarRelationFilter, Prisma.UserWhereInput> | null
|
||||
watermarkConfig?: Prisma.XOR<Prisma.WatermarkConfigNullableScalarRelationFilter, Prisma.WatermarkConfigWhereInput> | null
|
||||
activities?: Prisma.ShareActivityListRelationFilter
|
||||
}
|
||||
|
||||
export type ShareLinkOrderByWithRelationInput = {
|
||||
@@ -284,6 +335,8 @@ export type ShareLinkOrderByWithRelationInput = {
|
||||
defaultSortOrder?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
viewMode?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
fieldVisibility?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
views?: Prisma.SortOrder
|
||||
lastViewedAt?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
projectId?: Prisma.SortOrder
|
||||
@@ -295,6 +348,7 @@ export type ShareLinkOrderByWithRelationInput = {
|
||||
rootFolder?: Prisma.AssetOrderByWithRelationInput
|
||||
creator?: Prisma.UserOrderByWithRelationInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigOrderByWithRelationInput
|
||||
activities?: Prisma.ShareActivityOrderByRelationAggregateInput
|
||||
}
|
||||
|
||||
export type ShareLinkWhereUniqueInput = Prisma.AtLeast<{
|
||||
@@ -311,6 +365,8 @@ export type ShareLinkWhereUniqueInput = Prisma.AtLeast<{
|
||||
defaultSortOrder?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
viewMode?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
fieldVisibility?: Prisma.JsonNullableFilter<"ShareLink">
|
||||
views?: Prisma.IntFilter<"ShareLink"> | number
|
||||
lastViewedAt?: Prisma.DateTimeNullableFilter<"ShareLink"> | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFilter<"ShareLink"> | Date | string
|
||||
updatedAt?: Prisma.DateTimeFilter<"ShareLink"> | Date | string
|
||||
projectId?: Prisma.StringFilter<"ShareLink"> | string
|
||||
@@ -321,6 +377,7 @@ export type ShareLinkWhereUniqueInput = Prisma.AtLeast<{
|
||||
rootFolder?: Prisma.XOR<Prisma.AssetScalarRelationFilter, Prisma.AssetWhereInput>
|
||||
creator?: Prisma.XOR<Prisma.UserNullableScalarRelationFilter, Prisma.UserWhereInput> | null
|
||||
watermarkConfig?: Prisma.XOR<Prisma.WatermarkConfigNullableScalarRelationFilter, Prisma.WatermarkConfigWhereInput> | null
|
||||
activities?: Prisma.ShareActivityListRelationFilter
|
||||
}, "id" | "rootFolderId">
|
||||
|
||||
export type ShareLinkOrderByWithAggregationInput = {
|
||||
@@ -333,6 +390,8 @@ export type ShareLinkOrderByWithAggregationInput = {
|
||||
defaultSortOrder?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
viewMode?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
fieldVisibility?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
views?: Prisma.SortOrder
|
||||
lastViewedAt?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
projectId?: Prisma.SortOrder
|
||||
@@ -341,8 +400,10 @@ export type ShareLinkOrderByWithAggregationInput = {
|
||||
watermarkConfigId?: Prisma.SortOrderInput | Prisma.SortOrder
|
||||
watermarkStatus?: Prisma.SortOrder
|
||||
_count?: Prisma.ShareLinkCountOrderByAggregateInput
|
||||
_avg?: Prisma.ShareLinkAvgOrderByAggregateInput
|
||||
_max?: Prisma.ShareLinkMaxOrderByAggregateInput
|
||||
_min?: Prisma.ShareLinkMinOrderByAggregateInput
|
||||
_sum?: Prisma.ShareLinkSumOrderByAggregateInput
|
||||
}
|
||||
|
||||
export type ShareLinkScalarWhereWithAggregatesInput = {
|
||||
@@ -358,6 +419,8 @@ export type ShareLinkScalarWhereWithAggregatesInput = {
|
||||
defaultSortOrder?: Prisma.StringNullableWithAggregatesFilter<"ShareLink"> | string | null
|
||||
viewMode?: Prisma.StringNullableWithAggregatesFilter<"ShareLink"> | string | null
|
||||
fieldVisibility?: Prisma.JsonNullableWithAggregatesFilter<"ShareLink">
|
||||
views?: Prisma.IntWithAggregatesFilter<"ShareLink"> | number
|
||||
lastViewedAt?: Prisma.DateTimeNullableWithAggregatesFilter<"ShareLink"> | Date | string | null
|
||||
createdAt?: Prisma.DateTimeWithAggregatesFilter<"ShareLink"> | Date | string
|
||||
updatedAt?: Prisma.DateTimeWithAggregatesFilter<"ShareLink"> | Date | string
|
||||
projectId?: Prisma.StringWithAggregatesFilter<"ShareLink"> | string
|
||||
@@ -377,6 +440,8 @@ export type ShareLinkCreateInput = {
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: number
|
||||
lastViewedAt?: Date | string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
@@ -384,6 +449,7 @@ export type ShareLinkCreateInput = {
|
||||
rootFolder: Prisma.AssetCreateNestedOneWithoutShareLinkRootFolderInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutShareLinksInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigCreateNestedOneWithoutShareLinksInput
|
||||
activities?: Prisma.ShareActivityCreateNestedManyWithoutShareLinkInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedCreateInput = {
|
||||
@@ -396,6 +462,8 @@ export type ShareLinkUncheckedCreateInput = {
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: number
|
||||
lastViewedAt?: Date | string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
projectId: string
|
||||
@@ -403,6 +471,7 @@ export type ShareLinkUncheckedCreateInput = {
|
||||
creatorId?: string | null
|
||||
watermarkConfigId?: string | null
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
activities?: Prisma.ShareActivityUncheckedCreateNestedManyWithoutShareLinkInput
|
||||
}
|
||||
|
||||
export type ShareLinkUpdateInput = {
|
||||
@@ -415,6 +484,8 @@ export type ShareLinkUpdateInput = {
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
@@ -422,6 +493,7 @@ export type ShareLinkUpdateInput = {
|
||||
rootFolder?: Prisma.AssetUpdateOneRequiredWithoutShareLinkRootFolderNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutShareLinksNestedInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigUpdateOneWithoutShareLinksNestedInput
|
||||
activities?: Prisma.ShareActivityUpdateManyWithoutShareLinkNestedInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateInput = {
|
||||
@@ -434,6 +506,8 @@ export type ShareLinkUncheckedUpdateInput = {
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
projectId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -441,6 +515,7 @@ export type ShareLinkUncheckedUpdateInput = {
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkConfigId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
activities?: Prisma.ShareActivityUncheckedUpdateManyWithoutShareLinkNestedInput
|
||||
}
|
||||
|
||||
export type ShareLinkCreateManyInput = {
|
||||
@@ -453,6 +528,8 @@ export type ShareLinkCreateManyInput = {
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: number
|
||||
lastViewedAt?: Date | string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
projectId: string
|
||||
@@ -472,6 +549,8 @@ export type ShareLinkUpdateManyMutationInput = {
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
@@ -487,6 +566,8 @@ export type ShareLinkUncheckedUpdateManyInput = {
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
projectId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -516,6 +597,8 @@ export type ShareLinkCountOrderByAggregateInput = {
|
||||
defaultSortOrder?: Prisma.SortOrder
|
||||
viewMode?: Prisma.SortOrder
|
||||
fieldVisibility?: Prisma.SortOrder
|
||||
views?: Prisma.SortOrder
|
||||
lastViewedAt?: Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
projectId?: Prisma.SortOrder
|
||||
@@ -525,6 +608,10 @@ export type ShareLinkCountOrderByAggregateInput = {
|
||||
watermarkStatus?: Prisma.SortOrder
|
||||
}
|
||||
|
||||
export type ShareLinkAvgOrderByAggregateInput = {
|
||||
views?: Prisma.SortOrder
|
||||
}
|
||||
|
||||
export type ShareLinkMaxOrderByAggregateInput = {
|
||||
id?: Prisma.SortOrder
|
||||
name?: Prisma.SortOrder
|
||||
@@ -534,6 +621,8 @@ export type ShareLinkMaxOrderByAggregateInput = {
|
||||
allowDownload?: Prisma.SortOrder
|
||||
defaultSortOrder?: Prisma.SortOrder
|
||||
viewMode?: Prisma.SortOrder
|
||||
views?: Prisma.SortOrder
|
||||
lastViewedAt?: Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
projectId?: Prisma.SortOrder
|
||||
@@ -552,6 +641,8 @@ export type ShareLinkMinOrderByAggregateInput = {
|
||||
allowDownload?: Prisma.SortOrder
|
||||
defaultSortOrder?: Prisma.SortOrder
|
||||
viewMode?: Prisma.SortOrder
|
||||
views?: Prisma.SortOrder
|
||||
lastViewedAt?: Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
updatedAt?: Prisma.SortOrder
|
||||
projectId?: Prisma.SortOrder
|
||||
@@ -561,6 +652,15 @@ export type ShareLinkMinOrderByAggregateInput = {
|
||||
watermarkStatus?: Prisma.SortOrder
|
||||
}
|
||||
|
||||
export type ShareLinkSumOrderByAggregateInput = {
|
||||
views?: Prisma.SortOrder
|
||||
}
|
||||
|
||||
export type ShareLinkScalarRelationFilter = {
|
||||
is?: Prisma.ShareLinkWhereInput
|
||||
isNot?: Prisma.ShareLinkWhereInput
|
||||
}
|
||||
|
||||
export type ShareLinkNullableScalarRelationFilter = {
|
||||
is?: Prisma.ShareLinkWhereInput | null
|
||||
isNot?: Prisma.ShareLinkWhereInput | null
|
||||
@@ -650,10 +750,32 @@ export type ShareLinkUncheckedUpdateManyWithoutProjectNestedInput = {
|
||||
deleteMany?: Prisma.ShareLinkScalarWhereInput | Prisma.ShareLinkScalarWhereInput[]
|
||||
}
|
||||
|
||||
export type IntFieldUpdateOperationsInput = {
|
||||
set?: number
|
||||
increment?: number
|
||||
decrement?: number
|
||||
multiply?: number
|
||||
divide?: number
|
||||
}
|
||||
|
||||
export type EnumWatermarkStatusFieldUpdateOperationsInput = {
|
||||
set?: $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkCreateNestedOneWithoutActivitiesInput = {
|
||||
create?: Prisma.XOR<Prisma.ShareLinkCreateWithoutActivitiesInput, Prisma.ShareLinkUncheckedCreateWithoutActivitiesInput>
|
||||
connectOrCreate?: Prisma.ShareLinkCreateOrConnectWithoutActivitiesInput
|
||||
connect?: Prisma.ShareLinkWhereUniqueInput
|
||||
}
|
||||
|
||||
export type ShareLinkUpdateOneRequiredWithoutActivitiesNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.ShareLinkCreateWithoutActivitiesInput, Prisma.ShareLinkUncheckedCreateWithoutActivitiesInput>
|
||||
connectOrCreate?: Prisma.ShareLinkCreateOrConnectWithoutActivitiesInput
|
||||
upsert?: Prisma.ShareLinkUpsertWithoutActivitiesInput
|
||||
connect?: Prisma.ShareLinkWhereUniqueInput
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.ShareLinkUpdateToOneWithWhereWithoutActivitiesInput, Prisma.ShareLinkUpdateWithoutActivitiesInput>, Prisma.ShareLinkUncheckedUpdateWithoutActivitiesInput>
|
||||
}
|
||||
|
||||
export type ShareLinkCreateNestedManyWithoutWatermarkConfigInput = {
|
||||
create?: Prisma.XOR<Prisma.ShareLinkCreateWithoutWatermarkConfigInput, Prisma.ShareLinkUncheckedCreateWithoutWatermarkConfigInput> | Prisma.ShareLinkCreateWithoutWatermarkConfigInput[] | Prisma.ShareLinkUncheckedCreateWithoutWatermarkConfigInput[]
|
||||
connectOrCreate?: Prisma.ShareLinkCreateOrConnectWithoutWatermarkConfigInput | Prisma.ShareLinkCreateOrConnectWithoutWatermarkConfigInput[]
|
||||
@@ -738,12 +860,15 @@ export type ShareLinkCreateWithoutCreatorInput = {
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: number
|
||||
lastViewedAt?: Date | string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
project: Prisma.ProjectCreateNestedOneWithoutShareLinksInput
|
||||
rootFolder: Prisma.AssetCreateNestedOneWithoutShareLinkRootFolderInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigCreateNestedOneWithoutShareLinksInput
|
||||
activities?: Prisma.ShareActivityCreateNestedManyWithoutShareLinkInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedCreateWithoutCreatorInput = {
|
||||
@@ -756,12 +881,15 @@ export type ShareLinkUncheckedCreateWithoutCreatorInput = {
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: number
|
||||
lastViewedAt?: Date | string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
projectId: string
|
||||
rootFolderId: string
|
||||
watermarkConfigId?: string | null
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
activities?: Prisma.ShareActivityUncheckedCreateNestedManyWithoutShareLinkInput
|
||||
}
|
||||
|
||||
export type ShareLinkCreateOrConnectWithoutCreatorInput = {
|
||||
@@ -803,6 +931,8 @@ export type ShareLinkScalarWhereInput = {
|
||||
defaultSortOrder?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
viewMode?: Prisma.StringNullableFilter<"ShareLink"> | string | null
|
||||
fieldVisibility?: Prisma.JsonNullableFilter<"ShareLink">
|
||||
views?: Prisma.IntFilter<"ShareLink"> | number
|
||||
lastViewedAt?: Prisma.DateTimeNullableFilter<"ShareLink"> | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFilter<"ShareLink"> | Date | string
|
||||
updatedAt?: Prisma.DateTimeFilter<"ShareLink"> | Date | string
|
||||
projectId?: Prisma.StringFilter<"ShareLink"> | string
|
||||
@@ -822,12 +952,15 @@ export type ShareLinkCreateWithoutProjectInput = {
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: number
|
||||
lastViewedAt?: Date | string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
rootFolder: Prisma.AssetCreateNestedOneWithoutShareLinkRootFolderInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutShareLinksInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigCreateNestedOneWithoutShareLinksInput
|
||||
activities?: Prisma.ShareActivityCreateNestedManyWithoutShareLinkInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedCreateWithoutProjectInput = {
|
||||
@@ -840,12 +973,15 @@ export type ShareLinkUncheckedCreateWithoutProjectInput = {
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: number
|
||||
lastViewedAt?: Date | string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
rootFolderId: string
|
||||
creatorId?: string | null
|
||||
watermarkConfigId?: string | null
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
activities?: Prisma.ShareActivityUncheckedCreateNestedManyWithoutShareLinkInput
|
||||
}
|
||||
|
||||
export type ShareLinkCreateOrConnectWithoutProjectInput = {
|
||||
@@ -874,6 +1010,106 @@ export type ShareLinkUpdateManyWithWhereWithoutProjectInput = {
|
||||
data: Prisma.XOR<Prisma.ShareLinkUpdateManyMutationInput, Prisma.ShareLinkUncheckedUpdateManyWithoutProjectInput>
|
||||
}
|
||||
|
||||
export type ShareLinkCreateWithoutActivitiesInput = {
|
||||
id?: string
|
||||
name: string
|
||||
expireAt?: Date | string | null
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: number
|
||||
lastViewedAt?: Date | string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
project: Prisma.ProjectCreateNestedOneWithoutShareLinksInput
|
||||
rootFolder: Prisma.AssetCreateNestedOneWithoutShareLinkRootFolderInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutShareLinksInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigCreateNestedOneWithoutShareLinksInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedCreateWithoutActivitiesInput = {
|
||||
id?: string
|
||||
name: string
|
||||
expireAt?: Date | string | null
|
||||
password?: string | null
|
||||
isDisabled?: boolean
|
||||
allowDownload?: boolean
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: number
|
||||
lastViewedAt?: Date | string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
projectId: string
|
||||
rootFolderId: string
|
||||
creatorId?: string | null
|
||||
watermarkConfigId?: string | null
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkCreateOrConnectWithoutActivitiesInput = {
|
||||
where: Prisma.ShareLinkWhereUniqueInput
|
||||
create: Prisma.XOR<Prisma.ShareLinkCreateWithoutActivitiesInput, Prisma.ShareLinkUncheckedCreateWithoutActivitiesInput>
|
||||
}
|
||||
|
||||
export type ShareLinkUpsertWithoutActivitiesInput = {
|
||||
update: Prisma.XOR<Prisma.ShareLinkUpdateWithoutActivitiesInput, Prisma.ShareLinkUncheckedUpdateWithoutActivitiesInput>
|
||||
create: Prisma.XOR<Prisma.ShareLinkCreateWithoutActivitiesInput, Prisma.ShareLinkUncheckedCreateWithoutActivitiesInput>
|
||||
where?: Prisma.ShareLinkWhereInput
|
||||
}
|
||||
|
||||
export type ShareLinkUpdateToOneWithWhereWithoutActivitiesInput = {
|
||||
where?: Prisma.ShareLinkWhereInput
|
||||
data: Prisma.XOR<Prisma.ShareLinkUpdateWithoutActivitiesInput, Prisma.ShareLinkUncheckedUpdateWithoutActivitiesInput>
|
||||
}
|
||||
|
||||
export type ShareLinkUpdateWithoutActivitiesInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
project?: Prisma.ProjectUpdateOneRequiredWithoutShareLinksNestedInput
|
||||
rootFolder?: Prisma.AssetUpdateOneRequiredWithoutShareLinkRootFolderNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutShareLinksNestedInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigUpdateOneWithoutShareLinksNestedInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateWithoutActivitiesInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
name?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
expireAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
isDisabled?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
allowDownload?: Prisma.BoolFieldUpdateOperationsInput | boolean
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
projectId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
rootFolderId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkConfigId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
}
|
||||
|
||||
export type ShareLinkCreateWithoutWatermarkConfigInput = {
|
||||
id?: string
|
||||
name: string
|
||||
@@ -884,12 +1120,15 @@ export type ShareLinkCreateWithoutWatermarkConfigInput = {
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: number
|
||||
lastViewedAt?: Date | string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
project: Prisma.ProjectCreateNestedOneWithoutShareLinksInput
|
||||
rootFolder: Prisma.AssetCreateNestedOneWithoutShareLinkRootFolderInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutShareLinksInput
|
||||
activities?: Prisma.ShareActivityCreateNestedManyWithoutShareLinkInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedCreateWithoutWatermarkConfigInput = {
|
||||
@@ -902,12 +1141,15 @@ export type ShareLinkUncheckedCreateWithoutWatermarkConfigInput = {
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: number
|
||||
lastViewedAt?: Date | string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
projectId: string
|
||||
rootFolderId: string
|
||||
creatorId?: string | null
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
activities?: Prisma.ShareActivityUncheckedCreateNestedManyWithoutShareLinkInput
|
||||
}
|
||||
|
||||
export type ShareLinkCreateOrConnectWithoutWatermarkConfigInput = {
|
||||
@@ -946,12 +1188,15 @@ export type ShareLinkCreateWithoutRootFolderInput = {
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: number
|
||||
lastViewedAt?: Date | string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
project: Prisma.ProjectCreateNestedOneWithoutShareLinksInput
|
||||
creator?: Prisma.UserCreateNestedOneWithoutShareLinksInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigCreateNestedOneWithoutShareLinksInput
|
||||
activities?: Prisma.ShareActivityCreateNestedManyWithoutShareLinkInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedCreateWithoutRootFolderInput = {
|
||||
@@ -964,12 +1209,15 @@ export type ShareLinkUncheckedCreateWithoutRootFolderInput = {
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: number
|
||||
lastViewedAt?: Date | string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
projectId: string
|
||||
creatorId?: string | null
|
||||
watermarkConfigId?: string | null
|
||||
watermarkStatus?: $Enums.WatermarkStatus
|
||||
activities?: Prisma.ShareActivityUncheckedCreateNestedManyWithoutShareLinkInput
|
||||
}
|
||||
|
||||
export type ShareLinkCreateOrConnectWithoutRootFolderInput = {
|
||||
@@ -998,12 +1246,15 @@ export type ShareLinkUpdateWithoutRootFolderInput = {
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
project?: Prisma.ProjectUpdateOneRequiredWithoutShareLinksNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutShareLinksNestedInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigUpdateOneWithoutShareLinksNestedInput
|
||||
activities?: Prisma.ShareActivityUpdateManyWithoutShareLinkNestedInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateWithoutRootFolderInput = {
|
||||
@@ -1016,12 +1267,15 @@ export type ShareLinkUncheckedUpdateWithoutRootFolderInput = {
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
projectId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkConfigId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
activities?: Prisma.ShareActivityUncheckedUpdateManyWithoutShareLinkNestedInput
|
||||
}
|
||||
|
||||
export type ShareLinkCreateManyCreatorInput = {
|
||||
@@ -1034,6 +1288,8 @@ export type ShareLinkCreateManyCreatorInput = {
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: number
|
||||
lastViewedAt?: Date | string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
projectId: string
|
||||
@@ -1052,12 +1308,15 @@ export type ShareLinkUpdateWithoutCreatorInput = {
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
project?: Prisma.ProjectUpdateOneRequiredWithoutShareLinksNestedInput
|
||||
rootFolder?: Prisma.AssetUpdateOneRequiredWithoutShareLinkRootFolderNestedInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigUpdateOneWithoutShareLinksNestedInput
|
||||
activities?: Prisma.ShareActivityUpdateManyWithoutShareLinkNestedInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateWithoutCreatorInput = {
|
||||
@@ -1070,12 +1329,15 @@ export type ShareLinkUncheckedUpdateWithoutCreatorInput = {
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
projectId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
rootFolderId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
watermarkConfigId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
activities?: Prisma.ShareActivityUncheckedUpdateManyWithoutShareLinkNestedInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateManyWithoutCreatorInput = {
|
||||
@@ -1088,6 +1350,8 @@ export type ShareLinkUncheckedUpdateManyWithoutCreatorInput = {
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
projectId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -1106,6 +1370,8 @@ export type ShareLinkCreateManyProjectInput = {
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: number
|
||||
lastViewedAt?: Date | string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
rootFolderId: string
|
||||
@@ -1124,12 +1390,15 @@ export type ShareLinkUpdateWithoutProjectInput = {
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
rootFolder?: Prisma.AssetUpdateOneRequiredWithoutShareLinkRootFolderNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutShareLinksNestedInput
|
||||
watermarkConfig?: Prisma.WatermarkConfigUpdateOneWithoutShareLinksNestedInput
|
||||
activities?: Prisma.ShareActivityUpdateManyWithoutShareLinkNestedInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateWithoutProjectInput = {
|
||||
@@ -1142,12 +1411,15 @@ export type ShareLinkUncheckedUpdateWithoutProjectInput = {
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
rootFolderId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkConfigId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
activities?: Prisma.ShareActivityUncheckedUpdateManyWithoutShareLinkNestedInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateManyWithoutProjectInput = {
|
||||
@@ -1160,6 +1432,8 @@ export type ShareLinkUncheckedUpdateManyWithoutProjectInput = {
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
rootFolderId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -1178,6 +1452,8 @@ export type ShareLinkCreateManyWatermarkConfigInput = {
|
||||
defaultSortOrder?: string | null
|
||||
viewMode?: string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: number
|
||||
lastViewedAt?: Date | string | null
|
||||
createdAt?: Date | string
|
||||
updatedAt?: Date | string
|
||||
projectId: string
|
||||
@@ -1196,12 +1472,15 @@ export type ShareLinkUpdateWithoutWatermarkConfigInput = {
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
project?: Prisma.ProjectUpdateOneRequiredWithoutShareLinksNestedInput
|
||||
rootFolder?: Prisma.AssetUpdateOneRequiredWithoutShareLinkRootFolderNestedInput
|
||||
creator?: Prisma.UserUpdateOneWithoutShareLinksNestedInput
|
||||
activities?: Prisma.ShareActivityUpdateManyWithoutShareLinkNestedInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateWithoutWatermarkConfigInput = {
|
||||
@@ -1214,12 +1493,15 @@ export type ShareLinkUncheckedUpdateWithoutWatermarkConfigInput = {
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
projectId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
rootFolderId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
creatorId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
watermarkStatus?: Prisma.EnumWatermarkStatusFieldUpdateOperationsInput | $Enums.WatermarkStatus
|
||||
activities?: Prisma.ShareActivityUncheckedUpdateManyWithoutShareLinkNestedInput
|
||||
}
|
||||
|
||||
export type ShareLinkUncheckedUpdateManyWithoutWatermarkConfigInput = {
|
||||
@@ -1232,6 +1514,8 @@ export type ShareLinkUncheckedUpdateManyWithoutWatermarkConfigInput = {
|
||||
defaultSortOrder?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
viewMode?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
fieldVisibility?:PrismaJson.ShareLinkFieldVisibility | Prisma.NullableJsonNullValueInput
|
||||
views?: Prisma.IntFieldUpdateOperationsInput | number
|
||||
lastViewedAt?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null
|
||||
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
|
||||
projectId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
@@ -1241,6 +1525,35 @@ export type ShareLinkUncheckedUpdateManyWithoutWatermarkConfigInput = {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Count Type ShareLinkCountOutputType
|
||||
*/
|
||||
|
||||
export type ShareLinkCountOutputType = {
|
||||
activities: number
|
||||
}
|
||||
|
||||
export type ShareLinkCountOutputTypeSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
activities?: boolean | ShareLinkCountOutputTypeCountActivitiesArgs
|
||||
}
|
||||
|
||||
/**
|
||||
* ShareLinkCountOutputType without action
|
||||
*/
|
||||
export type ShareLinkCountOutputTypeDefaultArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
/**
|
||||
* Select specific fields to fetch from the ShareLinkCountOutputType
|
||||
*/
|
||||
select?: Prisma.ShareLinkCountOutputTypeSelect<ExtArgs> | null
|
||||
}
|
||||
|
||||
/**
|
||||
* ShareLinkCountOutputType without action
|
||||
*/
|
||||
export type ShareLinkCountOutputTypeCountActivitiesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
where?: Prisma.ShareActivityWhereInput
|
||||
}
|
||||
|
||||
|
||||
export type ShareLinkSelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
|
||||
id?: boolean
|
||||
@@ -1252,6 +1565,8 @@ export type ShareLinkSelect<ExtArgs extends runtime.Types.Extensions.InternalArg
|
||||
defaultSortOrder?: boolean
|
||||
viewMode?: boolean
|
||||
fieldVisibility?: boolean
|
||||
views?: boolean
|
||||
lastViewedAt?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
projectId?: boolean
|
||||
@@ -1263,6 +1578,8 @@ export type ShareLinkSelect<ExtArgs extends runtime.Types.Extensions.InternalArg
|
||||
rootFolder?: boolean | Prisma.AssetDefaultArgs<ExtArgs>
|
||||
creator?: boolean | Prisma.ShareLink$creatorArgs<ExtArgs>
|
||||
watermarkConfig?: boolean | Prisma.ShareLink$watermarkConfigArgs<ExtArgs>
|
||||
activities?: boolean | Prisma.ShareLink$activitiesArgs<ExtArgs>
|
||||
_count?: boolean | Prisma.ShareLinkCountOutputTypeDefaultArgs<ExtArgs>
|
||||
}, ExtArgs["result"]["shareLink"]>
|
||||
|
||||
export type ShareLinkSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
|
||||
@@ -1275,6 +1592,8 @@ export type ShareLinkSelectCreateManyAndReturn<ExtArgs extends runtime.Types.Ext
|
||||
defaultSortOrder?: boolean
|
||||
viewMode?: boolean
|
||||
fieldVisibility?: boolean
|
||||
views?: boolean
|
||||
lastViewedAt?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
projectId?: boolean
|
||||
@@ -1298,6 +1617,8 @@ export type ShareLinkSelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Ext
|
||||
defaultSortOrder?: boolean
|
||||
viewMode?: boolean
|
||||
fieldVisibility?: boolean
|
||||
views?: boolean
|
||||
lastViewedAt?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
projectId?: boolean
|
||||
@@ -1321,6 +1642,8 @@ export type ShareLinkSelectScalar = {
|
||||
defaultSortOrder?: boolean
|
||||
viewMode?: boolean
|
||||
fieldVisibility?: boolean
|
||||
views?: boolean
|
||||
lastViewedAt?: boolean
|
||||
createdAt?: boolean
|
||||
updatedAt?: boolean
|
||||
projectId?: boolean
|
||||
@@ -1330,12 +1653,14 @@ export type ShareLinkSelectScalar = {
|
||||
watermarkStatus?: boolean
|
||||
}
|
||||
|
||||
export type ShareLinkOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "name" | "expireAt" | "password" | "isDisabled" | "allowDownload" | "defaultSortOrder" | "viewMode" | "fieldVisibility" | "createdAt" | "updatedAt" | "projectId" | "rootFolderId" | "creatorId" | "watermarkConfigId" | "watermarkStatus", ExtArgs["result"]["shareLink"]>
|
||||
export type ShareLinkOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "name" | "expireAt" | "password" | "isDisabled" | "allowDownload" | "defaultSortOrder" | "viewMode" | "fieldVisibility" | "views" | "lastViewedAt" | "createdAt" | "updatedAt" | "projectId" | "rootFolderId" | "creatorId" | "watermarkConfigId" | "watermarkStatus", ExtArgs["result"]["shareLink"]>
|
||||
export type ShareLinkInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
project?: boolean | Prisma.ProjectDefaultArgs<ExtArgs>
|
||||
rootFolder?: boolean | Prisma.AssetDefaultArgs<ExtArgs>
|
||||
creator?: boolean | Prisma.ShareLink$creatorArgs<ExtArgs>
|
||||
watermarkConfig?: boolean | Prisma.ShareLink$watermarkConfigArgs<ExtArgs>
|
||||
activities?: boolean | Prisma.ShareLink$activitiesArgs<ExtArgs>
|
||||
_count?: boolean | Prisma.ShareLinkCountOutputTypeDefaultArgs<ExtArgs>
|
||||
}
|
||||
export type ShareLinkIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
project?: boolean | Prisma.ProjectDefaultArgs<ExtArgs>
|
||||
@@ -1357,6 +1682,7 @@ export type $ShareLinkPayload<ExtArgs extends runtime.Types.Extensions.InternalA
|
||||
rootFolder: Prisma.$AssetPayload<ExtArgs>
|
||||
creator: Prisma.$UserPayload<ExtArgs> | null
|
||||
watermarkConfig: Prisma.$WatermarkConfigPayload<ExtArgs> | null
|
||||
activities: Prisma.$ShareActivityPayload<ExtArgs>[]
|
||||
}
|
||||
scalars: runtime.Types.Extensions.GetPayloadResult<{
|
||||
id: string
|
||||
@@ -1371,6 +1697,8 @@ export type $ShareLinkPayload<ExtArgs extends runtime.Types.Extensions.InternalA
|
||||
* [ShareLinkFieldVisibility]
|
||||
*/
|
||||
fieldVisibility:PrismaJson.ShareLinkFieldVisibility | null
|
||||
views: number
|
||||
lastViewedAt: Date | null
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
projectId: string
|
||||
@@ -1776,6 +2104,7 @@ export interface Prisma__ShareLinkClient<T, Null = never, ExtArgs extends runtim
|
||||
rootFolder<T extends Prisma.AssetDefaultArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.AssetDefaultArgs<ExtArgs>>): Prisma.Prisma__AssetClient<runtime.Types.Result.GetResult<Prisma.$AssetPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions>
|
||||
creator<T extends Prisma.ShareLink$creatorArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.ShareLink$creatorArgs<ExtArgs>>): Prisma.Prisma__UserClient<runtime.Types.Result.GetResult<Prisma.$UserPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
|
||||
watermarkConfig<T extends Prisma.ShareLink$watermarkConfigArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.ShareLink$watermarkConfigArgs<ExtArgs>>): Prisma.Prisma__WatermarkConfigClient<runtime.Types.Result.GetResult<Prisma.$WatermarkConfigPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
|
||||
activities<T extends Prisma.ShareLink$activitiesArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.ShareLink$activitiesArgs<ExtArgs>>): Prisma.PrismaPromise<runtime.Types.Result.GetResult<Prisma.$ShareActivityPayload<ExtArgs>, T, "findMany", GlobalOmitOptions> | Null>
|
||||
/**
|
||||
* Attaches callbacks for the resolution and/or rejection of the Promise.
|
||||
* @param onfulfilled The callback to execute when the Promise is resolved.
|
||||
@@ -1814,6 +2143,8 @@ export interface ShareLinkFieldRefs {
|
||||
readonly defaultSortOrder: Prisma.FieldRef<"ShareLink", 'String'>
|
||||
readonly viewMode: Prisma.FieldRef<"ShareLink", 'String'>
|
||||
readonly fieldVisibility: Prisma.FieldRef<"ShareLink", 'Json'>
|
||||
readonly views: Prisma.FieldRef<"ShareLink", 'Int'>
|
||||
readonly lastViewedAt: Prisma.FieldRef<"ShareLink", 'DateTime'>
|
||||
readonly createdAt: Prisma.FieldRef<"ShareLink", 'DateTime'>
|
||||
readonly updatedAt: Prisma.FieldRef<"ShareLink", 'DateTime'>
|
||||
readonly projectId: Prisma.FieldRef<"ShareLink", 'String'>
|
||||
@@ -2259,6 +2590,30 @@ export type ShareLink$watermarkConfigArgs<ExtArgs extends runtime.Types.Extensio
|
||||
where?: Prisma.WatermarkConfigWhereInput
|
||||
}
|
||||
|
||||
/**
|
||||
* ShareLink.activities
|
||||
*/
|
||||
export type ShareLink$activitiesArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
/**
|
||||
* Select specific fields to fetch from the ShareActivity
|
||||
*/
|
||||
select?: Prisma.ShareActivitySelect<ExtArgs> | null
|
||||
/**
|
||||
* Omit specific fields from the ShareActivity
|
||||
*/
|
||||
omit?: Prisma.ShareActivityOmit<ExtArgs> | null
|
||||
/**
|
||||
* Choose, which related nodes to fetch as well
|
||||
*/
|
||||
include?: Prisma.ShareActivityInclude<ExtArgs> | null
|
||||
where?: Prisma.ShareActivityWhereInput
|
||||
orderBy?: Prisma.ShareActivityOrderByWithRelationInput | Prisma.ShareActivityOrderByWithRelationInput[]
|
||||
cursor?: Prisma.ShareActivityWhereUniqueInput
|
||||
take?: number
|
||||
skip?: number
|
||||
distinct?: Prisma.ShareActivityScalarFieldEnum | Prisma.ShareActivityScalarFieldEnum[]
|
||||
}
|
||||
|
||||
/**
|
||||
* ShareLink without action
|
||||
*/
|
||||
|
||||
@@ -16,6 +16,8 @@ export interface ShareLinkInfo {
|
||||
rootFolderId: string
|
||||
projectId: string
|
||||
isExpired: boolean
|
||||
views: number
|
||||
lastViewedAt: string | null
|
||||
watermarkConfigId?: string | null
|
||||
watermarkStatus?: 'disabled' | 'processing' | 'ready' | 'failed'
|
||||
watermarkConfig?: {
|
||||
@@ -28,6 +30,22 @@ export interface ShareLinkInfo {
|
||||
creator?: { id: string; name: string; image?: string | null } | null
|
||||
}
|
||||
|
||||
export type ShareActivityKind =
|
||||
'share_viewed' | 'asset_viewed' | 'asset_downloaded' | 'comment_created'
|
||||
|
||||
export interface ShareActivityInfo {
|
||||
id: string
|
||||
kind: ShareActivityKind
|
||||
createdAt: string
|
||||
user: { name: string; image?: string } | null
|
||||
asset: { id: string; name: string | null } | null
|
||||
}
|
||||
|
||||
export const recordShareViewRequestSchema = z.object({
|
||||
assetId: z.string().min(1).optional(),
|
||||
isShareEntry: z.boolean().optional(),
|
||||
})
|
||||
|
||||
export const createShareLinkRequestSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
expireAt: z.string().datetime().optional(),
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { client } from './client'
|
||||
|
||||
export function requestShareDownload(
|
||||
shareId: string,
|
||||
fileId: string,
|
||||
key: string,
|
||||
purpose?: 'download' | 'prepare' | 'clipboard',
|
||||
) {
|
||||
const password = localStorage.getItem(`share_pwd_${shareId}`)
|
||||
const postDownload = client.api.shares[':shareId'].files[':fileId']['download-url'].$post
|
||||
const input = { param: { shareId, fileId }, json: { key, purpose } }
|
||||
return password
|
||||
? postDownload(input, { headers: { 'x-share-password': password } })
|
||||
: postDownload(input)
|
||||
}
|
||||
@@ -419,6 +419,8 @@ describe('BreadcrumbNav component', () => {
|
||||
rootFolderId: 'rf-1',
|
||||
projectId: 'proj-1',
|
||||
isExpired: false,
|
||||
views: 0,
|
||||
lastViewedAt: null,
|
||||
createdAt: '2026-11-24T00:00:00.000Z',
|
||||
updatedAt: '2026-11-24T00:00:00.000Z',
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { requestShareDownload } from '@/ui/api/share-download'
|
||||
import { Badge } from '@/ui/components/ui/badge'
|
||||
import { Button } from '@/ui/components/ui/button'
|
||||
import {
|
||||
@@ -206,10 +207,7 @@ export function BreadcrumbNav({
|
||||
if (!fileId) return
|
||||
try {
|
||||
const res = shareId
|
||||
? await client.api.shares[':shareId'].files[':fileId']['download-url'].$post({
|
||||
param: { shareId, fileId },
|
||||
json: { key },
|
||||
})
|
||||
? await requestShareDownload(shareId, fileId, key)
|
||||
: await client.api.files['download-url'].$post({
|
||||
json: { key, assetId: fileId },
|
||||
})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use client'
|
||||
|
||||
import { client } from '@/ui/api/client'
|
||||
import { requestShareDownload } from '@/ui/api/share-download'
|
||||
import type { AssetInfo } from '@shumai/dtos'
|
||||
import { toast } from 'sonner'
|
||||
import { copyToClipboard, copyToClipboardDeferred, copyImageToClipboard } from '@/ui/lib/clipboard'
|
||||
@@ -39,18 +40,7 @@ export function useCopyActions({
|
||||
if (transcode?.url) return transcode.url
|
||||
if (transcode?.key && item.id) {
|
||||
if (isPublic && shareId) {
|
||||
const password = localStorage.getItem(`share_pwd_${shareId}`) || ''
|
||||
const res = await client.api.shares[':shareId'].files[':fileId']['download-url'].$post(
|
||||
{
|
||||
param: { shareId, fileId: item.id },
|
||||
json: { key: transcode.key },
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'x-share-password': password,
|
||||
},
|
||||
},
|
||||
)
|
||||
const res = await requestShareDownload(shareId, item.id, transcode.key, 'clipboard')
|
||||
if (res.ok) {
|
||||
const { url } = await res.json()
|
||||
return url
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use client'
|
||||
|
||||
import { client } from '@/ui/api/client'
|
||||
import { requestShareDownload } from '@/ui/api/share-download'
|
||||
import type { AssetInfo } from '@shumai/dtos'
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import type { InferRequestType, InferResponseType } from 'hono/client'
|
||||
@@ -20,6 +21,18 @@ interface UseFileActionsProps {
|
||||
shareId?: string
|
||||
}
|
||||
|
||||
async function requestShareDownloadUrl(
|
||||
shareId: string,
|
||||
fileId: string,
|
||||
key: string,
|
||||
purpose: 'prepare' | 'download',
|
||||
) {
|
||||
const response = await requestShareDownload(shareId, fileId, key, purpose)
|
||||
if (response.ok) return (await response.json()).url
|
||||
}
|
||||
|
||||
type DownloadFile = { id: string; name: string; url: string; shareDownloadKey?: string }
|
||||
|
||||
export function useFileActions({
|
||||
teamId,
|
||||
projectId,
|
||||
@@ -35,9 +48,7 @@ export function useFileActions({
|
||||
const [itemsToDelete, setItemsToDelete] = useState<AssetInfo[]>([])
|
||||
const [isDownloadDialogOpen, setIsDownloadDialogOpen] = useState(false)
|
||||
const [isLoadingLinks, setIsLoadingLinks] = useState(false)
|
||||
const [resolvedFiles, setResolvedFiles] = useState<
|
||||
Array<{ id: string; name: string; url: string }>
|
||||
>([])
|
||||
const [resolvedFiles, setResolvedFiles] = useState<DownloadFile[]>([])
|
||||
const [skippedArchivedCount, setSkippedArchivedCount] = useState(0)
|
||||
const [archiveConfirmState, setArchiveConfirmState] = useState<{
|
||||
open: boolean
|
||||
@@ -257,8 +268,7 @@ export function useFileActions({
|
||||
setSkippedArchivedCount(0)
|
||||
try {
|
||||
if (isPublic && shareId) {
|
||||
const password = localStorage.getItem(`share_pwd_${shareId}`) || ''
|
||||
const links: Array<{ id: string; name: string; url: string }> = []
|
||||
const links: DownloadFile[] = []
|
||||
let skipped = 0
|
||||
for (const item of items) {
|
||||
if (
|
||||
@@ -271,20 +281,9 @@ export function useFileActions({
|
||||
}
|
||||
const key = item.media?.original?.key
|
||||
if (!key || !item.id) continue
|
||||
const res = await client.api.shares[':shareId'].files[':fileId']['download-url'].$post(
|
||||
{
|
||||
param: { shareId, fileId: item.id },
|
||||
json: { key },
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'x-share-password': password,
|
||||
},
|
||||
},
|
||||
)
|
||||
if (res.ok) {
|
||||
const { url } = await res.json()
|
||||
links.push({ id: item.id, name: item.name || 'download', url })
|
||||
const url = await requestShareDownloadUrl(shareId, item.id, key, 'prepare')
|
||||
if (url) {
|
||||
links.push({ id: item.id, name: item.name || 'download', url, shareDownloadKey: key })
|
||||
}
|
||||
}
|
||||
setSkippedArchivedCount(skipped)
|
||||
@@ -407,9 +406,21 @@ export function useFileActions({
|
||||
|
||||
const runQueue = async () => {
|
||||
const batchSize = 5
|
||||
let failed = 0
|
||||
for (let i = 0; i < files.length; i += batchSize) {
|
||||
const chunk = files.slice(i, i + batchSize)
|
||||
for (const file of chunk) {
|
||||
const urls = await Promise.allSettled(
|
||||
chunk.map((file) =>
|
||||
shareId && file.shareDownloadKey
|
||||
? requestShareDownloadUrl(shareId, file.id, file.shareDownloadKey, 'download')
|
||||
: file.url,
|
||||
),
|
||||
)
|
||||
for (const result of urls) {
|
||||
if (result.status !== 'fulfilled' || !result.value) {
|
||||
failed++
|
||||
continue
|
||||
}
|
||||
// Use a hidden iframe instead of an anchor with target="_blank".
|
||||
// Download URLs respond with Content-Disposition: attachment, so the
|
||||
// browser starts the download in the background: no flash of a tab
|
||||
@@ -417,7 +428,7 @@ export function useFileActions({
|
||||
// the hidden iframe instead of navigating the SPA tab away.
|
||||
const iframe = document.createElement('iframe')
|
||||
iframe.style.display = 'none'
|
||||
iframe.src = file.url
|
||||
iframe.src = result.value
|
||||
document.body.appendChild(iframe)
|
||||
// Remove the iframe once the download has had time to start.
|
||||
window.setTimeout(() => iframe.remove(), 60_000)
|
||||
@@ -426,7 +437,8 @@ export function useFileActions({
|
||||
await delay(600)
|
||||
}
|
||||
}
|
||||
toast.success('All downloads initiated successfully')
|
||||
if (failed > 0) toast.error(m.share_download_start_failed())
|
||||
else toast.success('All downloads initiated successfully')
|
||||
}
|
||||
|
||||
runQueue().catch((err) => {
|
||||
|
||||
@@ -238,6 +238,8 @@ describe('MobileFileHeader', () => {
|
||||
rootFolderId: 'rf-1',
|
||||
projectId: 'proj-1',
|
||||
isExpired: false,
|
||||
views: 0,
|
||||
lastViewedAt: null,
|
||||
createdAt: '2026-11-24T00:00:00.000Z',
|
||||
updatedAt: '2026-11-24T00:00:00.000Z',
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { requestShareDownload } from '@/ui/api/share-download'
|
||||
import { Badge } from '@/ui/components/ui/badge'
|
||||
import { Button } from '@/ui/components/ui/button'
|
||||
import {
|
||||
@@ -113,10 +114,7 @@ export function MobileFileHeader({
|
||||
try {
|
||||
const res =
|
||||
isPublic && shareId
|
||||
? await client.api.shares[':shareId'].files[':fileId']['download-url'].$post({
|
||||
param: { shareId, fileId: activeFileId },
|
||||
json: { key },
|
||||
})
|
||||
? await requestShareDownload(shareId, activeFileId, key)
|
||||
: await client.api.files['download-url'].$post({
|
||||
json: { key, assetId: activeFileId },
|
||||
})
|
||||
|
||||
@@ -6,6 +6,7 @@ import { m } from '@/ui/paraglide/messages.js'
|
||||
import { useInfiniteQuery, useQuery } from '@tanstack/react-query'
|
||||
import { useEffect, useState, useMemo, useRef } from 'react'
|
||||
import { useIsMobile } from '@/ui/hooks/use-mobile'
|
||||
import { usePublicShareView } from '@/ui/hooks/use-public-share-view'
|
||||
import { TopNav } from './top-nav'
|
||||
import { FileBrowser } from './file-browser/file-browser'
|
||||
import { MobileFileBrowser } from './file-browser/mobile-file-browser'
|
||||
@@ -127,6 +128,7 @@ export function PublicShareManager({
|
||||
},
|
||||
)
|
||||
if (res.status === 401) throw new Error('Unauthorized')
|
||||
if (!res.ok) throw new Error('Failed to fetch shared asset')
|
||||
return (await res.json()) as unknown as AssetInfo
|
||||
},
|
||||
enabled: !!shareInfo && !!currentFolderId,
|
||||
@@ -258,6 +260,7 @@ export function PublicShareManager({
|
||||
},
|
||||
)
|
||||
if (res.status === 401) throw new Error('Unauthorized')
|
||||
if (!res.ok) throw new Error('Failed to fetch shared asset')
|
||||
return (await res.json()) as unknown as AssetInfo
|
||||
},
|
||||
enabled: !!viewingFileId && !!shareInfo,
|
||||
@@ -277,6 +280,7 @@ export function PublicShareManager({
|
||||
},
|
||||
)
|
||||
if (res.status === 401) throw new Error('Unauthorized')
|
||||
if (!res.ok) throw new Error('Failed to fetch shared asset')
|
||||
return (await res.json()) as unknown as AssetInfo
|
||||
},
|
||||
enabled: !!versionId && !!shareInfo,
|
||||
@@ -286,6 +290,12 @@ export function PublicShareManager({
|
||||
// or the stack itself) is what we actually display.
|
||||
const viewingFileData = versionId ? versionFileData : stackFileData
|
||||
const isViewingFileLoading = isStackFileLoading || (!!versionId && isVersionFileLoading)
|
||||
usePublicShareView({
|
||||
shareId,
|
||||
assetId: activeFileId ?? initialFolderId,
|
||||
password,
|
||||
ready: !!shareInfo && (viewingFileId ? !!viewingFileData : !initialFolderId || !!folderInfo),
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (foldersError?.message === 'Unauthorized') {
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
import type { ShareActivityKind } from '@shumai/dtos'
|
||||
import { useInfiniteQuery } from '@tanstack/react-query'
|
||||
import { isToday, isYesterday } from 'date-fns'
|
||||
import { CircleUserRound } from 'lucide-react'
|
||||
import { useEffect } from 'react'
|
||||
import { useInView } from 'react-intersection-observer'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import { getLocale } from '@/ui/paraglide/runtime.js'
|
||||
import { Avatar, AvatarFallback, AvatarImage } from './ui/avatar'
|
||||
import { Button } from './ui/button'
|
||||
import { ScrollArea } from './ui/scroll-area'
|
||||
|
||||
function activityLabel(kind: ShareActivityKind) {
|
||||
switch (kind) {
|
||||
case 'share_viewed':
|
||||
return m.share_activity_opened_share_link()
|
||||
case 'asset_viewed':
|
||||
return m.share_activity_viewed_asset()
|
||||
case 'asset_downloaded':
|
||||
return m.share_activity_downloaded()
|
||||
case 'comment_created':
|
||||
return m.share_activity_commented()
|
||||
}
|
||||
}
|
||||
|
||||
function formatDay(date: Date) {
|
||||
if (isToday(date)) return m.today()
|
||||
if (isYesterday(date)) return m.yesterday()
|
||||
return date.toLocaleDateString(getLocale(), { dateStyle: 'medium' })
|
||||
}
|
||||
|
||||
export function ShareActivityList({ shareId }: { shareId: string }) {
|
||||
const query = useInfiniteQuery({
|
||||
queryKey: ['share-activities', shareId],
|
||||
queryFn: async ({ pageParam, signal }) => {
|
||||
const response = await client.api.shares[':shareId'].activities.$get(
|
||||
{ param: { shareId }, query: { first: '20', after: pageParam } },
|
||||
{ init: { signal } },
|
||||
)
|
||||
if (!response.ok) throw new Error(m.share_activity_load_failed())
|
||||
return response.json()
|
||||
},
|
||||
initialPageParam: '',
|
||||
getNextPageParam: (page) => page.pageInfo.cursor || undefined,
|
||||
})
|
||||
const { ref, inView } = useInView()
|
||||
const { fetchNextPage, hasNextPage, isFetching, isError } = query
|
||||
useEffect(() => {
|
||||
if (inView && hasNextPage && !isFetching && !isError) void fetchNextPage()
|
||||
}, [fetchNextPage, hasNextPage, inView, isError, isFetching])
|
||||
|
||||
const events = new Map(
|
||||
query.data?.pages.flatMap((page) => page.data.map((event) => [event.id, event] as const)),
|
||||
)
|
||||
const days = Map.groupBy(events.values(), (event) => new Date(event.createdAt).toDateString())
|
||||
|
||||
return (
|
||||
<ScrollArea className="min-h-0 flex-1">
|
||||
<div className="space-y-4 p-3">
|
||||
{query.isPending && <p className="text-sm text-muted-foreground">{m.loading()}</p>}
|
||||
{query.isSuccess && events.size === 0 && (
|
||||
<p className="text-sm text-muted-foreground">{m.no_activity_yet()}</p>
|
||||
)}
|
||||
{[...days].map(([day, entries]) => (
|
||||
<section key={day} className="space-y-2">
|
||||
<h3 className="text-xs font-medium text-muted-foreground">
|
||||
{formatDay(new Date(entries[0].createdAt))}
|
||||
</h3>
|
||||
<ul className="space-y-2">
|
||||
{entries.map((event) => (
|
||||
<li
|
||||
key={event.id}
|
||||
className="grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 px-2 py-2"
|
||||
>
|
||||
{event.user ? (
|
||||
<Avatar className="size-8">
|
||||
<AvatarImage src={event.user.image} alt="" />
|
||||
<AvatarFallback>{event.user.name.slice(0, 2).toUpperCase()}</AvatarFallback>
|
||||
</Avatar>
|
||||
) : (
|
||||
<CircleUserRound aria-hidden="true" className="size-8 text-muted-foreground" />
|
||||
)}
|
||||
<div className="min-w-0">
|
||||
<div className="truncate text-sm font-medium">
|
||||
{event.user?.name || m.someone()}
|
||||
</div>
|
||||
<div className="flex items-baseline gap-x-2 text-xs text-muted-foreground">
|
||||
{event.asset && (
|
||||
<span className="min-w-0 truncate" title={event.asset.name ?? undefined}>
|
||||
{event.asset.name ?? m.share_activity_deleted_asset()}
|
||||
</span>
|
||||
)}
|
||||
<time dateTime={event.createdAt} className="shrink-0 whitespace-nowrap">
|
||||
{new Date(event.createdAt).toLocaleTimeString(getLocale(), {
|
||||
timeStyle: 'short',
|
||||
})}
|
||||
</time>
|
||||
</div>
|
||||
</div>
|
||||
<span className="max-w-24 text-right text-xs">{activityLabel(event.kind)}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
))}
|
||||
{query.isError && (
|
||||
<div className="space-y-2">
|
||||
<p className="text-sm text-muted-foreground">{m.share_activity_load_failed()}</p>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() => void (query.isFetchNextPageError ? fetchNextPage() : query.refetch())}
|
||||
>
|
||||
{m.retry()}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{hasNextPage && <div ref={ref}>{query.isFetchingNextPage && m.loading()}</div>}
|
||||
</div>
|
||||
</ScrollArea>
|
||||
)
|
||||
}
|
||||
@@ -52,6 +52,8 @@ const sampleShare: ShareLinkInfo = {
|
||||
rootFolderId: 'folder-share-1',
|
||||
projectId: 'proj-1',
|
||||
isExpired: false,
|
||||
views: 0,
|
||||
lastViewedAt: null,
|
||||
watermarkConfigId: null,
|
||||
watermarkStatus: 'disabled',
|
||||
watermarkConfig: null,
|
||||
|
||||
@@ -9,6 +9,8 @@ import { useMutation, useInfiniteQuery, useQuery, useQueryClient } from '@tansta
|
||||
import { useEffect, useState, useMemo } from 'react'
|
||||
import { FileBrowser } from './file-browser/file-browser'
|
||||
import { ShareSettingsSidebar } from './share-settings-sidebar'
|
||||
import { ShareActivityList } from './share-activity-list'
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from './ui/tabs'
|
||||
import { FolderTree } from './folder-tree'
|
||||
import { ResizeHandle } from './resize-handle'
|
||||
import { useFileSystemDnd } from './use-file-system-dnd'
|
||||
@@ -354,13 +356,30 @@ export default function ShareManager({
|
||||
}
|
||||
/>
|
||||
<div style={{ width: rightSidebarWidth }} className="flex-shrink-0 h-full">
|
||||
<ShareSettingsSidebar
|
||||
shareLink={shareLink}
|
||||
viewMode={displayStyle}
|
||||
onViewModeChange={(mode) => updateShare({ viewMode: mode })}
|
||||
defaultSortOrder={defaultSortOrder}
|
||||
onSortOrderChange={(sortOrder) => updateShare({ defaultSortOrder: sortOrder })}
|
||||
/>
|
||||
<Tabs defaultValue="settings" className="flex h-full min-h-0 flex-col px-2 py-1">
|
||||
<TabsList className="w-full shrink-0">
|
||||
<TabsTrigger value="settings" className="flex-1">
|
||||
{m.settings()}
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="activity" className="flex-1">
|
||||
{m.activity()}
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
<TabsContent value="settings" className="min-h-0 flex-1 overflow-hidden">
|
||||
<ShareSettingsSidebar
|
||||
shareLink={shareLink}
|
||||
viewMode={displayStyle}
|
||||
onViewModeChange={(mode) => updateShare({ viewMode: mode })}
|
||||
defaultSortOrder={defaultSortOrder}
|
||||
onSortOrderChange={(sortOrder) =>
|
||||
updateShare({ defaultSortOrder: sortOrder })
|
||||
}
|
||||
/>
|
||||
</TabsContent>
|
||||
<TabsContent value="activity" className="flex min-h-0 flex-1 flex-col">
|
||||
<ShareActivityList shareId={shareId} />
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { requestShareDownload } from '@/ui/api/share-download'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import { Download, AlertCircle } from 'lucide-react'
|
||||
import React, { useImperativeHandle } from 'react'
|
||||
@@ -18,10 +19,7 @@ export const DefaultViewer = React.forwardRef<MediaController, FileViewerProps>(
|
||||
if (!key || !file.id) return
|
||||
try {
|
||||
const res = shareId
|
||||
? await client.api.shares[':shareId'].files[':fileId']['download-url'].$post({
|
||||
param: { shareId, fileId: file.id },
|
||||
json: { key },
|
||||
})
|
||||
? await requestShareDownload(shareId, file.id, key)
|
||||
: await client.api.files['download-url'].$post({
|
||||
json: { key, assetId: file.id },
|
||||
})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { requestShareDownload } from '@/ui/api/share-download'
|
||||
import DrawingCanvas from '@/ui/components/drawing-canvas'
|
||||
import { useScreenSize } from '@/ui/hooks/useScreenSize'
|
||||
import { getBestTranscode } from '@/ui/lib/media'
|
||||
@@ -118,10 +119,7 @@ export const CompareImagePane = forwardRef<ComparePaneHandle, CompareImagePanePr
|
||||
if (!key || !file.id) return
|
||||
try {
|
||||
const res = shareId
|
||||
? await client.api.shares[':shareId'].files[':fileId']['download-url'].$post({
|
||||
param: { shareId, fileId: file.id },
|
||||
json: { key },
|
||||
})
|
||||
? await requestShareDownload(shareId, file.id, key)
|
||||
: await client.api.files['download-url'].$post({
|
||||
json: { key, assetId: file.id },
|
||||
})
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useScreenSize } from '@/ui/hooks/useScreenSize'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { requestShareDownload } from '@/ui/api/share-download'
|
||||
import { getBestTranscode } from '@/ui/lib/media'
|
||||
import { copyImageToClipboard } from '@/ui/lib/clipboard'
|
||||
import React, { useEffect, useRef, useState, useImperativeHandle } from 'react'
|
||||
@@ -106,10 +107,7 @@ export const ImageViewer = React.forwardRef<MediaController, FileViewerProps>(
|
||||
if (!key || !file.id) return
|
||||
try {
|
||||
const res = shareId
|
||||
? await client.api.shares[':shareId'].files[':fileId']['download-url'].$post({
|
||||
param: { shareId, fileId: file.id },
|
||||
json: { key },
|
||||
})
|
||||
? await requestShareDownload(shareId, file.id, key)
|
||||
: await client.api.files['download-url'].$post({
|
||||
json: { key, assetId: file.id },
|
||||
})
|
||||
|
||||
@@ -2,6 +2,7 @@ import React, { useCallback, useEffect, useImperativeHandle, useRef, useState }
|
||||
import { AlertCircle, Loader2 } from 'lucide-react'
|
||||
import { cn } from '@/ui/lib/utils'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { requestShareDownload } from '@/ui/api/share-download'
|
||||
import DrawingCanvas from '@/ui/components/drawing-canvas'
|
||||
import { useAnnotationStore } from '@/ui/stores/annotation-store'
|
||||
import type { FileViewerProps, MediaController } from '../types'
|
||||
@@ -65,10 +66,7 @@ export const ModelViewer = React.forwardRef<MediaController, FileViewerProps>(
|
||||
if (!key || !data.id) return
|
||||
try {
|
||||
const res = shareId
|
||||
? await client.api.shares[':shareId'].files[':fileId']['download-url'].$post({
|
||||
param: { shareId, fileId: data.id },
|
||||
json: { key },
|
||||
})
|
||||
? await requestShareDownload(shareId, data.id, key)
|
||||
: await client.api.files['download-url'].$post({
|
||||
json: { key, assetId: data.id },
|
||||
})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { requestShareDownload } from '@/ui/api/share-download'
|
||||
import DrawingCanvas from '@/ui/components/drawing-canvas'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import { useAnnotationStore } from '@/ui/stores/annotation-store'
|
||||
@@ -383,10 +384,7 @@ export const PdfViewer = React.forwardRef<MediaController, FileViewerProps>(
|
||||
if (!key || !file.id) return
|
||||
try {
|
||||
const res = shareId
|
||||
? await client.api.shares[':shareId'].files[':fileId']['download-url'].$post({
|
||||
param: { shareId, fileId: file.id },
|
||||
json: { key },
|
||||
})
|
||||
? await requestShareDownload(shareId, file.id, key)
|
||||
: await client.api.files['download-url'].$post({
|
||||
json: { key, assetId: file.id },
|
||||
})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { requestShareDownload } from '@/ui/api/share-download'
|
||||
import DrawingCanvas from '@/ui/components/drawing-canvas'
|
||||
import { cn } from '@/ui/lib/utils'
|
||||
import { useAnnotationStore } from '@/ui/stores/annotation-store'
|
||||
@@ -452,10 +453,7 @@ export const CompareVideoPane = forwardRef<ComparePaneHandle, CompareVideoPanePr
|
||||
if (!dlKey || !file.id) return
|
||||
try {
|
||||
const res = shareId
|
||||
? await client.api.shares[':shareId'].files[':fileId']['download-url'].$post({
|
||||
param: { shareId, fileId: file.id },
|
||||
json: { key: dlKey },
|
||||
})
|
||||
? await requestShareDownload(shareId, file.id, dlKey)
|
||||
: await client.api.files['download-url'].$post({
|
||||
json: { key: dlKey, assetId: file.id },
|
||||
})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { requestShareDownload } from '@/ui/api/share-download'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import { cn } from '@/ui/lib/utils'
|
||||
import { Play, AudioLines, Loader2, AlertCircle } from 'lucide-react'
|
||||
@@ -901,10 +902,7 @@ const VideoViewer = React.forwardRef<MediaController, FileViewerProps>(
|
||||
const handleDownload = async (key: string) => {
|
||||
try {
|
||||
const res = shareId
|
||||
? await client.api.shares[':shareId'].files[':fileId']['download-url'].$post({
|
||||
param: { shareId, fileId: data.id! },
|
||||
json: { key },
|
||||
})
|
||||
? await requestShareDownload(shareId, data.id!, key)
|
||||
: await client.api.files['download-url'].$post({
|
||||
json: { key, assetId: data.id! },
|
||||
})
|
||||
|
||||
@@ -306,6 +306,8 @@ function ShareDialogHarness(): ReactElement {
|
||||
rootFolderId: 'rf-1',
|
||||
projectId: 'proj-1',
|
||||
isExpired: false,
|
||||
views: 0,
|
||||
lastViewedAt: null,
|
||||
watermarkConfigId: null,
|
||||
watermarkStatus: 'disabled',
|
||||
watermarkConfig: null,
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import { createContext, useContext, useEffect, useRef, type ReactNode } from 'react'
|
||||
import { client } from '@/ui/api/client'
|
||||
|
||||
type ShareVisit = {
|
||||
shareId: string
|
||||
assetId?: string
|
||||
submitted: boolean
|
||||
entered: boolean
|
||||
}
|
||||
|
||||
const ShareVisitContext = createContext<{ current: ShareVisit | null } | null>(null)
|
||||
|
||||
export function PublicShareViewProvider({ children }: { children: ReactNode }) {
|
||||
const visit = useRef<ShareVisit | null>(null)
|
||||
return <ShareVisitContext.Provider value={visit}>{children}</ShareVisitContext.Provider>
|
||||
}
|
||||
|
||||
export function usePublicShareView({
|
||||
shareId,
|
||||
assetId,
|
||||
password,
|
||||
ready,
|
||||
}: {
|
||||
shareId: string
|
||||
assetId?: string
|
||||
password: string
|
||||
ready: boolean
|
||||
}) {
|
||||
const visit = useContext(ShareVisitContext)
|
||||
useEffect(() => {
|
||||
if (!visit) return
|
||||
if (visit.current?.shareId !== shareId || visit.current.assetId !== assetId) {
|
||||
visit.current = {
|
||||
shareId,
|
||||
assetId,
|
||||
submitted: false,
|
||||
entered: visit.current?.shareId === shareId && visit.current.entered,
|
||||
}
|
||||
}
|
||||
if (!ready || visit.current.submitted) return
|
||||
|
||||
const activeVisit = visit.current
|
||||
const isShareEntry = !activeVisit.entered
|
||||
activeVisit.submitted = true
|
||||
activeVisit.entered = true
|
||||
void client.api.shares[':shareId'].views
|
||||
.$post(
|
||||
{ param: { shareId }, json: { assetId, isShareEntry } },
|
||||
{ headers: { 'x-share-password': password } },
|
||||
)
|
||||
.then((response) => {
|
||||
if (!response.ok) throw new Error(`Share view returned ${response.status}`)
|
||||
})
|
||||
.catch((error: unknown) => console.error('Failed to record share view', error))
|
||||
}, [assetId, password, ready, shareId, visit])
|
||||
}
|
||||
@@ -1528,6 +1528,17 @@
|
||||
"dependency_added": "Dependency added",
|
||||
"dependency_removed": "Dependency removed",
|
||||
"comments": "Comments",
|
||||
"share_views": "Views",
|
||||
"share_last_viewed": "Last Viewed",
|
||||
"share_never_viewed": "Never viewed",
|
||||
"share_view_activity": "View Activity",
|
||||
"share_activity_opened_share_link": "Opened Share Link",
|
||||
"share_activity_viewed_asset": "Viewed Asset",
|
||||
"share_activity_downloaded": "Downloaded",
|
||||
"share_activity_commented": "Commented",
|
||||
"share_activity_deleted_asset": "Deleted asset",
|
||||
"share_activity_load_failed": "Could not load share activity",
|
||||
"share_download_start_failed": "Some downloads could not be started",
|
||||
"activity": "Activity",
|
||||
"activity_and_runs": "Activity & Runs",
|
||||
"add_comment": "Add Comment",
|
||||
|
||||
@@ -1465,6 +1465,17 @@
|
||||
"search_tasks_to_link": "연결할 작업 검색...",
|
||||
"dependency_added": "의존 관계를 추가했습니다",
|
||||
"dependency_removed": "의존 관계를 제거했습니다",
|
||||
"share_views": "조회 수",
|
||||
"share_last_viewed": "마지막 조회",
|
||||
"share_never_viewed": "조회 기록 없음",
|
||||
"share_view_activity": "활동 보기",
|
||||
"share_activity_opened_share_link": "공유 링크 열기",
|
||||
"share_activity_viewed_asset": "에셋 보기",
|
||||
"share_activity_downloaded": "다운로드",
|
||||
"share_activity_commented": "댓글 작성",
|
||||
"share_activity_deleted_asset": "삭제된 에셋",
|
||||
"share_activity_load_failed": "공유 활동을 불러올 수 없습니다",
|
||||
"share_download_start_failed": "일부 다운로드를 시작할 수 없습니다",
|
||||
"activity": "활동",
|
||||
"activity_and_runs": "활동 및 실행",
|
||||
"add_comment": "댓글 추가",
|
||||
|
||||
@@ -1528,6 +1528,17 @@
|
||||
"dependency_added": "依赖已添加",
|
||||
"dependency_removed": "依赖已移除",
|
||||
"comments": "评论",
|
||||
"share_views": "浏览次数",
|
||||
"share_last_viewed": "最近浏览",
|
||||
"share_never_viewed": "从未浏览",
|
||||
"share_view_activity": "查看活动",
|
||||
"share_activity_opened_share_link": "打开了分享链接",
|
||||
"share_activity_viewed_asset": "浏览了素材",
|
||||
"share_activity_downloaded": "下载了素材",
|
||||
"share_activity_commented": "发表了评论",
|
||||
"share_activity_deleted_asset": "已删除的素材",
|
||||
"share_activity_load_failed": "无法加载分享活动",
|
||||
"share_download_start_failed": "部分下载无法启动",
|
||||
"activity": "活动",
|
||||
"activity_and_runs": "活动与运行",
|
||||
"add_comment": "添加评论",
|
||||
|
||||
@@ -6,6 +6,15 @@ import { m } from '@/ui/paraglide/messages.js'
|
||||
import { copyToClipboard } from '@/ui/lib/clipboard'
|
||||
import { Switch } from '@/ui/components/ui/switch'
|
||||
import { Button } from '@/ui/components/ui/button'
|
||||
import { ShareActivityList } from '@/ui/components/share-activity-list'
|
||||
import {
|
||||
Sheet,
|
||||
SheetContent,
|
||||
SheetDescription,
|
||||
SheetHeader,
|
||||
SheetTitle,
|
||||
} from '@/ui/components/ui/sheet'
|
||||
import { formatTimeAgo } from '@/ui/lib/time'
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
@@ -24,7 +33,7 @@ import {
|
||||
useSuspenseQuery,
|
||||
} from '@tanstack/react-query'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { Copy, ExternalLink, Calendar, Link2, Share2, Loader2 } from 'lucide-react'
|
||||
import { useInView } from 'react-intersection-observer'
|
||||
import { toast } from 'sonner'
|
||||
@@ -56,6 +65,8 @@ function SharesPage() {
|
||||
|
||||
const rootFolderId = projectInfo?.rootFolder
|
||||
const [leftSidebarWidth, setLeftSidebarWidth] = useState(240)
|
||||
const [activityShare, setActivityShare] = useState<ShareLinkInfo | null>(null)
|
||||
const activityTrigger = useRef<HTMLButtonElement | null>(null)
|
||||
|
||||
const {
|
||||
shareConfigLeftSidebarCollapsed: isLeftSidebarCollapsed,
|
||||
@@ -185,6 +196,11 @@ function SharesPage() {
|
||||
<TableHead className="font-semibold px-4 py-3 w-[150px]">
|
||||
{m.created_date()}
|
||||
</TableHead>
|
||||
<TableHead className="font-semibold px-4 py-3">{m.share_views()}</TableHead>
|
||||
<TableHead className="font-semibold px-4 py-3">
|
||||
{m.share_last_viewed()}
|
||||
</TableHead>
|
||||
<TableHead className="font-semibold px-4 py-3">{m.activity()}</TableHead>
|
||||
<TableHead className="font-semibold px-4 py-3 text-right w-[120px]">
|
||||
{m.active()}
|
||||
</TableHead>
|
||||
@@ -260,6 +276,33 @@ function SharesPage() {
|
||||
<span>{new Date(share.createdAt).toLocaleDateString()}</span>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell className="px-4 py-3.5 tabular-nums">
|
||||
{share.views.toLocaleString()}
|
||||
</TableCell>
|
||||
<TableCell className="px-4 py-3.5 text-sm text-muted-foreground">
|
||||
{share.lastViewedAt ? (
|
||||
<time
|
||||
dateTime={share.lastViewedAt}
|
||||
title={new Date(share.lastViewedAt).toLocaleString()}
|
||||
>
|
||||
{formatTimeAgo(share.lastViewedAt)}
|
||||
</time>
|
||||
) : (
|
||||
m.share_never_viewed()
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell className="px-4 py-3.5">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={(event) => {
|
||||
activityTrigger.current = event.currentTarget
|
||||
setActivityShare(share)
|
||||
}}
|
||||
>
|
||||
{m.share_view_activity()}
|
||||
</Button>
|
||||
</TableCell>
|
||||
<TableCell className="px-4 py-3.5 text-right">
|
||||
<div className="flex justify-end">
|
||||
<Switch
|
||||
@@ -283,6 +326,21 @@ function SharesPage() {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Sheet open={!!activityShare} onOpenChange={(open) => !open && setActivityShare(null)}>
|
||||
<SheetContent
|
||||
className="gap-0 sm:max-w-md"
|
||||
onCloseAutoFocus={(event) => {
|
||||
event.preventDefault()
|
||||
activityTrigger.current?.focus()
|
||||
}}
|
||||
>
|
||||
<SheetHeader className="border-b pr-12">
|
||||
<SheetTitle>{m.activity()}</SheetTitle>
|
||||
<SheetDescription className="truncate">{activityShare?.name}</SheetDescription>
|
||||
</SheetHeader>
|
||||
{activityShare && <ShareActivityList shareId={activityShare.id} />}
|
||||
</SheetContent>
|
||||
</Sheet>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import { createFileRoute, Outlet } from '@tanstack/react-router'
|
||||
import { PublicShareViewProvider } from '@/ui/hooks/use-public-share-view'
|
||||
|
||||
function ShareLayout() {
|
||||
return <Outlet />
|
||||
return (
|
||||
<PublicShareViewProvider>
|
||||
<Outlet />
|
||||
</PublicShareViewProvider>
|
||||
)
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/share/$shareId')({
|
||||
|
||||
Reference in New Issue
Block a user