@crmy/shared 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,724 @@
1
+ // Copyright 2026 CRMy Contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { z } from 'zod';
4
+ // -- Reusable primitives --
5
+ export const uuid = z.string().uuid();
6
+ export const cursor = z.string().optional();
7
+ export const limit = z.number().int().min(1).max(100).default(20);
8
+ export const lifecycleStage = z.enum(['lead', 'prospect', 'customer', 'churned']);
9
+ export const oppStage = z.enum(['prospecting', 'qualification', 'proposal', 'negotiation', 'closed_won', 'closed_lost']);
10
+ export const forecastCat = z.enum(['pipeline', 'best_case', 'commit', 'closed']);
11
+ export const activityType = z.enum(['call', 'email', 'meeting', 'note', 'task']);
12
+ export const direction = z.enum(['inbound', 'outbound']);
13
+ export const userRole = z.enum(['owner', 'admin', 'member']);
14
+ export const subjectType = z.enum(['contact', 'account', 'opportunity', 'use_case']);
15
+ const tags = z.array(z.string()).default([]);
16
+ const customFields = z.record(z.unknown()).default({});
17
+ // -- Contact schemas --
18
+ export const contactCreate = z.object({
19
+ first_name: z.string().min(1),
20
+ last_name: z.string().default(''),
21
+ email: z.string().email().optional(),
22
+ phone: z.string().optional(),
23
+ title: z.string().optional(),
24
+ company_name: z.string().optional(),
25
+ account_id: uuid.optional(),
26
+ lifecycle_stage: lifecycleStage.default('lead'),
27
+ tags,
28
+ custom_fields: customFields,
29
+ source: z.string().optional(),
30
+ });
31
+ export const contactUpdate = z.object({
32
+ id: uuid,
33
+ patch: z.object({
34
+ first_name: z.string().min(1).optional(),
35
+ last_name: z.string().optional(),
36
+ email: z.string().email().optional(),
37
+ phone: z.string().optional(),
38
+ title: z.string().optional(),
39
+ company_name: z.string().optional(),
40
+ account_id: uuid.nullable().optional(),
41
+ owner_id: uuid.nullable().optional(),
42
+ lifecycle_stage: lifecycleStage.optional(),
43
+ source: z.string().optional(),
44
+ tags: z.array(z.string()).optional(),
45
+ custom_fields: z.record(z.unknown()).optional(),
46
+ }),
47
+ });
48
+ export const contactSearch = z.object({
49
+ query: z.string().optional(),
50
+ lifecycle_stage: lifecycleStage.optional(),
51
+ account_id: uuid.optional(),
52
+ owner_id: uuid.optional(),
53
+ tags: z.array(z.string()).optional(),
54
+ limit,
55
+ cursor,
56
+ });
57
+ export const contactSetLifecycle = z.object({
58
+ id: uuid,
59
+ lifecycle_stage: lifecycleStage,
60
+ reason: z.string().optional(),
61
+ });
62
+ export const contactGetTimeline = z.object({
63
+ id: uuid,
64
+ limit: limit.default(50),
65
+ types: z.array(activityType).optional(),
66
+ });
67
+ // -- Account schemas --
68
+ export const accountCreate = z.object({
69
+ name: z.string().min(1),
70
+ domain: z.string().optional(),
71
+ industry: z.string().optional(),
72
+ employee_count: z.number().int().positive().optional(),
73
+ annual_revenue: z.number().optional(),
74
+ currency_code: z.string().length(3).default('USD'),
75
+ website: z.string().url().optional(),
76
+ parent_id: uuid.optional(),
77
+ tags,
78
+ custom_fields: customFields,
79
+ });
80
+ export const accountUpdate = z.object({
81
+ id: uuid,
82
+ patch: z.object({
83
+ name: z.string().min(1).optional(),
84
+ domain: z.string().optional(),
85
+ industry: z.string().optional(),
86
+ employee_count: z.number().int().positive().nullable().optional(),
87
+ annual_revenue: z.number().nullable().optional(),
88
+ currency_code: z.string().length(3).optional(),
89
+ website: z.string().url().nullable().optional(),
90
+ parent_id: uuid.nullable().optional(),
91
+ owner_id: uuid.nullable().optional(),
92
+ tags: z.array(z.string()).optional(),
93
+ custom_fields: z.record(z.unknown()).optional(),
94
+ }),
95
+ });
96
+ export const accountSearch = z.object({
97
+ query: z.string().optional(),
98
+ industry: z.string().optional(),
99
+ owner_id: uuid.optional(),
100
+ min_revenue: z.number().optional(),
101
+ tags: z.array(z.string()).optional(),
102
+ limit,
103
+ cursor,
104
+ });
105
+ export const accountSetHealth = z.object({
106
+ id: uuid,
107
+ score: z.number().int().min(0).max(100),
108
+ rationale: z.string().optional(),
109
+ });
110
+ // -- Opportunity schemas --
111
+ export const opportunityCreate = z.object({
112
+ name: z.string().min(1),
113
+ account_id: uuid.optional(),
114
+ contact_id: uuid.optional(),
115
+ amount: z.number().optional(),
116
+ currency_code: z.string().length(3).default('USD'),
117
+ close_date: z.string().optional(),
118
+ stage: oppStage.default('prospecting'),
119
+ description: z.string().optional(),
120
+ custom_fields: customFields,
121
+ });
122
+ export const opportunityUpdate = z.object({
123
+ id: uuid,
124
+ patch: z.object({
125
+ name: z.string().min(1).optional(),
126
+ account_id: uuid.nullable().optional(),
127
+ contact_id: uuid.nullable().optional(),
128
+ owner_id: uuid.nullable().optional(),
129
+ amount: z.number().nullable().optional(),
130
+ currency_code: z.string().length(3).optional(),
131
+ close_date: z.string().nullable().optional(),
132
+ probability: z.number().int().min(0).max(100).nullable().optional(),
133
+ forecast_cat: forecastCat.optional(),
134
+ description: z.string().nullable().optional(),
135
+ custom_fields: z.record(z.unknown()).optional(),
136
+ }),
137
+ });
138
+ export const opportunitySearch = z.object({
139
+ query: z.string().optional(),
140
+ stage: oppStage.optional(),
141
+ owner_id: uuid.optional(),
142
+ account_id: uuid.optional(),
143
+ forecast_cat: forecastCat.optional(),
144
+ close_date_before: z.string().optional(),
145
+ close_date_after: z.string().optional(),
146
+ limit,
147
+ cursor,
148
+ });
149
+ export const opportunityAdvanceStage = z.object({
150
+ id: uuid,
151
+ stage: oppStage,
152
+ note: z.string().optional(),
153
+ lost_reason: z.string().optional(),
154
+ });
155
+ export const pipelineSummary = z.object({
156
+ owner_id: uuid.optional(),
157
+ group_by: z.enum(['stage', 'owner', 'forecast_cat']).default('stage'),
158
+ });
159
+ // -- Activity schemas --
160
+ export const activityCreate = z.object({
161
+ type: activityType,
162
+ subject: z.string().min(1),
163
+ body: z.string().optional(),
164
+ contact_id: uuid.optional(),
165
+ account_id: uuid.optional(),
166
+ opportunity_id: uuid.optional(),
167
+ due_at: z.string().optional(),
168
+ direction: direction.optional(),
169
+ custom_fields: customFields,
170
+ // Context Engine optional fields
171
+ performed_by: uuid.optional(),
172
+ subject_type: subjectType.optional(),
173
+ subject_id: uuid.optional(),
174
+ related_type: subjectType.optional(),
175
+ related_id: uuid.optional(),
176
+ detail: z.record(z.unknown()).optional(),
177
+ occurred_at: z.string().optional(),
178
+ outcome: z.string().optional(),
179
+ });
180
+ export const activityUpdate = z.object({
181
+ id: uuid,
182
+ patch: z.object({
183
+ subject: z.string().min(1).optional(),
184
+ body: z.string().nullable().optional(),
185
+ status: z.string().optional(),
186
+ due_at: z.string().nullable().optional(),
187
+ custom_fields: z.record(z.unknown()).optional(),
188
+ }),
189
+ });
190
+ export const activitySearch = z.object({
191
+ contact_id: uuid.optional(),
192
+ account_id: uuid.optional(),
193
+ opportunity_id: uuid.optional(),
194
+ type: activityType.optional(),
195
+ subject_type: subjectType.optional(),
196
+ subject_id: uuid.optional(),
197
+ performed_by: uuid.optional(),
198
+ outcome: z.string().optional(),
199
+ limit,
200
+ cursor,
201
+ });
202
+ export const activityComplete = z.object({
203
+ id: uuid,
204
+ completed_at: z.string().optional(),
205
+ note: z.string().optional(),
206
+ });
207
+ // -- Contact log activity (convenience) --
208
+ export const contactLogActivity = z.object({
209
+ contact_id: uuid,
210
+ type: activityType,
211
+ subject: z.string().min(1),
212
+ body: z.string().optional(),
213
+ opportunity_id: uuid.optional(),
214
+ due_at: z.string().optional(),
215
+ direction: direction.optional(),
216
+ });
217
+ // -- Analytics schemas --
218
+ export const crmSearch = z.object({
219
+ query: z.string().min(1),
220
+ limit: limit.default(10),
221
+ });
222
+ export const pipelineForecast = z.object({
223
+ period: z.enum(['month', 'quarter', 'year']).default('quarter'),
224
+ owner_id: uuid.optional(),
225
+ });
226
+ export const accountHealthReport = z.object({
227
+ account_id: uuid,
228
+ });
229
+ // -- HITL schemas --
230
+ export const hitlSubmit = z.object({
231
+ action_type: z.string().min(1),
232
+ action_summary: z.string().min(1),
233
+ action_payload: z.unknown(),
234
+ auto_approve_after_seconds: z.number().int().min(0).optional(),
235
+ });
236
+ export const hitlCheckStatus = z.object({
237
+ request_id: uuid,
238
+ });
239
+ export const hitlListPending = z.object({
240
+ limit: limit.default(20),
241
+ });
242
+ export const hitlResolve = z.object({
243
+ request_id: uuid,
244
+ decision: z.enum(['approved', 'rejected']),
245
+ note: z.string().optional(),
246
+ });
247
+ // -- Meta schemas --
248
+ export const schemaGet = z.object({
249
+ object_type: z.enum(['contact', 'account', 'opportunity', 'activity', 'use_case']),
250
+ });
251
+ export const tenantGetStats = z.object({});
252
+ // -- Auth schemas --
253
+ export const authRegister = z.object({
254
+ name: z.string().min(1),
255
+ email: z.string().email(),
256
+ password: z.string().min(8),
257
+ tenant_name: z.string().min(1),
258
+ });
259
+ export const authLogin = z.object({
260
+ email: z.string().email(),
261
+ password: z.string(),
262
+ });
263
+ export const apiKeyCreate = z.object({
264
+ label: z.string().min(1),
265
+ scopes: z.array(z.string()).default(['read', 'write']),
266
+ expires_at: z.string().optional(),
267
+ actor_id: uuid.optional(),
268
+ });
269
+ // -- Use Case schemas --
270
+ export const useCaseStage = z.enum(['discovery', 'poc', 'production', 'scaling', 'sunset']);
271
+ export const useCaseCreate = z.object({
272
+ account_id: uuid,
273
+ name: z.string().min(1),
274
+ stage: useCaseStage.default('discovery'),
275
+ description: z.string().optional(),
276
+ opportunity_id: uuid.optional(),
277
+ unit_label: z.string().optional(),
278
+ consumption_unit: z.string().optional(),
279
+ consumption_capacity: z.number().int().optional(),
280
+ attributed_arr: z.number().int().optional(),
281
+ currency_code: z.string().length(3).default('USD'),
282
+ expansion_potential: z.number().int().optional(),
283
+ started_at: z.string().optional(),
284
+ target_prod_date: z.string().optional(),
285
+ sunset_date: z.string().optional(),
286
+ tags,
287
+ custom_fields: customFields,
288
+ });
289
+ export const useCaseUpdate = z.object({
290
+ id: uuid,
291
+ patch: z.object({
292
+ name: z.string().min(1).optional(),
293
+ stage: useCaseStage.optional(),
294
+ description: z.string().nullable().optional(),
295
+ opportunity_id: uuid.nullable().optional(),
296
+ owner_id: uuid.nullable().optional(),
297
+ unit_label: z.string().nullable().optional(),
298
+ consumption_unit: z.string().nullable().optional(),
299
+ consumption_capacity: z.number().int().nullable().optional(),
300
+ attributed_arr: z.number().int().nullable().optional(),
301
+ currency_code: z.string().length(3).optional(),
302
+ expansion_potential: z.number().int().nullable().optional(),
303
+ started_at: z.string().nullable().optional(),
304
+ target_prod_date: z.string().nullable().optional(),
305
+ sunset_date: z.string().nullable().optional(),
306
+ tags: z.array(z.string()).optional(),
307
+ custom_fields: z.record(z.unknown()).optional(),
308
+ }),
309
+ });
310
+ export const useCaseSearch = z.object({
311
+ account_id: uuid.optional(),
312
+ stage: useCaseStage.optional(),
313
+ owner_id: uuid.optional(),
314
+ product_line: z.string().optional(),
315
+ tags: z.array(z.string()).optional(),
316
+ query: z.string().optional(),
317
+ limit,
318
+ cursor,
319
+ });
320
+ export const useCaseGet = z.object({ id: uuid });
321
+ export const useCaseDelete = z.object({ id: uuid });
322
+ export const useCaseAdvanceStage = z.object({
323
+ id: uuid,
324
+ stage: useCaseStage,
325
+ note: z.string().optional(),
326
+ });
327
+ export const useCaseUpdateConsumption = z.object({
328
+ id: uuid,
329
+ consumption_current: z.number().int(),
330
+ note: z.string().optional(),
331
+ });
332
+ export const useCaseSetHealth = z.object({
333
+ id: uuid,
334
+ score: z.number().int().min(0).max(100),
335
+ rationale: z.string().optional(),
336
+ });
337
+ export const useCaseLinkContact = z.object({
338
+ use_case_id: uuid,
339
+ contact_id: uuid,
340
+ role: z.string().default('stakeholder'),
341
+ });
342
+ export const useCaseUnlinkContact = z.object({
343
+ use_case_id: uuid,
344
+ contact_id: uuid,
345
+ });
346
+ export const useCaseListContacts = z.object({
347
+ use_case_id: uuid,
348
+ });
349
+ export const useCaseGetTimeline = z.object({
350
+ id: uuid,
351
+ limit: limit.default(50),
352
+ types: z.array(activityType).optional(),
353
+ });
354
+ export const useCaseSummary = z.object({
355
+ account_id: uuid.optional(),
356
+ group_by: z.enum(['stage', 'product_line', 'owner']).default('stage'),
357
+ });
358
+ // -- Webhook schemas --
359
+ export const webhookCreate = z.object({
360
+ url: z.string().url(),
361
+ events: z.array(z.string()).min(1),
362
+ description: z.string().optional(),
363
+ });
364
+ export const webhookUpdate = z.object({
365
+ id: uuid,
366
+ patch: z.object({
367
+ url: z.string().url().optional(),
368
+ events: z.array(z.string()).optional(),
369
+ active: z.boolean().optional(),
370
+ description: z.string().nullable().optional(),
371
+ }),
372
+ });
373
+ export const webhookDelete = z.object({ id: uuid });
374
+ export const webhookGet = z.object({ id: uuid });
375
+ export const webhookList = z.object({
376
+ active: z.boolean().optional(),
377
+ limit,
378
+ cursor,
379
+ });
380
+ export const webhookListDeliveries = z.object({
381
+ endpoint_id: uuid.optional(),
382
+ status: z.enum(['pending', 'success', 'failed']).optional(),
383
+ limit,
384
+ cursor,
385
+ });
386
+ // -- Email schemas --
387
+ export const emailCreate = z.object({
388
+ contact_id: uuid.optional(),
389
+ account_id: uuid.optional(),
390
+ opportunity_id: uuid.optional(),
391
+ use_case_id: uuid.optional(),
392
+ subject: z.string().min(1),
393
+ body_html: z.string().optional(),
394
+ body_text: z.string().optional(),
395
+ to_address: z.string().email(),
396
+ require_approval: z.boolean().default(true),
397
+ });
398
+ export const emailGet = z.object({ id: uuid });
399
+ export const emailSearch = z.object({
400
+ contact_id: uuid.optional(),
401
+ status: z.enum(['draft', 'pending_approval', 'approved', 'sending', 'sent', 'failed', 'rejected']).optional(),
402
+ limit,
403
+ cursor,
404
+ });
405
+ export const emailSequenceCreate = z.object({
406
+ name: z.string().min(1),
407
+ description: z.string().optional(),
408
+ steps: z.array(z.object({
409
+ delay_days: z.number().int().min(0),
410
+ subject: z.string().min(1),
411
+ body_html: z.string().optional(),
412
+ body_text: z.string().optional(),
413
+ })).min(1),
414
+ });
415
+ export const emailSequenceEnroll = z.object({
416
+ sequence_id: uuid,
417
+ contact_id: uuid,
418
+ });
419
+ // -- Custom field schemas --
420
+ export const customFieldCreate = z.object({
421
+ object_type: z.enum(['contact', 'account', 'opportunity', 'activity', 'use_case']),
422
+ field_name: z.string().min(1).regex(/^[a-z][a-z0-9_]*$/),
423
+ field_type: z.enum(['text', 'number', 'boolean', 'date', 'select', 'multi_select']),
424
+ label: z.string().min(1),
425
+ description: z.string().optional(),
426
+ required: z.boolean().default(false),
427
+ options: z.array(z.string()).optional(),
428
+ default_value: z.unknown().optional(),
429
+ });
430
+ export const customFieldUpdate = z.object({
431
+ id: uuid,
432
+ patch: z.object({
433
+ label: z.string().min(1).optional(),
434
+ description: z.string().nullable().optional(),
435
+ required: z.boolean().optional(),
436
+ options: z.array(z.string()).optional(),
437
+ default_value: z.unknown().optional(),
438
+ sort_order: z.number().int().optional(),
439
+ }),
440
+ });
441
+ export const customFieldDelete = z.object({ id: uuid });
442
+ export const customFieldList = z.object({
443
+ object_type: z.enum(['contact', 'account', 'opportunity', 'activity', 'use_case']),
444
+ });
445
+ // -- Bulk schemas --
446
+ export const bulkImport = z.object({
447
+ object_type: z.enum(['contact', 'account', 'opportunity', 'activity', 'use_case']),
448
+ records: z.array(z.record(z.unknown())).min(1).max(10000),
449
+ });
450
+ export const bulkExport = z.object({
451
+ object_type: z.enum(['contact', 'account', 'opportunity', 'activity', 'use_case']),
452
+ filters: z.record(z.unknown()).default({}),
453
+ });
454
+ export const bulkJobGet = z.object({ id: uuid });
455
+ export const bulkJobList = z.object({
456
+ status: z.enum(['pending', 'processing', 'completed', 'failed']).optional(),
457
+ limit,
458
+ cursor,
459
+ });
460
+ // -- Note schemas --
461
+ const noteObjectType = z.enum(['contact', 'account', 'opportunity', 'activity', 'use_case']);
462
+ const noteVisibility = z.enum(['internal', 'external']);
463
+ export const noteCreate = z.object({
464
+ object_type: noteObjectType,
465
+ object_id: uuid,
466
+ parent_id: uuid.optional(),
467
+ body: z.string().min(1),
468
+ visibility: noteVisibility.default('internal'),
469
+ mentions: z.array(z.string()).default([]),
470
+ pinned: z.boolean().default(false),
471
+ });
472
+ export const noteUpdate = z.object({
473
+ id: uuid,
474
+ patch: z.object({
475
+ body: z.string().min(1).optional(),
476
+ visibility: noteVisibility.optional(),
477
+ pinned: z.boolean().optional(),
478
+ }),
479
+ });
480
+ export const noteGet = z.object({ id: uuid });
481
+ export const noteDelete = z.object({ id: uuid });
482
+ export const noteList = z.object({
483
+ object_type: noteObjectType,
484
+ object_id: uuid,
485
+ visibility: noteVisibility.optional(),
486
+ pinned: z.boolean().optional(),
487
+ limit,
488
+ cursor,
489
+ });
490
+ // -- Workflow schemas --
491
+ const workflowActionType = z.enum([
492
+ 'send_notification', 'update_field', 'create_activity',
493
+ 'add_tag', 'remove_tag', 'assign_owner', 'create_note', 'webhook',
494
+ ]);
495
+ const workflowActionSchema = z.object({
496
+ type: workflowActionType,
497
+ config: z.record(z.unknown()),
498
+ });
499
+ export const workflowCreate = z.object({
500
+ name: z.string().min(1),
501
+ description: z.string().optional(),
502
+ trigger_event: z.string().min(1),
503
+ trigger_filter: z.record(z.unknown()).default({}),
504
+ actions: z.array(workflowActionSchema).min(1),
505
+ is_active: z.boolean().default(true),
506
+ });
507
+ export const workflowUpdate = z.object({
508
+ id: uuid,
509
+ patch: z.object({
510
+ name: z.string().min(1).optional(),
511
+ description: z.string().nullable().optional(),
512
+ trigger_event: z.string().min(1).optional(),
513
+ trigger_filter: z.record(z.unknown()).optional(),
514
+ actions: z.array(workflowActionSchema).optional(),
515
+ is_active: z.boolean().optional(),
516
+ }),
517
+ });
518
+ export const workflowGet = z.object({ id: uuid });
519
+ export const workflowDelete = z.object({ id: uuid });
520
+ export const workflowList = z.object({
521
+ trigger_event: z.string().optional(),
522
+ is_active: z.boolean().optional(),
523
+ limit,
524
+ cursor,
525
+ });
526
+ export const workflowRunList = z.object({
527
+ workflow_id: uuid,
528
+ status: z.enum(['running', 'completed', 'failed']).optional(),
529
+ limit,
530
+ cursor,
531
+ });
532
+ // -- v0.4/v0.5 Context Engine schemas --
533
+ export const actorType = z.enum(['human', 'agent']);
534
+ export const assignmentStatus = z.enum([
535
+ 'pending', 'accepted', 'in_progress', 'blocked',
536
+ 'completed', 'declined', 'cancelled',
537
+ ]);
538
+ export const assignmentPriority = z.enum(['low', 'normal', 'high', 'urgent']);
539
+ export const activityTypeCategory = z.enum([
540
+ 'outreach', 'meeting', 'proposal', 'contract',
541
+ 'internal', 'lifecycle', 'handoff',
542
+ ]);
543
+ // -- Activity Type Registry schemas --
544
+ export const activityTypeRegistryAdd = z.object({
545
+ type_name: z.string().min(1).max(100).regex(/^[a-z][a-z0-9_]*$/),
546
+ label: z.string().min(1).max(200),
547
+ description: z.string().optional(),
548
+ category: activityTypeCategory,
549
+ });
550
+ export const activityTypeRegistryRemove = z.object({
551
+ type_name: z.string().min(1),
552
+ });
553
+ export const activityTypeRegistryList = z.object({
554
+ category: activityTypeCategory.optional(),
555
+ });
556
+ // -- Context Type Registry schemas --
557
+ export const contextTypeRegistryAdd = z.object({
558
+ type_name: z.string().min(1).max(100).regex(/^[a-z][a-z0-9_]*$/),
559
+ label: z.string().min(1).max(200),
560
+ description: z.string().optional(),
561
+ });
562
+ export const contextTypeRegistryRemove = z.object({
563
+ type_name: z.string().min(1),
564
+ });
565
+ export const contextTypeRegistryList = z.object({});
566
+ // -- Briefing schema --
567
+ export const briefingGet = z.object({
568
+ subject_type: subjectType,
569
+ subject_id: uuid,
570
+ since: z.string().optional(),
571
+ context_types: z.array(z.string()).optional(),
572
+ include_stale: z.boolean().default(false),
573
+ format: z.enum(['json', 'text']).default('json'),
574
+ });
575
+ // -- Context search (full-text) schema --
576
+ export const contextSearch = z.object({
577
+ query: z.string().min(1),
578
+ subject_type: subjectType.optional(),
579
+ subject_id: uuid.optional(),
580
+ context_type: z.string().optional(),
581
+ tag: z.string().optional(),
582
+ current_only: z.boolean().default(true),
583
+ limit: z.number().int().min(1).max(100).default(20),
584
+ });
585
+ // -- Context review schema --
586
+ export const contextReview = z.object({
587
+ id: uuid,
588
+ });
589
+ // -- Context stale list schema --
590
+ export const contextStaleList = z.object({
591
+ subject_type: subjectType.optional(),
592
+ subject_id: uuid.optional(),
593
+ limit: z.number().int().min(1).max(100).default(20),
594
+ });
595
+ // -- Actor schemas --
596
+ export const actorCreate = z.object({
597
+ actor_type: actorType,
598
+ display_name: z.string().min(1),
599
+ email: z.string().email().optional(),
600
+ phone: z.string().optional(),
601
+ user_id: uuid.optional(),
602
+ role: z.string().optional(),
603
+ agent_identifier: z.string().optional(),
604
+ agent_model: z.string().optional(),
605
+ metadata: z.record(z.unknown()).default({}),
606
+ });
607
+ export const actorUpdate = z.object({
608
+ id: uuid,
609
+ patch: z.object({
610
+ display_name: z.string().min(1).optional(),
611
+ email: z.string().email().nullable().optional(),
612
+ phone: z.string().nullable().optional(),
613
+ role: z.string().nullable().optional(),
614
+ agent_identifier: z.string().nullable().optional(),
615
+ agent_model: z.string().nullable().optional(),
616
+ scopes: z.array(z.string()).optional(),
617
+ metadata: z.record(z.unknown()).optional(),
618
+ is_active: z.boolean().optional(),
619
+ }),
620
+ });
621
+ export const actorGet = z.object({ id: uuid });
622
+ export const actorSearch = z.object({
623
+ actor_type: actorType.optional(),
624
+ query: z.string().optional(),
625
+ is_active: z.boolean().optional(),
626
+ limit,
627
+ cursor,
628
+ });
629
+ // -- Assignment schemas --
630
+ export const assignmentCreate = z.object({
631
+ title: z.string().min(1),
632
+ description: z.string().optional(),
633
+ assignment_type: z.string().min(1),
634
+ assigned_to: uuid,
635
+ subject_type: subjectType.optional(),
636
+ subject_id: uuid.optional(),
637
+ priority: assignmentPriority.default('normal'),
638
+ due_at: z.string().optional(),
639
+ context: z.string().optional(),
640
+ metadata: z.record(z.unknown()).default({}),
641
+ });
642
+ export const assignmentUpdate = z.object({
643
+ id: uuid,
644
+ patch: z.object({
645
+ title: z.string().min(1).optional(),
646
+ description: z.string().nullable().optional(),
647
+ priority: assignmentPriority.optional(),
648
+ due_at: z.string().nullable().optional(),
649
+ status: assignmentStatus.optional(),
650
+ context: z.string().nullable().optional(),
651
+ metadata: z.record(z.unknown()).optional(),
652
+ }),
653
+ });
654
+ export const assignmentGet = z.object({ id: uuid });
655
+ export const assignmentSearch = z.object({
656
+ assigned_to: uuid.optional(),
657
+ assigned_by: uuid.optional(),
658
+ status: assignmentStatus.optional(),
659
+ priority: assignmentPriority.optional(),
660
+ subject_type: subjectType.optional(),
661
+ subject_id: uuid.optional(),
662
+ limit,
663
+ cursor,
664
+ });
665
+ export const assignmentAccept = z.object({ id: uuid });
666
+ export const assignmentComplete = z.object({
667
+ id: uuid,
668
+ completed_by_activity_id: uuid.optional(),
669
+ });
670
+ export const assignmentDecline = z.object({
671
+ id: uuid,
672
+ reason: z.string().optional(),
673
+ });
674
+ export const assignmentStart = z.object({ id: uuid });
675
+ export const assignmentBlock = z.object({
676
+ id: uuid,
677
+ reason: z.string().optional(),
678
+ });
679
+ export const assignmentCancel = z.object({
680
+ id: uuid,
681
+ reason: z.string().optional(),
682
+ });
683
+ // -- Context Entry schemas --
684
+ const contextTag = z.string().min(1).max(100).regex(/^[a-z0-9][a-z0-9-]*$/);
685
+ export const contextEntryCreate = z.object({
686
+ subject_type: subjectType,
687
+ subject_id: uuid,
688
+ context_type: z.string().min(1),
689
+ title: z.string().optional(),
690
+ body: z.string().min(1).max(50000),
691
+ structured_data: z.record(z.unknown()).default({}),
692
+ confidence: z.number().min(0).max(1).optional(),
693
+ tags: z.array(contextTag).max(20).default([]),
694
+ source: z.string().optional(),
695
+ source_ref: z.string().optional(),
696
+ source_activity_id: uuid.optional(),
697
+ valid_until: z.string().optional(),
698
+ });
699
+ export const contextEntryGet = z.object({ id: uuid });
700
+ export const contextEntrySearch = z.object({
701
+ subject_type: subjectType.optional(),
702
+ subject_id: uuid.optional(),
703
+ context_type: z.string().optional(),
704
+ authored_by: uuid.optional(),
705
+ is_current: z.boolean().optional(),
706
+ query: z.string().optional(),
707
+ limit,
708
+ cursor,
709
+ });
710
+ export const contextEntrySupersede = z.object({
711
+ id: uuid,
712
+ body: z.string().min(1).max(50000),
713
+ title: z.string().optional(),
714
+ structured_data: z.record(z.unknown()).optional(),
715
+ confidence: z.number().min(0).max(1).optional(),
716
+ tags: z.array(contextTag).max(20).optional(),
717
+ });
718
+ export const activityGetTimeline = z.object({
719
+ subject_type: subjectType,
720
+ subject_id: uuid,
721
+ limit: limit.default(50),
722
+ types: z.array(activityType).optional(),
723
+ });
724
+ //# sourceMappingURL=schemas.js.map