mirror of
https://github.com/hanzoai/sign.git
synced 2026-10-21 01:21:51 +00:00
The product is branded Hanzo eSign (esign.hanzo.ai, repo hanzoai/esign). Rename all workspace packages @hanzo/sign-* → @hanzo/esign-* (1052 files) and align docker/Dockerfile turbo --scope/--filter to the actual remix package name @hanzo/esign (was a pre-existing mismatch with -remix that broke the build). Protected deps (@hanzo/insights, @hanzo/logo) untouched.
38 lines
1022 B
TypeScript
38 lines
1022 B
TypeScript
import { AppError, AppErrorCode } from '@hanzo/esign-lib/errors/app-error';
|
|
import { prisma } from '@hanzo/esign-prisma';
|
|
|
|
import { TEAM_DOCUMENT_VISIBILITY_MAP } from '../../constants/teams';
|
|
import type { TFolderType } from '../../types/folder-type';
|
|
import { buildTeamWhereQuery } from '../../utils/teams';
|
|
import { getTeamById } from '../team/get-team';
|
|
|
|
export interface GetFolderByIdOptions {
|
|
userId: number;
|
|
teamId: number;
|
|
folderId: string;
|
|
type?: TFolderType;
|
|
}
|
|
|
|
export const getFolderById = async ({ userId, teamId, folderId, type }: GetFolderByIdOptions) => {
|
|
const team = await getTeamById({ userId, teamId });
|
|
|
|
const folder = await prisma.folder.findFirst({
|
|
where: {
|
|
id: folderId,
|
|
team: buildTeamWhereQuery({ teamId, userId }),
|
|
type,
|
|
visibility: {
|
|
in: TEAM_DOCUMENT_VISIBILITY_MAP[team.currentTeamRole],
|
|
},
|
|
},
|
|
});
|
|
|
|
if (!folder) {
|
|
throw new AppError(AppErrorCode.NOT_FOUND, {
|
|
message: 'Folder not found',
|
|
});
|
|
}
|
|
|
|
return folder;
|
|
};
|