@company-semantics/contracts 0.131.0 → 0.132.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.131.0",
3
+ "version": "0.132.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -60,6 +60,10 @@
60
60
  "types": "./src/content/index.ts",
61
61
  "default": "./src/content/index.ts"
62
62
  },
63
+ "./impersonation": {
64
+ "types": "./src/impersonation/index.ts",
65
+ "default": "./src/impersonation/index.ts"
66
+ },
63
67
  "./schemas/guard-result.schema.json": "./schemas/guard-result.schema.json"
64
68
  },
65
69
  "types": "./src/index.ts",
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Impersonation Domain Barrel
3
+ *
4
+ * Re-exports impersonation types and response schemas.
5
+ * Import from '@company-semantics/contracts/impersonation'.
6
+ */
7
+
8
+ // =============================================================================
9
+ // Core Types (from flat module)
10
+ // =============================================================================
11
+
12
+ export type {
13
+ AuthMode,
14
+ ImpersonationSession,
15
+ RestrictedImpersonationAction,
16
+ ImpersonationCapability,
17
+ ImpersonationSessionSummary,
18
+ ImpersonationAuditEventType,
19
+ } from '../impersonation'
20
+
21
+ export { RESTRICTED_IMPERSONATION_ACTIONS } from '../impersonation'
22
+
23
+ // =============================================================================
24
+ // HTTP Response Schemas (Zod)
25
+ // =============================================================================
26
+
27
+ export {
28
+ ImpersonationSessionSchema,
29
+ ImpersonationSessionResponseSchema,
30
+ ImpersonationSessionNullableResponseSchema,
31
+ EndImpersonationResponseSchema,
32
+ } from './schemas'
33
+
34
+ export type {
35
+ ImpersonationSessionResponse,
36
+ EndImpersonationResponse,
37
+ } from './schemas'
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Impersonation Response Schemas
3
+ *
4
+ * Zod schemas for impersonation HTTP endpoint responses.
5
+ * These schemas are used for runtime validation at API contract surfaces.
6
+ *
7
+ * Mirrors the ImpersonationSession interface in ../impersonation.ts.
8
+ * Both are maintained in parallel — Zod schema mirrors the TS interface.
9
+ */
10
+
11
+ import { z } from 'zod'
12
+
13
+ export const ImpersonationSessionSchema = z.object({
14
+ impersonationSessionId: z.string(),
15
+ adminUserId: z.string(),
16
+ targetUserId: z.string(),
17
+ reason: z.string(),
18
+ reasonHash: z.string(),
19
+ startedAt: z.string().datetime({ offset: true }),
20
+ expiresAt: z.string().datetime({ offset: true }),
21
+ endedAt: z.string().datetime({ offset: true }).nullable(),
22
+ ipAddress: z.string(),
23
+ userAgent: z.string(),
24
+ })
25
+
26
+ export const ImpersonationSessionResponseSchema = z.object({
27
+ session: ImpersonationSessionSchema,
28
+ })
29
+
30
+ export const ImpersonationSessionNullableResponseSchema = z.object({
31
+ session: ImpersonationSessionSchema.nullable(),
32
+ })
33
+
34
+ export const EndImpersonationResponseSchema = z.object({
35
+ success: z.literal(true),
36
+ ok: z.literal(true),
37
+ })
38
+
39
+ export type ImpersonationSessionResponse = z.infer<typeof ImpersonationSessionResponseSchema>
40
+ export type EndImpersonationResponse = z.infer<typeof EndImpersonationResponseSchema>