mirror of
https://github.com/documenso/documenso.git
synced 2026-07-23 16:33:57 +10:00
feat: add recipient creation
This commit is contained in:
@@ -1,80 +0,0 @@
|
||||
import { initContract } from '@ts-rest/core';
|
||||
|
||||
import {
|
||||
AuthorizationHeadersSchema,
|
||||
CreateDocumentMutationSchema,
|
||||
DeleteDocumentMutationSchema,
|
||||
GetDocumentsQuerySchema,
|
||||
SendDocumentForSigningMutationSchema,
|
||||
SuccessfulDocumentResponseSchema,
|
||||
SuccessfulResponseSchema,
|
||||
SuccessfulSigningResponseSchema,
|
||||
UnsuccessfulResponseSchema,
|
||||
UploadDocumentSuccessfulSchema,
|
||||
} from './schema';
|
||||
|
||||
const c = initContract();
|
||||
|
||||
export const contract = c.router(
|
||||
{
|
||||
getDocuments: {
|
||||
method: 'GET',
|
||||
path: '/documents',
|
||||
query: GetDocumentsQuerySchema,
|
||||
responses: {
|
||||
200: SuccessfulResponseSchema,
|
||||
401: UnsuccessfulResponseSchema,
|
||||
404: UnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Get all documents',
|
||||
},
|
||||
getDocument: {
|
||||
method: 'GET',
|
||||
path: `/documents/:id`,
|
||||
responses: {
|
||||
200: SuccessfulDocumentResponseSchema,
|
||||
401: UnsuccessfulResponseSchema,
|
||||
404: UnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Get a single document',
|
||||
},
|
||||
createDocument: {
|
||||
method: 'POST',
|
||||
path: '/documents',
|
||||
body: CreateDocumentMutationSchema,
|
||||
responses: {
|
||||
200: UploadDocumentSuccessfulSchema,
|
||||
401: UnsuccessfulResponseSchema,
|
||||
404: UnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Upload a new document and get a presigned URL',
|
||||
},
|
||||
sendDocumentForSigning: {
|
||||
method: 'PATCH',
|
||||
path: '/documents/:id/send',
|
||||
body: SendDocumentForSigningMutationSchema,
|
||||
responses: {
|
||||
200: SuccessfulSigningResponseSchema,
|
||||
400: UnsuccessfulResponseSchema,
|
||||
401: UnsuccessfulResponseSchema,
|
||||
404: UnsuccessfulResponseSchema,
|
||||
500: UnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Send a document for signing',
|
||||
},
|
||||
deleteDocument: {
|
||||
method: 'DELETE',
|
||||
path: `/documents/:id`,
|
||||
body: DeleteDocumentMutationSchema,
|
||||
responses: {
|
||||
200: SuccessfulDocumentResponseSchema,
|
||||
401: UnsuccessfulResponseSchema,
|
||||
404: UnsuccessfulResponseSchema,
|
||||
},
|
||||
summary: 'Delete a document',
|
||||
},
|
||||
},
|
||||
{
|
||||
baseHeaders: AuthorizationHeadersSchema,
|
||||
},
|
||||
);
|
||||
@@ -1,65 +0,0 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import { FieldType } from '@documenso/prisma/client';
|
||||
|
||||
export const GetDocumentsQuerySchema = z.object({
|
||||
page: z.string().optional(),
|
||||
perPage: z.string().optional(),
|
||||
});
|
||||
|
||||
export const DeleteDocumentMutationSchema = z.string();
|
||||
|
||||
export const SuccessfulDocumentResponseSchema = z.object({
|
||||
id: z.number(),
|
||||
userId: z.number(),
|
||||
title: z.string(),
|
||||
status: z.string(),
|
||||
documentDataId: z.string(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
completedAt: z.date().nullable(),
|
||||
});
|
||||
|
||||
export const SendDocumentForSigningMutationSchema = z.object({
|
||||
signerEmail: z.string(),
|
||||
signerName: z.string().optional(),
|
||||
emailSubject: z.string().optional(),
|
||||
emailBody: z.string().optional(),
|
||||
fields: z.array(
|
||||
z.object({
|
||||
fieldType: z.nativeEnum(FieldType),
|
||||
pageNumber: z.number(),
|
||||
pageX: z.number(),
|
||||
pageY: z.number(),
|
||||
pageWidth: z.number(),
|
||||
pageHeight: z.number(),
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
export const UploadDocumentSuccessfulSchema = z.object({
|
||||
url: z.string(),
|
||||
key: z.string(),
|
||||
});
|
||||
|
||||
export const CreateDocumentMutationSchema = z.object({
|
||||
fileName: z.string(),
|
||||
contentType: z.string().default('PDF'),
|
||||
});
|
||||
|
||||
export const SuccessfulResponseSchema = z.object({
|
||||
documents: SuccessfulDocumentResponseSchema.array(),
|
||||
totalPages: z.number(),
|
||||
});
|
||||
|
||||
export const SuccessfulSigningResponseSchema = z.object({
|
||||
message: z.string(),
|
||||
});
|
||||
|
||||
export const UnsuccessfulResponseSchema = z.object({
|
||||
message: z.string(),
|
||||
});
|
||||
|
||||
export const AuthorizationHeadersSchema = z.object({
|
||||
authorization: z.string(),
|
||||
});
|
||||
@@ -1,3 +0,0 @@
|
||||
import { createNextRoute, createNextRouter } from '@ts-rest/next';
|
||||
|
||||
export { createNextRoute, createNextRouter };
|
||||
Reference in New Issue
Block a user