Add categories and suppliers with CRUD routes
- category table with hierarchical parent_id, sort ordering, soft-delete - supplier table with contact info, account number, payment terms - CRUD routes for both with search on suppliers - Zod validation schemas in @forte/shared - Products will link to suppliers via join table (many-to-many) - 26 tests passing
This commit is contained in:
@@ -15,3 +15,16 @@ export type {
|
||||
MemberCreateInput,
|
||||
MemberUpdateInput,
|
||||
} from './account.schema.js'
|
||||
|
||||
export {
|
||||
CategoryCreateSchema,
|
||||
CategoryUpdateSchema,
|
||||
SupplierCreateSchema,
|
||||
SupplierUpdateSchema,
|
||||
} from './inventory.schema.js'
|
||||
export type {
|
||||
CategoryCreateInput,
|
||||
CategoryUpdateInput,
|
||||
SupplierCreateInput,
|
||||
SupplierUpdateInput,
|
||||
} from './inventory.schema.js'
|
||||
|
||||
27
packages/shared/src/schemas/inventory.schema.ts
Normal file
27
packages/shared/src/schemas/inventory.schema.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
export const CategoryCreateSchema = z.object({
|
||||
name: z.string().min(1).max(255),
|
||||
description: z.string().optional(),
|
||||
parentId: z.string().uuid().optional(),
|
||||
sortOrder: z.number().int().default(0),
|
||||
})
|
||||
export type CategoryCreateInput = z.infer<typeof CategoryCreateSchema>
|
||||
|
||||
export const CategoryUpdateSchema = CategoryCreateSchema.partial()
|
||||
export type CategoryUpdateInput = z.infer<typeof CategoryUpdateSchema>
|
||||
|
||||
export const SupplierCreateSchema = z.object({
|
||||
name: z.string().min(1).max(255),
|
||||
contactName: z.string().max(255).optional(),
|
||||
email: z.string().email().optional(),
|
||||
phone: z.string().max(50).optional(),
|
||||
website: z.string().max(255).optional(),
|
||||
accountNumber: z.string().max(100).optional(),
|
||||
paymentTerms: z.string().max(100).optional(),
|
||||
notes: z.string().optional(),
|
||||
})
|
||||
export type SupplierCreateInput = z.infer<typeof SupplierCreateSchema>
|
||||
|
||||
export const SupplierUpdateSchema = SupplierCreateSchema.partial()
|
||||
export type SupplierUpdateInput = z.infer<typeof SupplierUpdateSchema>
|
||||
Reference in New Issue
Block a user