@guildxyz/bev3
Version:
Schemas and types related to the Guild.xyz v3 API
101 lines (98 loc) • 2.62 kB
text/typescript
import { z } from 'zod';
export const RoleSystemSchema = z.object({
permissionsAncestor: z
.boolean()
.describe("Whether the role is an ancestor role")
.optional(),
permissions: z
.object({
read: z
.string()
.regex(
new RegExp(
"^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
),
)
.describe("The reward ID that controls this permission action")
.optional(),
update: z
.string()
.regex(
new RegExp(
"^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
),
)
.describe("The reward ID that controls this permission action")
.optional(),
delete: z
.string()
.regex(
new RegExp(
"^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
),
)
.describe("The reward ID that controls this permission action")
.optional(),
})
.optional(),
memberCount: z
.number()
.int()
.gte(0)
.describe("The number of members assigned to this role"),
rewards: z
.array(
z.object({
rewardId: z
.string()
.regex(
new RegExp(
"^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
),
)
.describe("TODO")
.optional(),
}),
)
.optional(),
topLevelAccessGroupId: z
.string()
.describe("The ID of the top-level access group"),
accessGroups: z.array(
z.object({
accessGroupId: z
.string()
.regex(
new RegExp(
"^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
),
)
.describe("Access group ID")
.optional(),
gate: z
.enum(["AND", "OR", "ANY_OF"])
.describe("Access group gate")
.optional(),
rules: z
.array(
z.object({
accessRuleId: z
.string()
.regex(
new RegExp(
"^[0-9a-f]{8}-[0-9a-f]{4}-[45][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
),
)
.describe("Access rule ID")
.optional(),
integrationId: z.string().describe("Integration ID").optional(),
params: z
.record(z.any())
.describe("Access rule parameters")
.optional(),
}),
)
.optional(),
}),
),
});