@company-semantics/contracts 0.120.0 → 0.122.0

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.
@@ -145,3 +145,25 @@ export type {
145
145
  TimelineIcon,
146
146
  TimelineUIEvent,
147
147
  } from './timeline-ui'
148
+
149
+ // =============================================================================
150
+ // HTTP Response Schemas (Zod)
151
+ // =============================================================================
152
+
153
+ export {
154
+ ExecutionSummarySchema,
155
+ ExecutionListResponseSchema,
156
+ TimelineEventSchema,
157
+ ExecutionTimelineResponseSchema,
158
+ ConfirmExecutionResponseSchema,
159
+ RejectExecutionResponseSchema,
160
+ } from './schemas'
161
+
162
+ export type {
163
+ ExecutionSummaryResponse,
164
+ ExecutionListResponse,
165
+ TimelineEvent,
166
+ ExecutionTimelineResponse,
167
+ ConfirmExecutionResponse,
168
+ RejectExecutionResponse,
169
+ } from './schemas'
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Execution Response Schemas
3
+ *
4
+ * Zod schemas for execution HTTP endpoint responses.
5
+ * These schemas are used for runtime validation at API contract surfaces.
6
+ *
7
+ * @see ADR-CONT-029 for design rationale
8
+ */
9
+
10
+ import { z } from 'zod'
11
+
12
+ // =============================================================================
13
+ // Execution Summary
14
+ // =============================================================================
15
+
16
+ export const ExecutionSummarySchema = z.object({
17
+ executionId: z.string().uuid(),
18
+ kind: z.string(),
19
+ status: z.enum(['pending', 'succeeded', 'failed']),
20
+ decidedAt: z.string().datetime({ offset: true }),
21
+ completedAt: z.string().datetime({ offset: true }).optional(),
22
+ target: z.object({ type: z.string() }),
23
+ })
24
+
25
+ export type ExecutionSummaryResponse = z.infer<typeof ExecutionSummarySchema>
26
+
27
+ // =============================================================================
28
+ // Execution List Response
29
+ // =============================================================================
30
+
31
+ export const ExecutionListResponseSchema = z.object({
32
+ executions: z.array(ExecutionSummarySchema),
33
+ nextCursor: z.string().nullable().optional(),
34
+ hasMore: z.boolean().optional(),
35
+ })
36
+
37
+ export type ExecutionListResponse = z.infer<typeof ExecutionListResponseSchema>
38
+
39
+ // =============================================================================
40
+ // Timeline Event
41
+ // =============================================================================
42
+
43
+ const TimelineRelatedIdsSchema = z.object({
44
+ decisionId: z.string().optional(),
45
+ artifactId: z.string().optional(),
46
+ rollbackId: z.string().optional(),
47
+ provenanceIds: z.array(z.string()).optional(),
48
+ })
49
+
50
+ export const TimelineEventSchema = z.object({
51
+ eventId: z.string(),
52
+ executionId: z.string().uuid(),
53
+ timestamp: z.string(),
54
+ createdAt: z.string(),
55
+ kind: z.string(),
56
+ summary: z.string(),
57
+ details: z.record(z.string(), z.unknown()).optional(),
58
+ relatedIds: TimelineRelatedIdsSchema.optional(),
59
+ visibilityLevel: z.enum(['system', 'oversight', 'org_admin', 'user']),
60
+ })
61
+
62
+ export type TimelineEvent = z.infer<typeof TimelineEventSchema>
63
+
64
+ // =============================================================================
65
+ // Execution Timeline Response
66
+ // =============================================================================
67
+
68
+ export const ExecutionTimelineResponseSchema = z.object({
69
+ events: z.array(TimelineEventSchema),
70
+ })
71
+
72
+ export type ExecutionTimelineResponse = z.infer<typeof ExecutionTimelineResponseSchema>
73
+
74
+ // =============================================================================
75
+ // Execution Lifecycle Responses
76
+ // =============================================================================
77
+
78
+ export const ConfirmExecutionResponseSchema = z.object({
79
+ status: z.enum([
80
+ 'executing',
81
+ 'blocked_pending_approval',
82
+ 'already_confirmed',
83
+ 'awaiting_approval',
84
+ ]),
85
+ code: z.string().optional(),
86
+ executionId: z.string().optional(),
87
+ })
88
+
89
+ export type ConfirmExecutionResponse = z.infer<typeof ConfirmExecutionResponseSchema>
90
+
91
+ export const RejectExecutionResponseSchema = z.object({
92
+ status: z.literal('cancelled'),
93
+ })
94
+
95
+ export type RejectExecutionResponse = z.infer<typeof RejectExecutionResponseSchema>
package/src/org/index.ts CHANGED
@@ -179,3 +179,25 @@ export type {
179
179
  ScopeCheckResponse,
180
180
  ScopeCheckBatchResponse,
181
181
  } from './schemas';
182
+
183
+ // Org lifecycle response schemas (PRD-00446)
184
+ export {
185
+ InviteResponseSchema,
186
+ InviteListResponseSchema,
187
+ DomainResponseSchema,
188
+ DomainListResponseSchema,
189
+ OrgBillingResponseSchema,
190
+ OrgDeletionStatusSchema,
191
+ OwnershipTransferResponseSchema,
192
+ OwnershipTransferPreviewSchema,
193
+ } from './schemas';
194
+ export type {
195
+ InviteResponse,
196
+ InviteListResponse,
197
+ DomainResponse,
198
+ DomainListResponse,
199
+ OrgBillingResponse,
200
+ OrgDeletionStatus,
201
+ OwnershipTransferResponse,
202
+ OwnershipTransferPreview,
203
+ } from './schemas';
@@ -371,3 +371,134 @@ export const ScopeCheckBatchResponseSchema = z.object({
371
371
  });
