mirror of
https://github.com/hanzoai/sign.git
synced 2026-10-30 14:57:59 +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.
68 lines
1.6 KiB
TypeScript
68 lines
1.6 KiB
TypeScript
import { DOCUMENT_AUDIT_LOG_TYPE } from '@hanzo/esign-lib/types/document-audit-logs';
|
|
import type { ApiRequestMetadata } from '@hanzo/esign-lib/universal/extract-request-metadata';
|
|
import { createDocumentAuditLogData } from '@hanzo/esign-lib/utils/document-audit-logs';
|
|
import { prisma } from '@hanzo/esign-prisma';
|
|
|
|
type UnsafeDeleteEnvelopeItemOptions = {
|
|
envelopeId: string;
|
|
envelopeItemId: string;
|
|
user: {
|
|
id: number;
|
|
name: string | null;
|
|
email: string;
|
|
};
|
|
apiRequestMetadata: ApiRequestMetadata;
|
|
};
|
|
|
|
export const UNSAFE_deleteEnvelopeItem = async ({
|
|
envelopeId,
|
|
envelopeItemId,
|
|
user,
|
|
apiRequestMetadata,
|
|
}: UnsafeDeleteEnvelopeItemOptions) => {
|
|
const result = await prisma.$transaction(async (tx) => {
|
|
const deletedEnvelopeItem = await tx.envelopeItem.delete({
|
|
where: {
|
|
id: envelopeItemId,
|
|
envelopeId,
|
|
},
|
|
select: {
|
|
id: true,
|
|
title: true,
|
|
documentData: {
|
|
select: {
|
|
id: true,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
await tx.documentAuditLog.create({
|
|
data: createDocumentAuditLogData({
|
|
type: DOCUMENT_AUDIT_LOG_TYPE.ENVELOPE_ITEM_DELETED,
|
|
envelopeId,
|
|
data: {
|
|
envelopeItemId: deletedEnvelopeItem.id,
|
|
envelopeItemTitle: deletedEnvelopeItem.title,
|
|
},
|
|
user: {
|
|
name: user.name,
|
|
email: user.email,
|
|
},
|
|
requestMetadata: apiRequestMetadata.requestMetadata,
|
|
}),
|
|
});
|
|
|
|
return deletedEnvelopeItem;
|
|
});
|
|
|
|
await prisma.documentData.delete({
|
|
where: {
|
|
id: result.documentData.id,
|
|
envelopeItem: {
|
|
is: null,
|
|
},
|
|
},
|
|
});
|
|
};
|