mirror of
https://github.com/documenso/documenso.git
synced 2026-07-25 09:25:08 +10:00
Merge branch 'main' into feat/document-file-conversion
Resolved conflicts:
- create-document-data.ts: merged initialData + originalData/originalMimeType
- files.helpers.ts: kept both imports
- envelope-drop-zone-wrapper.tsx: adopted buildDropzoneRejectionDescription
- create-envelope-items.ts: adopted UNSAFE_createEnvelopeItems
- create-envelope.ts: integrated convertToPdfIfNeeded into createEnvelopeRouteCaller
Extended putPdfFileServerSide to accept { initialData, originalData,
originalMimeType } options; updated seal-document.handler call site.
This commit is contained in:
@@ -43,6 +43,9 @@ import {
|
||||
|
||||
const c = initContract();
|
||||
|
||||
const deprecatedDescription =
|
||||
'This endpoint is deprecated, but will continue to be supported. For more details, see https://docs.documenso.com/developers/public-api.';
|
||||
|
||||
export const ApiContractV1 = c.router(
|
||||
{
|
||||
getDocuments: {
|
||||
@@ -55,6 +58,8 @@ export const ApiContractV1 = c.router(
|
||||
404: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Get all documents',
|
||||
deprecated: true,
|
||||
description: deprecatedDescription,
|
||||
},
|
||||
|
||||
getDocument: {
|
||||
@@ -66,6 +71,8 @@ export const ApiContractV1 = c.router(
|
||||
404: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Get a single document',
|
||||
deprecated: true,
|
||||
description: deprecatedDescription,
|
||||
},
|
||||
|
||||
downloadSignedDocument: {
|
||||
@@ -78,6 +85,8 @@ export const ApiContractV1 = c.router(
|
||||
404: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Download a signed document when the storage transport is S3',
|
||||
deprecated: true,
|
||||
description: deprecatedDescription,
|
||||
},
|
||||
|
||||
createDocument: {
|
||||
@@ -90,6 +99,8 @@ export const ApiContractV1 = c.router(
|
||||
404: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Upload a new document and get a presigned URL',
|
||||
deprecated: true,
|
||||
description: deprecatedDescription,
|
||||
},
|
||||
|
||||
createTemplate: {
|
||||
@@ -102,6 +113,8 @@ export const ApiContractV1 = c.router(
|
||||
404: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Create a new template and get a presigned URL',
|
||||
deprecated: true,
|
||||
description: deprecatedDescription,
|
||||
},
|
||||
|
||||
deleteTemplate: {
|
||||
@@ -114,6 +127,8 @@ export const ApiContractV1 = c.router(
|
||||
404: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Delete a template',
|
||||
deprecated: true,
|
||||
description: deprecatedDescription,
|
||||
},
|
||||
|
||||
getTemplate: {
|
||||
@@ -125,6 +140,8 @@ export const ApiContractV1 = c.router(
|
||||
404: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Get a single template',
|
||||
deprecated: true,
|
||||
description: deprecatedDescription,
|
||||
},
|
||||
|
||||
getTemplates: {
|
||||
@@ -137,6 +154,8 @@ export const ApiContractV1 = c.router(
|
||||
404: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Get all templates',
|
||||
deprecated: true,
|
||||
description: deprecatedDescription,
|
||||
},
|
||||
|
||||
createDocumentFromTemplate: {
|
||||
@@ -150,7 +169,7 @@ export const ApiContractV1 = c.router(
|
||||
},
|
||||
summary: 'Create a new document from an existing template',
|
||||
deprecated: true,
|
||||
description: `This has been deprecated in favour of "/api/v1/templates/:templateId/generate-document". You may face unpredictable behavior using this endpoint as it is no longer maintained.`,
|
||||
description: `${deprecatedDescription} \n\nIf you must use the V1 API, use "/api/v1/templates/:templateId/generate-document" instead.`,
|
||||
},
|
||||
|
||||
generateDocumentFromTemplate: {
|
||||
@@ -165,8 +184,8 @@ export const ApiContractV1 = c.router(
|
||||
500: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Create a new document from an existing template',
|
||||
description:
|
||||
'Create a new document from an existing template. Passing in values for title and meta will override the original values defined in the template. If you do not pass in values for recipients, it will use the values defined in the template.',
|
||||
deprecated: true,
|
||||
description: `${deprecatedDescription} \n\nCreate a new document from an existing template. Passing in values for title and meta will override the original values defined in the template. If you do not pass in values for recipients, it will use the values defined in the template.`,
|
||||
},
|
||||
|
||||
sendDocument: {
|
||||
@@ -181,9 +200,8 @@ export const ApiContractV1 = c.router(
|
||||
500: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Send a document for signing',
|
||||
// I'm aware this should be in the variable itself, which it is, however it's difficult for users to find in our current UI.
|
||||
description:
|
||||
'Notes\n\n`sendEmail` - Whether to send an email to the recipients asking them to action the document. If you disable this, you will need to manually distribute the document to the recipients using the generated signing links. Defaults to true',
|
||||
deprecated: true,
|
||||
description: `${deprecatedDescription} \n\nNotes\n\nsendEmail - Whether to send an email to the recipients asking them to action the document. If you disable this, you will need to manually distribute the document to the recipients using the generated signing links. Defaults to true`,
|
||||
},
|
||||
|
||||
resendDocument: {
|
||||
@@ -198,6 +216,8 @@ export const ApiContractV1 = c.router(
|
||||
500: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Re-send a document for signing',
|
||||
deprecated: true,
|
||||
description: deprecatedDescription,
|
||||
},
|
||||
|
||||
deleteDocument: {
|
||||
@@ -210,6 +230,8 @@ export const ApiContractV1 = c.router(
|
||||
404: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Delete a document',
|
||||
deprecated: true,
|
||||
description: deprecatedDescription,
|
||||
},
|
||||
|
||||
createRecipient: {
|
||||
@@ -224,6 +246,8 @@ export const ApiContractV1 = c.router(
|
||||
500: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Create a recipient for a document',
|
||||
deprecated: true,
|
||||
description: deprecatedDescription,
|
||||
},
|
||||
|
||||
updateRecipient: {
|
||||
@@ -238,6 +262,8 @@ export const ApiContractV1 = c.router(
|
||||
500: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Update a recipient for a document',
|
||||
deprecated: true,
|
||||
description: deprecatedDescription,
|
||||
},
|
||||
|
||||
deleteRecipient: {
|
||||
@@ -252,6 +278,8 @@ export const ApiContractV1 = c.router(
|
||||
500: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Delete a recipient from a document',
|
||||
deprecated: true,
|
||||
description: deprecatedDescription,
|
||||
},
|
||||
|
||||
createField: {
|
||||
@@ -266,6 +294,8 @@ export const ApiContractV1 = c.router(
|
||||
500: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Create a field for a document',
|
||||
deprecated: true,
|
||||
description: deprecatedDescription,
|
||||
},
|
||||
|
||||
updateField: {
|
||||
@@ -280,6 +310,8 @@ export const ApiContractV1 = c.router(
|
||||
500: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Update a field for a document',
|
||||
deprecated: true,
|
||||
description: deprecatedDescription,
|
||||
},
|
||||
|
||||
deleteField: {
|
||||
@@ -294,6 +326,8 @@ export const ApiContractV1 = c.router(
|
||||
500: ZUnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Delete a field from a document',
|
||||
deprecated: true,
|
||||
description: deprecatedDescription,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -67,6 +67,7 @@ export const ApiContractV1Implementation = tsr.router(ApiContractV1, {
|
||||
perPage,
|
||||
userId: user.id,
|
||||
teamId: team.id,
|
||||
folderId: args.query.folderId,
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -77,6 +78,7 @@ export const ApiContractV1Implementation = tsr.router(ApiContractV1, {
|
||||
externalId: document.externalId,
|
||||
userId: document.userId,
|
||||
teamId: document.teamId,
|
||||
folderId: document.folderId,
|
||||
title: document.title,
|
||||
status: document.status,
|
||||
createdAt: document.createdAt,
|
||||
@@ -164,6 +166,7 @@ export const ApiContractV1Implementation = tsr.router(ApiContractV1, {
|
||||
externalId: envelope.externalId,
|
||||
userId: envelope.userId,
|
||||
teamId: envelope.teamId,
|
||||
folderId: envelope.folderId,
|
||||
title: envelope.title,
|
||||
status: envelope.status,
|
||||
createdAt: envelope.createdAt,
|
||||
@@ -796,6 +799,7 @@ export const ApiContractV1Implementation = tsr.router(ApiContractV1, {
|
||||
title: body.title,
|
||||
},
|
||||
attachments: body.attachments,
|
||||
formValues: body.formValues,
|
||||
requestMetadata: metadata,
|
||||
});
|
||||
|
||||
@@ -1043,12 +1047,7 @@ export const ApiContractV1Implementation = tsr.router(ApiContractV1, {
|
||||
},
|
||||
};
|
||||
} catch (err) {
|
||||
return {
|
||||
status: 500,
|
||||
body: {
|
||||
message: 'An error has occured while sending the document for signing',
|
||||
},
|
||||
};
|
||||
return AppError.toRestAPIError(err);
|
||||
}
|
||||
}),
|
||||
|
||||
@@ -1392,7 +1391,7 @@ export const ApiContractV1Implementation = tsr.router(ApiContractV1, {
|
||||
throw new Error('Invalid page number');
|
||||
}
|
||||
|
||||
const recipient = await prisma.recipient.findFirst({
|
||||
const recipient = await tx.recipient.findFirst({
|
||||
where: {
|
||||
id: Number(recipientId),
|
||||
envelopeId: envelope.id,
|
||||
|
||||
@@ -11,7 +11,8 @@ export const OpenAPIV1 = Object.assign(
|
||||
info: {
|
||||
title: 'Documenso API',
|
||||
version: '1.0.0',
|
||||
description: 'The Documenso API for retrieving, creating, updating and deleting documents.',
|
||||
description:
|
||||
'API V1 is deprecated, but will continue to be supported. For more details, see https://docs.documenso.com/developers/public-api. \n\nThe Documenso API for retrieving, creating, updating and deleting documents.',
|
||||
},
|
||||
servers: [
|
||||
{
|
||||
|
||||
+19
-12
@@ -24,6 +24,7 @@ import {
|
||||
import { ZDocumentEmailSettingsSchema } from '@documenso/lib/types/document-email';
|
||||
import { ZEnvelopeAttachmentTypeSchema } from '@documenso/lib/types/envelope-attachment';
|
||||
import { ZFieldMetaPrefillFieldsSchema, ZFieldMetaSchema } from '@documenso/lib/types/field-meta';
|
||||
import { zEmail } from '@documenso/lib/utils/zod';
|
||||
|
||||
extendZodWithOpenApi(z);
|
||||
|
||||
@@ -35,6 +36,10 @@ export const ZNoBodyMutationSchema = null;
|
||||
export const ZGetDocumentsQuerySchema = z.object({
|
||||
page: z.coerce.number().min(1).optional().default(1),
|
||||
perPage: z.coerce.number().min(1).optional().default(10),
|
||||
folderId: z
|
||||
.string()
|
||||
.describe('Filter documents by folder ID. When omitted, returns root documents.')
|
||||
.optional(),
|
||||
});
|
||||
|
||||
export type TGetDocumentsQuerySchema = z.infer<typeof ZGetDocumentsQuerySchema>;
|
||||
@@ -48,6 +53,7 @@ export const ZSuccessfulDocumentResponseSchema = z.object({
|
||||
externalId: z.string().nullish(),
|
||||
userId: z.number(),
|
||||
teamId: z.number().nullish(),
|
||||
folderId: z.string().nullish(),
|
||||
title: z.string(),
|
||||
status: z.string(),
|
||||
createdAt: z.date(),
|
||||
@@ -145,7 +151,7 @@ export const ZCreateDocumentMutationSchema = z.object({
|
||||
recipients: z.array(
|
||||
z.object({
|
||||
name: z.string().min(1),
|
||||
email: z.string().email().min(1),
|
||||
email: zEmail().min(1),
|
||||
role: z.nativeEnum(RecipientRole).optional().default(RecipientRole.SIGNER),
|
||||
signingOrder: z.number().nullish(),
|
||||
}),
|
||||
@@ -219,7 +225,7 @@ export const ZCreateDocumentMutationResponseSchema = z.object({
|
||||
z.object({
|
||||
recipientId: z.number(),
|
||||
name: z.string(),
|
||||
email: z.string().email().min(1),
|
||||
email: zEmail().min(1),
|
||||
token: z.string(),
|
||||
role: z.nativeEnum(RecipientRole),
|
||||
signingOrder: z.number().nullish(),
|
||||
@@ -239,7 +245,7 @@ export const ZCreateDocumentFromTemplateMutationSchema = z.object({
|
||||
recipients: z.array(
|
||||
z.object({
|
||||
name: z.string().min(1),
|
||||
email: z.string().email().min(1),
|
||||
email: zEmail().min(1),
|
||||
role: z.nativeEnum(RecipientRole).optional().default(RecipientRole.SIGNER),
|
||||
signingOrder: z.number().nullish(),
|
||||
}),
|
||||
@@ -294,7 +300,7 @@ export const ZCreateDocumentFromTemplateMutationResponseSchema = z.object({
|
||||
z.object({
|
||||
recipientId: z.number(),
|
||||
name: z.string(),
|
||||
email: z.string().email().min(1),
|
||||
email: zEmail().min(1),
|
||||
token: z.string(),
|
||||
role: z.nativeEnum(RecipientRole).optional().default(RecipientRole.SIGNER),
|
||||
signingOrder: z.number().nullish(),
|
||||
@@ -321,7 +327,7 @@ export const ZGenerateDocumentFromTemplateMutationSchema = z.object({
|
||||
.array(
|
||||
z.object({
|
||||
id: z.number(),
|
||||
email: z.string().email(),
|
||||
email: zEmail(),
|
||||
name: z.string().optional(),
|
||||
signingOrder: z.number().optional(),
|
||||
}),
|
||||
@@ -381,7 +387,7 @@ export const ZGenerateDocumentFromTemplateMutationResponseSchema = z.object({
|
||||
z.object({
|
||||
recipientId: z.number(),
|
||||
name: z.string(),
|
||||
email: z.string().email().min(1),
|
||||
email: zEmail().min(1),
|
||||
token: z.string(),
|
||||
role: z.nativeEnum(RecipientRole),
|
||||
signingOrder: z.number().nullish(),
|
||||
@@ -397,7 +403,7 @@ export type TGenerateDocumentFromTemplateMutationResponseSchema = z.infer<
|
||||
|
||||
export const ZCreateRecipientMutationSchema = z.object({
|
||||
name: z.string().min(1),
|
||||
email: z.string().email().min(1),
|
||||
email: zEmail().min(1),
|
||||
role: z.nativeEnum(RecipientRole).optional().default(RecipientRole.SIGNER),
|
||||
signingOrder: z.number().nullish(),
|
||||
authOptions: z
|
||||
@@ -432,13 +438,13 @@ export const ZSuccessfulRecipientResponseSchema = z.object({
|
||||
// !: This handles the fact that we have null documentId's for templates
|
||||
// !: while we won't need the default we must add it to satisfy typescript
|
||||
documentId: z.number().nullish().default(-1),
|
||||
email: z.string().email().min(1),
|
||||
email: zEmail().min(1),
|
||||
name: z.string(),
|
||||
role: z.nativeEnum(RecipientRole),
|
||||
signingOrder: z.number().nullish(),
|
||||
token: z.string(),
|
||||
// !: Not used for now
|
||||
// expired: z.string(),
|
||||
expiresAt: z.date().nullish(),
|
||||
expirationNotifiedAt: z.date().nullish(),
|
||||
signedAt: z.date().nullable(),
|
||||
readStatus: z.nativeEnum(ReadStatus),
|
||||
signingStatus: z.nativeEnum(SigningStatus),
|
||||
@@ -571,12 +577,13 @@ export const ZRecipientSchema = z.object({
|
||||
id: z.number(),
|
||||
documentId: z.number().nullish(),
|
||||
templateId: z.number().nullish(),
|
||||
email: z.string().email().min(1),
|
||||
email: zEmail().min(1),
|
||||
name: z.string(),
|
||||
token: z.string(),
|
||||
signingOrder: z.number().nullish(),
|
||||
documentDeletedAt: z.date().nullish(),
|
||||
expired: z.date().nullish(),
|
||||
expiresAt: z.date().nullish(),
|
||||
expirationNotifiedAt: z.date().nullish(),
|
||||
signedAt: z.date().nullish(),
|
||||
authOptions: z.unknown(),
|
||||
role: z.nativeEnum(RecipientRole),
|
||||
|
||||
Reference in New Issue
Block a user