Files
zooqueen fb4e3df0e3 rename: @hanzo/sign-* → @hanzo/esign-* (full eSign brand consistency)
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.
2026-06-21 19:56:09 -07:00

69 lines
1.4 KiB
TypeScript

import { EnvelopeType, Prisma } from '@prisma/client';
import { prisma } from '@hanzo/esign-prisma';
type GetAllUsersProps = {
username: string;
email: string;
page: number;
perPage: number;
};
export const findUsers = async ({
username = '',
email = '',
page = 1,
perPage = 10,
}: GetAllUsersProps) => {
// SQLite `LIKE` (Prisma `contains`) is case-insensitive for ASCII, so the
// Postgres `mode: 'insensitive'` is unnecessary and unsupported here.
const whereClause = Prisma.validator<Prisma.UserWhereInput>()({
OR: [
{
name: {
contains: username,
},
},
{
email: {
contains: email,
},
},
],
});
const [users, count] = await Promise.all([
prisma.user.findMany({
select: {
_count: {
select: {
envelopes: {
where: {
type: EnvelopeType.DOCUMENT,
},
},
},
},
id: true,
name: true,
email: true,
roles: true,
},
where: whereClause,
skip: Math.max(page - 1, 0) * perPage,
take: perPage,
}),
prisma.user.count({
where: whereClause,
}),
]);
return {
users: users.map((user) => ({
...user,
documentCount: user._count.envelopes,
})),
totalPages: Math.ceil(count / perPage),
};
};