pl-api: Mostly finish migration to valibot

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-10-16 01:08:56 +02:00
parent 6633b28645
commit 2f7e149f75
44 changed files with 457 additions and 394 deletions

View File

@ -1,4 +1,4 @@
import { z } from 'zod';
import * as v from 'valibot';
import { Entities } from 'pl-fe/entity-store/entities';
import { useEntity } from 'pl-fe/entity-store/hooks';
@ -19,7 +19,7 @@ const useRelationship = (accountId: string | undefined, opts: UseRelationshipOpt
() => client.accounts.getRelationships([accountId!]),
{
enabled: enabled && !!accountId,
schema: z.any().transform(arr => arr[0]),
schema: v.pipe(v.any(), v.transform(arr => arr[0])),
},
);

View File

@ -1,4 +1,4 @@
import { z } from 'zod';
import * as v from 'valibot';
import { Entities } from 'pl-fe/entity-store/entities';
import { useCreateEntity } from 'pl-fe/entity-store/hooks';
@ -13,7 +13,7 @@ const useDemoteGroupMember = (group: Pick<Group, 'id'>, groupMember: Pick<GroupM
const { createEntity } = useCreateEntity(
[Entities.GROUP_MEMBERSHIPS, groupMember.id],
({ account_ids, role }: { account_ids: string[]; role: GroupRole }) => client.experimental.groups.demoteGroupUsers(group.id, account_ids, role),
{ schema: z.any().transform((arr) => arr[0]), transform: normalizeGroupMember },
{ schema: v.pipe(v.any(), v.transform(arr => arr[0])), transform: normalizeGroupMember },
);
return createEntity;

View File

@ -1,4 +1,4 @@
import { z } from 'zod';
import * as v from 'valibot';
import { Entities } from 'pl-fe/entity-store/entities';
import { useEntity } from 'pl-fe/entity-store/hooks';
@ -14,7 +14,7 @@ const useGroupRelationship = (groupId: string | undefined) => {
() => client.experimental.groups.getGroupRelationships([groupId!]),
{
enabled: !!groupId,
schema: z.any().transform(arr => arr[0]),
schema: v.pipe(v.any(), v.transform(arr => arr[0])),
},
);

View File

@ -1,4 +1,4 @@
import { z } from 'zod';
import * as v from 'valibot';
import { Entities } from 'pl-fe/entity-store/entities';
import { useCreateEntity } from 'pl-fe/entity-store/hooks';
@ -13,7 +13,7 @@ const usePromoteGroupMember = (group: Pick<Group, 'id'>, groupMember: Pick<Group
const { createEntity } = useCreateEntity(
[Entities.GROUP_MEMBERSHIPS, groupMember.id],
({ account_ids, role }: { account_ids: string[]; role: GroupRole }) => client.experimental.groups.promoteGroupUsers(group.id, account_ids, role),
{ schema: z.any().transform((arr) => arr[0]), transform: normalizeGroupMember },
{ schema: v.pipe(v.any(), v.transform(arr => arr[0])), transform: normalizeGroupMember },
);
return createEntity;