@company-semantics/contracts 0.36.0 → 0.36.1

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.36.0",
3
+ "version": "0.36.1",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
package/src/index.ts CHANGED
@@ -130,9 +130,24 @@ export type {
130
130
  IntegrationStatus,
131
131
  WorkspaceIntegration,
132
132
  WorkspaceAuditEvent,
133
+ // Workspace expansion DTOs (Phase 3)
134
+ // @see ADR-CONT-031 for design rationale
135
+ OrgInviteStatus,
136
+ OrgInvite,
137
+ CreateInviteRequest,
138
+ AcceptInviteRequest,
139
+ RemoveMemberRequest,
140
+ ChangeMemberRoleRequest,
141
+ OrgAuthPolicy,
142
+ UpdateAuthPolicyRequest,
143
+ PromoteIntegrationRequest,
144
+ DemoteIntegrationRequest,
145
+ Phase3AuditAction,
146
+ // Workspace capability types (Phase 3)
147
+ WorkspaceCapability,
133
148
  } from './org/index'
134
149
 
135
- export { ROLE_DISPLAY_MAP } from './org/index'
150
+ export { ROLE_DISPLAY_MAP, WORKSPACE_CAPABILITIES, ROLE_CAPABILITY_MAP } from './org/index'
136
151
 
137
152
  // MCP tool discovery types
138
153
  // @see company-semantics-backend/src/interfaces/mcp/ for implementation
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Workspace Capability Types
3
+ *
4
+ * Capability constants for Phase 3 workspace expansion features.
5
+ * These define the permission boundaries for workspace actions.
6
+ *
7
+ * INVARIANTS:
8
+ * - Capabilities are checked server-side before any mutation
9
+ * - UI uses capabilities to gate action visibility
10
+ * - Capabilities map to RBAC roles (see RoleCapabilityMap)
11
+ *
12
+ * @see ADR-CONT-031 for design rationale
13
+ */
14
+
15
+ // =============================================================================
16
+ // Workspace Capability Type
17
+ // =============================================================================
18
+
19
+ /**
20
+ * Capabilities for workspace actions.
21
+ * Used for capability-based access control in Phase 3 features.
22
+ *
23
+ * Capability hierarchy (implicit):
24
+ * - owner: all capabilities
25
+ * - admin: invite_member, manage_members (limited)
26
+ * - member: none (read-only)
27
+ */
28
+ export type WorkspaceCapability =
29
+ // Member management
30
+ | 'org.invite_member'
31
+ | 'org.manage_members'
32
+ // Integration management
33
+ | 'org.promote_integration'
34
+ | 'org.demote_integration'
35
+ // Auth policy
36
+ | 'org.manage_auth'
37
+ // Domain claiming (future)
38
+ | 'org.claim_domain';
39
+
40
+ /**
41
+ * All workspace capabilities.
42
+ * Use for iteration and validation.
43
+ */
44
+ export const WORKSPACE_CAPABILITIES: readonly WorkspaceCapability[] = [
45
+ 'org.invite_member',
46
+ 'org.manage_members',
47
+ 'org.promote_integration',
48
+ 'org.demote_integration',
49
+ 'org.manage_auth',
50
+ 'org.claim_domain',
51
+ ] as const;
52
+
53
+ // =============================================================================
54
+ // Role → Capability Mapping
55
+ // =============================================================================
56
+
57
+ /**
58
+ * Capabilities granted to each workspace role.
59
+ *
60
+ * INVARIANTS:
61
+ * - Owner has all capabilities (cannot be restricted)
62
+ * - Admin cannot demote other admins (enforce in service layer)
63
+ * - Member has no mutation capabilities
64
+ *
65
+ * @see Phase 3 Invariant #4: Admin floor
66
+ * @see Phase 3 Invariant #5: Admin ≠ owner
67
+ */
68
+ export const ROLE_CAPABILITY_MAP = {
69
+ owner: [
70
+ 'org.invite_member',
71
+ 'org.manage_members',
72
+ 'org.promote_integration',
73
+ 'org.demote_integration',
74
+ 'org.manage_auth',
75
+ 'org.claim_domain',
76
+ ],
77
+ admin: [
78
+ 'org.invite_member',
79
+ 'org.manage_members', // Note: cannot remove/demote other admins
80
+ 'org.demote_integration', // Can demote own integrations only
81
+ ],
82
+ member: [],
83
+ } as const satisfies Record<string, readonly WorkspaceCapability[]>;
package/src/org/index.ts CHANGED
@@ -20,6 +20,22 @@ export type {
20
20
  IntegrationStatus,
21
21
  WorkspaceIntegration,
22
22
  WorkspaceAuditEvent,
23
+ // Workspace expansion DTOs (Phase 3)
24
+ OrgInviteStatus,
25
+ OrgInvite,
26
+ CreateInviteRequest,
27
+ AcceptInviteRequest,
28
+ RemoveMemberRequest,
29
+ ChangeMemberRoleRequest,
30
+ OrgAuthPolicy,
31
+ UpdateAuthPolicyRequest,
32
+ PromoteIntegrationRequest,
33
+ DemoteIntegrationRequest,
34
+ Phase3AuditAction,
23
35
  } from './types';
24
36
 
25
37
  export { ROLE_DISPLAY_MAP } from './types';
