2023-12-31 13:58:15 +11:00
import { initContract } from '@ts-rest/core' ;
import {
ZAuthorizationHeadersSchema ,
2024-02-20 19:46:18 +11:00
ZCreateDocumentFromTemplateMutationResponseSchema ,
ZCreateDocumentFromTemplateMutationSchema ,
2024-02-12 15:16:09 +11:00
ZCreateDocumentMutationResponseSchema ,
2023-12-31 13:58:15 +11:00
ZCreateDocumentMutationSchema ,
2024-01-29 22:53:15 +11:00
ZCreateFieldMutationSchema ,
2024-01-22 17:38:02 +11:00
ZCreateRecipientMutationSchema ,
2023-12-31 13:58:15 +11:00
ZDeleteDocumentMutationSchema ,
2024-01-29 22:53:15 +11:00
ZDeleteFieldMutationSchema ,
ZDeleteRecipientMutationSchema ,
2024-04-19 14:04:11 +03:00
ZDownloadDocumentSuccessfulSchema ,
2024-05-10 19:45:19 +07:00
ZGenerateDocumentFromTemplateMutationResponseSchema ,
ZGenerateDocumentFromTemplateMutationSchema ,
2023-12-31 13:58:15 +11:00
ZGetDocumentsQuerySchema ,
2024-02-22 13:39:34 +11:00
ZSendDocumentForSigningMutationSchema ,
2023-12-31 13:58:15 +11:00
ZSuccessfulDocumentResponseSchema ,
2024-01-29 22:53:15 +11:00
ZSuccessfulFieldResponseSchema ,
2024-02-20 19:46:18 +11:00
ZSuccessfulGetDocumentResponseSchema ,
2024-01-22 17:38:02 +11:00
ZSuccessfulRecipientResponseSchema ,
2023-12-31 13:58:15 +11:00
ZSuccessfulResponseSchema ,
ZSuccessfulSigningResponseSchema ,
ZUnsuccessfulResponseSchema ,
2024-01-29 22:53:15 +11:00
ZUpdateFieldMutationSchema ,
ZUpdateRecipientMutationSchema ,
2023-12-31 13:58:15 +11:00
} from './schema' ;
const c = initContract ( ) ;
export const ApiContractV1 = c . router (
{
getDocuments : {
method : 'GET' ,
2024-01-22 17:38:02 +11:00
path : '/api/v1/documents' ,
2023-12-31 13:58:15 +11:00
query : ZGetDocumentsQuerySchema ,
responses : {
200 : ZSuccessfulResponseSchema ,
401 : ZUnsuccessfulResponseSchema ,
404 : ZUnsuccessfulResponseSchema ,
} ,
summary : 'Get all documents' ,
} ,
getDocument : {
method : 'GET' ,
2024-01-22 17:38:02 +11:00
path : '/api/v1/documents/:id' ,
2023-12-31 13:58:15 +11:00
responses : {
2024-02-20 19:46:18 +11:00
200 : ZSuccessfulGetDocumentResponseSchema ,
2023-12-31 13:58:15 +11:00
401 : ZUnsuccessfulResponseSchema ,
404 : ZUnsuccessfulResponseSchema ,
} ,
summary : 'Get a single document' ,
} ,
2024-04-19 14:04:11 +03:00
downloadSignedDocument : {
method : 'GET' ,
path : '/api/v1/documents/:id/download' ,
responses : {
200 : ZDownloadDocumentSuccessfulSchema ,
401 : ZUnsuccessfulResponseSchema ,
404 : ZUnsuccessfulResponseSchema ,
} ,
summary : 'Download a signed document when the storage transport is S3' ,
} ,
2023-12-31 13:58:15 +11:00
createDocument : {
method : 'POST' ,
2024-01-22 17:38:02 +11:00
path : '/api/v1/documents' ,
2023-12-31 13:58:15 +11:00
body : ZCreateDocumentMutationSchema ,
responses : {
2024-02-12 15:16:09 +11:00
200 : ZCreateDocumentMutationResponseSchema ,
2023-12-31 13:58:15 +11:00
401 : ZUnsuccessfulResponseSchema ,
404 : ZUnsuccessfulResponseSchema ,
} ,
summary : 'Upload a new document and get a presigned URL' ,
} ,
2024-02-20 19:46:18 +11:00
createDocumentFromTemplate : {
method : 'POST' ,
path : '/api/v1/templates/:templateId/create-document' ,
body : ZCreateDocumentFromTemplateMutationSchema ,
responses : {
200 : ZCreateDocumentFromTemplateMutationResponseSchema ,
401 : ZUnsuccessfulResponseSchema ,
404 : ZUnsuccessfulResponseSchema ,
} ,
2024-02-22 13:39:34 +11:00
summary : 'Create a new document from an existing template' ,
2024-05-10 19:45:19 +07:00
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. ` ,
} ,
generateDocumentFromTemplate : {
method : 'POST' ,
path : '/api/v1/templates/:templateId/generate-document' ,
body : ZGenerateDocumentFromTemplateMutationSchema ,
responses : {
200 : ZGenerateDocumentFromTemplateMutationResponseSchema ,
400 : ZUnsuccessfulResponseSchema ,
401 : ZUnsuccessfulResponseSchema ,
404 : ZUnsuccessfulResponseSchema ,
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.' ,
2024-02-20 19:46:18 +11:00
} ,
2023-12-31 13:58:15 +11:00
sendDocument : {
2024-01-22 17:38:02 +11:00
method : 'POST' ,
path : '/api/v1/documents/:id/send' ,
2024-02-22 13:39:34 +11:00
body : ZSendDocumentForSigningMutationSchema ,
2023-12-31 13:58:15 +11:00
responses : {
200 : ZSuccessfulSigningResponseSchema ,
400 : ZUnsuccessfulResponseSchema ,
401 : ZUnsuccessfulResponseSchema ,
404 : ZUnsuccessfulResponseSchema ,
500 : ZUnsuccessfulResponseSchema ,
} ,
summary : 'Send a document for signing' ,
} ,
deleteDocument : {
method : 'DELETE' ,
2024-01-22 17:38:02 +11:00
path : '/api/v1/documents/:id' ,
2023-12-31 13:58:15 +11:00
body : ZDeleteDocumentMutationSchema ,
responses : {
200 : ZSuccessfulDocumentResponseSchema ,
401 : ZUnsuccessfulResponseSchema ,
404 : ZUnsuccessfulResponseSchema ,
} ,
summary : 'Delete a document' ,
} ,
2024-01-22 17:38:02 +11:00
createRecipient : {
method : 'POST' ,
path : '/api/v1/documents/:id/recipients' ,
body : ZCreateRecipientMutationSchema ,
responses : {
200 : ZSuccessfulRecipientResponseSchema ,
400 : ZUnsuccessfulResponseSchema ,
401 : ZUnsuccessfulResponseSchema ,
404 : ZUnsuccessfulResponseSchema ,
500 : ZUnsuccessfulResponseSchema ,
} ,
summary : 'Create a recipient for a document' ,
} ,
2024-01-29 22:53:15 +11:00
updateRecipient : {
method : 'PATCH' ,
path : '/api/v1/documents/:id/recipients/:recipientId' ,
body : ZUpdateRecipientMutationSchema ,
responses : {
200 : ZSuccessfulRecipientResponseSchema ,
400 : ZUnsuccessfulResponseSchema ,
401 : ZUnsuccessfulResponseSchema ,
404 : ZUnsuccessfulResponseSchema ,
500 : ZUnsuccessfulResponseSchema ,
} ,
summary : 'Update a recipient for a document' ,
} ,
deleteRecipient : {
method : 'DELETE' ,
path : '/api/v1/documents/:id/recipients/:recipientId' ,
body : ZDeleteRecipientMutationSchema ,
responses : {
200 : ZSuccessfulRecipientResponseSchema ,
400 : ZUnsuccessfulResponseSchema ,
401 : ZUnsuccessfulResponseSchema ,
404 : ZUnsuccessfulResponseSchema ,
500 : ZUnsuccessfulResponseSchema ,
} ,
summary : 'Delete a recipient from a document' ,
} ,
createField : {
method : 'POST' ,
path : '/api/v1/documents/:id/fields' ,
body : ZCreateFieldMutationSchema ,
responses : {
200 : ZSuccessfulFieldResponseSchema ,
400 : ZUnsuccessfulResponseSchema ,
401 : ZUnsuccessfulResponseSchema ,
404 : ZUnsuccessfulResponseSchema ,
500 : ZUnsuccessfulResponseSchema ,
} ,
summary : 'Create a field for a document' ,
} ,
updateField : {
method : 'PATCH' ,
path : '/api/v1/documents/:id/fields/:fieldId' ,
body : ZUpdateFieldMutationSchema ,
responses : {
200 : ZSuccessfulFieldResponseSchema ,
400 : ZUnsuccessfulResponseSchema ,
401 : ZUnsuccessfulResponseSchema ,
404 : ZUnsuccessfulResponseSchema ,
500 : ZUnsuccessfulResponseSchema ,
} ,
summary : 'Update a field for a document' ,
} ,
deleteField : {
method : 'DELETE' ,
path : '/api/v1/documents/:id/fields/:fieldId' ,
body : ZDeleteFieldMutationSchema ,
responses : {
200 : ZSuccessfulFieldResponseSchema ,
400 : ZUnsuccessfulResponseSchema ,
401 : ZUnsuccessfulResponseSchema ,
404 : ZUnsuccessfulResponseSchema ,
500 : ZUnsuccessfulResponseSchema ,
} ,
summary : 'Delete a field from a document' ,
} ,
2023-12-31 13:58:15 +11:00
} ,
{
baseHeaders : ZAuthorizationHeadersSchema ,
} ,
) ;