@company-semantics/contracts 0.58.0 → 0.60.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@company-semantics/contracts",
3
- "version": "0.58.0",
3
+ "version": "0.60.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Chat Domain Barrel
3
+ *
4
+ * Re-exports chat persistence and sharing types.
5
+ * Import from '@company-semantics/contracts/chat'.
6
+ */
7
+
8
+ // =============================================================================
9
+ // Types
10
+ // =============================================================================
11
+
12
+ export type {
13
+ ChatVisibility,
14
+ ChatSummary,
15
+ ChatShareInfo,
16
+ SharedChatView,
17
+ SharedChatMessage,
18
+ CreateShareRequest,
19
+ UpdateShareRequest,
20
+ } from './types'
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Chat Domain Types
3
+ *
4
+ * Shared types for chat persistence and sharing across Company Semantics codebases.
5
+ * Types only - no runtime code, no business logic.
6
+ */
7
+
8
+ // =============================================================================
9
+ // Visibility
10
+ // =============================================================================
11
+
12
+ /**
13
+ * Chat share visibility.
14
+ * - private: Token exists but access requires authentication as chat owner
15
+ * - public: Token grants anonymous access to anyone with the link
16
+ */
17
+ export type ChatVisibility = 'private' | 'public'
18
+
19
+ // =============================================================================
20
+ // Chat Summary
21
+ // =============================================================================
22
+
23
+ /**
24
+ * Lightweight chat summary for list views.
25
+ */
26
+ export interface ChatSummary {
27
+ id: string
28
+ title: string
29
+ messageCount: number
30
+ createdAt: string
31
+ updatedAt: string
32
+ /** True if this chat has an active (non-revoked) share */
33
+ isShared: boolean
34
+ }
35
+
36
+ // =============================================================================
37
+ // Share Types
38
+ // =============================================================================
39
+
40
+ /**
41
+ * Chat share record with snapshot metadata.
42
+ *
43
+ * CRITICAL INVARIANT (SNAPSHOT-1):
44
+ * A chat share must never expose messages with sequenceNumber > messageCountAtShare.
45
+ * Enforced in ChatShareService.viewSharedChat() only.
46
+ */
47
+ export interface ChatShareInfo {
48
+ id: string
49
+ chatId: string
50
+ token: string
51
+ visibility: ChatVisibility
52
+ shareUrl: string
53
+ /** Message count at time of sharing - the snapshot boundary */
54
+ messageCountAtShare: number
55
+ /** Title snapshot at share time */
56
+ titleAtShare: string
57
+ createdAt: string
58
+ createdByName: string
59
+ isRevoked: boolean
60
+ }
61
+
62
+ /**
63
+ * Shared chat view returned to viewers.
64
+ * Messages are limited by the snapshot boundary.
65
+ */
66
+ export interface SharedChatView {
67
+ title: string
68
+ messages: SharedChatMessage[]
69
+ sharedAt: string
70
+ sharedByName: string
71
+ visibility: ChatVisibility
72
+ }
73
+
74
+ /**
75
+ * Individual message in a shared chat view.
76
+ */
77
+ export interface SharedChatMessage {
78
+ role: 'user' | 'assistant'
79
+ content: string
80
+ /** Optional rich content parts (tool calls, artifacts, etc.) */
81
+ parts?: unknown[]
82
+ }
83
+
84
+ // =============================================================================
85
+ // API Request/Response Types
86
+ // =============================================================================
87
+
88
+ /**
89
+ * Request to create a new share for a chat.
90
+ */
91
+ export interface CreateShareRequest {
92
+ chatId: string
93
+ visibility: ChatVisibility
94
+ /** Optional: send email notification to this address */
95
+ recipientEmail?: string
96
+ }
97
+
98
+ /**
99
+ * Request to update an existing share.
100
+ */
101
+ export interface UpdateShareRequest {
102
+ visibility?: ChatVisibility
103
+ /** If true, update snapshot to include new messages added since share creation */
104
+ updateSnapshot?: boolean
105
+ }
@@ -82,6 +82,12 @@ export const EMAIL_KINDS = {
82
82
  plainTextRequired: true,
83
83
  htmlSupported: false,
84
84
  },
85
+ 'chat.shared': {
86
+ kind: 'chat.shared',
87
+ subject: 'A chat has been shared with you',
88
+ plainTextRequired: true,
89
+ htmlSupported: true,
90
+ },
85
91
  } as const satisfies Record<EmailKind, EmailKindDefinition>
86
92
 
87
93
  // =============================================================================
@@ -28,6 +28,7 @@ export type EmailKind =
28
28
  | 'auth.magic_link' // future
29
29
  | 'org.invite' // future
30
30
  | 'security.alert' // future
31
+ | 'chat.shared'
31
32
 
32
33
  // =============================================================================
33
34
  // Email Payloads
@@ -65,6 +66,18 @@ export interface EmailPayloads {
65
66
  /** ISO timestamp of when the alert was triggered */
66
67
  timestamp: string
67
68
  }
69
+ 'chat.shared': {
70
+ /** Display name of the person who shared */
71
+ sharedByName: string
72
+ /** Title of the chat being shared */
73
+ chatTitle: string
74
+ /** Full URL to view the shared chat */
75
+ shareUrl: string
76
+ /** Share visibility mode */
77
+ visibility: 'private' | 'public'
78
+ /** First ~200 chars of chat content for email preview. Generated server-side from snapshot. */
79
+ previewText?: string
80
+ }
68
81
  }
69
82
 
70
83
  // =============================================================================
package/src/index.ts CHANGED
@@ -139,6 +139,18 @@ export {
139
139
  isValidEmailKind,
140
140
  } from './email/index'
141
141
 
142
+ // Chat domain types
143
+ // @see PRD-00142 for share chat design rationale
144
+ export type {
145
+ ChatVisibility,
146
+ ChatSummary,
147
+ ChatShareInfo,
148
+ SharedChatView,
149
+ SharedChatMessage,
150
+ CreateShareRequest,
151
+ UpdateShareRequest,
152
+ } from './chat/index'
153
+
142
154
  // Organization domain types
143
155
  // @see ADR-BE-XXX for design rationale (Personal vs Shared Organization Model)
144
156
  export type {