mirror of
https://github.com/documenso/documenso.git
synced 2025-11-14 16:51:38 +10:00
feat: add envelopes api (#2105)
This commit is contained in:
@ -4,18 +4,11 @@ import { authenticatedProcedure } from '../../trpc';
|
||||
import {
|
||||
ZCreateAttachmentRequestSchema,
|
||||
ZCreateAttachmentResponseSchema,
|
||||
createAttachmentMeta,
|
||||
} from './create-attachment.types';
|
||||
|
||||
export const createAttachmentRoute = authenticatedProcedure
|
||||
.meta({
|
||||
openapi: {
|
||||
method: 'POST',
|
||||
path: '/envelope/attachment/create',
|
||||
summary: 'Create attachment',
|
||||
description: 'Create a new attachment for an envelope',
|
||||
tags: ['Envelope'],
|
||||
},
|
||||
})
|
||||
.meta(createAttachmentMeta)
|
||||
.input(ZCreateAttachmentRequestSchema)
|
||||
.output(ZCreateAttachmentResponseSchema)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
|
||||
@ -1,5 +1,17 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import type { TrpcRouteMeta } from '../../trpc';
|
||||
|
||||
export const createAttachmentMeta: TrpcRouteMeta = {
|
||||
openapi: {
|
||||
method: 'POST',
|
||||
path: '/envelope/attachment/create',
|
||||
summary: 'Create attachment',
|
||||
description: 'Create a new attachment for an envelope',
|
||||
tags: ['Envelope Attachments'],
|
||||
},
|
||||
};
|
||||
|
||||
export const ZCreateAttachmentRequestSchema = z.object({
|
||||
envelopeId: z.string(),
|
||||
data: z.object({
|
||||
|
||||
@ -4,18 +4,11 @@ import { authenticatedProcedure } from '../../trpc';
|
||||
import {
|
||||
ZDeleteAttachmentRequestSchema,
|
||||
ZDeleteAttachmentResponseSchema,
|
||||
deleteAttachmentMeta,
|
||||
} from './delete-attachment.types';
|
||||
|
||||
export const deleteAttachmentRoute = authenticatedProcedure
|
||||
.meta({
|
||||
openapi: {
|
||||
method: 'POST',
|
||||
path: '/envelope/attachment/delete',
|
||||
summary: 'Delete attachment',
|
||||
description: 'Delete an attachment from an envelope',
|
||||
tags: ['Envelope'],
|
||||
},
|
||||
})
|
||||
.meta(deleteAttachmentMeta)
|
||||
.input(ZDeleteAttachmentRequestSchema)
|
||||
.output(ZDeleteAttachmentResponseSchema)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
|
||||
@ -1,5 +1,17 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import type { TrpcRouteMeta } from '../../trpc';
|
||||
|
||||
export const deleteAttachmentMeta: TrpcRouteMeta = {
|
||||
openapi: {
|
||||
method: 'POST',
|
||||
path: '/envelope/attachment/delete',
|
||||
summary: 'Delete attachment',
|
||||
description: 'Delete an attachment from an envelope',
|
||||
tags: ['Envelope Attachments'],
|
||||
},
|
||||
};
|
||||
|
||||
export const ZDeleteAttachmentRequestSchema = z.object({
|
||||
id: z.string(),
|
||||
});
|
||||
|
||||
@ -2,22 +2,15 @@ import { AppError, AppErrorCode } from '@documenso/lib/errors/app-error';
|
||||
import { findAttachmentsByEnvelopeId } from '@documenso/lib/server-only/envelope-attachment/find-attachments-by-envelope-id';
|
||||
import { findAttachmentsByToken } from '@documenso/lib/server-only/envelope-attachment/find-attachments-by-token';
|
||||
|
||||
import { procedure } from '../../trpc';
|
||||
import { maybeAuthenticatedProcedure } from '../../trpc';
|
||||
import {
|
||||
ZFindAttachmentsRequestSchema,
|
||||
ZFindAttachmentsResponseSchema,
|
||||
findAttachmentsMeta,
|
||||
} from './find-attachments.types';
|
||||
|
||||
export const findAttachmentsRoute = procedure
|
||||
.meta({
|
||||
openapi: {
|
||||
method: 'GET',
|
||||
path: '/envelope/attachment',
|
||||
summary: 'Find attachments',
|
||||
description: 'Find all attachments for an envelope',
|
||||
tags: ['Envelope'],
|
||||
},
|
||||
})
|
||||
export const findAttachmentsRoute = maybeAuthenticatedProcedure
|
||||
.meta(findAttachmentsMeta)
|
||||
.input(ZFindAttachmentsRequestSchema)
|
||||
.output(ZFindAttachmentsResponseSchema)
|
||||
.query(async ({ input, ctx }) => {
|
||||
|
||||
@ -2,6 +2,18 @@ import { z } from 'zod';
|
||||
|
||||
import { ZEnvelopeAttachmentTypeSchema } from '@documenso/lib/types/envelope-attachment';
|
||||
|
||||
import type { TrpcRouteMeta } from '../../trpc';
|
||||
|
||||
export const findAttachmentsMeta: TrpcRouteMeta = {
|
||||
openapi: {
|
||||
method: 'GET',
|
||||
path: '/envelope/attachment',
|
||||
summary: 'Find attachments',
|
||||
description: 'Find all attachments for an envelope',
|
||||
tags: ['Envelope Attachments'],
|
||||
},
|
||||
};
|
||||
|
||||
export const ZFindAttachmentsRequestSchema = z.object({
|
||||
envelopeId: z.string(),
|
||||
token: z.string().optional(),
|
||||
|
||||
@ -4,18 +4,11 @@ import { authenticatedProcedure } from '../../trpc';
|
||||
import {
|
||||
ZUpdateAttachmentRequestSchema,
|
||||
ZUpdateAttachmentResponseSchema,
|
||||
updateAttachmentMeta,
|
||||
} from './update-attachment.types';
|
||||
|
||||
export const updateAttachmentRoute = authenticatedProcedure
|
||||
.meta({
|
||||
openapi: {
|
||||
method: 'POST',
|
||||
path: '/envelope/attachment/update',
|
||||
summary: 'Update attachment',
|
||||
description: 'Update an existing attachment',
|
||||
tags: ['Envelope'],
|
||||
},
|
||||
})
|
||||
.meta(updateAttachmentMeta)
|
||||
.input(ZUpdateAttachmentRequestSchema)
|
||||
.output(ZUpdateAttachmentResponseSchema)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
|
||||
@ -1,5 +1,17 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
import type { TrpcRouteMeta } from '../../trpc';
|
||||
|
||||
export const updateAttachmentMeta: TrpcRouteMeta = {
|
||||
openapi: {
|
||||
method: 'POST',
|
||||
path: '/envelope/attachment/update',
|
||||
summary: 'Update attachment',
|
||||
description: 'Update an existing attachment',
|
||||
tags: ['Envelope Attachments'],
|
||||
},
|
||||
};
|
||||
|
||||
export const ZUpdateAttachmentRequestSchema = z.object({
|
||||
id: z.string(),
|
||||
data: z.object({
|
||||
|
||||
Reference in New Issue
Block a user