forked from kibertoad/message-queue-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
userConsumerSchemas.ts
27 lines (22 loc) · 940 Bytes
/
userConsumerSchemas.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import z from 'zod'
export const PERMISSIONS_MESSAGE_SCHEMA = z.object({
id: z.string(),
messageType: z.enum(['add', 'remove']),
userIds: z.array(z.number()).describe('User IDs'),
permissions: z.array(z.string()).nonempty().describe('List of user permissions'),
timestamp: z.string().optional(),
})
export const PERMISSIONS_ADD_MESSAGE_SCHEMA = z.object({
id: z.string(),
messageType: z.literal('add'),
timestamp: z.string().optional(),
metadata: z.record(z.string(), z.unknown()).optional(),
})
export const PERMISSIONS_REMOVE_MESSAGE_SCHEMA = z.object({
id: z.string(),
messageType: z.literal('remove'),
timestamp: z.string().optional(),
})
export type PERMISSIONS_MESSAGE_TYPE = z.infer<typeof PERMISSIONS_MESSAGE_SCHEMA>
export type PERMISSIONS_ADD_MESSAGE_TYPE = z.infer<typeof PERMISSIONS_ADD_MESSAGE_SCHEMA>
export type PERMISSIONS_REMOVE_MESSAGE_TYPE = z.infer<typeof PERMISSIONS_REMOVE_MESSAGE_SCHEMA>