38
+
39
+ // Workspace capability types (Phase 3)
40
+ export type { WorkspaceCapability } from './capabilities';
41
+ export { WORKSPACE_CAPABILITIES, ROLE_CAPABILITY_MAP } from './capabilities';
package/src/org/types.ts CHANGED
@@ -126,16 +126,23 @@ export type IntegrationStatus = 'active' | 'expired' | 'revoked';
126
126
  /**
127
127
  * Workspace integration for the integrations list.
128
128
  * Shows connections visible to workspace admins.
129
+ *
130
+ * SECURITY: connectedBy.id should be empty string (not exposed for security).
131
+ * lastActivity is aggregated to reduce precision for timing attack mitigation.
132
+ * @see security-safety-reviewer finding: Excessive Information Disclosure
129
133
  */
130
134
  export interface WorkspaceIntegration {
131
135
  id: string;
132
136
  provider: string;
133
137
  status: IntegrationStatus;
134
138
  connectedBy: {
139
+ /** Always empty string for security (user IDs not exposed) */
135
140
  id: string;
141
+ /** Name of the user who connected this integration, or 'A team member' if unknown */
136
142
  name: string;
137
143
  };
138
144
  executionScope: ExecutionScope;
145
+ /** Aggregated last activity (e.g., 'within the last day', 'within the last week') */
139
146
  lastActivity: string | null;
140
147
  }
141
148
 
@@ -154,3 +161,133 @@ export interface WorkspaceAuditEvent {
154
161
  action: string;
155
162
  summary: string;
156
163
  }
164
+
165
+ // =============================================================================
166
+ // Workspace Expansion DTOs (Phase 3)
167
+ // @see ADR-CONT-031 for design rationale
168
+ // =============================================================================
169
+
170
+ /**
171
+ * Status of an organization invite.
172
+ */
173
+ export type OrgInviteStatus = 'pending' | 'accepted' | 'expired' | 'revoked';
174
+
175
+ /**
176
+ * Organization invite for the workspace invites list.
177
+ * Represents a pending or historical invitation.
178
+ */
179
+ export interface OrgInvite {
180
+ id: string;
181
+ orgId: string;
182
+ email: string;
183
+ role: WorkspaceRole;
184
+ invitedBy: {
185
+ id: string;
186
+ name: string;
187
+ };
188
+ status: OrgInviteStatus;
189
+ createdAt: string;
190
+ expiresAt: string;
191
+ acceptedAt?: string;
192
+ }
193
+
194
+ /**
195
+ * Request payload for creating an organization invite.
196
+ */
197
+ export interface CreateInviteRequest {
198
+ email: string;
199
+ role: 'admin' | 'member';
200
+ }
201
+
202
+ /**
203
+ * Request payload for accepting an organization invite.
204
+ */
205
+ export interface AcceptInviteRequest {
206
+ token: string;
207
+ }
208
+
209
+ /**
210
+ * Request payload for removing a member from the workspace.
211
+ */
212
+ export interface RemoveMemberRequest {
213
+ memberId: string;
214
+ }
215
+
216
+ /**
217
+ * Request payload for changing a member's role.
218
+ */
219
+ export interface ChangeMemberRoleRequest {
220
+ memberId: string;
221
+ newRole: 'admin' | 'member';
222
+ }
223
+
224
+ /**
225
+ * Organization authentication policy.
226
+ * Configures authentication requirements for workspace members.
227
+ *
228
+ * INVARIANT: Auth policy changes do not affect existing sessions
229
+ * (unless explicitly revoked via separate action).
230
+ * @see Phase 3 Invariant #11: No retroactive enforcement
231
+ */
232
+ export interface OrgAuthPolicy {
233
+ /** Whether SSO is required for all members */
234
+ requireSSO: boolean;
235
+ /** List of allowed authentication providers (e.g., 'google', 'microsoft', 'okta') */
236
+ allowedProviders: string[];
237
+ }
238
+
239
+ /**
240
+ * Request payload for updating organization auth policy.
241
+ */
242
+ export interface UpdateAuthPolicyRequest {
243
+ requireSSO?: boolean;
244
+ allowedProviders?: string[];
245
+ }
246
+
247
+ /**
248
+ * Request payload for promoting an integration to org scope.
249
+ *
250
+ * INVARIANT: acknowledgedRisk must be true to prove explicit intent.
251
+ * @see Phase 3 Invariant #15: Blast radius acknowledgment
252
+ */
253
+ export interface PromoteIntegrationRequest {
254
+ /** User must acknowledge the blast radius of org-wide access */
255
+ acknowledgedRisk: boolean;
256
+ }
257
+
258
+ /**
259
+ * Request payload for demoting an integration to self scope.
260
+ */
261
+ export interface DemoteIntegrationRequest {
262
+ /** Optional reason for demotion */
263
+ reason?: string;
264
+ }
265
+
266
+ // =============================================================================
267
+ // Phase 3 Audit Action Types
268
+ // @see ADR-CONT-031 for design rationale
269
+ // =============================================================================
270
+
271
+ /**
272
+ * Audit actions for Phase 3 workspace expansion features.
273
+ * These actions are emitted by the backend when workspace state changes.
274
+ *
275
+ * INVARIANT: All mutations must emit corresponding audit events.
276
+ * @see Phase 3 Invariant #13: All mutations are auditable
277
+ */
278
+ export type Phase3AuditAction =
279
+ // Invite lifecycle
280
+ | 'org.member.invited'
281
+ | 'org.member.joined'
282
+ | 'org.invite.revoked'
283
+ | 'org.invite.expired'
284
+ // Member mutations
285
+ | 'org.member.removed'
286
+ | 'org.member.role_changed'
287
+ // Organization transition
288
+ | 'org.type_transition'
289
+ // Integration scope changes
290
+ | 'integration.scope_promoted'
291
+ | 'integration.scope_demoted'
292
+ // Auth policy
293
+ | 'org.auth_policy.updated';