mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 00:03:33 +10:00
fix: move open meta around
This commit is contained in:
@ -49,20 +49,20 @@ export const DocumentDuplicateDialog = ({
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const envelopeItems = envelopeItemsPayload?.envelopeItems || [];
|
const envelopeItems = envelopeItemsPayload?.data || [];
|
||||||
|
|
||||||
const documentsPath = formatDocumentsPath(team.url);
|
const documentsPath = formatDocumentsPath(team.url);
|
||||||
|
|
||||||
const { mutateAsync: duplicateEnvelope, isPending: isDuplicating } =
|
const { mutateAsync: duplicateEnvelope, isPending: isDuplicating } =
|
||||||
trpcReact.envelope.duplicate.useMutation({
|
trpcReact.envelope.duplicate.useMutation({
|
||||||
onSuccess: async ({ duplicatedEnvelopeId }) => {
|
onSuccess: async ({ id }) => {
|
||||||
toast({
|
toast({
|
||||||
title: _(msg`Document Duplicated`),
|
title: _(msg`Document Duplicated`),
|
||||||
description: _(msg`Your document has been successfully duplicated.`),
|
description: _(msg`Your document has been successfully duplicated.`),
|
||||||
duration: 5000,
|
duration: 5000,
|
||||||
});
|
});
|
||||||
|
|
||||||
await navigate(`${documentsPath}/${duplicatedEnvelopeId}/edit`);
|
await navigate(`${documentsPath}/${id}/edit`);
|
||||||
onOpenChange(false);
|
onOpenChange(false);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@ -61,12 +61,12 @@ export const EnvelopeDownloadDialog = ({
|
|||||||
access: token ? { type: 'recipient', token } : { type: 'user' },
|
access: token ? { type: 'recipient', token } : { type: 'user' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
initialData: initialEnvelopeItems ? { envelopeItems: initialEnvelopeItems } : undefined,
|
initialData: initialEnvelopeItems ? { data: initialEnvelopeItems } : undefined,
|
||||||
enabled: open,
|
enabled: open,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const envelopeItems = envelopeItemsPayload?.envelopeItems || [];
|
const envelopeItems = envelopeItemsPayload?.data || [];
|
||||||
|
|
||||||
const onDownload = async (
|
const onDownload = async (
|
||||||
envelopeItem: EnvelopeItemToDownload,
|
envelopeItem: EnvelopeItemToDownload,
|
||||||
|
|||||||
@ -43,7 +43,7 @@ export const EnvelopeDuplicateDialog = ({
|
|||||||
|
|
||||||
const { mutateAsync: duplicateEnvelope, isPending: isDuplicating } =
|
const { mutateAsync: duplicateEnvelope, isPending: isDuplicating } =
|
||||||
trpc.envelope.duplicate.useMutation({
|
trpc.envelope.duplicate.useMutation({
|
||||||
onSuccess: async ({ duplicatedEnvelopeId }) => {
|
onSuccess: async ({ id }) => {
|
||||||
toast({
|
toast({
|
||||||
title: t`Envelope Duplicated`,
|
title: t`Envelope Duplicated`,
|
||||||
description: t`Your envelope has been successfully duplicated.`,
|
description: t`Your envelope has been successfully duplicated.`,
|
||||||
@ -55,7 +55,7 @@ export const EnvelopeDuplicateDialog = ({
|
|||||||
? formatDocumentsPath(team.url)
|
? formatDocumentsPath(team.url)
|
||||||
: formatTemplatesPath(team.url);
|
: formatTemplatesPath(team.url);
|
||||||
|
|
||||||
await navigate(`${path}/${duplicatedEnvelopeId}/edit`);
|
await navigate(`${path}/${id}/edit`);
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@ -143,7 +143,7 @@ export function TemplateUseDialog({
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const envelopeItems = response?.envelopeItems ?? [];
|
const envelopeItems = response?.data ?? [];
|
||||||
|
|
||||||
const { mutateAsync: createDocumentFromTemplate } =
|
const { mutateAsync: createDocumentFromTemplate } =
|
||||||
trpc.template.createDocumentFromTemplate.useMutation();
|
trpc.template.createDocumentFromTemplate.useMutation();
|
||||||
|
|||||||
@ -67,8 +67,8 @@ export const EnvelopeEditorUploadPage = () => {
|
|||||||
|
|
||||||
const { mutateAsync: createEnvelopeItems, isPending: isCreatingEnvelopeItems } =
|
const { mutateAsync: createEnvelopeItems, isPending: isCreatingEnvelopeItems } =
|
||||||
trpc.envelope.item.createMany.useMutation({
|
trpc.envelope.item.createMany.useMutation({
|
||||||
onSuccess: (data) => {
|
onSuccess: ({ data }) => {
|
||||||
const createdEnvelopes = data.createdEnvelopeItems.filter(
|
const createdEnvelopes = data.filter(
|
||||||
(item) => !envelope.envelopeItems.find((envelopeItem) => envelopeItem.id === item.id),
|
(item) => !envelope.envelopeItems.find((envelopeItem) => envelopeItem.id === item.id),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -79,10 +79,10 @@ export const EnvelopeEditorUploadPage = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { mutateAsync: updateEnvelopeItems } = trpc.envelope.item.updateMany.useMutation({
|
const { mutateAsync: updateEnvelopeItems } = trpc.envelope.item.updateMany.useMutation({
|
||||||
onSuccess: (data) => {
|
onSuccess: ({ data }) => {
|
||||||
setLocalEnvelope({
|
setLocalEnvelope({
|
||||||
envelopeItems: envelope.envelopeItems.map((originalItem) => {
|
envelopeItems: envelope.envelopeItems.map((originalItem) => {
|
||||||
const updatedItem = data.updatedEnvelopeItems.find((item) => item.id === originalItem.id);
|
const updatedItem = data.find((item) => item.id === originalItem.id);
|
||||||
|
|
||||||
if (updatedItem) {
|
if (updatedItem) {
|
||||||
return {
|
return {
|
||||||
@ -126,7 +126,7 @@ export const EnvelopeEditorUploadPage = () => {
|
|||||||
formData.append('files', file);
|
formData.append('files', file);
|
||||||
}
|
}
|
||||||
|
|
||||||
const { createdEnvelopeItems } = await createEnvelopeItems(formData).catch((error) => {
|
const { data } = await createEnvelopeItems(formData).catch((error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
|
||||||
// Set error state on files in batch upload.
|
// Set error state on files in batch upload.
|
||||||
@ -148,7 +148,7 @@ export const EnvelopeEditorUploadPage = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return filteredFiles.concat(
|
return filteredFiles.concat(
|
||||||
createdEnvelopeItems.map((item) => ({
|
data.map((item) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
envelopeItemId: item.id,
|
envelopeItemId: item.id,
|
||||||
title: item.title,
|
title: item.title,
|
||||||
|
|||||||
@ -150,7 +150,7 @@ export const EnvelopeEditorProvider = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const envelopeRecipientSetMutationQuery = trpc.envelope.recipient.set.useMutation({
|
const envelopeRecipientSetMutationQuery = trpc.envelope.recipient.set.useMutation({
|
||||||
onSuccess: ({ recipients }) => {
|
onSuccess: ({ data: recipients }) => {
|
||||||
setEnvelope((prev) => ({
|
setEnvelope((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
recipients,
|
recipients,
|
||||||
@ -196,7 +196,7 @@ export const EnvelopeEditorProvider = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Insert the IDs into the local fields.
|
// Insert the IDs into the local fields.
|
||||||
envelopeFields.fields.forEach((field) => {
|
envelopeFields.data.forEach((field) => {
|
||||||
const localField = localFields.find((localField) => localField.formId === field.formId);
|
const localField = localFields.find((localField) => localField.formId === field.formId);
|
||||||
|
|
||||||
if (localField && !localField.id) {
|
if (localField && !localField.id) {
|
||||||
|
|||||||
@ -4,18 +4,11 @@ import { authenticatedProcedure } from '../../trpc';
|
|||||||
import {
|
import {
|
||||||
ZCreateAttachmentRequestSchema,
|
ZCreateAttachmentRequestSchema,
|
||||||
ZCreateAttachmentResponseSchema,
|
ZCreateAttachmentResponseSchema,
|
||||||
|
createAttachmentMeta,
|
||||||
} from './create-attachment.types';
|
} from './create-attachment.types';
|
||||||
|
|
||||||
export const createAttachmentRoute = authenticatedProcedure
|
export const createAttachmentRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(createAttachmentMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/attachment/create',
|
|
||||||
summary: 'Create attachment',
|
|
||||||
description: 'Create a new attachment for an envelope',
|
|
||||||
tags: ['Envelope Attachments'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZCreateAttachmentRequestSchema)
|
.input(ZCreateAttachmentRequestSchema)
|
||||||
.output(ZCreateAttachmentResponseSchema)
|
.output(ZCreateAttachmentResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
|
|||||||
@ -1,5 +1,17 @@
|
|||||||
import { z } from 'zod';
|
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({
|
export const ZCreateAttachmentRequestSchema = z.object({
|
||||||
envelopeId: z.string(),
|
envelopeId: z.string(),
|
||||||
data: z.object({
|
data: z.object({
|
||||||
|
|||||||
@ -4,18 +4,11 @@ import { authenticatedProcedure } from '../../trpc';
|
|||||||
import {
|
import {
|
||||||
ZDeleteAttachmentRequestSchema,
|
ZDeleteAttachmentRequestSchema,
|
||||||
ZDeleteAttachmentResponseSchema,
|
ZDeleteAttachmentResponseSchema,
|
||||||
|
deleteAttachmentMeta,
|
||||||
} from './delete-attachment.types';
|
} from './delete-attachment.types';
|
||||||
|
|
||||||
export const deleteAttachmentRoute = authenticatedProcedure
|
export const deleteAttachmentRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(deleteAttachmentMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/attachment/delete',
|
|
||||||
summary: 'Delete attachment',
|
|
||||||
description: 'Delete an attachment from an envelope',
|
|
||||||
tags: ['Envelope Attachments'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZDeleteAttachmentRequestSchema)
|
.input(ZDeleteAttachmentRequestSchema)
|
||||||
.output(ZDeleteAttachmentResponseSchema)
|
.output(ZDeleteAttachmentResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
|
|||||||
@ -1,5 +1,17 @@
|
|||||||
import { z } from 'zod';
|
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({
|
export const ZDeleteAttachmentRequestSchema = z.object({
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,18 +6,11 @@ import { maybeAuthenticatedProcedure } from '../../trpc';
|
|||||||
import {
|
import {
|
||||||
ZFindAttachmentsRequestSchema,
|
ZFindAttachmentsRequestSchema,
|
||||||
ZFindAttachmentsResponseSchema,
|
ZFindAttachmentsResponseSchema,
|
||||||
|
findAttachmentsMeta,
|
||||||
} from './find-attachments.types';
|
} from './find-attachments.types';
|
||||||
|
|
||||||
export const findAttachmentsRoute = maybeAuthenticatedProcedure
|
export const findAttachmentsRoute = maybeAuthenticatedProcedure
|
||||||
.meta({
|
.meta(findAttachmentsMeta)
|
||||||
openapi: {
|
|
||||||
method: 'GET',
|
|
||||||
path: '/envelope/attachment',
|
|
||||||
summary: 'Find attachments',
|
|
||||||
description: 'Find all attachments for an envelope',
|
|
||||||
tags: ['Envelope Attachments'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZFindAttachmentsRequestSchema)
|
.input(ZFindAttachmentsRequestSchema)
|
||||||
.output(ZFindAttachmentsResponseSchema)
|
.output(ZFindAttachmentsResponseSchema)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
|
|||||||
@ -2,6 +2,18 @@ import { z } from 'zod';
|
|||||||
|
|
||||||
import { ZEnvelopeAttachmentTypeSchema } from '@documenso/lib/types/envelope-attachment';
|
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({
|
export const ZFindAttachmentsRequestSchema = z.object({
|
||||||
envelopeId: z.string(),
|
envelopeId: z.string(),
|
||||||
token: z.string().optional(),
|
token: z.string().optional(),
|
||||||
|
|||||||
@ -4,18 +4,11 @@ import { authenticatedProcedure } from '../../trpc';
|
|||||||
import {
|
import {
|
||||||
ZUpdateAttachmentRequestSchema,
|
ZUpdateAttachmentRequestSchema,
|
||||||
ZUpdateAttachmentResponseSchema,
|
ZUpdateAttachmentResponseSchema,
|
||||||
|
updateAttachmentMeta,
|
||||||
} from './update-attachment.types';
|
} from './update-attachment.types';
|
||||||
|
|
||||||
export const updateAttachmentRoute = authenticatedProcedure
|
export const updateAttachmentRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(updateAttachmentMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/attachment/update',
|
|
||||||
summary: 'Update attachment',
|
|
||||||
description: 'Update an existing attachment',
|
|
||||||
tags: ['Envelope Attachments'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZUpdateAttachmentRequestSchema)
|
.input(ZUpdateAttachmentRequestSchema)
|
||||||
.output(ZUpdateAttachmentResponseSchema)
|
.output(ZUpdateAttachmentResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
|
|||||||
@ -1,5 +1,17 @@
|
|||||||
import { z } from 'zod';
|
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({
|
export const ZUpdateAttachmentRequestSchema = z.object({
|
||||||
id: z.string(),
|
id: z.string(),
|
||||||
data: z.object({
|
data: z.object({
|
||||||
|
|||||||
@ -11,18 +11,11 @@ import { authenticatedProcedure } from '../trpc';
|
|||||||
import {
|
import {
|
||||||
ZCreateEnvelopeItemsRequestSchema,
|
ZCreateEnvelopeItemsRequestSchema,
|
||||||
ZCreateEnvelopeItemsResponseSchema,
|
ZCreateEnvelopeItemsResponseSchema,
|
||||||
|
createEnvelopeItemsMeta,
|
||||||
} from './create-envelope-items.types';
|
} from './create-envelope-items.types';
|
||||||
|
|
||||||
export const createEnvelopeItemsRoute = authenticatedProcedure
|
export const createEnvelopeItemsRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(createEnvelopeItemsMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/item/create-many',
|
|
||||||
summary: 'Create envelope items',
|
|
||||||
description: 'Create multiple envelope items for an envelope',
|
|
||||||
tags: ['Envelope Items'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZCreateEnvelopeItemsRequestSchema)
|
.input(ZCreateEnvelopeItemsRequestSchema)
|
||||||
.output(ZCreateEnvelopeItemsResponseSchema)
|
.output(ZCreateEnvelopeItemsResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
@ -142,6 +135,6 @@ export const createEnvelopeItemsRoute = authenticatedProcedure
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
createdEnvelopeItems: result,
|
data: result,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,6 +4,17 @@ import { zfd } from 'zod-form-data';
|
|||||||
import EnvelopeItemSchema from '@documenso/prisma/generated/zod/modelSchema/EnvelopeItemSchema';
|
import EnvelopeItemSchema from '@documenso/prisma/generated/zod/modelSchema/EnvelopeItemSchema';
|
||||||
|
|
||||||
import { zodFormData } from '../../utils/zod-form-data';
|
import { zodFormData } from '../../utils/zod-form-data';
|
||||||
|
import type { TrpcRouteMeta } from '../trpc';
|
||||||
|
|
||||||
|
export const createEnvelopeItemsMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'POST',
|
||||||
|
path: '/envelope/item/create-many',
|
||||||
|
summary: 'Create envelope items',
|
||||||
|
description: 'Create multiple envelope items for an envelope',
|
||||||
|
tags: ['Envelope Items'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const ZCreateEnvelopeItemsPayloadSchema = z.object({
|
export const ZCreateEnvelopeItemsPayloadSchema = z.object({
|
||||||
envelopeId: z.string(),
|
envelopeId: z.string(),
|
||||||
@ -16,7 +27,7 @@ export const ZCreateEnvelopeItemsRequestSchema = zodFormData({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const ZCreateEnvelopeItemsResponseSchema = z.object({
|
export const ZCreateEnvelopeItemsResponseSchema = z.object({
|
||||||
createdEnvelopeItems: EnvelopeItemSchema.pick({
|
data: EnvelopeItemSchema.pick({
|
||||||
id: true,
|
id: true,
|
||||||
title: true,
|
title: true,
|
||||||
envelopeId: true,
|
envelopeId: true,
|
||||||
|
|||||||
@ -7,17 +7,11 @@ import { authenticatedProcedure } from '../trpc';
|
|||||||
import {
|
import {
|
||||||
ZCreateEnvelopeRequestSchema,
|
ZCreateEnvelopeRequestSchema,
|
||||||
ZCreateEnvelopeResponseSchema,
|
ZCreateEnvelopeResponseSchema,
|
||||||
|
createEnvelopeMeta,
|
||||||
} from './create-envelope.types';
|
} from './create-envelope.types';
|
||||||
|
|
||||||
export const createEnvelopeRoute = authenticatedProcedure
|
export const createEnvelopeRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(createEnvelopeMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/create',
|
|
||||||
summary: 'Create envelope',
|
|
||||||
tags: ['Envelope'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZCreateEnvelopeRequestSchema)
|
.input(ZCreateEnvelopeRequestSchema)
|
||||||
.output(ZCreateEnvelopeResponseSchema)
|
.output(ZCreateEnvelopeResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
|
|||||||
@ -27,14 +27,13 @@ import {
|
|||||||
import { ZCreateRecipientSchema } from '../recipient-router/schema';
|
import { ZCreateRecipientSchema } from '../recipient-router/schema';
|
||||||
import type { TrpcRouteMeta } from '../trpc';
|
import type { TrpcRouteMeta } from '../trpc';
|
||||||
|
|
||||||
// Currently not in use until we allow passthrough documents on create.
|
|
||||||
export const createEnvelopeMeta: TrpcRouteMeta = {
|
export const createEnvelopeMeta: TrpcRouteMeta = {
|
||||||
openapi: {
|
openapi: {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
path: '/envelope/create',
|
path: '/envelope/create',
|
||||||
contentTypes: ['multipart/form-data'],
|
contentTypes: ['multipart/form-data'],
|
||||||
summary: 'Create envelope',
|
summary: 'Create envelope',
|
||||||
description: 'Create a envelope using form data.',
|
description: 'Create an envelope using form data.',
|
||||||
tags: ['Envelope'],
|
tags: ['Envelope'],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -9,18 +9,11 @@ import { authenticatedProcedure } from '../trpc';
|
|||||||
import {
|
import {
|
||||||
ZDeleteEnvelopeItemRequestSchema,
|
ZDeleteEnvelopeItemRequestSchema,
|
||||||
ZDeleteEnvelopeItemResponseSchema,
|
ZDeleteEnvelopeItemResponseSchema,
|
||||||
|
deleteEnvelopeItemMeta,
|
||||||
} from './delete-envelope-item.types';
|
} from './delete-envelope-item.types';
|
||||||
|
|
||||||
export const deleteEnvelopeItemRoute = authenticatedProcedure
|
export const deleteEnvelopeItemRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(deleteEnvelopeItemMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/item/delete',
|
|
||||||
summary: 'Delete envelope item',
|
|
||||||
description: 'Delete an envelope item from an envelope',
|
|
||||||
tags: ['Envelope Items'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZDeleteEnvelopeItemRequestSchema)
|
.input(ZDeleteEnvelopeItemRequestSchema)
|
||||||
.output(ZDeleteEnvelopeItemResponseSchema)
|
.output(ZDeleteEnvelopeItemResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
|
|||||||
@ -1,5 +1,17 @@
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
import type { TrpcRouteMeta } from '../trpc';
|
||||||
|
|
||||||
|
export const deleteEnvelopeItemMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'POST',
|
||||||
|
path: '/envelope/item/delete',
|
||||||
|
summary: 'Delete envelope item',
|
||||||
|
description: 'Delete an envelope item from an envelope',
|
||||||
|
tags: ['Envelope Items'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const ZDeleteEnvelopeItemRequestSchema = z.object({
|
export const ZDeleteEnvelopeItemRequestSchema = z.object({
|
||||||
envelopeId: z.string(),
|
envelopeId: z.string(),
|
||||||
envelopeItemId: z.string(),
|
envelopeItemId: z.string(),
|
||||||
|
|||||||
@ -10,17 +10,11 @@ import { authenticatedProcedure } from '../trpc';
|
|||||||
import {
|
import {
|
||||||
ZDeleteEnvelopeRequestSchema,
|
ZDeleteEnvelopeRequestSchema,
|
||||||
ZDeleteEnvelopeResponseSchema,
|
ZDeleteEnvelopeResponseSchema,
|
||||||
|
deleteEnvelopeMeta,
|
||||||
} from './delete-envelope.types';
|
} from './delete-envelope.types';
|
||||||
|
|
||||||
export const deleteEnvelopeRoute = authenticatedProcedure
|
export const deleteEnvelopeRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(deleteEnvelopeMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/delete',
|
|
||||||
summary: 'Delete envelope',
|
|
||||||
tags: ['Envelope'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZDeleteEnvelopeRequestSchema)
|
.input(ZDeleteEnvelopeRequestSchema)
|
||||||
.output(ZDeleteEnvelopeResponseSchema)
|
.output(ZDeleteEnvelopeResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
|
|||||||
@ -1,5 +1,16 @@
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
import type { TrpcRouteMeta } from '../trpc';
|
||||||
|
|
||||||
|
export const deleteEnvelopeMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'POST',
|
||||||
|
path: '/envelope/delete',
|
||||||
|
summary: 'Delete envelope',
|
||||||
|
tags: ['Envelope'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const ZDeleteEnvelopeRequestSchema = z.object({
|
export const ZDeleteEnvelopeRequestSchema = z.object({
|
||||||
envelopeId: z.string(),
|
envelopeId: z.string(),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -5,18 +5,11 @@ import { authenticatedProcedure } from '../trpc';
|
|||||||
import {
|
import {
|
||||||
ZDistributeEnvelopeRequestSchema,
|
ZDistributeEnvelopeRequestSchema,
|
||||||
ZDistributeEnvelopeResponseSchema,
|
ZDistributeEnvelopeResponseSchema,
|
||||||
|
distributeEnvelopeMeta,
|
||||||
} from './distribute-envelope.types';
|
} from './distribute-envelope.types';
|
||||||
|
|
||||||
export const distributeEnvelopeRoute = authenticatedProcedure
|
export const distributeEnvelopeRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(distributeEnvelopeMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/distribute',
|
|
||||||
summary: 'Distribute envelope',
|
|
||||||
description: 'Send the envelope to recipients based on your distribution method',
|
|
||||||
tags: ['Envelope'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZDistributeEnvelopeRequestSchema)
|
.input(ZDistributeEnvelopeRequestSchema)
|
||||||
.output(ZDistributeEnvelopeResponseSchema)
|
.output(ZDistributeEnvelopeResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
|
|||||||
@ -2,6 +2,18 @@ import { z } from 'zod';
|
|||||||
|
|
||||||
import { ZDocumentMetaUpdateSchema } from '@documenso/lib/types/document-meta';
|
import { ZDocumentMetaUpdateSchema } from '@documenso/lib/types/document-meta';
|
||||||
|
|
||||||
|
import type { TrpcRouteMeta } from '../trpc';
|
||||||
|
|
||||||
|
export const distributeEnvelopeMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'POST',
|
||||||
|
path: '/envelope/distribute',
|
||||||
|
summary: 'Distribute envelope',
|
||||||
|
description: 'Send the envelope to recipients based on your distribution method',
|
||||||
|
tags: ['Envelope'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const ZDistributeEnvelopeRequestSchema = z.object({
|
export const ZDistributeEnvelopeRequestSchema = z.object({
|
||||||
envelopeId: z.string().describe('The ID of the envelope to send.'),
|
envelopeId: z.string().describe('The ID of the envelope to send.'),
|
||||||
meta: ZDocumentMetaUpdateSchema.pick({
|
meta: ZDocumentMetaUpdateSchema.pick({
|
||||||
|
|||||||
@ -4,18 +4,11 @@ import { authenticatedProcedure } from '../trpc';
|
|||||||
import {
|
import {
|
||||||
ZDuplicateEnvelopeRequestSchema,
|
ZDuplicateEnvelopeRequestSchema,
|
||||||
ZDuplicateEnvelopeResponseSchema,
|
ZDuplicateEnvelopeResponseSchema,
|
||||||
|
duplicateEnvelopeMeta,
|
||||||
} from './duplicate-envelope.types';
|
} from './duplicate-envelope.types';
|
||||||
|
|
||||||
export const duplicateEnvelopeRoute = authenticatedProcedure
|
export const duplicateEnvelopeRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(duplicateEnvelopeMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/duplicate',
|
|
||||||
summary: 'Duplicate envelope',
|
|
||||||
description: 'Duplicate an envelope with all its settings',
|
|
||||||
tags: ['Envelope'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZDuplicateEnvelopeRequestSchema)
|
.input(ZDuplicateEnvelopeRequestSchema)
|
||||||
.output(ZDuplicateEnvelopeResponseSchema)
|
.output(ZDuplicateEnvelopeResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
@ -38,6 +31,6 @@ export const duplicateEnvelopeRoute = authenticatedProcedure
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
duplicatedEnvelopeId: duplicatedEnvelope.id,
|
id: duplicatedEnvelope.id,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,11 +1,23 @@
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
import type { TrpcRouteMeta } from '../trpc';
|
||||||
|
|
||||||
|
export const duplicateEnvelopeMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'POST',
|
||||||
|
path: '/envelope/duplicate',
|
||||||
|
summary: 'Duplicate envelope',
|
||||||
|
description: 'Duplicate an envelope with all its settings',
|
||||||
|
tags: ['Envelope'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const ZDuplicateEnvelopeRequestSchema = z.object({
|
export const ZDuplicateEnvelopeRequestSchema = z.object({
|
||||||
envelopeId: z.string(),
|
envelopeId: z.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const ZDuplicateEnvelopeResponseSchema = z.object({
|
export const ZDuplicateEnvelopeResponseSchema = z.object({
|
||||||
duplicatedEnvelopeId: z.string(),
|
id: z.string().describe('The ID of the newly created envelope.'),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TDuplicateEnvelopeRequest = z.infer<typeof ZDuplicateEnvelopeRequestSchema>;
|
export type TDuplicateEnvelopeRequest = z.infer<typeof ZDuplicateEnvelopeRequestSchema>;
|
||||||
|
|||||||
@ -4,18 +4,11 @@ import { authenticatedProcedure } from '../../trpc';
|
|||||||
import {
|
import {
|
||||||
ZCreateEnvelopeFieldsRequestSchema,
|
ZCreateEnvelopeFieldsRequestSchema,
|
||||||
ZCreateEnvelopeFieldsResponseSchema,
|
ZCreateEnvelopeFieldsResponseSchema,
|
||||||
|
createEnvelopeFieldsMeta,
|
||||||
} from './create-envelope-fields.types';
|
} from './create-envelope-fields.types';
|
||||||
|
|
||||||
export const createEnvelopeFieldsRoute = authenticatedProcedure
|
export const createEnvelopeFieldsRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(createEnvelopeFieldsMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/field/create-many',
|
|
||||||
summary: 'Create envelope fields',
|
|
||||||
description: 'Create multiple fields for an envelope',
|
|
||||||
tags: ['Envelope Fields'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZCreateEnvelopeFieldsRequestSchema)
|
.input(ZCreateEnvelopeFieldsRequestSchema)
|
||||||
.output(ZCreateEnvelopeFieldsResponseSchema)
|
.output(ZCreateEnvelopeFieldsResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
@ -28,7 +21,7 @@ export const createEnvelopeFieldsRoute = authenticatedProcedure
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await createEnvelopeFields({
|
const { fields: data } = await createEnvelopeFields({
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
teamId,
|
teamId,
|
||||||
id: {
|
id: {
|
||||||
@ -38,4 +31,8 @@ export const createEnvelopeFieldsRoute = authenticatedProcedure
|
|||||||
fields,
|
fields,
|
||||||
requestMetadata: metadata,
|
requestMetadata: metadata,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,19 @@ import {
|
|||||||
} from '@documenso/lib/types/field';
|
} from '@documenso/lib/types/field';
|
||||||
import { ZFieldAndMetaSchema } from '@documenso/lib/types/field-meta';
|
import { ZFieldAndMetaSchema } from '@documenso/lib/types/field-meta';
|
||||||
|
|
||||||
|
import type { TrpcRouteMeta } from '../../trpc';
|
||||||
|
|
||||||
|
export const createEnvelopeFieldsMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'POST',
|
||||||
|
path: '/envelope/field/create-many',
|
||||||
|
contentTypes: ['multipart/form-data'],
|
||||||
|
summary: 'Create envelope fields',
|
||||||
|
description: 'Create multiple fields for an envelope',
|
||||||
|
tags: ['Envelope Fields'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const ZCreateFieldSchema = ZFieldAndMetaSchema.and(
|
const ZCreateFieldSchema = ZFieldAndMetaSchema.and(
|
||||||
z.object({
|
z.object({
|
||||||
recipientId: z.number().describe('The ID of the recipient to create the field for'),
|
recipientId: z.number().describe('The ID of the recipient to create the field for'),
|
||||||
@ -33,7 +46,7 @@ export const ZCreateEnvelopeFieldsRequestSchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const ZCreateEnvelopeFieldsResponseSchema = z.object({
|
export const ZCreateEnvelopeFieldsResponseSchema = z.object({
|
||||||
fields: z.array(ZFieldSchema),
|
data: z.array(ZFieldSchema),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TCreateEnvelopeFieldsRequest = z.infer<typeof ZCreateEnvelopeFieldsRequestSchema>;
|
export type TCreateEnvelopeFieldsRequest = z.infer<typeof ZCreateEnvelopeFieldsRequestSchema>;
|
||||||
|
|||||||
@ -11,18 +11,11 @@ import { authenticatedProcedure } from '../../trpc';
|
|||||||
import {
|
import {
|
||||||
ZDeleteEnvelopeFieldRequestSchema,
|
ZDeleteEnvelopeFieldRequestSchema,
|
||||||
ZDeleteEnvelopeFieldResponseSchema,
|
ZDeleteEnvelopeFieldResponseSchema,
|
||||||
|
deleteEnvelopeFieldMeta,
|
||||||
} from './delete-envelope-field.types';
|
} from './delete-envelope-field.types';
|
||||||
|
|
||||||
export const deleteEnvelopeFieldRoute = authenticatedProcedure
|
export const deleteEnvelopeFieldRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(deleteEnvelopeFieldMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/field/delete',
|
|
||||||
summary: 'Delete envelope field',
|
|
||||||
description: 'Delete an envelope field',
|
|
||||||
tags: ['Envelope Fields'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZDeleteEnvelopeFieldRequestSchema)
|
.input(ZDeleteEnvelopeFieldRequestSchema)
|
||||||
.output(ZDeleteEnvelopeFieldResponseSchema)
|
.output(ZDeleteEnvelopeFieldResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
|
|||||||
@ -1,5 +1,17 @@
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
import type { TrpcRouteMeta } from '../../trpc';
|
||||||
|
|
||||||
|
export const deleteEnvelopeFieldMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'POST',
|
||||||
|
path: '/envelope/field/delete',
|
||||||
|
summary: 'Delete envelope field',
|
||||||
|
description: 'Delete an envelope field',
|
||||||
|
tags: ['Envelope Fields'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const ZDeleteEnvelopeFieldRequestSchema = z.object({
|
export const ZDeleteEnvelopeFieldRequestSchema = z.object({
|
||||||
fieldId: z.number(),
|
fieldId: z.number(),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,18 +4,11 @@ import { authenticatedProcedure } from '../../trpc';
|
|||||||
import {
|
import {
|
||||||
ZGetEnvelopeFieldRequestSchema,
|
ZGetEnvelopeFieldRequestSchema,
|
||||||
ZGetEnvelopeFieldResponseSchema,
|
ZGetEnvelopeFieldResponseSchema,
|
||||||
|
getEnvelopeFieldMeta,
|
||||||
} from './get-envelope-field.types';
|
} from './get-envelope-field.types';
|
||||||
|
|
||||||
export const getEnvelopeFieldRoute = authenticatedProcedure
|
export const getEnvelopeFieldRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(getEnvelopeFieldMeta)
|
||||||
openapi: {
|
|
||||||
method: 'GET',
|
|
||||||
path: '/envelope/field/{fieldId}',
|
|
||||||
summary: 'Get envelope field',
|
|
||||||
description: 'Returns an envelope field given an ID',
|
|
||||||
tags: ['Envelope Fields'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZGetEnvelopeFieldRequestSchema)
|
.input(ZGetEnvelopeFieldRequestSchema)
|
||||||
.output(ZGetEnvelopeFieldResponseSchema)
|
.output(ZGetEnvelopeFieldResponseSchema)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
|
|||||||
@ -2,6 +2,18 @@ import { z } from 'zod';
|
|||||||
|
|
||||||
import { ZEnvelopeFieldSchema } from '@documenso/lib/types/field';
|
import { ZEnvelopeFieldSchema } from '@documenso/lib/types/field';
|
||||||
|
|
||||||
|
import type { TrpcRouteMeta } from '../../trpc';
|
||||||
|
|
||||||
|
export const getEnvelopeFieldMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'GET',
|
||||||
|
path: '/envelope/field/{fieldId}',
|
||||||
|
summary: 'Get envelope field',
|
||||||
|
description: 'Returns an envelope field given an ID',
|
||||||
|
tags: ['Envelope Fields'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const ZGetEnvelopeFieldRequestSchema = z.object({
|
export const ZGetEnvelopeFieldRequestSchema = z.object({
|
||||||
fieldId: z.number(),
|
fieldId: z.number(),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,18 +4,11 @@ import { authenticatedProcedure } from '../../trpc';
|
|||||||
import {
|
import {
|
||||||
ZUpdateEnvelopeFieldsRequestSchema,
|
ZUpdateEnvelopeFieldsRequestSchema,
|
||||||
ZUpdateEnvelopeFieldsResponseSchema,
|
ZUpdateEnvelopeFieldsResponseSchema,
|
||||||
|
updateEnvelopeFieldsMeta,
|
||||||
} from './update-envelope-fields.types';
|
} from './update-envelope-fields.types';
|
||||||
|
|
||||||
export const updateEnvelopeFieldsRoute = authenticatedProcedure
|
export const updateEnvelopeFieldsRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(updateEnvelopeFieldsMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/field/update-many',
|
|
||||||
summary: 'Update envelope fields',
|
|
||||||
description: 'Update multiple envelope fields for an envelope',
|
|
||||||
tags: ['Envelope Fields'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZUpdateEnvelopeFieldsRequestSchema)
|
.input(ZUpdateEnvelopeFieldsRequestSchema)
|
||||||
.output(ZUpdateEnvelopeFieldsResponseSchema)
|
.output(ZUpdateEnvelopeFieldsResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
@ -28,7 +21,7 @@ export const updateEnvelopeFieldsRoute = authenticatedProcedure
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await updateEnvelopeFields({
|
const { fields: data } = await updateEnvelopeFields({
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
teamId,
|
teamId,
|
||||||
id: {
|
id: {
|
||||||
@ -39,4 +32,8 @@ export const updateEnvelopeFieldsRoute = authenticatedProcedure
|
|||||||
fields,
|
fields,
|
||||||
requestMetadata: ctx.metadata,
|
requestMetadata: ctx.metadata,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@ -10,6 +10,18 @@ import {
|
|||||||
} from '@documenso/lib/types/field';
|
} from '@documenso/lib/types/field';
|
||||||
import { ZFieldAndMetaSchema } from '@documenso/lib/types/field-meta';
|
import { ZFieldAndMetaSchema } from '@documenso/lib/types/field-meta';
|
||||||
|
|
||||||
|
import type { TrpcRouteMeta } from '../../trpc';
|
||||||
|
|
||||||
|
export const updateEnvelopeFieldsMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'POST',
|
||||||
|
path: '/envelope/field/update-many',
|
||||||
|
summary: 'Update envelope fields',
|
||||||
|
description: 'Update multiple envelope fields for an envelope',
|
||||||
|
tags: ['Envelope Fields'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const ZUpdateFieldSchema = ZFieldAndMetaSchema.and(
|
const ZUpdateFieldSchema = ZFieldAndMetaSchema.and(
|
||||||
z.object({
|
z.object({
|
||||||
id: z.number().describe('The ID of the field to update.'),
|
id: z.number().describe('The ID of the field to update.'),
|
||||||
@ -33,7 +45,7 @@ export const ZUpdateEnvelopeFieldsRequestSchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const ZUpdateEnvelopeFieldsResponseSchema = z.object({
|
export const ZUpdateEnvelopeFieldsResponseSchema = z.object({
|
||||||
fields: z.array(ZFieldSchema),
|
data: z.array(ZFieldSchema),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TUpdateEnvelopeFieldsRequest = z.infer<typeof ZUpdateEnvelopeFieldsRequestSchema>;
|
export type TUpdateEnvelopeFieldsRequest = z.infer<typeof ZUpdateEnvelopeFieldsRequestSchema>;
|
||||||
|
|||||||
@ -4,18 +4,11 @@ import { authenticatedProcedure } from '../../trpc';
|
|||||||
import {
|
import {
|
||||||
ZCreateEnvelopeRecipientsRequestSchema,
|
ZCreateEnvelopeRecipientsRequestSchema,
|
||||||
ZCreateEnvelopeRecipientsResponseSchema,
|
ZCreateEnvelopeRecipientsResponseSchema,
|
||||||
|
createEnvelopeRecipientsMeta,
|
||||||
} from './create-envelope-recipients.types';
|
} from './create-envelope-recipients.types';
|
||||||
|
|
||||||
export const createEnvelopeRecipientsRoute = authenticatedProcedure
|
export const createEnvelopeRecipientsRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(createEnvelopeRecipientsMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/recipient/create-many',
|
|
||||||
summary: 'Create envelope recipients',
|
|
||||||
description: 'Create multiple recipients for an envelope',
|
|
||||||
tags: ['Envelope Recipients'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZCreateEnvelopeRecipientsRequestSchema)
|
.input(ZCreateEnvelopeRecipientsRequestSchema)
|
||||||
.output(ZCreateEnvelopeRecipientsResponseSchema)
|
.output(ZCreateEnvelopeRecipientsResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
@ -28,7 +21,7 @@ export const createEnvelopeRecipientsRoute = authenticatedProcedure
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await createEnvelopeRecipients({
|
const { recipients: data } = await createEnvelopeRecipients({
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
teamId,
|
teamId,
|
||||||
id: {
|
id: {
|
||||||
@ -38,4 +31,8 @@ export const createEnvelopeRecipientsRoute = authenticatedProcedure
|
|||||||
recipients,
|
recipients,
|
||||||
requestMetadata: metadata,
|
requestMetadata: metadata,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,6 +3,17 @@ import { z } from 'zod';
|
|||||||
import { ZEnvelopeRecipientLiteSchema } from '@documenso/lib/types/recipient';
|
import { ZEnvelopeRecipientLiteSchema } from '@documenso/lib/types/recipient';
|
||||||
|
|
||||||
import { ZCreateRecipientSchema } from '../../recipient-router/schema';
|
import { ZCreateRecipientSchema } from '../../recipient-router/schema';
|
||||||
|
import type { TrpcRouteMeta } from '../../trpc';
|
||||||
|
|
||||||
|
export const createEnvelopeRecipientsMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'POST',
|
||||||
|
path: '/envelope/recipient/create-many',
|
||||||
|
summary: 'Create envelope recipients',
|
||||||
|
description: 'Create multiple recipients for an envelope',
|
||||||
|
tags: ['Envelope Recipients'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const ZCreateEnvelopeRecipientsRequestSchema = z.object({
|
export const ZCreateEnvelopeRecipientsRequestSchema = z.object({
|
||||||
envelopeId: z.string(),
|
envelopeId: z.string(),
|
||||||
@ -10,7 +21,7 @@ export const ZCreateEnvelopeRecipientsRequestSchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const ZCreateEnvelopeRecipientsResponseSchema = z.object({
|
export const ZCreateEnvelopeRecipientsResponseSchema = z.object({
|
||||||
recipients: ZEnvelopeRecipientLiteSchema.array(),
|
data: ZEnvelopeRecipientLiteSchema.array(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TCreateEnvelopeRecipientsRequest = z.infer<
|
export type TCreateEnvelopeRecipientsRequest = z.infer<
|
||||||
|
|||||||
@ -4,18 +4,11 @@ import { authenticatedProcedure } from '../../trpc';
|
|||||||
import {
|
import {
|
||||||
ZDeleteEnvelopeRecipientRequestSchema,
|
ZDeleteEnvelopeRecipientRequestSchema,
|
||||||
ZDeleteEnvelopeRecipientResponseSchema,
|
ZDeleteEnvelopeRecipientResponseSchema,
|
||||||
|
deleteEnvelopeRecipientMeta,
|
||||||
} from './delete-envelope-recipient.types';
|
} from './delete-envelope-recipient.types';
|
||||||
|
|
||||||
export const deleteEnvelopeRecipientRoute = authenticatedProcedure
|
export const deleteEnvelopeRecipientRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(deleteEnvelopeRecipientMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/recipient/delete',
|
|
||||||
summary: 'Delete envelope recipient',
|
|
||||||
description: 'Delete an envelope recipient',
|
|
||||||
tags: ['Envelope Recipients'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZDeleteEnvelopeRecipientRequestSchema)
|
.input(ZDeleteEnvelopeRecipientRequestSchema)
|
||||||
.output(ZDeleteEnvelopeRecipientResponseSchema)
|
.output(ZDeleteEnvelopeRecipientResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
|
|||||||
@ -1,5 +1,17 @@
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
import type { TrpcRouteMeta } from '../../trpc';
|
||||||
|
|
||||||
|
export const deleteEnvelopeRecipientMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'POST',
|
||||||
|
path: '/envelope/recipient/delete',
|
||||||
|
summary: 'Delete envelope recipient',
|
||||||
|
description: 'Delete an envelope recipient',
|
||||||
|
tags: ['Envelope Recipients'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const ZDeleteEnvelopeRecipientRequestSchema = z.object({
|
export const ZDeleteEnvelopeRecipientRequestSchema = z.object({
|
||||||
recipientId: z.number(),
|
recipientId: z.number(),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -6,18 +6,11 @@ import { authenticatedProcedure } from '../../trpc';
|
|||||||
import {
|
import {
|
||||||
ZGetEnvelopeRecipientRequestSchema,
|
ZGetEnvelopeRecipientRequestSchema,
|
||||||
ZGetEnvelopeRecipientResponseSchema,
|
ZGetEnvelopeRecipientResponseSchema,
|
||||||
|
getEnvelopeRecipientMeta,
|
||||||
} from './get-envelope-recipient.types';
|
} from './get-envelope-recipient.types';
|
||||||
|
|
||||||
export const getEnvelopeRecipientRoute = authenticatedProcedure
|
export const getEnvelopeRecipientRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(getEnvelopeRecipientMeta)
|
||||||
openapi: {
|
|
||||||
method: 'GET',
|
|
||||||
path: '/envelope/recipient/{recipientId}',
|
|
||||||
summary: 'Get envelope recipient',
|
|
||||||
description: 'Returns an envelope recipient given an ID',
|
|
||||||
tags: ['Envelope Recipients'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZGetEnvelopeRecipientRequestSchema)
|
.input(ZGetEnvelopeRecipientRequestSchema)
|
||||||
.output(ZGetEnvelopeRecipientResponseSchema)
|
.output(ZGetEnvelopeRecipientResponseSchema)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
|
|||||||
@ -2,6 +2,18 @@ import { z } from 'zod';
|
|||||||
|
|
||||||
import { ZEnvelopeRecipientSchema } from '@documenso/lib/types/recipient';
|
import { ZEnvelopeRecipientSchema } from '@documenso/lib/types/recipient';
|
||||||
|
|
||||||
|
import type { TrpcRouteMeta } from '../../trpc';
|
||||||
|
|
||||||
|
export const getEnvelopeRecipientMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'GET',
|
||||||
|
path: '/envelope/recipient/{recipientId}',
|
||||||
|
summary: 'Get envelope recipient',
|
||||||
|
description: 'Returns an envelope recipient given an ID',
|
||||||
|
tags: ['Envelope Recipients'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const ZGetEnvelopeRecipientRequestSchema = z.object({
|
export const ZGetEnvelopeRecipientRequestSchema = z.object({
|
||||||
recipientId: z.number(),
|
recipientId: z.number(),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,18 +4,11 @@ import { authenticatedProcedure } from '../../trpc';
|
|||||||
import {
|
import {
|
||||||
ZUpdateEnvelopeRecipientsRequestSchema,
|
ZUpdateEnvelopeRecipientsRequestSchema,
|
||||||
ZUpdateEnvelopeRecipientsResponseSchema,
|
ZUpdateEnvelopeRecipientsResponseSchema,
|
||||||
|
updateEnvelopeRecipientsMeta,
|
||||||
} from './update-envelope-recipients.types';
|
} from './update-envelope-recipients.types';
|
||||||
|
|
||||||
export const updateEnvelopeRecipientsRoute = authenticatedProcedure
|
export const updateEnvelopeRecipientsRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(updateEnvelopeRecipientsMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/recipient/update-many',
|
|
||||||
summary: 'Update envelope recipients',
|
|
||||||
description: 'Update multiple recipients for an envelope',
|
|
||||||
tags: ['Envelope Recipients'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZUpdateEnvelopeRecipientsRequestSchema)
|
.input(ZUpdateEnvelopeRecipientsRequestSchema)
|
||||||
.output(ZUpdateEnvelopeRecipientsResponseSchema)
|
.output(ZUpdateEnvelopeRecipientsResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
@ -28,7 +21,7 @@ export const updateEnvelopeRecipientsRoute = authenticatedProcedure
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await updateEnvelopeRecipients({
|
const { recipients: data } = await updateEnvelopeRecipients({
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
teamId,
|
teamId,
|
||||||
id: {
|
id: {
|
||||||
@ -38,4 +31,8 @@ export const updateEnvelopeRecipientsRoute = authenticatedProcedure
|
|||||||
recipients,
|
recipients,
|
||||||
requestMetadata: ctx.metadata,
|
requestMetadata: ctx.metadata,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,6 +3,17 @@ import { z } from 'zod';
|
|||||||
import { ZRecipientLiteSchema } from '@documenso/lib/types/recipient';
|
import { ZRecipientLiteSchema } from '@documenso/lib/types/recipient';
|
||||||
|
|
||||||
import { ZUpdateRecipientSchema } from '../../recipient-router/schema';
|
import { ZUpdateRecipientSchema } from '../../recipient-router/schema';
|
||||||
|
import type { TrpcRouteMeta } from '../../trpc';
|
||||||
|
|
||||||
|
export const updateEnvelopeRecipientsMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'POST',
|
||||||
|
path: '/envelope/recipient/update-many',
|
||||||
|
summary: 'Update envelope recipients',
|
||||||
|
description: 'Update multiple recipients for an envelope',
|
||||||
|
tags: ['Envelope Recipients'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const ZUpdateEnvelopeRecipientsRequestSchema = z.object({
|
export const ZUpdateEnvelopeRecipientsRequestSchema = z.object({
|
||||||
envelopeId: z.string(),
|
envelopeId: z.string(),
|
||||||
@ -10,7 +21,7 @@ export const ZUpdateEnvelopeRecipientsRequestSchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const ZUpdateEnvelopeRecipientsResponseSchema = z.object({
|
export const ZUpdateEnvelopeRecipientsResponseSchema = z.object({
|
||||||
recipients: ZRecipientLiteSchema.array(),
|
data: ZRecipientLiteSchema.array(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export type TUpdateEnvelopeRecipientsRequest = z.infer<
|
export type TUpdateEnvelopeRecipientsRequest = z.infer<
|
||||||
|
|||||||
@ -34,10 +34,25 @@ export const getEnvelopeItemsByTokenRoute = maybeAuthenticatedProcedure
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return await handleGetEnvelopeItemsByUser({ envelopeId, userId: user.id, teamId });
|
const { envelopeItems: data } = await handleGetEnvelopeItemsByUser({
|
||||||
|
envelopeId,
|
||||||
|
userId: user.id,
|
||||||
|
teamId,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return await handleGetEnvelopeItemsByToken({ envelopeId, token: access.token });
|
const { envelopeItems: data } = await handleGetEnvelopeItemsByToken({
|
||||||
|
envelopeId,
|
||||||
|
token: access.token,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleGetEnvelopeItemsByToken = async ({
|
const handleGetEnvelopeItemsByToken = async ({
|
||||||
|
|||||||
@ -16,7 +16,7 @@ export const ZGetEnvelopeItemsByTokenRequestSchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const ZGetEnvelopeItemsByTokenResponseSchema = z.object({
|
export const ZGetEnvelopeItemsByTokenResponseSchema = z.object({
|
||||||
envelopeItems: EnvelopeItemSchema.pick({
|
data: EnvelopeItemSchema.pick({
|
||||||
id: true,
|
id: true,
|
||||||
envelopeId: true,
|
envelopeId: true,
|
||||||
title: true,
|
title: true,
|
||||||
|
|||||||
@ -50,6 +50,6 @@ export const getEnvelopeItemsRoute = authenticatedProcedure
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
envelopeItems: envelope.envelopeItems,
|
data: envelope.envelopeItems,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@ -8,7 +8,7 @@ export const ZGetEnvelopeItemsRequestSchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const ZGetEnvelopeItemsResponseSchema = z.object({
|
export const ZGetEnvelopeItemsResponseSchema = z.object({
|
||||||
envelopeItems: EnvelopeItemSchema.pick({
|
data: EnvelopeItemSchema.pick({
|
||||||
id: true,
|
id: true,
|
||||||
title: true,
|
title: true,
|
||||||
order: true,
|
order: true,
|
||||||
|
|||||||
@ -1,18 +1,14 @@
|
|||||||
import { getEnvelopeById } from '@documenso/lib/server-only/envelope/get-envelope-by-id';
|
import { getEnvelopeById } from '@documenso/lib/server-only/envelope/get-envelope-by-id';
|
||||||
|
|
||||||
import { authenticatedProcedure } from '../trpc';
|
import { authenticatedProcedure } from '../trpc';
|
||||||
import { ZGetEnvelopeRequestSchema, ZGetEnvelopeResponseSchema } from './get-envelope.types';
|
import {
|
||||||
|
ZGetEnvelopeRequestSchema,
|
||||||
|
ZGetEnvelopeResponseSchema,
|
||||||
|
getEnvelopeMeta,
|
||||||
|
} from './get-envelope.types';
|
||||||
|
|
||||||
export const getEnvelopeRoute = authenticatedProcedure
|
export const getEnvelopeRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(getEnvelopeMeta)
|
||||||
openapi: {
|
|
||||||
method: 'GET',
|
|
||||||
path: '/envelope/{envelopeId}',
|
|
||||||
summary: 'Get envelope',
|
|
||||||
description: 'Returns an envelope given an ID',
|
|
||||||
tags: ['Envelope'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZGetEnvelopeRequestSchema)
|
.input(ZGetEnvelopeRequestSchema)
|
||||||
.output(ZGetEnvelopeResponseSchema)
|
.output(ZGetEnvelopeResponseSchema)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
|
|||||||
@ -2,6 +2,18 @@ import { z } from 'zod';
|
|||||||
|
|
||||||
import { ZEnvelopeSchema } from '@documenso/lib/types/envelope';
|
import { ZEnvelopeSchema } from '@documenso/lib/types/envelope';
|
||||||
|
|
||||||
|
import type { TrpcRouteMeta } from '../trpc';
|
||||||
|
|
||||||
|
export const getEnvelopeMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'GET',
|
||||||
|
path: '/envelope/{envelopeId}',
|
||||||
|
summary: 'Get envelope',
|
||||||
|
description: 'Returns an envelope given an ID',
|
||||||
|
tags: ['Envelope'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const ZGetEnvelopeRequestSchema = z.object({
|
export const ZGetEnvelopeRequestSchema = z.object({
|
||||||
envelopeId: z.string(),
|
envelopeId: z.string(),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,19 +4,11 @@ import { authenticatedProcedure } from '../trpc';
|
|||||||
import {
|
import {
|
||||||
ZRedistributeEnvelopeRequestSchema,
|
ZRedistributeEnvelopeRequestSchema,
|
||||||
ZRedistributeEnvelopeResponseSchema,
|
ZRedistributeEnvelopeResponseSchema,
|
||||||
|
redistributeEnvelopeMeta,
|
||||||
} from './redistribute-envelope.types';
|
} from './redistribute-envelope.types';
|
||||||
|
|
||||||
export const redistributeEnvelopeRoute = authenticatedProcedure
|
export const redistributeEnvelopeRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(redistributeEnvelopeMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/redistribute',
|
|
||||||
summary: 'Redistribute envelope',
|
|
||||||
description:
|
|
||||||
'Redistribute the envelope to the provided recipients who have not actioned the envelope. Will use the distribution method set in the envelope',
|
|
||||||
tags: ['Envelope'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZRedistributeEnvelopeRequestSchema)
|
.input(ZRedistributeEnvelopeRequestSchema)
|
||||||
.output(ZRedistributeEnvelopeResponseSchema)
|
.output(ZRedistributeEnvelopeResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
|
|||||||
@ -1,5 +1,18 @@
|
|||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
|
|
||||||
|
import type { TrpcRouteMeta } from '../trpc';
|
||||||
|
|
||||||
|
export const redistributeEnvelopeMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'POST',
|
||||||
|
path: '/envelope/redistribute',
|
||||||
|
summary: 'Redistribute envelope',
|
||||||
|
description:
|
||||||
|
'Redistribute the envelope to the provided recipients who have not actioned the envelope. Will use the distribution method set in the envelope',
|
||||||
|
tags: ['Envelope'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const ZRedistributeEnvelopeRequestSchema = z.object({
|
export const ZRedistributeEnvelopeRequestSchema = z.object({
|
||||||
envelopeId: z.string(),
|
envelopeId: z.string(),
|
||||||
recipients: z
|
recipients: z
|
||||||
|
|||||||
@ -65,7 +65,7 @@ export const setEnvelopeFieldsRoute = authenticatedProcedure
|
|||||||
.exhaustive();
|
.exhaustive();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fields: result.fields.map((field) => ({
|
data: result.fields.map((field) => ({
|
||||||
id: field.id,
|
id: field.id,
|
||||||
formId: field.formId,
|
formId: field.formId,
|
||||||
})),
|
})),
|
||||||
|
|||||||
@ -37,7 +37,7 @@ export const ZSetEnvelopeFieldsRequestSchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const ZSetEnvelopeFieldsResponseSchema = z.object({
|
export const ZSetEnvelopeFieldsResponseSchema = z.object({
|
||||||
fields: z
|
data: z
|
||||||
.object({
|
.object({
|
||||||
id: z.number(),
|
id: z.number(),
|
||||||
formId: z.string().optional(),
|
formId: z.string().optional(),
|
||||||
|
|||||||
@ -23,7 +23,7 @@ export const setEnvelopeRecipientsRoute = authenticatedProcedure
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return await match(envelopeType)
|
const { recipients: data } = await match(envelopeType)
|
||||||
.with(EnvelopeType.DOCUMENT, async () =>
|
.with(EnvelopeType.DOCUMENT, async () =>
|
||||||
setDocumentRecipients({
|
setDocumentRecipients({
|
||||||
userId: ctx.user.id,
|
userId: ctx.user.id,
|
||||||
@ -48,4 +48,8 @@ export const setEnvelopeRecipientsRoute = authenticatedProcedure
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.exhaustive();
|
.exhaustive();
|
||||||
|
|
||||||
|
return {
|
||||||
|
data,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@ -20,7 +20,7 @@ export const ZSetEnvelopeRecipientsRequestSchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const ZSetEnvelopeRecipientsResponseSchema = z.object({
|
export const ZSetEnvelopeRecipientsResponseSchema = z.object({
|
||||||
recipients: ZRecipientLiteSchema.omit({
|
data: ZRecipientLiteSchema.omit({
|
||||||
documentId: true,
|
documentId: true,
|
||||||
templateId: true,
|
templateId: true,
|
||||||
}).array(),
|
}).array(),
|
||||||
|
|||||||
@ -7,18 +7,11 @@ import { authenticatedProcedure } from '../trpc';
|
|||||||
import {
|
import {
|
||||||
ZUpdateEnvelopeItemsRequestSchema,
|
ZUpdateEnvelopeItemsRequestSchema,
|
||||||
ZUpdateEnvelopeItemsResponseSchema,
|
ZUpdateEnvelopeItemsResponseSchema,
|
||||||
|
updateEnvelopeItemsMeta,
|
||||||
} from './update-envelope-items.types';
|
} from './update-envelope-items.types';
|
||||||
|
|
||||||
export const updateEnvelopeItemsRoute = authenticatedProcedure
|
export const updateEnvelopeItemsRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(updateEnvelopeItemsMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/item/update-many',
|
|
||||||
summary: 'Update envelope items',
|
|
||||||
description: 'Update multiple envelope items for an envelope',
|
|
||||||
tags: ['Envelope Items'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZUpdateEnvelopeItemsRequestSchema)
|
.input(ZUpdateEnvelopeItemsRequestSchema)
|
||||||
.output(ZUpdateEnvelopeItemsResponseSchema)
|
.output(ZUpdateEnvelopeItemsResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
@ -102,6 +95,6 @@ export const updateEnvelopeItemsRoute = authenticatedProcedure
|
|||||||
// Todo: Envelope [AUDIT_LOGS]
|
// Todo: Envelope [AUDIT_LOGS]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
updatedEnvelopeItems,
|
data: updatedEnvelopeItems,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@ -3,6 +3,17 @@ import { z } from 'zod';
|
|||||||
import EnvelopeItemSchema from '@documenso/prisma/generated/zod/modelSchema/EnvelopeItemSchema';
|
import EnvelopeItemSchema from '@documenso/prisma/generated/zod/modelSchema/EnvelopeItemSchema';
|
||||||
|
|
||||||
import { ZDocumentTitleSchema } from '../document-router/schema';
|
import { ZDocumentTitleSchema } from '../document-router/schema';
|
||||||
|
import type { TrpcRouteMeta } from '../trpc';
|
||||||
|
|
||||||
|
export const updateEnvelopeItemsMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'POST',
|
||||||
|
path: '/envelope/item/update-many',
|
||||||
|
summary: 'Update envelope items',
|
||||||
|
description: 'Update multiple envelope items for an envelope',
|
||||||
|
tags: ['Envelope Items'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const ZUpdateEnvelopeItemsRequestSchema = z.object({
|
export const ZUpdateEnvelopeItemsRequestSchema = z.object({
|
||||||
envelopeId: z.string(),
|
envelopeId: z.string(),
|
||||||
@ -17,7 +28,7 @@ export const ZUpdateEnvelopeItemsRequestSchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const ZUpdateEnvelopeItemsResponseSchema = z.object({
|
export const ZUpdateEnvelopeItemsResponseSchema = z.object({
|
||||||
updatedEnvelopeItems: EnvelopeItemSchema.pick({
|
data: EnvelopeItemSchema.pick({
|
||||||
id: true,
|
id: true,
|
||||||
order: true,
|
order: true,
|
||||||
title: true,
|
title: true,
|
||||||
|
|||||||
@ -4,17 +4,11 @@ import { authenticatedProcedure } from '../trpc';
|
|||||||
import {
|
import {
|
||||||
ZUpdateEnvelopeRequestSchema,
|
ZUpdateEnvelopeRequestSchema,
|
||||||
ZUpdateEnvelopeResponseSchema,
|
ZUpdateEnvelopeResponseSchema,
|
||||||
|
updateEnvelopeMeta,
|
||||||
} from './update-envelope.types';
|
} from './update-envelope.types';
|
||||||
|
|
||||||
export const updateEnvelopeRoute = authenticatedProcedure
|
export const updateEnvelopeRoute = authenticatedProcedure
|
||||||
.meta({
|
.meta(updateEnvelopeMeta)
|
||||||
openapi: {
|
|
||||||
method: 'POST',
|
|
||||||
path: '/envelope/update',
|
|
||||||
summary: 'Update envelope',
|
|
||||||
tags: ['Envelope'],
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.input(ZUpdateEnvelopeRequestSchema)
|
.input(ZUpdateEnvelopeRequestSchema)
|
||||||
.output(ZUpdateEnvelopeResponseSchema)
|
.output(ZUpdateEnvelopeResponseSchema)
|
||||||
.mutation(async ({ input, ctx }) => {
|
.mutation(async ({ input, ctx }) => {
|
||||||
|
|||||||
@ -12,6 +12,16 @@ import {
|
|||||||
ZDocumentTitleSchema,
|
ZDocumentTitleSchema,
|
||||||
ZDocumentVisibilitySchema,
|
ZDocumentVisibilitySchema,
|
||||||
} from '../document-router/schema';
|
} from '../document-router/schema';
|
||||||
|
import type { TrpcRouteMeta } from '../trpc';
|
||||||
|
|
||||||
|
export const updateEnvelopeMeta: TrpcRouteMeta = {
|
||||||
|
openapi: {
|
||||||
|
method: 'POST',
|
||||||
|
path: '/envelope/update',
|
||||||
|
summary: 'Update envelope',
|
||||||
|
tags: ['Envelope'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export const ZUpdateEnvelopeRequestSchema = z.object({
|
export const ZUpdateEnvelopeRequestSchema = z.object({
|
||||||
envelopeId: z.string(),
|
envelopeId: z.string(),
|
||||||
|
|||||||
Reference in New Issue
Block a user