import { z } from 'zod';

import { ZSuccessResponseSchema } from '../schema';
import type { TrpcRouteMeta } from '../trpc';

export const redistributeDocumentMeta: TrpcRouteMeta = {
  openapi: {
    method: 'POST',
    path: '/document/redistribute',
    summary: 'Redistribute document',
    description:
      'Deprecated: this endpoint is being replaced by the Envelope API. See https://docs.documenso.com/docs/developers/api/migrate-to-envelopes for the migration guide. Redistribute the document to the provided recipients who have not actioned the document. Will use the distribution method set in the document. This also refreshes the signing-link expiration for the targeted unsigned recipients, renewing any expired links.',
    tags: ['Document'],
    deprecated: true,
  },
};

export const ZRedistributeDocumentRequestSchema = z.object({
  documentId: z.number(),
  recipients: z.array(z.number()).min(1).describe('The IDs of the recipients to redistribute the document to.'),
});

export const ZRedistributeDocumentResponseSchema = ZSuccessResponseSchema;

export type TRedistributeDocumentRequest = z.infer<typeof ZRedistributeDocumentRequestSchema>;
export type TRedistributeDocumentResponse = z.infer<typeof ZRedistributeDocumentResponseSchema>;
