@@ -53,14 +53,25 @@ export const updateObligationSchema = z.object({
5353} ) ;
5454
5555// ── Disputes ──────────────────────────────────────────────────
56+ export const disputeStageSchema = z . enum ( [
57+ 'filed' ,
58+ 'response_pending' ,
59+ 'evidence_gathering' ,
60+ 'in_review' ,
61+ 'negotiation' ,
62+ 'resolved' ,
63+ ] ) ;
64+
65+ export const disputeStatusSchema = z . enum ( [ 'open' , 'resolved' , 'dismissed' ] ) ;
5666
5767export const createDisputeSchema = z . object ( {
5868 title : z . string ( ) . min ( 1 ) . max ( 500 ) ,
5969 counterparty : z . string ( ) . min ( 1 ) . max ( 255 ) ,
6070 dispute_type : z . string ( ) . min ( 1 ) . max ( 100 ) ,
6171 amount_claimed : z . number ( ) . min ( 0 ) . optional ( ) ,
6272 amount_at_stake : z . number ( ) . min ( 0 ) . optional ( ) ,
63- status : z . enum ( [ 'open' , 'resolved' , 'dismissed' ] ) . optional ( ) ,
73+ stage : disputeStageSchema . optional ( ) ,
74+ status : disputeStatusSchema . optional ( ) ,
6475 priority : z . number ( ) . int ( ) . min ( 1 ) . max ( 10 ) . optional ( ) ,
6576 description : z . string ( ) . max ( 5000 ) . optional ( ) ,
6677 next_action : z . string ( ) . max ( 1000 ) . optional ( ) ,
@@ -70,11 +81,19 @@ export const createDisputeSchema = z.object({
7081} ) ;
7182
7283export const updateDisputeSchema = z . object ( {
73- status : z . enum ( [ 'open' , 'resolved' , 'dismissed' ] ) . optional ( ) ,
84+ status : disputeStatusSchema . optional ( ) ,
85+ stage : disputeStageSchema . optional ( ) ,
86+ title : z . string ( ) . min ( 1 ) . max ( 500 ) . optional ( ) ,
87+ counterparty : z . string ( ) . min ( 1 ) . max ( 255 ) . optional ( ) ,
88+ dispute_type : z . string ( ) . min ( 1 ) . max ( 100 ) . optional ( ) ,
89+ amount_claimed : z . number ( ) . min ( 0 ) . optional ( ) ,
90+ amount_at_stake : z . number ( ) . min ( 0 ) . optional ( ) ,
7491 priority : z . number ( ) . int ( ) . min ( 1 ) . max ( 10 ) . optional ( ) ,
7592 next_action : z . string ( ) . max ( 1000 ) . optional ( ) ,
7693 next_action_date : z . string ( ) . regex ( / ^ \d { 4 } - \d { 2 } - \d { 2 } $ / ) . optional ( ) ,
7794 description : z . string ( ) . max ( 5000 ) . optional ( ) ,
95+ resolution_target : z . string ( ) . max ( 1000 ) . optional ( ) ,
96+ metadata : z . record ( z . string ( ) , z . unknown ( ) ) . optional ( ) ,
7897} ) ;
7998
8099export const createCorrespondenceSchema = z . object ( {
@@ -280,3 +299,66 @@ export const disputeQuerySchema = z.object({
280299export const recommendationQuerySchema = z . object ( {
281300 status : z . string ( ) . max ( 50 ) . optional ( ) ,
282301} ) ;
302+
303+ // ── Tasks ────────────────────────────────────────────────────
304+
305+ export const taskStatusSchema = z . enum ( [ 'queued' , 'running' , 'needs_review' , 'verified' , 'done' , 'failed' ] ) ;
306+
307+ export const taskTypeSchema = z . enum ( [ 'general' , 'financial' , 'legal' , 'administrative' , 'maintenance' , 'communication' ] ) ;
308+
309+ export const verificationTypeSchema = z . enum ( [ 'hard' , 'soft' ] ) ;
310+
311+ export const createTaskSchema = z . object ( {
312+ external_id : z . string ( ) . min ( 1 ) . max ( 500 ) ,
313+ notion_page_id : z . string ( ) . max ( 500 ) . optional ( ) ,
314+ title : z . string ( ) . min ( 1 ) . max ( 1000 ) ,
315+ description : z . string ( ) . max ( 10000 ) . optional ( ) ,
316+ task_type : taskTypeSchema . optional ( ) ,
317+ source : z . enum ( [ 'notion' , 'email' , 'mention' , 'manual' , 'api' ] ) . optional ( ) ,
318+ priority : z . number ( ) . int ( ) . min ( 1 ) . max ( 10 ) . optional ( ) ,
319+ assigned_to : z . string ( ) . max ( 255 ) . optional ( ) ,
320+ due_date : z . string ( ) . regex ( / ^ \d { 4 } - \d { 2 } - \d { 2 } $ / , 'Must be YYYY-MM-DD' ) . optional ( ) ,
321+ verification_type : verificationTypeSchema . optional ( ) ,
322+ metadata : z . record ( z . string ( ) , z . unknown ( ) ) . optional ( ) ,
323+ } ) ;
324+
325+ export const updateTaskStatusSchema = z . object ( {
326+ status : taskStatusSchema ,
327+ notes : z . string ( ) . max ( 2000 ) . optional ( ) ,
328+ } ) ;
329+
330+ export const verifyTaskSchema = z . object ( {
331+ verification_artifact : z . string ( ) . min ( 1 ) . max ( 2000 ) ,
332+ verification_notes : z . string ( ) . max ( 5000 ) . optional ( ) ,
333+ ledger_record_id : z . string ( ) . max ( 500 ) . optional ( ) ,
334+ } ) ;
335+
336+ export const spawnRecommendationFromTaskSchema = z . object ( {
337+ rec_type : z . string ( ) . min ( 1 ) . max ( 100 ) ,
338+ priority : z . number ( ) . int ( ) . min ( 1 ) . max ( 5 ) . optional ( ) ,
339+ action_type : z . string ( ) . max ( 100 ) . optional ( ) ,
340+ estimated_savings : z . number ( ) . min ( 0 ) . optional ( ) ,
341+ } ) ;
342+
343+ export const taskQuerySchema = z . object ( {
344+ status : taskStatusSchema . optional ( ) ,
345+ task_type : taskTypeSchema . optional ( ) ,
346+ source : z . string ( ) . max ( 50 ) . optional ( ) ,
347+ priority_max : z . coerce . number ( ) . int ( ) . min ( 1 ) . max ( 10 ) . optional ( ) ,
348+ limit : z . coerce . number ( ) . int ( ) . min ( 1 ) . max ( 100 ) . optional ( ) ,
349+ offset : z . coerce . number ( ) . int ( ) . min ( 0 ) . optional ( ) ,
350+ } ) ;
351+
352+ export const notionWebhookPayloadSchema = z . object ( {
353+ external_id : z . string ( ) . min ( 1 ) . max ( 500 ) ,
354+ notion_page_id : z . string ( ) . max ( 500 ) . optional ( ) ,
355+ title : z . string ( ) . min ( 1 ) . max ( 1000 ) ,
356+ description : z . string ( ) . max ( 10000 ) . optional ( ) ,
357+ task_type : taskTypeSchema . optional ( ) ,
358+ source : z . enum ( [ 'email' , 'mention' , 'manual' ] ) . optional ( ) ,
359+ priority : z . number ( ) . int ( ) . min ( 1 ) . max ( 10 ) . optional ( ) ,
360+ assigned_to : z . string ( ) . max ( 255 ) . optional ( ) ,
361+ due_date : z . string ( ) . regex ( / ^ \d { 4 } - \d { 2 } - \d { 2 } $ / ) . nullable ( ) . optional ( ) ,
362+ verification_type : verificationTypeSchema . optional ( ) ,
363+ metadata : z . record ( z . string ( ) , z . unknown ( ) ) . optional ( ) ,
364+ } ) ;
0 commit comments