share api, queries, permissions, migration, entity lib
Some checks are pending
Node.js CI / build (push) Waiting to run

This commit is contained in:
Francis Cao 2026-01-15 16:25:56 -08:00
parent a270b0afea
commit 29f2c7b7d4
11 changed files with 256 additions and 23 deletions

View file

@ -2,6 +2,7 @@ export * from './link';
export * from './pixel';
export * from './report';
export * from './segment';
export * from './share';
export * from './team';
export * from './teamUser';
export * from './user';

View file

@ -0,0 +1,46 @@
import type { Prisma } from '@/generated/prisma/client';
import prisma from '@/lib/prisma';
export async function findShare(criteria: Prisma.ShareFindUniqueArgs) {
return prisma.client.share.findUnique(criteria);
}
export async function getShare(entityId: string) {
return findShare({
where: {
id: entityId,
},
});
}
export async function getShareByCode(slug: string) {
return findShare({
where: {
slug,
},
});
}
export async function createShare(
data: Prisma.ShareCreateInput | Prisma.ShareUncheckedCreateInput,
) {
return prisma.client.share.create({
data,
});
}
export async function updateShare(
shareId: string,
data: Prisma.ShareUpdateInput | Prisma.ShareUncheckedUpdateInput,
) {
return prisma.client.share.update({
where: {
id: shareId,
},
data,
});
}
export async function deleteShare(shareId: string) {
return prisma.client.share.delete({ where: { id: shareId } });
}

View file

@ -16,15 +16,6 @@ export async function getWebsite(websiteId: string) {
});
}
export async function getSharedWebsite(shareId: string) {
return findWebsite({
where: {
shareId,
deletedAt: null,
},
});
}
export async function getWebsites(criteria: Prisma.WebsiteFindManyArgs, filters: QueryFilters) {
const { search } = filters;
const { getSearchParameters, pagedQuery } = prisma;