@company-semantics/contracts 0.58.0 → 0.59.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.59.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,103 @@
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
+ }
33
+
34
+ // =============================================================================
35
+ // Share Types
36
+ // =============================================================================
37
+
38
+ /**
39
+ * Chat share record with snapshot metadata.
40
+ *
41
+ * CRITICAL INVARIANT (SNAPSHOT-1):
42
+ * A chat share must never expose messages with sequenceNumber > messageCountAtShare.
43
+ * Enforced in ChatShareService.viewSharedChat() only.
44
+ */
45
+ export interface ChatShareInfo {
46
+ id: string
47
+ chatId: string
48
+ token: string
49
+ visibility: ChatVisibility
50
+ shareUrl: string
51
+ /** Message count at time of sharing - the snapshot boundary */
52
+ messageCountAtShare: number
53
+ /** Title snapshot at share time */
54
+ titleAtShare: string
55
+ createdAt: string
56
+ createdByName: string
57
+ isRevoked: boolean
58
+ }
59
+
60
+ /**
61
+ * Shared chat view returned to viewers.
62
+ * Messages are limited by the snapshot boundary.
63
+ */
64
+ export interface SharedChatView {
65
+ title: string
66
+ messages: SharedChatMessage[]
67
+ sharedAt: string
68
+ sharedByName: string
69
+ visibility: ChatVisibility
70
+ }
71
+
72
+ /**
73
+ * Individual message in a shared chat view.
74
+ */
75
+ export interface SharedChatMessage {
76
+ role: 'user' | 'assistant'
77
+ content: string
78
+ /** Optional rich content parts (tool calls, artifacts, etc.) */
79
+ parts?: unknown[]
80
+ }
81
+
82
+ // =============================================================================
83
+ // API Request/Response Types
84
+ // =============================================================================
85
+
86
+ /**
87
+ * Request to create a new share for a chat.
88
+ */
89
+ export interface CreateShareRequest {
90
+ chatId: string
91
+ visibility: ChatVisibility
92
+ /** Optional: send email notification to this address */
93
+ recipientEmail?: string
94
+ }
95
+
96
+ /**
97
+ * Request to update an existing share.
98
+ */
99
+ export interface UpdateShareRequest {
100
+ visibility?: ChatVisibility
101
+ /** If true, update snapshot to include new messages added since share creation */
102
+ updateSnapshot?: boolean
103
+ }
@@ -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 {