mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-26 21:53:06 +00:00
Add baseUpdatedAt CAS on domain staff writes, assertCampaignDocCas helper, opsDomainOutbox with hybrid forms (Manter/Usar), and int/unit pins. Closes #176. Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import { z } from 'zod'
|
|
|
|
import { campaignDemandKinds, campaignDemandStatuses } from '@/lib/schemas/campaignDemand'
|
|
import { optionalBaseUpdatedAtSchema } from '@/lib/schemas/opsCas'
|
|
import {
|
|
positiveRelationshipId,
|
|
trimmedNullableText,
|
|
trimmedOptionalText,
|
|
} from '@/lib/schemas/primitives'
|
|
|
|
export const campaignDemandCreateSchema = z.object({
|
|
title: z.string().trim().min(2).max(160),
|
|
kind: z.enum(campaignDemandKinds),
|
|
description: trimmedOptionalText(4000),
|
|
municipality: positiveRelationshipId,
|
|
activity: positiveRelationshipId.optional(),
|
|
/** Staff may record on behalf of a leadership; leaders get their own. */
|
|
leadership: positiveRelationshipId.optional(),
|
|
})
|
|
|
|
export const campaignDemandTransitionSchema = z.object({
|
|
id: positiveRelationshipId,
|
|
status: z.enum(campaignDemandStatuses),
|
|
decisionNote: trimmedNullableText(2000),
|
|
/** OH13 — CAS token; absent → last-write-wins. */
|
|
baseUpdatedAt: optionalBaseUpdatedAtSchema,
|
|
})
|
|
|
|
export const campaignDemandCostSchema = z.object({
|
|
id: positiveRelationshipId,
|
|
cost: z.number().min(0).max(100_000_000).nullable(),
|
|
})
|
|
|
|
export type CampaignDemandCreateInput = z.input<typeof campaignDemandCreateSchema>
|
|
export type CampaignDemandTransitionInput = z.input<typeof campaignDemandTransitionSchema>
|
|
export type CampaignDemandCostInput = z.input<typeof campaignDemandCostSchema>
|