@@ -5,12 +5,25 @@ import { queryOptions as __TANSTACK_QUERY_OPTIONS, mutationOptions as __TANSTACK
55
66/** Commands */
77export const commands = {
8+ /**
9+ * Get a user by ID.
10+ *
11+ * Returns an error if the user does not exist.
12+ */
813 getUser : ( id : number ) => typedError < User , ApiError > ( __TAURI_INVOKE ( "get_user" , { id } ) ) ,
14+ // List all users.
915 listUsers : ( ) => __TAURI_INVOKE < User [ ] > ( "list_users" ) ,
16+ /**
17+ * List todos for a specific user, optionally filtering by title.
18+ *
19+ * If `title` is provided, only todos containing that substring are returned.
20+ */
1021 listTodos : ( userId : number , title : string | null ) => __TAURI_INVOKE < Todo [ ] > ( "list_todos" , { userId, title } ) ,
1122 createUser : ( name : string , email : string ) => typedError < User , ApiError > ( __TAURI_INVOKE ( "create_user" , { name, email } ) ) ,
1223 createTodo : ( title : string , userId : number ) => typedError < Todo , ApiError > ( __TAURI_INVOKE ( "create_todo" , { title, userId } ) ) ,
24+ // Delete a user by ID, returning an error if the user does not exist.
1325 deleteUser : ( id : number ) => typedError < null , ApiError > ( __TAURI_INVOKE ( "delete_user" , { id } ) ) ,
26+ // Delete a todo by ID, returning an error if the todo does not exist.
1427 deleteTodo : ( id : number ) => typedError < null , ApiError > ( __TAURI_INVOKE ( "delete_todo" , { id } ) ) ,
1528} ;
1629
@@ -23,8 +36,19 @@ export const queryKeys = {
2336
2437/** Queries */
2538export const queries = {
39+ /**
40+ * Get a user by ID.
41+ *
42+ * Returns an error if the user does not exist.
43+ */
2644 getUser : ( id : number ) => __TANSTACK_QUERY_OPTIONS < User , ApiError > ( { queryKey : queryKeys . getUser ( id ) , queryFn : ( ) => unwrapTypedError ( commands . getUser ( id ) ) } ) ,
45+ // List all users.
2746 listUsers : ( ) => __TANSTACK_QUERY_OPTIONS < User [ ] > ( { queryKey : queryKeys . listUsers ( ) , queryFn : ( ) => commands . listUsers ( ) } ) ,
47+ /**
48+ * List todos for a specific user, optionally filtering by title.
49+ *
50+ * If `title` is provided, only todos containing that substring are returned.
51+ */
2852 listTodos : ( userId : number , title : string | null ) => __TANSTACK_QUERY_OPTIONS < Todo [ ] > ( { queryKey : queryKeys . listTodos ( userId , title ) , queryFn : ( ) => commands . listTodos ( userId , title ) } ) ,
2953} ;
3054
@@ -40,20 +64,25 @@ export const mutationKeys = {
4064export const mutations = {
4165 createUser : ( ) => __TANSTACK_MUTATION_OPTIONS < User , ApiError , { name : string , email : string } > ( { mutationKey : mutationKeys . createUser ( ) , mutationFn : ( { name, email } : { name : string , email : string } ) => unwrapTypedError ( commands . createUser ( name , email ) ) } ) ,
4266 createTodo : ( ) => __TANSTACK_MUTATION_OPTIONS < Todo , ApiError , { title : string , userId : number } > ( { mutationKey : mutationKeys . createTodo ( ) , mutationFn : ( { title, userId } : { title : string , userId : number } ) => unwrapTypedError ( commands . createTodo ( title , userId ) ) } ) ,
67+ // Delete a user by ID, returning an error if the user does not exist.
4368 deleteUser : ( ) => __TANSTACK_MUTATION_OPTIONS < null , ApiError , { id : number } > ( { mutationKey : mutationKeys . deleteUser ( ) , mutationFn : ( { id } : { id : number } ) => unwrapTypedError ( commands . deleteUser ( id ) ) } ) ,
69+ // Delete a todo by ID, returning an error if the todo does not exist.
4470 deleteTodo : ( ) => __TANSTACK_MUTATION_OPTIONS < null , ApiError , { id : number } > ( { mutationKey : mutationKeys . deleteTodo ( ) , mutationFn : ( { id } : { id : number } ) => unwrapTypedError ( commands . deleteTodo ( id ) ) } ) ,
4571} ;
4672
4773/* Types */
74+ // A simple API error type for demonstration purposes.
4875export type ApiError = { type : "NotFound" ; data : string } | { type : "Internal" ; data : string } ;
4976
77+ // A todo item associated with a user.
5078export type Todo = {
5179 id : number ,
5280 title : string ,
5381 completed : boolean ,
5482 user_id : number ,
5583} ;
5684
85+ // A user of the application.
5786export type User = {
5887 id : number ,
5988 name : string ,
0 commit comments