@company-semantics/contracts 0.57.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.57.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 {
@@ -154,8 +166,6 @@ export type {
154
166
  WorkspaceMember,
155
167
  AuthMethodConfig,
156
168
  WorkspaceAuthConfig,
157
- IntegrationStatus,
158
- WorkspaceIntegration,
159
169
  WorkspaceAuditEvent,
160
170
  // Workspace expansion DTOs (Phase 3)
161
171
  // @see ADR-CONT-031 for design rationale
@@ -167,8 +177,6 @@ export type {
167
177
  ChangeMemberRoleRequest,
168
178
  OrgAuthPolicy,
169
179
  UpdateAuthPolicyRequest,
170
- PromoteIntegrationRequest,
171
- DemoteIntegrationRequest,
172
180
  Phase3AuditAction,
173
181
  // Workspace capability types (Phase 3)
174
182
  WorkspaceCapability,
package/src/org/index.ts CHANGED
@@ -17,8 +17,6 @@ export type {
17
17
  WorkspaceMember,
18
18
  AuthMethodConfig,
19
19
  WorkspaceAuthConfig,
20
- IntegrationStatus,
21
- WorkspaceIntegration,
22
20
  WorkspaceAuditEvent,
23
21
  // Workspace expansion DTOs (Phase 3)
24
22
  OrgInviteStatus,
@@ -29,8 +27,6 @@ export type {
29
27
  ChangeMemberRoleRequest,
30
28
  OrgAuthPolicy,
31
29
  UpdateAuthPolicyRequest,
32
- PromoteIntegrationRequest,
33
- DemoteIntegrationRequest,
34
30
  Phase3AuditAction,
35
31
  // Multi-org membership types (Phase 4)
36
32
  UserOrgMembership,
package/src/org/types.ts CHANGED
@@ -134,34 +134,6 @@ export interface WorkspaceAuthConfig {
134
134
  };
135
135
  }
136
136
 
137
- /**
138
- * Integration connection status.
139
- */
140
- export type IntegrationStatus = 'active' | 'expired' | 'revoked';
141
-
142
- /**
143
- * Workspace integration for the integrations list.
144
- * Shows connections visible to workspace admins.
145
- *
146
- * SECURITY: connectedBy.id should be empty string (not exposed for security).
147
- * lastActivity is aggregated to reduce precision for timing attack mitigation.
148
- * @see security-safety-reviewer finding: Excessive Information Disclosure
149
- */
150
- export interface WorkspaceIntegration {
151
- id: string;
152
- provider: string;
153
- status: IntegrationStatus;
154
- connectedBy: {
155
- /** Always empty string for security (user IDs not exposed) */
156
- id: string;
157
- /** Name of the user who connected this integration, or 'A team member' if unknown */
158
- name: string;
159
- };
160
- executionScope: ExecutionScope;
161
- /** Aggregated last activity (e.g., 'within the last day', 'within the last week') */
162
- lastActivity: string | null;
163
- }
164
-
165
137
  /**
166
138
  * Audit event for the workspace audit log.
167
139
  * Filtered to spec events only (server-side).
@@ -260,25 +232,6 @@ export interface UpdateAuthPolicyRequest {
260
232
  allowedProviders?: string[];
261
233
  }
262
234
 
263
- /**
264
- * Request payload for promoting an integration to org scope.
265
- *
266
- * INVARIANT: acknowledgedRisk must be true to prove explicit intent.
267
- * @see Phase 3 Invariant #15: Blast radius acknowledgment
268
- */
269
- export interface PromoteIntegrationRequest {
270
- /** User must acknowledge the blast radius of org-wide access */
271
- acknowledgedRisk: boolean;
272
- }
273
-
274
- /**
275
- * Request payload for demoting an integration to self scope.
276
- */
277
- export interface DemoteIntegrationRequest {
278
- /** Optional reason for demotion */
279
- reason?: string;
280
- }
281
-
282
235
  // =============================================================================
283
236
  // Phase 3 Audit Action Types
284
237
  // @see ADR-CONT-031 for design rationale