mirror of
https://github.com/SamyRai/turash.git
synced 2025-12-26 23:01:33 +00:00
- Remove nested git repository from bugulma/frontend/.git - Add all frontend files to main repository tracking - Convert from separate frontend/backend repos to unified monorepo - Preserve all frontend code and development history as tracked files - Eliminate nested repository complexity for simpler development workflow This creates a proper monorepo structure with frontend and backend coexisting in the same repository for easier development and deployment.
83 lines
2.7 KiB
TypeScript
83 lines
2.7 KiB
TypeScript
import { z } from 'zod';
|
|
import { resourceDirectionSchema } from '@/schemas/backend/resource-flow';
|
|
import { idSchema, nameSchema, timestampSchema } from '@/schemas/common';
|
|
|
|
type TFunction = (key: string) => string;
|
|
|
|
/**
|
|
* Proposal status enum
|
|
* Uses Zod v4's improved enum support
|
|
*/
|
|
export const proposalStatusSchema = z
|
|
.enum(['pending', 'accepted', 'rejected'])
|
|
.describe('Proposal status');
|
|
export type ProposalStatus = z.infer<typeof proposalStatusSchema>;
|
|
|
|
/**
|
|
* Proposal schema with internationalized error messages
|
|
* Uses Zod v4's composition and common schemas for DRY code
|
|
*/
|
|
export const getProposalSchema = (t: TFunction) =>
|
|
z.object({
|
|
id: idSchema,
|
|
fromOrgId: idSchema.describe('Source organization ID'),
|
|
toOrgId: idSchema.describe('Target organization ID'),
|
|
resourceId: idSchema.describe('Resource flow ID'),
|
|
resourceType: resourceDirectionSchema.describe('Resource direction (input/output)'),
|
|
resourceName: nameSchema.describe('Resource name (denormalized for display)'),
|
|
message: z
|
|
.string()
|
|
.max(500, { message: t('validation.proposal.message_max') })
|
|
.optional()
|
|
.describe('Proposal message'),
|
|
status: proposalStatusSchema,
|
|
createdAt: timestampSchema.describe('Creation timestamp'),
|
|
});
|
|
|
|
export const proposalSchema = getProposalSchema((key: string) => key);
|
|
export type Proposal = z.infer<typeof proposalSchema>;
|
|
|
|
/**
|
|
* Request schema for creating a proposal
|
|
* Uses Zod v4's composition with common schemas
|
|
*/
|
|
export const createProposalRequestSchema = z.object({
|
|
from_org_id: idSchema.describe('Source organization ID'),
|
|
to_org_id: idSchema.describe('Target organization ID'),
|
|
resource_id: idSchema.describe('Resource flow ID'),
|
|
resource_type: resourceDirectionSchema,
|
|
resource_name: nameSchema.describe('Resource name'),
|
|
message: z.string().max(500).optional().describe('Proposal message'),
|
|
});
|
|
|
|
export type CreateProposalRequest = z.infer<typeof createProposalRequestSchema>;
|
|
|
|
/**
|
|
* Request schema for updating proposal status
|
|
*/
|
|
export const updateProposalStatusRequestSchema = z.object({
|
|
status: proposalStatusSchema,
|
|
});
|
|
|
|
export type UpdateProposalStatusRequest = z.infer<typeof updateProposalStatusRequestSchema>;
|
|
|
|
/**
|
|
* Response schema for proposals list
|
|
*/
|
|
export const proposalsResponseSchema = z.object({
|
|
proposals: z.array(proposalSchema),
|
|
count: z.number().nonnegative(),
|
|
});
|
|
|
|
export type ProposalsResponse = z.infer<typeof proposalsResponseSchema>;
|
|
|
|
/**
|
|
* Response schema for organization proposals
|
|
*/
|
|
export const organizationProposalsResponseSchema = z.object({
|
|
incoming: z.array(proposalSchema),
|
|
outgoing: z.array(proposalSchema),
|
|
});
|
|
|
|
export type OrganizationProposalsResponse = z.infer<typeof organizationProposalsResponseSchema>;
|