1
- /* eslint-disable @typescript-eslint/ban-ts-comment */
2
1
import { Entity , schema } from '@data-client/endpoint' ;
3
2
import { useController , useSuspense } from '@data-client/react' ;
4
3
import { User } from '__tests__/new' ;
@@ -197,31 +196,31 @@ it('should precisely type function arguments', () => {
197
196
// path: '/todos/:id?'
198
197
( ) => {
199
198
const optionalUndefSearch = new RestEndpoint ( {
200
- path : '/todos/:id? ' ,
199
+ path : '/todos{ /:id} ' ,
201
200
searchParams : { } as
202
201
| {
203
202
userId ?: string | number ;
204
203
}
205
204
| undefined ,
206
205
} ) ;
207
206
const optionalSearch = new RestEndpoint ( {
208
- path : '/todos/:id? ' ,
207
+ path : '/todos{ /:id} ' ,
209
208
searchParams : { } as {
210
209
userId ?: string | number ;
211
210
} ,
212
211
} ) ;
213
212
const undef = new RestEndpoint ( {
214
- path : '/todos/:id? ' ,
213
+ path : '/todos{ /:id} ' ,
215
214
searchParams : undefined ,
216
215
} ) ;
217
216
const requiredSearch = new RestEndpoint ( {
218
- path : '/todos/:id? ' ,
217
+ path : '/todos{ /:id} ' ,
219
218
searchParams : { } as {
220
219
userId : string | number ;
221
220
} ,
222
221
} ) ;
223
222
const noSearch = new RestEndpoint ( {
224
- path : '/todos/:id? ' ,
223
+ path : '/todos{ /:id} ' ,
225
224
} ) ;
226
225
( ) => optionalUndefSearch ( ) ;
227
226
( ) => optionalUndefSearch ( { } ) ;
@@ -573,20 +572,19 @@ it('should handle more open ended type definitions', () => {
573
572
574
573
( ) => {
575
574
const getThing = new RestEndpoint ( {
576
- path : '/:id* :bob' ,
575
+ path : '{/*id} :bob' ,
577
576
} ) ;
578
577
579
578
getThing ( { id : 5 , bob : 'hi' } ) ;
580
579
// @ts -expect-error
581
580
getThing ( { id : 'hi' } ) ;
582
- // @ts -expect-error
583
581
getThing ( { bob : 'hi' } ) ;
584
582
// @ts -expect-error
585
583
getThing ( 5 ) ;
586
584
} ;
587
585
( ) => {
588
586
const getThing = new RestEndpoint ( {
589
- path : '/:id+ :bob' ,
587
+ path : '/*id :bob' ,
590
588
} ) ;
591
589
592
590
getThing ( { id : 5 , bob : 'hi' } ) ;
@@ -601,7 +599,7 @@ it('should handle more open ended type definitions', () => {
601
599
} ;
602
600
( ) => {
603
601
const getThing = new RestEndpoint ( {
604
- path : '/:id\\+ :bob' ,
602
+ path : '/:id\\, :bob' ,
605
603
} ) ;
606
604
607
605
getThing ( { id : 5 , bob : 'hi' } ) ;
@@ -616,7 +614,7 @@ it('should handle more open ended type definitions', () => {
616
614
} ;
617
615
( ) => {
618
616
const getThing = new RestEndpoint ( {
619
- path : '/:id: bob+ ' ,
617
+ path : '/:id/* bob' ,
620
618
} ) ;
621
619
622
620
getThing ( { id : 5 , bob : 'hi' } ) ;
@@ -631,7 +629,7 @@ it('should handle more open ended type definitions', () => {
631
629
} ;
632
630
( ) => {
633
631
const getThing = new RestEndpoint ( {
634
- path : '/:foo/(.* )' ,
632
+ path : '/:foo/(.)' ,
635
633
} ) ;
636
634
637
635
getThing ( { foo : 'hi' } ) ;
@@ -644,7 +642,7 @@ it('should handle more open ended type definitions', () => {
644
642
} ;
645
643
( ) => {
646
644
const getThing = new RestEndpoint ( {
647
- path : '/:attr1? {-:attr2}? {-:attr3}? ' ,
645
+ path : '{ /:attr1} {-:attr2}{-:attr3}' ,
648
646
} ) ;
649
647
650
648
getThing ( { attr1 : 'hi' } ) ;
0 commit comments