@@ -13,38 +13,42 @@ import type {
1313
1414export const listsEndpoints = {
1515 findManyLists : defineEndpoint ( {
16- function : async ( ) : Promise < Response > => {
16+ function : async ( { signal } ) : Promise < Response > => {
1717 const { API_URL } = Config . getConfig < AppConfig > ( ) ;
18- return fetch ( `${ API_URL } /toledo/lists` , Api . requestOptions ) ;
18+ return fetch ( `${ API_URL } /toledo/lists` , {
19+ ...Api . requestOptions ,
20+ signal,
21+ } ) ;
1922 } ,
2023 transformer : async ( response ) : Promise < List [ ] | undefined > => {
2124 const json = await response . json ( ) ;
2225 const lists : List [ ] = [ ...json ] ;
2326 return lists ;
2427 } ,
2528 } ) ,
26- findListById : defineEndpoint ( {
27- function : async ( id : string ) : Promise < Response > => {
29+ findListById : defineEndpoint < { id : string } > ( {
30+ function : async ( { args , signal } ) : Promise < Response > => {
2831 const { API_URL } = Config . getConfig < AppConfig > ( ) ;
29- return fetch (
30- ` ${ API_URL } /toledo/lists/ ${ id } ?include=items` ,
31- Api . requestOptions
32- ) ;
32+ return fetch ( ` ${ API_URL } /toledo/lists/ ${ args . id } ?include=items` , {
33+ ... Api . requestOptions ,
34+ signal ,
35+ } ) ;
3336 } ,
3437 transformer : async ( response ) : Promise < List > => {
3538 const json = await response . json ( ) ;
3639 const list : List = { ...json } ;
3740 return list ;
3841 } ,
3942 } ) ,
40- createList : defineEndpoint ( {
41- function : async ( list : NewList ) : Promise < Response > => {
42- const body = JSON . stringify ( list ) ;
43+ createList : defineEndpoint < { list : NewList } > ( {
44+ function : async ( { args , signal } ) : Promise < Response > => {
45+ const body = JSON . stringify ( args . list ) ;
4346 const { API_URL } = Config . getConfig < AppConfig > ( ) ;
4447 return fetch ( `${ API_URL } /toledo/lists` , {
4548 ...Api . requestOptions ,
4649 method : 'POST' ,
4750 body,
51+ signal,
4852 } ) ;
4953 } ,
5054 transformer : async ( response ) : Promise < List > => {
@@ -53,14 +57,15 @@ export const listsEndpoints = {
5357 return list ;
5458 } ,
5559 } ) ,
56- updateList : defineEndpoint ( {
57- function : async ( list : UpdatedList ) : Promise < Response > => {
58- const body = JSON . stringify ( list ) ;
60+ updateList : defineEndpoint < { list : UpdatedList } > ( {
61+ function : async ( { args , signal } ) : Promise < Response > => {
62+ const body = JSON . stringify ( args . list ) ;
5963 const { API_URL } = Config . getConfig < AppConfig > ( ) ;
60- return fetch ( `${ API_URL } /toledo/lists/${ list . id } ?include=items` , {
64+ return fetch ( `${ API_URL } /toledo/lists/${ args . list . id } ?include=items` , {
6165 ...Api . requestOptions ,
6266 method : 'PATCH' ,
6367 body,
68+ signal,
6469 } ) ;
6570 } ,
6671 transformer : async ( response ) : Promise < List > => {
@@ -69,21 +74,23 @@ export const listsEndpoints = {
6974 return list ;
7075 } ,
7176 } ) ,
72- deleteList : defineEndpoint ( {
73- function : async ( id : string ) : Promise < void > => {
77+ deleteList : defineEndpoint < { id : string } > ( {
78+ function : async ( { args , signal } ) : Promise < void > => {
7479 const { API_URL } = Config . getConfig < AppConfig > ( ) ;
75- await fetch ( `${ API_URL } /toledo/lists/${ id } ` , {
80+ await fetch ( `${ API_URL } /toledo/lists/${ args . id } ` , {
7681 ...Api . requestOptions ,
7782 method : 'DELETE' ,
83+ signal,
7884 } ) ;
7985 } ,
8086 } ) ,
81- generateListInvite : defineEndpoint ( {
82- function : async ( id : string ) : Promise < Response > => {
87+ generateListInvite : defineEndpoint < { id : string } > ( {
88+ function : async ( { args , signal } ) : Promise < Response > => {
8389 const { API_URL } = Config . getConfig < AppConfig > ( ) ;
84- return fetch ( `${ API_URL } /toledo/lists/${ id } /generate-invite` , {
90+ return fetch ( `${ API_URL } /toledo/lists/${ args . id } /generate-invite` , {
8591 ...Api . requestOptions ,
8692 method : 'POST' ,
93+ signal,
8794 } ) ;
8895 } ,
8996 transformer : async ( response ) : Promise < ListInviteLink > => {
@@ -92,23 +99,28 @@ export const listsEndpoints = {
9299 return inviteLink ;
93100 } ,
94101 } ) ,
95- acceptListInvite : defineEndpoint ( {
96- function : async ( id : string , code : string ) : Promise < Response > => {
102+ acceptListInvite : defineEndpoint < { id : string ; code : string } > ( {
103+ function : async ( { args , signal } ) : Promise < Response > => {
97104 const { API_URL } = Config . getConfig < AppConfig > ( ) ;
98- return fetch ( `${ API_URL } /toledo/lists/${ id } /accept-invite?code=${ code } ` , {
99- ...Api . requestOptions ,
100- method : 'PUT' ,
101- } ) ;
105+ return fetch (
106+ `${ API_URL } /toledo/lists/${ args . id } /accept-invite?code=${ args . code } ` ,
107+ {
108+ ...Api . requestOptions ,
109+ method : 'PUT' ,
110+ signal,
111+ }
112+ ) ;
102113 } ,
103114 } ) ,
104- createListItem : defineEndpoint ( {
105- function : async ( listId : string , item : NewListItem ) : Promise < Response > => {
106- const body = JSON . stringify ( item ) ;
115+ createListItem : defineEndpoint < { listId : string ; item : NewListItem } > ( {
116+ function : async ( { args , signal } ) : Promise < Response > => {
117+ const body = JSON . stringify ( args . item ) ;
107118 const { API_URL } = Config . getConfig < AppConfig > ( ) ;
108- return fetch ( `${ API_URL } /toledo/lists/${ listId } /items` , {
119+ return fetch ( `${ API_URL } /toledo/lists/${ args . listId } /items` , {
109120 ...Api . requestOptions ,
110121 method : 'POST' ,
111122 body,
123+ signal,
112124 } ) ;
113125 } ,
114126 transformer : async ( response ) : Promise < ListItem > => {
@@ -117,29 +129,37 @@ export const listsEndpoints = {
117129 return list ;
118130 } ,
119131 } ) ,
120- updateListItem : defineEndpoint ( {
121- function : async ( item : ListItem ) : Promise < Response > => {
122- const body = JSON . stringify ( item ) ;
132+ updateListItem : defineEndpoint < { item : ListItem } > ( {
133+ function : async ( { args , signal } ) : Promise < Response > => {
134+ const body = JSON . stringify ( args . item ) ;
123135 const { API_URL } = Config . getConfig < AppConfig > ( ) ;
124- return fetch ( `${ API_URL } /toledo/lists/${ item . listId } /items/${ item . id } ` , {
125- ...Api . requestOptions ,
126- method : 'PATCH' ,
127- body,
128- } ) ;
136+ return fetch (
137+ `${ API_URL } /toledo/lists/${ args . item . listId } /items/${ args . item . id } ` ,
138+ {
139+ ...Api . requestOptions ,
140+ method : 'PATCH' ,
141+ body,
142+ signal,
143+ }
144+ ) ;
129145 } ,
130146 transformer : async ( response ) : Promise < ListItem > => {
131147 const json = await response . json ( ) ;
132148 const list : ListItem = { ...json } ;
133149 return list ;
134150 } ,
135151 } ) ,
136- deleteListItem : defineEndpoint ( {
137- function : async ( listId : string , itemId : string ) : Promise < void > => {
152+ deleteListItem : defineEndpoint < { listId : string ; itemId : string } > ( {
153+ function : async ( { args , signal } ) : Promise < void > => {
138154 const { API_URL } = Config . getConfig < AppConfig > ( ) ;
139- await fetch ( `${ API_URL } /toledo/lists/${ listId } /items/${ itemId } ` , {
140- ...Api . requestOptions ,
141- method : 'DELETE' ,
142- } ) ;
155+ await fetch (
156+ `${ API_URL } /toledo/lists/${ args . listId } /items/${ args . itemId } ` ,
157+ {
158+ ...Api . requestOptions ,
159+ method : 'DELETE' ,
160+ signal,
161+ }
162+ ) ;
143163 } ,
144164 } ) ,
145165} ;
0 commit comments