mirror of
https://github.com/documenso/documenso.git
synced 2026-07-25 01:15:49 +10:00
fix: additional backwards compat
This commit is contained in:
@@ -40,6 +40,7 @@ export const getDocumentWithDetailsById = async ({
|
|||||||
fields: envelope.fields.map((field) => ({
|
fields: envelope.fields.map((field) => ({
|
||||||
...field,
|
...field,
|
||||||
documentId: legacyDocumentId,
|
documentId: legacyDocumentId,
|
||||||
|
templateId: null,
|
||||||
})),
|
})),
|
||||||
user: {
|
user: {
|
||||||
id: envelope.userId,
|
id: envelope.userId,
|
||||||
@@ -50,6 +51,16 @@ export const getDocumentWithDetailsById = async ({
|
|||||||
id: envelope.teamId,
|
id: envelope.teamId,
|
||||||
url: envelope.team.url,
|
url: envelope.team.url,
|
||||||
},
|
},
|
||||||
recipients: envelope.recipients,
|
recipients: envelope.recipients.map((recipient) => ({
|
||||||
|
...recipient,
|
||||||
|
documentId: legacyDocumentId,
|
||||||
|
templateId: null,
|
||||||
|
})),
|
||||||
|
documentDataId: firstDocumentData.id,
|
||||||
|
documentMeta: {
|
||||||
|
...envelope.documentMeta,
|
||||||
|
documentId: legacyDocumentId,
|
||||||
|
password: null,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -265,6 +265,8 @@ export const createEnvelope = async ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const firstEnvelopeItem = envelope.envelopeItems[0];
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
(data.recipients || []).map(async (recipient) => {
|
(data.recipients || []).map(async (recipient) => {
|
||||||
const recipientAuthOptions = createRecipientAuthOptions({
|
const recipientAuthOptions = createRecipientAuthOptions({
|
||||||
@@ -272,44 +274,37 @@ export const createEnvelope = async ({
|
|||||||
actionAuth: recipient.actionAuth ?? [],
|
actionAuth: recipient.actionAuth ?? [],
|
||||||
});
|
});
|
||||||
|
|
||||||
// Todo: Envelopes - Allow fields.
|
const recipientFieldsToCreate = (recipient.fields || []).map((field) => {
|
||||||
// const recipientFieldsToCreate = (recipient.fields || []).map((field) => {
|
let envelopeItemId = firstEnvelopeItem.id;
|
||||||
// let envelopeItemId = envelope.envelopeItems[0].id;?
|
|
||||||
|
|
||||||
// const foundEnvelopeItem = envelope.envelopeItems.find(
|
if (field.documentDataId) {
|
||||||
// (item) => item.documentDataId === field.documentDataId,
|
const foundEnvelopeItem = envelope.envelopeItems.find(
|
||||||
// );
|
(item) => item.documentDataId === field.documentDataId,
|
||||||
|
);
|
||||||
|
|
||||||
// if (field.documentDataId && !foundEnvelopeItem) {
|
if (!foundEnvelopeItem) {
|
||||||
// throw new AppError(AppErrorCode.INVALID_REQUEST, {
|
throw new AppError(AppErrorCode.NOT_FOUND, {
|
||||||
// message: 'Envelope item not found',
|
message: 'Document data not found',
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (foundEnvelopeItem) {
|
envelopeItemId = foundEnvelopeItem.id;
|
||||||
// envelopeItemId = foundEnvelopeItem.id;
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// if (!envelopeItemId) {
|
return {
|
||||||
// throw new AppError(AppErrorCode.INVALID_REQUEST, {
|
envelopeId: envelope.id,
|
||||||
// message: 'Envelope item not found',
|
envelopeItemId,
|
||||||
// });
|
type: field.type,
|
||||||
// }
|
page: field.page,
|
||||||
|
positionX: field.positionX,
|
||||||
// return {
|
positionY: field.positionY,
|
||||||
// envelopeId: envelope.id,
|
width: field.width,
|
||||||
// envelopeItemId,
|
height: field.height,
|
||||||
// type: field.type,
|
customText: '',
|
||||||
// page: field.page,
|
inserted: false,
|
||||||
// positionX: field.positionX,
|
fieldMeta: field.fieldMeta || undefined,
|
||||||
// positionY: field.positionY,
|
};
|
||||||
// width: field.width,
|
});
|
||||||
// height: field.height,
|
|
||||||
// customText: '',
|
|
||||||
// inserted: false,
|
|
||||||
// fieldMeta: field.fieldMeta || undefined,
|
|
||||||
// };
|
|
||||||
// });
|
|
||||||
|
|
||||||
await tx.recipient.create({
|
await tx.recipient.create({
|
||||||
data: {
|
data: {
|
||||||
@@ -323,11 +318,11 @@ export const createEnvelope = async ({
|
|||||||
signingStatus:
|
signingStatus:
|
||||||
recipient.role === RecipientRole.CC ? SigningStatus.SIGNED : SigningStatus.NOT_SIGNED,
|
recipient.role === RecipientRole.CC ? SigningStatus.SIGNED : SigningStatus.NOT_SIGNED,
|
||||||
authOptions: recipientAuthOptions,
|
authOptions: recipientAuthOptions,
|
||||||
// fields: {
|
fields: {
|
||||||
// createMany: {
|
createMany: {
|
||||||
// data: recipientFieldsToCreate,
|
data: recipientFieldsToCreate,
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -116,9 +116,14 @@ const ZEnvelopeForSigningResponse = z.object({
|
|||||||
signingOrder: true,
|
signingOrder: true,
|
||||||
rejectionReason: true,
|
rejectionReason: true,
|
||||||
}).extend({
|
}).extend({
|
||||||
fields: ZFieldSchema.extend({
|
fields: ZFieldSchema.omit({
|
||||||
signature: SignatureSchema.nullish(),
|
documentId: true,
|
||||||
}).array(),
|
templateId: true,
|
||||||
|
})
|
||||||
|
.extend({
|
||||||
|
signature: SignatureSchema.nullish(),
|
||||||
|
})
|
||||||
|
.array(),
|
||||||
}),
|
}),
|
||||||
recipientSignature: SignatureSchema.pick({
|
recipientSignature: SignatureSchema.pick({
|
||||||
signatureImageAsBase64: true,
|
signatureImageAsBase64: true,
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { prisma } from '@documenso/prisma';
|
|||||||
|
|
||||||
import { AppError, AppErrorCode } from '../../errors/app-error';
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||||
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
||||||
|
import { mapFieldToLegacyField } from '../../utils/fields';
|
||||||
import { canRecipientFieldsBeModified } from '../../utils/recipients';
|
import { canRecipientFieldsBeModified } from '../../utils/recipients';
|
||||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||||
|
|
||||||
@@ -162,6 +163,6 @@ export const createEnvelopeFields = async ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fields: createdFields,
|
fields: createdFields.map((field) => mapFieldToLegacyField(field, envelope)),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import type { EnvelopeType } from '@prisma/client';
|
|||||||
import { prisma } from '@documenso/prisma';
|
import { prisma } from '@documenso/prisma';
|
||||||
|
|
||||||
import { AppError, AppErrorCode } from '../../errors/app-error';
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||||
|
import { mapFieldToLegacyField } from '../../utils/fields';
|
||||||
import { buildTeamWhereQuery } from '../../utils/teams';
|
import { buildTeamWhereQuery } from '../../utils/teams';
|
||||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||||
|
|
||||||
@@ -56,5 +57,5 @@ export const getFieldById = async ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return field;
|
return mapFieldToLegacyField(field, envelope);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import { prisma } from '@documenso/prisma';
|
|||||||
|
|
||||||
import { AppError, AppErrorCode } from '../../errors/app-error';
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||||
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
||||||
|
import { mapFieldToLegacyField } from '../../utils/fields';
|
||||||
import { canRecipientFieldsBeModified } from '../../utils/recipients';
|
import { canRecipientFieldsBeModified } from '../../utils/recipients';
|
||||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||||
|
|
||||||
@@ -345,7 +346,9 @@ export const setFieldsForDocument = async ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fields: [...filteredFields, ...persistedFields],
|
fields: [...filteredFields, ...persistedFields].map((field) =>
|
||||||
|
mapFieldToLegacyField(field, envelope),
|
||||||
|
),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import { prisma } from '@documenso/prisma';
|
|||||||
|
|
||||||
import { AppError, AppErrorCode } from '../../errors/app-error';
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||||
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
||||||
|
import { mapFieldToLegacyField } from '../../utils/fields';
|
||||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||||
|
|
||||||
export type SetFieldsForTemplateOptions = {
|
export type SetFieldsForTemplateOptions = {
|
||||||
@@ -240,6 +241,8 @@ export const setFieldsForTemplate = async ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fields: [...filteredFields, ...persistedFields],
|
fields: [...filteredFields, ...persistedFields].map((field) =>
|
||||||
|
mapFieldToLegacyField(field, envelope),
|
||||||
|
),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
import { prisma } from '@documenso/prisma';
|
import { prisma } from '@documenso/prisma';
|
||||||
|
|
||||||
import { AppError, AppErrorCode } from '../../errors/app-error';
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||||
|
import { mapFieldToLegacyField } from '../../utils/fields';
|
||||||
import { canRecipientFieldsBeModified } from '../../utils/recipients';
|
import { canRecipientFieldsBeModified } from '../../utils/recipients';
|
||||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||||
|
|
||||||
@@ -146,6 +147,6 @@ export const updateDocumentFields = async ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fields: updatedFields,
|
fields: updatedFields.map((field) => mapFieldToLegacyField(field, envelope)),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import type { TFieldMetaSchema } from '@documenso/lib/types/field-meta';
|
|||||||
import { prisma } from '@documenso/prisma';
|
import { prisma } from '@documenso/prisma';
|
||||||
|
|
||||||
import { AppError, AppErrorCode } from '../../errors/app-error';
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||||
|
import { mapFieldToLegacyField } from '../../utils/fields';
|
||||||
import { canRecipientFieldsBeModified } from '../../utils/recipients';
|
import { canRecipientFieldsBeModified } from '../../utils/recipients';
|
||||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||||
|
|
||||||
@@ -110,6 +111,6 @@ export const updateTemplateFields = async ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fields: updatedFields,
|
fields: updatedFields.map((field) => mapFieldToLegacyField(field, envelope)),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { prisma } from '@documenso/prisma';
|
|||||||
|
|
||||||
import { AppError, AppErrorCode } from '../../errors/app-error';
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||||
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
||||||
|
import { mapRecipientToLegacyRecipient } from '../../utils/recipients';
|
||||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||||
|
|
||||||
export interface CreateDocumentRecipientsOptions {
|
export interface CreateDocumentRecipientsOptions {
|
||||||
@@ -133,6 +134,8 @@ export const createDocumentRecipients = async ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
recipients: createdRecipients,
|
recipients: createdRecipients.map((recipient) =>
|
||||||
|
mapRecipientToLegacyRecipient(recipient, envelope),
|
||||||
|
),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { createRecipientAuthOptions } from '@documenso/lib/utils/document-auth';
|
|||||||
import { prisma } from '@documenso/prisma';
|
import { prisma } from '@documenso/prisma';
|
||||||
|
|
||||||
import { AppError, AppErrorCode } from '../../errors/app-error';
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||||
|
import { mapRecipientToLegacyRecipient } from '../../utils/recipients';
|
||||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||||
|
|
||||||
export interface CreateTemplateRecipientsOptions {
|
export interface CreateTemplateRecipientsOptions {
|
||||||
@@ -107,6 +108,8 @@ export const createTemplateRecipients = async ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
recipients: createdRecipients,
|
recipients: createdRecipients.map((recipient) =>
|
||||||
|
mapRecipientToLegacyRecipient(recipient, template),
|
||||||
|
),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { EnvelopeType } from '@prisma/client';
|
import { EnvelopeType } from '@prisma/client';
|
||||||
import { match } from 'ts-pattern';
|
|
||||||
|
|
||||||
import { prisma } from '@documenso/prisma';
|
import { prisma } from '@documenso/prisma';
|
||||||
|
|
||||||
@@ -48,14 +47,16 @@ export const getRecipientById = async ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const legacyId = match(type)
|
const legacyId = {
|
||||||
.with(EnvelopeType.DOCUMENT, () => ({
|
documentId:
|
||||||
documentId: mapSecondaryIdToDocumentId(recipient.envelope.secondaryId),
|
type === EnvelopeType.DOCUMENT
|
||||||
}))
|
? mapSecondaryIdToDocumentId(recipient.envelope.secondaryId)
|
||||||
.with(EnvelopeType.TEMPLATE, () => ({
|
: null,
|
||||||
templateId: mapSecondaryIdToTemplateId(recipient.envelope.secondaryId),
|
templateId:
|
||||||
}))
|
type === EnvelopeType.TEMPLATE
|
||||||
.exhaustive();
|
? mapSecondaryIdToTemplateId(recipient.envelope.secondaryId)
|
||||||
|
: null,
|
||||||
|
};
|
||||||
|
|
||||||
// Backwards compatibility mapping.
|
// Backwards compatibility mapping.
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import { getI18nInstance } from '../../client-only/providers/i18n-server';
|
|||||||
import { NEXT_PUBLIC_WEBAPP_URL } from '../../constants/app';
|
import { NEXT_PUBLIC_WEBAPP_URL } from '../../constants/app';
|
||||||
import { AppError, AppErrorCode } from '../../errors/app-error';
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||||
import { extractDerivedDocumentEmailSettings } from '../../types/document-email';
|
import { extractDerivedDocumentEmailSettings } from '../../types/document-email';
|
||||||
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
import { type EnvelopeIdOptions, mapSecondaryIdToDocumentId } from '../../utils/envelope';
|
||||||
import { canRecipientBeModified } from '../../utils/recipients';
|
import { canRecipientBeModified } from '../../utils/recipients';
|
||||||
import { renderEmailWithI18N } from '../../utils/render-email-with-i18n';
|
import { renderEmailWithI18N } from '../../utils/render-email-with-i18n';
|
||||||
import { getEmailContext } from '../email/get-email-context';
|
import { getEmailContext } from '../email/get-email-context';
|
||||||
@@ -344,7 +344,11 @@ export const setDocumentRecipients = async ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
recipients: [...filteredRecipients, ...persistedRecipients],
|
recipients: [...filteredRecipients, ...persistedRecipients].map((recipient) => ({
|
||||||
|
...recipient,
|
||||||
|
documentId: mapSecondaryIdToDocumentId(envelope.secondaryId),
|
||||||
|
templateId: null,
|
||||||
|
})),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
} from '../../types/document-auth';
|
} from '../../types/document-auth';
|
||||||
import { nanoid } from '../../universal/id';
|
import { nanoid } from '../../universal/id';
|
||||||
import { createRecipientAuthOptions } from '../../utils/document-auth';
|
import { createRecipientAuthOptions } from '../../utils/document-auth';
|
||||||
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
import { type EnvelopeIdOptions, mapSecondaryIdToTemplateId } from '../../utils/envelope';
|
||||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||||
|
|
||||||
export type SetTemplateRecipientsOptions = {
|
export type SetTemplateRecipientsOptions = {
|
||||||
@@ -211,6 +211,10 @@ export const setTemplateRecipients = async ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
recipients: [...filteredRecipients, ...persistedRecipients],
|
recipients: [...filteredRecipients, ...persistedRecipients].map((recipient) => ({
|
||||||
|
...recipient,
|
||||||
|
documentId: null,
|
||||||
|
templateId: mapSecondaryIdToTemplateId(envelope.secondaryId),
|
||||||
|
})),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ import { createRecipientAuthOptions } from '@documenso/lib/utils/document-auth';
|
|||||||
import { prisma } from '@documenso/prisma';
|
import { prisma } from '@documenso/prisma';
|
||||||
|
|
||||||
import { AppError, AppErrorCode } from '../../errors/app-error';
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||||
import type { EnvelopeIdOptions } from '../../utils/envelope';
|
import { type EnvelopeIdOptions, mapSecondaryIdToDocumentId } from '../../utils/envelope';
|
||||||
|
import { mapFieldToLegacyField } from '../../utils/fields';
|
||||||
import { canRecipientBeModified } from '../../utils/recipients';
|
import { canRecipientBeModified } from '../../utils/recipients';
|
||||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||||
|
|
||||||
@@ -185,7 +186,12 @@ export const updateDocumentRecipients = async ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
recipients: updatedRecipients,
|
recipients: updatedRecipients.map((recipient) => ({
|
||||||
|
...recipient,
|
||||||
|
documentId: mapSecondaryIdToDocumentId(envelope.secondaryId),
|
||||||
|
templateId: null,
|
||||||
|
fields: recipient.fields.map((field) => mapFieldToLegacyField(field, envelope)),
|
||||||
|
})),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import { createRecipientAuthOptions } from '@documenso/lib/utils/document-auth';
|
|||||||
import { prisma } from '@documenso/prisma';
|
import { prisma } from '@documenso/prisma';
|
||||||
|
|
||||||
import { AppError, AppErrorCode } from '../../errors/app-error';
|
import { AppError, AppErrorCode } from '../../errors/app-error';
|
||||||
|
import { mapSecondaryIdToTemplateId } from '../../utils/envelope';
|
||||||
|
import { mapFieldToLegacyField } from '../../utils/fields';
|
||||||
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
import { getEnvelopeWhereInput } from '../envelope/get-envelope-by-id';
|
||||||
|
|
||||||
export interface UpdateTemplateRecipientsOptions {
|
export interface UpdateTemplateRecipientsOptions {
|
||||||
@@ -156,6 +158,11 @@ export const updateTemplateRecipients = async ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
recipients: updatedRecipients,
|
recipients: updatedRecipients.map((recipient) => ({
|
||||||
|
...recipient,
|
||||||
|
documentId: null,
|
||||||
|
templateId: mapSecondaryIdToTemplateId(envelope.secondaryId),
|
||||||
|
fields: recipient.fields.map((field) => mapFieldToLegacyField(field, envelope)),
|
||||||
|
})),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,10 +48,12 @@ export const getTemplateByDirectLinkToken = async ({
|
|||||||
|
|
||||||
const recipientsWithMappedFields = envelope.recipients.map((recipient) => ({
|
const recipientsWithMappedFields = envelope.recipients.map((recipient) => ({
|
||||||
...recipient,
|
...recipient,
|
||||||
|
templateId: mapSecondaryIdToTemplateId(envelope.secondaryId),
|
||||||
|
documentId: null,
|
||||||
fields: recipient.fields.map((field) => ({
|
fields: recipient.fields.map((field) => ({
|
||||||
...field,
|
...field,
|
||||||
templateId: mapSecondaryIdToTemplateId(envelope.secondaryId),
|
templateId: mapSecondaryIdToTemplateId(envelope.secondaryId),
|
||||||
documentId: undefined,
|
documentId: null,
|
||||||
})),
|
})),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -71,6 +73,7 @@ export const getTemplateByDirectLinkToken = async ({
|
|||||||
publicTitle: envelope.publicTitle,
|
publicTitle: envelope.publicTitle,
|
||||||
publicDescription: envelope.publicDescription,
|
publicDescription: envelope.publicDescription,
|
||||||
folderId: envelope.folderId,
|
folderId: envelope.folderId,
|
||||||
|
templateDocumentDataId: firstDocumentData.id,
|
||||||
templateDocumentData: {
|
templateDocumentData: {
|
||||||
...firstDocumentData,
|
...firstDocumentData,
|
||||||
envelopeItemId: envelope.envelopeItems[0].id,
|
envelopeItemId: envelope.envelopeItems[0].id,
|
||||||
@@ -79,7 +82,10 @@ export const getTemplateByDirectLinkToken = async ({
|
|||||||
...directLink,
|
...directLink,
|
||||||
templateId: mapSecondaryIdToTemplateId(envelope.secondaryId),
|
templateId: mapSecondaryIdToTemplateId(envelope.secondaryId),
|
||||||
},
|
},
|
||||||
templateMeta: envelope.documentMeta,
|
templateMeta: {
|
||||||
|
...envelope.documentMeta,
|
||||||
|
templateId: mapSecondaryIdToTemplateId(envelope.secondaryId),
|
||||||
|
},
|
||||||
recipients: recipientsWithMappedFields,
|
recipients: recipientsWithMappedFields,
|
||||||
fields: recipientsWithMappedFields.flatMap((recipient) => recipient.fields),
|
fields: recipientsWithMappedFields.flatMap((recipient) => recipient.fields),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -68,13 +68,23 @@ export const getTemplateById = async ({ id, userId, teamId }: GetTemplateByIdOpt
|
|||||||
...rest,
|
...rest,
|
||||||
envelopeId: envelope.id,
|
envelopeId: envelope.id,
|
||||||
type: envelope.templateType,
|
type: envelope.templateType,
|
||||||
|
templateDocumentDataId: firstTemplateDocumentData.id,
|
||||||
templateDocumentData: {
|
templateDocumentData: {
|
||||||
...firstTemplateDocumentData,
|
...firstTemplateDocumentData,
|
||||||
envelopeItemId: envelope.envelopeItems[0].id,
|
envelopeItemId: envelope.envelopeItems[0].id,
|
||||||
},
|
},
|
||||||
templateMeta: envelope.documentMeta,
|
templateMeta: {
|
||||||
|
...envelope.documentMeta,
|
||||||
|
templateId: legacyTemplateId,
|
||||||
|
},
|
||||||
fields: envelope.fields.map((field) => ({
|
fields: envelope.fields.map((field) => ({
|
||||||
...field,
|
...field,
|
||||||
|
documentId: null,
|
||||||
|
templateId: legacyTemplateId,
|
||||||
|
})),
|
||||||
|
recipients: envelope.recipients.map((recipient) => ({
|
||||||
|
...recipient,
|
||||||
|
documentId: null,
|
||||||
templateId: legacyTemplateId,
|
templateId: legacyTemplateId,
|
||||||
})),
|
})),
|
||||||
directLink: envelope.directLink
|
directLink: envelope.directLink
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ export const ZDocumentSchema = LegacyDocumentSchema.pick({
|
|||||||
.nullish()
|
.nullish()
|
||||||
.describe('The ID of the template that the document was created from, if any.'),
|
.describe('The ID of the template that the document was created from, if any.'),
|
||||||
|
|
||||||
|
// Backwards compatibility.
|
||||||
|
documentDataId: z.string().default(''),
|
||||||
|
|
||||||
// Todo: Maybe we want to alter this a bit since this returns a lot of data.
|
// Todo: Maybe we want to alter this a bit since this returns a lot of data.
|
||||||
documentData: DocumentDataSchema.pick({
|
documentData: DocumentDataSchema.pick({
|
||||||
type: true,
|
type: true,
|
||||||
@@ -66,7 +69,11 @@ export const ZDocumentSchema = LegacyDocumentSchema.pick({
|
|||||||
emailSettings: true,
|
emailSettings: true,
|
||||||
emailId: true,
|
emailId: true,
|
||||||
emailReplyTo: true,
|
emailReplyTo: true,
|
||||||
}).nullable(),
|
}).extend({
|
||||||
|
password: z.string().nullable().default(null),
|
||||||
|
documentId: z.number().default(-1).optional(),
|
||||||
|
}),
|
||||||
|
|
||||||
folder: FolderSchema.pick({
|
folder: FolderSchema.pick({
|
||||||
id: true,
|
id: true,
|
||||||
name: true,
|
name: true,
|
||||||
@@ -108,6 +115,9 @@ export const ZDocumentLiteSchema = LegacyDocumentSchema.pick({
|
|||||||
}).extend({
|
}).extend({
|
||||||
envelopeId: z.string(),
|
envelopeId: z.string(),
|
||||||
|
|
||||||
|
// Backwards compatibility.
|
||||||
|
documentDataId: z.string().default(''),
|
||||||
|
|
||||||
// Which "Template" the document was created from.
|
// Which "Template" the document was created from.
|
||||||
templateId: z
|
templateId: z
|
||||||
.number()
|
.number()
|
||||||
@@ -140,6 +150,9 @@ export const ZDocumentManySchema = LegacyDocumentSchema.pick({
|
|||||||
}).extend({
|
}).extend({
|
||||||
envelopeId: z.string(),
|
envelopeId: z.string(),
|
||||||
|
|
||||||
|
// Backwards compatibility.
|
||||||
|
documentDataId: z.string().default(''),
|
||||||
|
|
||||||
// Which "Template" the document was created from.
|
// Which "Template" the document was created from.
|
||||||
templateId: z
|
templateId: z
|
||||||
.number()
|
.number()
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ export const ZTemplateSchema = TemplateSchema.pick({
|
|||||||
}).extend({
|
}).extend({
|
||||||
envelopeId: z.string(),
|
envelopeId: z.string(),
|
||||||
|
|
||||||
|
// Backwards compatibility.
|
||||||
|
templateDocumentDataId: z.string().default(''),
|
||||||
|
|
||||||
// Todo: Maybe we want to alter this a bit since this returns a lot of data.
|
// Todo: Maybe we want to alter this a bit since this returns a lot of data.
|
||||||
templateDocumentData: DocumentDataSchema.pick({
|
templateDocumentData: DocumentDataSchema.pick({
|
||||||
type: true,
|
type: true,
|
||||||
@@ -61,6 +64,8 @@ export const ZTemplateSchema = TemplateSchema.pick({
|
|||||||
emailSettings: true,
|
emailSettings: true,
|
||||||
emailId: true,
|
emailId: true,
|
||||||
emailReplyTo: true,
|
emailReplyTo: true,
|
||||||
|
}).extend({
|
||||||
|
templateId: z.number().nullable(),
|
||||||
}),
|
}),
|
||||||
directLink: LegacyTemplateDirectLinkSchema.nullable(),
|
directLink: LegacyTemplateDirectLinkSchema.nullable(),
|
||||||
user: UserSchema.pick({
|
user: UserSchema.pick({
|
||||||
@@ -106,6 +111,9 @@ export const ZTemplateLiteSchema = TemplateSchema.pick({
|
|||||||
useLegacyFieldInsertion: true,
|
useLegacyFieldInsertion: true,
|
||||||
}).extend({
|
}).extend({
|
||||||
envelopeId: z.string(),
|
envelopeId: z.string(),
|
||||||
|
|
||||||
|
// Backwards compatibility.
|
||||||
|
templateDocumentDataId: z.string().default(''),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TTemplateLite = z.infer<typeof ZTemplateLiteSchema>;
|
export type TTemplateLite = z.infer<typeof ZTemplateLiteSchema>;
|
||||||
@@ -144,6 +152,8 @@ export const ZTemplateManySchema = TemplateSchema.pick({
|
|||||||
token: true,
|
token: true,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
}).nullable(),
|
}).nullable(),
|
||||||
|
// Backwards compatibility.
|
||||||
|
templateDocumentDataId: z.string().default(''),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TTemplateMany = z.infer<typeof ZTemplateManySchema>;
|
export type TTemplateMany = z.infer<typeof ZTemplateManySchema>;
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
|
import type { Envelope } from '@prisma/client';
|
||||||
|
import { EnvelopeType } from '@prisma/client';
|
||||||
import { customAlphabet } from 'nanoid';
|
import { customAlphabet } from 'nanoid';
|
||||||
|
|
||||||
|
import { mapSecondaryIdToDocumentId, mapSecondaryIdToTemplateId } from '../utils/envelope';
|
||||||
|
|
||||||
export const alphaid = customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', 21);
|
export const alphaid = customAlphabet('0123456789abcdefghijklmnopqrstuvwxyz', 21);
|
||||||
|
|
||||||
export { nanoid } from 'nanoid';
|
export { nanoid } from 'nanoid';
|
||||||
@@ -29,3 +33,16 @@ type DatabaseIdPrefix =
|
|||||||
| 'team_setting';
|
| 'team_setting';
|
||||||
|
|
||||||
export const generateDatabaseId = (prefix: DatabaseIdPrefix) => prefixedId(prefix, 16);
|
export const generateDatabaseId = (prefix: DatabaseIdPrefix) => prefixedId(prefix, 16);
|
||||||
|
|
||||||
|
export const extractLegacyIds = (envelope: Pick<Envelope, 'type' | 'secondaryId'>) => {
|
||||||
|
return {
|
||||||
|
documentId:
|
||||||
|
envelope.type === EnvelopeType.DOCUMENT
|
||||||
|
? mapSecondaryIdToDocumentId(envelope.secondaryId)
|
||||||
|
: null,
|
||||||
|
templateId:
|
||||||
|
envelope.type === EnvelopeType.TEMPLATE
|
||||||
|
? mapSecondaryIdToTemplateId(envelope.secondaryId)
|
||||||
|
: null,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { DEFAULT_DOCUMENT_TIME_ZONE } from '../constants/time-zones';
|
|||||||
import type { TDocumentLite, TDocumentMany } from '../types/document';
|
import type { TDocumentLite, TDocumentMany } from '../types/document';
|
||||||
import { DEFAULT_DOCUMENT_EMAIL_SETTINGS } from '../types/document-email';
|
import { DEFAULT_DOCUMENT_EMAIL_SETTINGS } from '../types/document-email';
|
||||||
import { mapSecondaryIdToDocumentId } from './envelope';
|
import { mapSecondaryIdToDocumentId } from './envelope';
|
||||||
|
import { mapRecipientToLegacyRecipient } from './recipients';
|
||||||
|
|
||||||
export const isDocumentCompleted = (document: Pick<Envelope, 'status'> | DocumentStatus) => {
|
export const isDocumentCompleted = (document: Pick<Envelope, 'status'> | DocumentStatus) => {
|
||||||
const status = typeof document === 'string' ? document : document.status;
|
const status = typeof document === 'string' ? document : document.status;
|
||||||
@@ -84,6 +85,7 @@ export const mapEnvelopeToDocumentLite = (envelope: Envelope): TDocumentLite =>
|
|||||||
formValues: envelope.formValues,
|
formValues: envelope.formValues,
|
||||||
title: envelope.title,
|
title: envelope.title,
|
||||||
createdAt: envelope.createdAt,
|
createdAt: envelope.createdAt,
|
||||||
|
documentDataId: '', // Backwards compatibility.
|
||||||
updatedAt: envelope.updatedAt,
|
updatedAt: envelope.updatedAt,
|
||||||
completedAt: envelope.completedAt,
|
completedAt: envelope.completedAt,
|
||||||
deletedAt: envelope.deletedAt,
|
deletedAt: envelope.deletedAt,
|
||||||
@@ -122,6 +124,7 @@ export const mapEnvelopesToDocumentMany = (
|
|||||||
formValues: envelope.formValues,
|
formValues: envelope.formValues,
|
||||||
title: envelope.title,
|
title: envelope.title,
|
||||||
createdAt: envelope.createdAt,
|
createdAt: envelope.createdAt,
|
||||||
|
documentDataId: '', // Backwards compatibility.
|
||||||
updatedAt: envelope.updatedAt,
|
updatedAt: envelope.updatedAt,
|
||||||
completedAt: envelope.completedAt,
|
completedAt: envelope.completedAt,
|
||||||
deletedAt: envelope.deletedAt,
|
deletedAt: envelope.deletedAt,
|
||||||
@@ -138,6 +141,8 @@ export const mapEnvelopesToDocumentMany = (
|
|||||||
id: envelope.teamId,
|
id: envelope.teamId,
|
||||||
url: envelope.team.url,
|
url: envelope.team.url,
|
||||||
},
|
},
|
||||||
recipients: envelope.recipients,
|
recipients: envelope.recipients.map((recipient) =>
|
||||||
|
mapRecipientToLegacyRecipient(recipient, envelope),
|
||||||
|
),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import type { Field } from '@prisma/client';
|
import { type Envelope, type Field } from '@prisma/client';
|
||||||
|
|
||||||
|
import { extractLegacyIds } from '../universal/id';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sort the fields by the Y position on the document.
|
* Sort the fields by the Y position on the document.
|
||||||
@@ -63,3 +65,15 @@ export const validateFieldsUninserted = (): boolean => {
|
|||||||
|
|
||||||
return errorElements.length === 0;
|
return errorElements.length === 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const mapFieldToLegacyField = (
|
||||||
|
field: Field,
|
||||||
|
envelope: Pick<Envelope, 'type' | 'secondaryId'>,
|
||||||
|
) => {
|
||||||
|
const legacyId = extractLegacyIds(envelope);
|
||||||
|
|
||||||
|
return {
|
||||||
|
...field,
|
||||||
|
...legacyId,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
import type { Envelope } from '@prisma/client';
|
||||||
import { type Field, type Recipient, RecipientRole, SigningStatus } from '@prisma/client';
|
import { type Field, type Recipient, RecipientRole, SigningStatus } from '@prisma/client';
|
||||||
|
|
||||||
import { NEXT_PUBLIC_WEBAPP_URL } from '../constants/app';
|
import { NEXT_PUBLIC_WEBAPP_URL } from '../constants/app';
|
||||||
|
import { extractLegacyIds } from '../universal/id';
|
||||||
|
|
||||||
export const formatSigningLink = (token: string) => `${NEXT_PUBLIC_WEBAPP_URL()}/sign/${token}`;
|
export const formatSigningLink = (token: string) => `${NEXT_PUBLIC_WEBAPP_URL()}/sign/${token}`;
|
||||||
|
|
||||||
@@ -44,3 +46,15 @@ export const canRecipientFieldsBeModified = (recipient: Recipient, fields: Field
|
|||||||
|
|
||||||
return recipient.role !== RecipientRole.VIEWER && recipient.role !== RecipientRole.CC;
|
return recipient.role !== RecipientRole.VIEWER && recipient.role !== RecipientRole.CC;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const mapRecipientToLegacyRecipient = (
|
||||||
|
recipient: Recipient,
|
||||||
|
envelope: Pick<Envelope, 'type' | 'secondaryId'>,
|
||||||
|
) => {
|
||||||
|
const legacyId = extractLegacyIds(envelope);
|
||||||
|
|
||||||
|
return {
|
||||||
|
...recipient,
|
||||||
|
...legacyId,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|||||||
@@ -65,5 +65,6 @@ export const mapEnvelopeToTemplateLite = (envelope: Envelope): TTemplateLite =>
|
|||||||
publicDescription: envelope.publicDescription,
|
publicDescription: envelope.publicDescription,
|
||||||
folderId: envelope.folderId,
|
folderId: envelope.folderId,
|
||||||
useLegacyFieldInsertion: envelope.useLegacyFieldInsertion,
|
useLegacyFieldInsertion: envelope.useLegacyFieldInsertion,
|
||||||
|
templateDocumentDataId: '',
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -69,7 +69,16 @@ export const createDocumentTemporaryRoute = authenticatedProcedure
|
|||||||
visibility,
|
visibility,
|
||||||
globalAccessAuth,
|
globalAccessAuth,
|
||||||
globalActionAuth,
|
globalActionAuth,
|
||||||
recipients,
|
recipients: (recipients || []).map((recipient) => ({
|
||||||
|
...recipient,
|
||||||
|
fields: (recipient.fields || []).map((field) => ({
|
||||||
|
...field,
|
||||||
|
page: field.pageNumber,
|
||||||
|
positionX: field.pageX,
|
||||||
|
positionY: field.pageY,
|
||||||
|
documentDataId: documentData.id,
|
||||||
|
})),
|
||||||
|
})),
|
||||||
folderId,
|
folderId,
|
||||||
envelopeItems: [
|
envelopeItems: [
|
||||||
{
|
{
|
||||||
@@ -102,14 +111,25 @@ export const createDocumentTemporaryRoute = authenticatedProcedure
|
|||||||
document: {
|
document: {
|
||||||
...createdEnvelope,
|
...createdEnvelope,
|
||||||
envelopeId: createdEnvelope.id,
|
envelopeId: createdEnvelope.id,
|
||||||
|
documentDataId: firstDocumentData.id,
|
||||||
documentData: {
|
documentData: {
|
||||||
...firstDocumentData,
|
...firstDocumentData,
|
||||||
envelopeItemId: envelopeItems[0].id,
|
envelopeItemId: envelopeItems[0].id,
|
||||||
},
|
},
|
||||||
|
documentMeta: {
|
||||||
|
...createdEnvelope.documentMeta,
|
||||||
|
documentId: legacyDocumentId,
|
||||||
|
},
|
||||||
id: legacyDocumentId,
|
id: legacyDocumentId,
|
||||||
fields: createdEnvelope.fields.map((field) => ({
|
fields: createdEnvelope.fields.map((field) => ({
|
||||||
...field,
|
...field,
|
||||||
documentId: legacyDocumentId,
|
documentId: legacyDocumentId,
|
||||||
|
templateId: null,
|
||||||
|
})),
|
||||||
|
recipients: createdEnvelope.recipients.map((recipient) => ({
|
||||||
|
...recipient,
|
||||||
|
documentId: legacyDocumentId,
|
||||||
|
templateId: null,
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
folder: createdEnvelope.folder, // Todo: Remove this prior to api-v2 release.
|
folder: createdEnvelope.folder, // Todo: Remove this prior to api-v2 release.
|
||||||
|
|||||||
@@ -39,7 +39,16 @@ export const createEmbeddingDocumentRoute = procedure
|
|||||||
type: EnvelopeType.DOCUMENT,
|
type: EnvelopeType.DOCUMENT,
|
||||||
title,
|
title,
|
||||||
externalId,
|
externalId,
|
||||||
recipients,
|
recipients: (recipients || []).map((recipient) => ({
|
||||||
|
...recipient,
|
||||||
|
fields: (recipient.fields || []).map((field) => ({
|
||||||
|
...field,
|
||||||
|
page: field.pageNumber,
|
||||||
|
positionX: field.pageX,
|
||||||
|
positionY: field.pageY,
|
||||||
|
documentDataId,
|
||||||
|
})),
|
||||||
|
})),
|
||||||
envelopeItems: [
|
envelopeItems: [
|
||||||
{
|
{
|
||||||
documentDataId,
|
documentDataId,
|
||||||
|
|||||||
@@ -42,7 +42,13 @@ export const getMultiSignDocumentRoute = procedure
|
|||||||
// Transform fields to match our schema
|
// Transform fields to match our schema
|
||||||
const transformedFields = fields.map((field) => ({
|
const transformedFields = fields.map((field) => ({
|
||||||
...field,
|
...field,
|
||||||
recipient,
|
recipient: {
|
||||||
|
...recipient,
|
||||||
|
documentId: document.id,
|
||||||
|
templateId: null,
|
||||||
|
},
|
||||||
|
documentId: document.id,
|
||||||
|
templateId: null,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -7,6 +7,14 @@ import {
|
|||||||
} from '@documenso/lib/types/document-auth';
|
} from '@documenso/lib/types/document-auth';
|
||||||
import { ZDocumentFormValuesSchema } from '@documenso/lib/types/document-form-values';
|
import { ZDocumentFormValuesSchema } from '@documenso/lib/types/document-form-values';
|
||||||
import { ZDocumentMetaCreateSchema } from '@documenso/lib/types/document-meta';
|
import { ZDocumentMetaCreateSchema } from '@documenso/lib/types/document-meta';
|
||||||
|
import {
|
||||||
|
ZFieldHeightSchema,
|
||||||
|
ZFieldPageNumberSchema,
|
||||||
|
ZFieldPageXSchema,
|
||||||
|
ZFieldPageYSchema,
|
||||||
|
ZFieldWidthSchema,
|
||||||
|
} from '@documenso/lib/types/field';
|
||||||
|
import { ZFieldAndMetaSchema } from '@documenso/lib/types/field-meta';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ZDocumentExternalIdSchema,
|
ZDocumentExternalIdSchema,
|
||||||
@@ -48,18 +56,22 @@ export const ZCreateEnvelopeRequestSchema = z.object({
|
|||||||
recipients: z
|
recipients: z
|
||||||
.array(
|
.array(
|
||||||
ZCreateRecipientSchema.extend({
|
ZCreateRecipientSchema.extend({
|
||||||
// Todo: Envelopes ?
|
fields: ZFieldAndMetaSchema.and(
|
||||||
// fields: ZFieldAndMetaSchema.and(
|
z.object({
|
||||||
// z.object({
|
documentDataId: z
|
||||||
// pageNumber: ZFieldPageNumberSchema,
|
.string()
|
||||||
// pageX: ZFieldPageXSchema,
|
.describe(
|
||||||
// pageY: ZFieldPageYSchema,
|
'The ID of the document data to create the field on. If empty, the first document data will be used.',
|
||||||
// width: ZFieldWidthSchema,
|
),
|
||||||
// height: ZFieldHeightSchema,
|
page: ZFieldPageNumberSchema,
|
||||||
// }),
|
positionX: ZFieldPageXSchema,
|
||||||
// )
|
positionY: ZFieldPageYSchema,
|
||||||
// .array()
|
width: ZFieldWidthSchema,
|
||||||
// .optional(),
|
height: ZFieldHeightSchema,
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.array()
|
||||||
|
.optional(),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.optional(),
|
.optional(),
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ export const ZSetEnvelopeRecipientsRequestSchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const ZSetEnvelopeRecipientsResponseSchema = z.object({
|
export const ZSetEnvelopeRecipientsResponseSchema = z.object({
|
||||||
recipients: ZRecipientLiteSchema.array(),
|
recipients: ZRecipientLiteSchema.omit({
|
||||||
|
documentId: true,
|
||||||
|
templateId: true,
|
||||||
|
}).array(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TSetEnvelopeRecipientsRequest = z.infer<typeof ZSetEnvelopeRecipientsRequestSchema>;
|
export type TSetEnvelopeRecipientsRequest = z.infer<typeof ZSetEnvelopeRecipientsRequestSchema>;
|
||||||
|
|||||||
@@ -57,7 +57,10 @@ export const ZSignEnvelopeFieldRequestSchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const ZSignEnvelopeFieldResponseSchema = z.object({
|
export const ZSignEnvelopeFieldResponseSchema = z.object({
|
||||||
signedField: ZFieldSchema.extend({
|
signedField: ZFieldSchema.omit({
|
||||||
|
templateId: true,
|
||||||
|
documentId: true,
|
||||||
|
}).extend({
|
||||||
signature: SignatureSchema.nullish(),
|
signature: SignatureSchema.nullish(),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import { getTemplateById } from '@documenso/lib/server-only/template/get-templat
|
|||||||
import { toggleTemplateDirectLink } from '@documenso/lib/server-only/template/toggle-template-direct-link';
|
import { toggleTemplateDirectLink } from '@documenso/lib/server-only/template/toggle-template-direct-link';
|
||||||
import { getPresignPostUrl } from '@documenso/lib/universal/upload/server-actions';
|
import { getPresignPostUrl } from '@documenso/lib/universal/upload/server-actions';
|
||||||
import { mapSecondaryIdToTemplateId } from '@documenso/lib/utils/envelope';
|
import { mapSecondaryIdToTemplateId } from '@documenso/lib/utils/envelope';
|
||||||
|
import { mapFieldToLegacyField } from '@documenso/lib/utils/fields';
|
||||||
|
import { mapRecipientToLegacyRecipient } from '@documenso/lib/utils/recipients';
|
||||||
import { mapEnvelopeToTemplateLite } from '@documenso/lib/utils/templates';
|
import { mapEnvelopeToTemplateLite } from '@documenso/lib/utils/templates';
|
||||||
|
|
||||||
import { ZGenericSuccessResponse, ZSuccessResponseSchema } from '../document-router/schema';
|
import { ZGenericSuccessResponse, ZSuccessResponseSchema } from '../document-router/schema';
|
||||||
@@ -106,8 +108,10 @@ export const templateRouter = router({
|
|||||||
folderId: envelope.folderId,
|
folderId: envelope.folderId,
|
||||||
useLegacyFieldInsertion: envelope.useLegacyFieldInsertion,
|
useLegacyFieldInsertion: envelope.useLegacyFieldInsertion,
|
||||||
team: envelope.team,
|
team: envelope.team,
|
||||||
fields: envelope.fields,
|
fields: envelope.fields.map((field) => mapFieldToLegacyField(field, envelope)),
|
||||||
recipients: envelope.recipients,
|
recipients: envelope.recipients.map((recipient) =>
|
||||||
|
mapRecipientToLegacyRecipient(recipient, envelope),
|
||||||
|
),
|
||||||
templateMeta: envelope.documentMeta,
|
templateMeta: envelope.documentMeta,
|
||||||
directLink: envelope.directLink,
|
directLink: envelope.directLink,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user