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.
115 lines
4.0 KiB
TypeScript
115 lines
4.0 KiB
TypeScript
import { z } from 'zod';
|
|
import { nameSchema, optionalUrlSchema } from '@/schemas/common';
|
|
import { organizationSubtypeSchema } from '@/schemas/organizationSubtype';
|
|
|
|
/**
|
|
* Backend-aligned Organization schema
|
|
* Matches the Go backend domain.Organization struct
|
|
*
|
|
* Organization is the main entity that can represent various types:
|
|
* - commercial: Businesses that participate in resource matching
|
|
* - governmental: Government organizations
|
|
* - cultural: Museums, theaters, etc.
|
|
* - religious: Religious organizations
|
|
* - educational: Schools, universities
|
|
* - infrastructure: Public utilities, bridges
|
|
* - healthcare: Hospitals, clinics
|
|
* - other: Other organization types
|
|
*
|
|
* Uses Zod v4's composition features for DRY code
|
|
*/
|
|
// Comprehensive schema matching the Go backend domain.Organization struct
|
|
export const backendOrganizationSchema = z.object({
|
|
// Core identity
|
|
ID: z.string(),
|
|
Name: z.string(),
|
|
|
|
// Categorization
|
|
Subtype: z.string().optional(),
|
|
Sector: z.string().optional(),
|
|
|
|
// Basic information
|
|
Description: z.string().optional(),
|
|
LogoURL: z.string().optional(),
|
|
GalleryImages: z.array(z.string()).optional(),
|
|
Website: z.string().optional(),
|
|
|
|
// Location (derived from primary address)
|
|
Latitude: z.number().optional(),
|
|
Longitude: z.number().optional(),
|
|
|
|
// Business-specific fields
|
|
LegalForm: z.string().optional(),
|
|
PrimaryContact: z.any().optional(), // JSON object
|
|
IndustrialSector: z.string().optional(),
|
|
CompanySize: z.number().optional(),
|
|
YearsOperation: z.number().optional(),
|
|
SupplyChainRole: z.string().optional(),
|
|
Certifications: z.array(z.string()).optional(),
|
|
BusinessFocus: z.array(z.string()).optional(),
|
|
StrategicVision: z.string().optional(),
|
|
DriversBarriers: z.string().optional(),
|
|
ReadinessMaturity: z.number().optional(),
|
|
TrustScore: z.number().optional(),
|
|
TechnicalExpertise: z.array(z.string()).optional(),
|
|
AvailableTechnology: z.array(z.string()).optional(),
|
|
ManagementSystems: z.array(z.string()).optional(),
|
|
|
|
// Products and Services
|
|
SellsProducts: z.any().optional(), // JSON array of products
|
|
OffersServices: z.any().optional(), // JSON array of services
|
|
NeedsServices: z.any().optional(), // JSON array of service needs
|
|
|
|
// Historical/cultural building fields
|
|
YearBuilt: z.string().optional(),
|
|
BuilderOwner: z.string().optional(),
|
|
Architect: z.string().optional(),
|
|
OriginalPurpose: z.string().optional(),
|
|
CurrentUse: z.string().optional(),
|
|
Style: z.string().optional(),
|
|
Materials: z.string().optional(),
|
|
Storeys: z.number().optional(),
|
|
HeritageStatus: z.string().optional(),
|
|
|
|
// Metadata
|
|
Verified: z.boolean().optional(),
|
|
Notes: z.string().optional(),
|
|
Sources: z.any().optional(), // JSON object with source info
|
|
|
|
// Relationships
|
|
TrustNetwork: z.array(z.string()).optional(),
|
|
ExistingSymbioticRelationships: z.array(z.string()).optional(),
|
|
|
|
// Legacy compatibility
|
|
Products: z.any().optional(), // JSON array
|
|
|
|
// Timestamps
|
|
CreatedAt: z.string().optional(),
|
|
UpdatedAt: z.string().optional(),
|
|
|
|
// Associated data (populated via joins)
|
|
Addresses: z.any().optional(),
|
|
OwnedSites: z.any().optional(),
|
|
OperatingSites: z.any().optional(),
|
|
ResourceFlows: z.any().optional(),
|
|
}).passthrough(); // Allow additional fields for future compatibility
|
|
|
|
export type BackendOrganization = z.infer<typeof backendOrganizationSchema>;
|
|
|
|
/**
|
|
* Request schema for creating an organization
|
|
* Uses Zod v4's composition for consistency
|
|
*/
|
|
export const createOrganizationRequestSchema = z.object({
|
|
name: nameSchema,
|
|
sector: z.string().min(1).describe('Business sector'),
|
|
description: z.string().optional().describe('Organization description'),
|
|
subtype: organizationSubtypeSchema.optional(),
|
|
logoUrl: optionalUrlSchema,
|
|
galleryImages: z.array(optionalUrlSchema).optional().default([]).describe('Array of gallery image URLs'),
|
|
website: optionalUrlSchema,
|
|
address: z.string().optional().describe('Physical address'),
|
|
});
|
|
|
|
export type CreateOrganizationRequest = z.infer<typeof createOrganizationRequestSchema>;
|