@@ -108,7 +108,10 @@ declare abstract class BaseService {
108
108
constructor ( client : Client ) ;
109
109
}
110
110
interface SendOptions extends RequestInit {
111
- [ key : string ] : any ; // for backward compatibility
111
+ // for backward compatibility and to minimize the verbosity,
112
+ // any top-level field that doesn't exist in RequestInit or the
113
+ // fields below will be treated as query parameter.
114
+ [ key : string ] : any ;
112
115
/**
113
116
* Optional custom fetch function to use for sending the request.
114
117
*/
@@ -124,7 +127,7 @@ interface SendOptions extends RequestInit {
124
127
*/
125
128
body ?: any ;
126
129
/**
127
- * Query params that will be appended to the request url.
130
+ * Query parameters that will be appended to the request url.
128
131
*/
129
132
query ?: {
130
133
[ key : string ] : any ;
@@ -570,7 +573,7 @@ interface OAuth2AuthConfig extends SendOptions {
570
573
// optional query params to send with the PocketBase auth request (eg. fields, expand, etc.)
571
574
query ?: RecordOptions ;
572
575
}
573
- declare class RecordService extends CrudService < RecordModel > {
576
+ declare class RecordService < M = RecordModel > extends CrudService < M > {
574
577
readonly collectionIdOrName : string ;
575
578
constructor ( client : Client , collectionIdOrName : string ) ;
576
579
/**
@@ -589,11 +592,11 @@ declare class RecordService extends CrudService<RecordModel> {
589
592
*
590
593
* Subscribe to the realtime changes of a single record in the collection.
591
594
*/
592
- subscribeOne < T = RecordModel > ( recordId : string , callback : ( data : RecordSubscription < T > ) => void ) : Promise < UnsubscribeFunc > ;
595
+ subscribeOne < T = M > ( recordId : string , callback : ( data : RecordSubscription < T > ) => void ) : Promise < UnsubscribeFunc > ;
593
596
/**
594
597
* @deprecated This form of subscribe is deprecated. Please use `subscribe("*", callback)`.
595
598
*/
596
- subscribe < T = RecordModel > ( callback : ( data : RecordSubscription < T > ) => void ) : Promise < UnsubscribeFunc > ;
599
+ subscribe < T = M > ( callback : ( data : RecordSubscription < T > ) => void ) : Promise < UnsubscribeFunc > ;
597
600
/**
598
601
* Subscribe to realtime changes to the specified topic ("*" or record id).
599
602
*
@@ -607,7 +610,7 @@ declare class RecordService extends CrudService<RecordModel> {
607
610
* You can use the returned `UnsubscribeFunc` to remove only a single subscription.
608
611
* Or use `unsubscribe(topic)` if you want to remove all subscriptions attached to the topic.
609
612
*/
610
- subscribe < T = RecordModel > ( topic : string , callback : ( data : RecordSubscription < T > ) => void ) : Promise < UnsubscribeFunc > ;
613
+ subscribe < T = M > ( topic : string , callback : ( data : RecordSubscription < T > ) => void ) : Promise < UnsubscribeFunc > ;
611
614
/**
612
615
* Unsubscribe from all subscriptions of the specified topic
613
616
* ("*" or record id).
@@ -622,27 +625,27 @@ declare class RecordService extends CrudService<RecordModel> {
622
625
/**
623
626
* @inheritdoc
624
627
*/
625
- getFullList < T = RecordModel > ( options ?: RecordFullListOptions ) : Promise < Array < T > > ;
628
+ getFullList < T = M > ( options ?: RecordFullListOptions ) : Promise < Array < T > > ;
626
629
/**
627
630
* @inheritdoc
628
631
*/
629
- getFullList < T = RecordModel > ( batch ?: number , options ?: RecordListOptions ) : Promise < Array < T > > ;
632
+ getFullList < T = M > ( batch ?: number , options ?: RecordListOptions ) : Promise < Array < T > > ;
630
633
/**
631
634
* @inheritdoc
632
635
*/
633
- getList < T = RecordModel > ( page ?: number , perPage ?: number , options ?: RecordListOptions ) : Promise < ListResult < T > > ;
636
+ getList < T = M > ( page ?: number , perPage ?: number , options ?: RecordListOptions ) : Promise < ListResult < T > > ;
634
637
/**
635
638
* @inheritdoc
636
639
*/
637
- getFirstListItem < T = RecordModel > ( filter : string , options ?: RecordListOptions ) : Promise < T > ;
640
+ getFirstListItem < T = M > ( filter : string , options ?: RecordListOptions ) : Promise < T > ;
638
641
/**
639
642
* @inheritdoc
640
643
*/
641
- getOne < T = RecordModel > ( id : string , options ?: RecordOptions ) : Promise < T > ;
644
+ getOne < T = M > ( id : string , options ?: RecordOptions ) : Promise < T > ;
642
645
/**
643
646
* @inheritdoc
644
647
*/
645
- create < T = RecordModel > ( bodyParams ?: {
648
+ create < T = M > ( bodyParams ?: {
646
649
[ key : string ] : any ;
647
650
} | FormData , options ?: RecordOptions ) : Promise < T > ;
648
651
/**
@@ -651,7 +654,7 @@ declare class RecordService extends CrudService<RecordModel> {
651
654
* If the current `client.authStore.model` matches with the updated id, then
652
655
* on success the `client.authStore.model` will be updated with the result.
653
656
*/
654
- update < T = RecordModel > ( id : string , bodyParams ?: {
657
+ update < T = M > ( id : string , bodyParams ?: {
655
658
[ key : string ] : any ;
656
659
} | FormData , options ?: RecordOptions ) : Promise < T > ;
657
660
/**
@@ -667,7 +670,7 @@ declare class RecordService extends CrudService<RecordModel> {
667
670
/**
668
671
* Prepare successful collection authorization response.
669
672
*/
670
- protected authResponse < T = RecordModel > ( responseData : any ) : RecordAuthResponse < T > ;
673
+ protected authResponse < T = M > ( responseData : any ) : RecordAuthResponse < T > ;
671
674
/**
672
675
* Returns all available collection auth methods.
673
676
*/
@@ -680,12 +683,12 @@ declare class RecordService extends CrudService<RecordModel> {
680
683
* - the authentication token
681
684
* - the authenticated record model
682
685
*/
683
- authWithPassword < T = RecordModel > ( usernameOrEmail : string , password : string , options ?: RecordOptions ) : Promise < RecordAuthResponse < T > > ;
686
+ authWithPassword < T = M > ( usernameOrEmail : string , password : string , options ?: RecordOptions ) : Promise < RecordAuthResponse < T > > ;
684
687
/**
685
688
* @deprecated
686
689
* Consider using authWithPassword(usernameOrEmail, password, options?).
687
690
*/
688
- authWithPassword < T = RecordModel > ( usernameOrEmail : string , password : string , body ?: any , query ?: any ) : Promise < RecordAuthResponse < T > > ;
691
+ authWithPassword < T = M > ( usernameOrEmail : string , password : string , body ?: any , query ?: any ) : Promise < RecordAuthResponse < T > > ;
689
692
/**
690
693
* Authenticate a single auth collection record with OAuth2 code.
691
694
*
@@ -697,14 +700,14 @@ declare class RecordService extends CrudService<RecordModel> {
697
700
* - the authenticated record model
698
701
* - the OAuth2 account data (eg. name, email, avatar, etc.)
699
702
*/
700
- authWithOAuth2Code < T = RecordModel > ( provider : string , code : string , codeVerifier : string , redirectUrl : string , createData ?: {
703
+ authWithOAuth2Code < T = M > ( provider : string , code : string , codeVerifier : string , redirectUrl : string , createData ?: {
701
704
[ key : string ] : any ;
702
705
} , options ?: RecordOptions ) : Promise < RecordAuthResponse < T > > ;
703
706
/**
704
707
* @deprecated
705
708
* Consider using authWithOAuth2Code(provider, code, codeVerifier, redirectUrl, createdData, options?).
706
709
*/
707
- authWithOAuth2Code < T = RecordModel > ( provider : string , code : string , codeVerifier : string , redirectUrl : string , createData ?: {
710
+ authWithOAuth2Code < T = M > ( provider : string , code : string , codeVerifier : string , redirectUrl : string , createData ?: {
708
711
[ key : string ] : any ;
709
712
} , body ?: any , query ?: any ) : Promise < RecordAuthResponse < T > > ;
710
713
/**
@@ -713,7 +716,7 @@ declare class RecordService extends CrudService<RecordModel> {
713
716
* Please use `authWithOAuth2Code()` OR its simplified realtime version
714
717
* as shown in https://pocketbase.io/docs/authentication/#oauth2-integration.
715
718
*/
716
- authWithOAuth2 < T = RecordModel > ( provider : string , code : string , codeVerifier : string , redirectUrl : string , createData ?: {
719
+ authWithOAuth2 < T = M > ( provider : string , code : string , codeVerifier : string , redirectUrl : string , createData ?: {
717
720
[ key : string ] : any ;
718
721
} , bodyParams ?: {
719
722
[ key : string ] : any ;
@@ -749,19 +752,19 @@ declare class RecordService extends CrudService<RecordModel> {
749
752
* you have to configure `https://yourdomain.com/api/oauth2-redirect`
750
753
* as redirect URL.
751
754
*/
752
- authWithOAuth2 < T = RecordModel > ( options : OAuth2AuthConfig ) : Promise < RecordAuthResponse < T > > ;
755
+ authWithOAuth2 < T = M > ( options : OAuth2AuthConfig ) : Promise < RecordAuthResponse < T > > ;
753
756
/**
754
757
* Refreshes the current authenticated record instance and
755
758
* returns a new token and record data.
756
759
*
757
760
* On success this method also automatically updates the client's AuthStore.
758
761
*/
759
- authRefresh < T = RecordModel > ( options ?: RecordOptions ) : Promise < RecordAuthResponse < T > > ;
762
+ authRefresh < T = M > ( options ?: RecordOptions ) : Promise < RecordAuthResponse < T > > ;
760
763
/**
761
764
* @deprecated
762
765
* Consider using authRefresh(options?).
763
766
*/
764
- authRefresh < T = RecordModel > ( body ?: any , query ?: any ) : Promise < RecordAuthResponse < T > > ;
767
+ authRefresh < T = M > ( body ?: any , query ?: any ) : Promise < RecordAuthResponse < T > > ;
765
768
/**
766
769
* Sends auth record password reset request.
767
770
*/
@@ -1046,7 +1049,7 @@ declare class Client {
1046
1049
* @param {string } idOrName
1047
1050
* @return {RecordService }
1048
1051
*/
1049
- collection ( idOrName : string ) : RecordService ;
1052
+ collection < M = RecordModel > ( idOrName : string ) : RecordService < M > ;
1050
1053
/**
1051
1054
* Globally enable or disable auto cancellation for pending duplicated requests.
1052
1055
*/
0 commit comments