Files
esign/packages/lib/server-only/limits/server.ts
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

48 lines
1.0 KiB
TypeScript

import { prisma } from '@hanzo/esign-prisma';
import { SELFHOSTED_PLAN_LIMITS } from './constants';
import { ERROR_CODES } from './errors';
import type { TLimitsResponseSchema } from './schema';
export type GetServerLimitsOptions = {
userId: number;
teamId: number;
};
/**
* Hanzo eSign is fully AGPL — no paywalls, no plan tiers. Every team gets the
* self-hosted unlimited limits.
*/
export const getServerLimits = async ({
userId,
teamId,
}: GetServerLimitsOptions): Promise<TLimitsResponseSchema> => {
const organisation = await prisma.organisation.findFirst({
where: {
teams: {
some: {
id: teamId,
},
},
members: {
some: {
userId,
},
},
},
include: {
organisationClaim: true,
},
});
if (!organisation) {
throw new Error(ERROR_CODES.USER_FETCH_FAILED);
}
return {
quota: SELFHOSTED_PLAN_LIMITS,
remaining: SELFHOSTED_PLAN_LIMITS,
maximumEnvelopeItemCount: organisation.organisationClaim.envelopeItemCount,
};
};