mirror of
https://github.com/saltbo/zpan.git
synced 2026-09-21 04:59:47 +08:00
Replace opt-in profile listings with an opt-out private flag and a unified privacy endpoint. BREAKING CHANGE: showOnProfile, listedAt, and the profile-listing endpoints are replaced by private and PUT /api/shares/:token/privacy.
79 lines
2.4 KiB
TypeScript
79 lines
2.4 KiB
TypeScript
import { z } from 'zod'
|
|
|
|
export const shareKindSchema = z.enum(['landing', 'direct'])
|
|
|
|
export type ShareKind = z.infer<typeof shareKindSchema>
|
|
|
|
export const shareRecipientSchema = z.object({
|
|
recipientUserId: z.string().optional(),
|
|
recipientEmail: z.string().email().optional(),
|
|
})
|
|
|
|
export const shareRecipientViewSchema = z.object({
|
|
id: z.string(),
|
|
shareId: z.string(),
|
|
recipientUserId: z.string().nullable(),
|
|
recipientEmail: z.string().nullable(),
|
|
createdAt: z.string(),
|
|
})
|
|
|
|
export const createShareSchema = z.object({
|
|
matterId: z.string().min(1),
|
|
orgId: z.string().min(1),
|
|
creatorId: z.string().min(1),
|
|
kind: shareKindSchema,
|
|
password: z.string().optional(),
|
|
expiresAt: z.date().optional(),
|
|
downloadLimit: z.number().int().positive().optional(),
|
|
recipients: z.array(shareRecipientSchema).optional(),
|
|
private: z.boolean().default(false),
|
|
})
|
|
|
|
export type CreateShareInput = z.input<typeof createShareSchema>
|
|
|
|
export const listSharesQuerySchema = z.object({
|
|
page: z.coerce.number().int().positive().default(1),
|
|
pageSize: z.coerce.number().int().positive().default(20),
|
|
status: z.enum(['active', 'revoked']).optional(),
|
|
box: z.enum(['sent', 'received']).default('sent'),
|
|
})
|
|
|
|
export const createShareRequestSchema = z.object({
|
|
matterId: z.string().min(1),
|
|
kind: shareKindSchema,
|
|
password: z.string().optional(),
|
|
expiresAt: z.string().datetime({ offset: true }).optional(),
|
|
downloadLimit: z.number().int().positive().optional(),
|
|
recipients: z.array(shareRecipientSchema).optional(),
|
|
private: z.boolean().default(false),
|
|
})
|
|
|
|
export type CreateShareRequest = z.input<typeof createShareRequestSchema>
|
|
|
|
export const shareObjectItemSchema = z.object({
|
|
ref: z.string(),
|
|
name: z.string(),
|
|
type: z.string(),
|
|
size: z.number().int().nullable(),
|
|
isFolder: z.boolean(),
|
|
})
|
|
|
|
export const shareObjectsResponseSchema = z.object({
|
|
items: z.array(shareObjectItemSchema),
|
|
total: z.number().int(),
|
|
page: z.number().int(),
|
|
pageSize: z.number().int(),
|
|
breadcrumb: z.array(z.object({ name: z.string(), path: z.string() })),
|
|
})
|
|
|
|
export type ShareObjectItem = z.infer<typeof shareObjectItemSchema>
|
|
export type ShareObjectsResponse = z.infer<typeof shareObjectsResponseSchema>
|
|
|
|
export const saveShareRequestSchema = z.object({
|
|
targetOrgId: z.string().min(1),
|
|
targetParent: z.string().default(''),
|
|
targetSubpath: z.array(z.string()).optional(),
|
|
})
|
|
|
|
export type SaveShareRequest = z.infer<typeof saveShareRequestSchema>
|