372
372
 
373
373
  export type ScopeCheckBatchResponse = z.infer<typeof ScopeCheckBatchResponseSchema>;
374
+
375
+ // ---------------------------------------------------------------------------
376
+ // Invite sub-schema
377
+ // ---------------------------------------------------------------------------
378
+
379
+ const OrgInviteSchema = z.object({
380
+ id: z.string(),
381
+ orgId: z.string(),
382
+ email: z.string(),
383
+ role: z.enum(['owner', 'admin', 'member', 'auditor']),
384
+ invitedBy: z.object({ id: z.string(), name: z.string() }),
385
+ status: z.enum(['pending', 'accepted', 'expired', 'revoked']),
386
+ createdAt: z.string(),
387
+ expiresAt: z.string(),
388
+ acceptedAt: z.string().optional(),
389
+ });
390
+
391
+ // ---------------------------------------------------------------------------
392
+ // POST /api/workspace/invites
393
+ // ---------------------------------------------------------------------------
394
+
395
+ export const InviteResponseSchema = z.object({
396
+ invite: OrgInviteSchema,
397
+ });
398
+
399
+ export type InviteResponse = z.infer<typeof InviteResponseSchema>;
400
+
401
+ // ---------------------------------------------------------------------------
402
+ // GET /api/workspace/invites
403
+ // ---------------------------------------------------------------------------
404
+
405
+ export const InviteListResponseSchema = z.array(OrgInviteSchema);
406
+
407
+ export type InviteListResponse = z.infer<typeof InviteListResponseSchema>;
408
+
409
+ // ---------------------------------------------------------------------------
410
+ // OrgDomain sub-schema
411
+ // ---------------------------------------------------------------------------
412
+
413
+ const OrgDomainSchema = z.object({
414
+ id: z.string(),
415
+ orgId: z.string(),
416
+ domain: z.string(),
417
+ status: z.enum(['pending', 'verified']),
418
+ verificationMethod: z.enum(['dns_txt', 'email', 'idp']),
419
+ verificationToken: z.string().optional(),
420
+ verifiedAt: z.string().nullable(),
421
+ createdAt: z.string(),
422
+ verifiedBy: z.object({ id: z.string(), name: z.string(), email: z.string() }).optional(),
423
+ });
424
+
425
+ // ---------------------------------------------------------------------------
426
+ // GET /api/workspace/domains/:id/verify (single domain)
427
+ // POST /api/workspace/domains/:id/verify (returns verified OrgDomain)
428
+ // ---------------------------------------------------------------------------
429
+
430
+ export const DomainResponseSchema = OrgDomainSchema;
431
+
432
+ export type DomainResponse = z.infer<typeof DomainResponseSchema>;
433
+
434
+ // ---------------------------------------------------------------------------
435
+ // GET /api/workspace/domains
436
+ // ---------------------------------------------------------------------------
437
+
438
+ export const DomainListResponseSchema = z.array(OrgDomainSchema);
439
+
440
+ export type DomainListResponse = z.infer<typeof DomainListResponseSchema>;
441
+
442
+ // ---------------------------------------------------------------------------
443
+ // GET /api/orgs/:orgId/billing
444
+ // ---------------------------------------------------------------------------
445
+
446
+ export const OrgBillingResponseSchema = z.object({
447
+ planName: z.string(),
448
+ planStatus: z.enum(['active', 'trialing', 'past_due', 'canceled']),
449
+ billingCadence: z.string(),
450
+ seatCount: z.number(),
451
+ seatLimit: z.number(),
452
+ billingOwnerUserId: z.string(),
453
+ });
454
+
455
+ export type OrgBillingResponse = z.infer<typeof OrgBillingResponseSchema>;
456
+
457
+ // ---------------------------------------------------------------------------
458
+ // GET /api/org/deletion-eligibility
459
+ // ---------------------------------------------------------------------------
460
+
461
+ const MemberClassificationSchema = z.object({
462
+ userId: z.string(),
463
+ email: z.string(),
464
+ suggestedFate: z.enum(['REMOVE_FROM_ORG', 'DELETE_ACCOUNT', 'BLOCKED']),
465
+ reason: z.string(),
466
+ });
467
+
468
+ export const OrgDeletionStatusSchema = z.object({
469
+ orgId: z.string(),
470
+ eligible: z.boolean(),
471
+ isPersonalOrg: z.boolean(),
472
+ ownerStatus: z.string().optional(),
473
+ deletionRequestedAt: z.string().optional(),
474
+ classifications: z.array(MemberClassificationSchema),
475
+ });
476
+
477
+ export type OrgDeletionStatus = z.infer<typeof OrgDeletionStatusSchema>;
478
+
479
+ // ---------------------------------------------------------------------------
480
+ // POST /api/org/transfer-ownership (initiate)
481
+ // ---------------------------------------------------------------------------
482
+
483
+ export const OwnershipTransferResponseSchema = z.object({
484
+ transferId: z.string(),
485
+ expiresAt: z.string(),
486
+ message: z.string(),
487
+ });
488
+
489
+ export type OwnershipTransferResponse = z.infer<typeof OwnershipTransferResponseSchema>;
490
+
491
+ // ---------------------------------------------------------------------------
492
+ // POST /api/org/transfer-ownership/preview
493
+ // ---------------------------------------------------------------------------
494
+
495
+ export const OwnershipTransferPreviewSchema = z.object({
496
+ workspaceName: z.string(),
497
+ initiatorName: z.string(),
498
+ initiatorEmail: z.string(),
499
+ note: z.string().optional(),
500
+ expiresAt: z.string(),
501
+ token: z.string(),
502
+ });
503
+
504
+ export type OwnershipTransferPreview = z.infer<typeof OwnershipTransferPreviewSchema>;