69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
import { CreateClientSchema } from "@capakraken/shared";
|
|
import {
|
|
adminProcedure,
|
|
createTRPCRouter,
|
|
managerProcedure,
|
|
planningReadProcedure,
|
|
protectedProcedure,
|
|
} from "../trpc.js";
|
|
import {
|
|
batchUpdateClientSortOrder,
|
|
clientBatchSortOrderInputSchema,
|
|
clientIdInputSchema,
|
|
clientIdentifierInputSchema,
|
|
clientListInputSchema,
|
|
clientTreeInputSchema,
|
|
clientUpdateInputSchema,
|
|
createClient,
|
|
deactivateClient,
|
|
deleteClient,
|
|
getClientById,
|
|
getClientByIdentifier,
|
|
getClientTree,
|
|
listClients,
|
|
resolveClientByIdentifier,
|
|
updateClient,
|
|
} from "./client-procedure-support.js";
|
|
|
|
export const clientRouter = createTRPCRouter({
|
|
list: planningReadProcedure
|
|
.input(clientListInputSchema)
|
|
.query(({ ctx, input }) => listClients(ctx, input)),
|
|
|
|
getTree: planningReadProcedure
|
|
.input(clientTreeInputSchema)
|
|
.query(({ ctx, input }) => getClientTree(ctx, input)),
|
|
|
|
getById: planningReadProcedure
|
|
.input(clientIdInputSchema)
|
|
.query(({ ctx, input }) => getClientById(ctx, input)),
|
|
|
|
resolveByIdentifier: protectedProcedure
|
|
.input(clientIdentifierInputSchema)
|
|
.query(({ ctx, input }) => resolveClientByIdentifier(ctx, input)),
|
|
|
|
getByIdentifier: planningReadProcedure
|
|
.input(clientIdentifierInputSchema)
|
|
.query(({ ctx, input }) => getClientByIdentifier(ctx, input)),
|
|
|
|
create: managerProcedure
|
|
.input(CreateClientSchema)
|
|
.mutation(({ ctx, input }) => createClient(ctx, input)),
|
|
|
|
update: managerProcedure
|
|
.input(clientUpdateInputSchema)
|
|
.mutation(({ ctx, input }) => updateClient(ctx, input)),
|
|
|
|
deactivate: managerProcedure
|
|
.input(clientIdInputSchema)
|
|
.mutation(({ ctx, input }) => deactivateClient(ctx, input)),
|
|
|
|
delete: adminProcedure
|
|
.input(clientIdInputSchema)
|
|
.mutation(({ ctx, input }) => deleteClient(ctx, input)),
|
|
|
|
batchUpdateSortOrder: managerProcedure
|
|
.input(clientBatchSortOrderInputSchema)
|
|
.mutation(({ ctx, input }) => batchUpdateClientSortOrder(ctx, input)),
|
|
});
|