@@ -3,8 +3,8 @@ import type { Strapi5ResponseSingle, Strapi5RequestParams, Strapi5ResponseMany }
3
3
import { useStrapiClient } from '#imports'
4
4
5
5
interface StrapiV5Client < T > {
6
- find < F = T > ( contentType : string , params ?: Strapi5RequestParams ) : Promise < Strapi5ResponseMany < F > >
7
- findOne < F = T > ( contentType : string , documentId ?: string | Strapi5RequestParams , params ?: Strapi5RequestParams ) : Promise < Strapi5ResponseSingle < F > >
6
+ find < F = T > ( contentType : string , params ?: Strapi5RequestParams < F > ) : Promise < Strapi5ResponseMany < F > >
7
+ findOne < F = T > ( contentType : string , documentId ?: string | Strapi5RequestParams < F > , params ?: Strapi5RequestParams < F > ) : Promise < Strapi5ResponseSingle < F > >
8
8
create < F = T > ( contentType : string , data : Partial < F > ) : Promise < Strapi5ResponseSingle < F > >
9
9
update < F = T > ( contentType : string , documentId : string | Partial < F > , data ?: Partial < F > ) : Promise < Strapi5ResponseSingle < F > >
10
10
delete < F = T > ( contentType : string , documentId ?: string ) : Promise < Strapi5ResponseSingle < F > >
@@ -17,10 +17,10 @@ export const useStrapi = <T>(): StrapiV5Client<T> => {
17
17
* Get a list of {content-type} entries
18
18
*
19
19
* @param {string } contentType - Content type's name pluralized
20
- * @param {Strapi5RequestParams } [params] - Query parameters
20
+ * @param {Strapi5RequestParams<T> } [params] - Query parameters
21
21
* @returns Promise<T>
22
22
*/
23
- const find = < T > ( contentType : string , params ?: Strapi5RequestParams , fetchOptions ?: FetchOptions ) : Promise < Strapi5ResponseMany < T > > => {
23
+ const find = < T > ( contentType : string , params ?: Strapi5RequestParams < T > , fetchOptions ?: FetchOptions ) : Promise < Strapi5ResponseMany < T > > => {
24
24
return client ( `/${ contentType } ` , { method : 'GET' , params, ...fetchOptions } )
25
25
}
26
26
@@ -29,10 +29,10 @@ export const useStrapi = <T>(): StrapiV5Client<T> => {
29
29
*
30
30
* @param {string } contentType - Content type's name pluralized
31
31
* @param {string } documentId - ID of entry
32
- * @param {Strapi5RequestParams } [params] - Query parameters
32
+ * @param {Strapi5RequestParams<T> } [params] - Query parameters
33
33
* @returns Promise<T>
34
34
*/
35
- const findOne = < T > ( contentType : string , documentId ?: string | Strapi5RequestParams , params ?: Strapi5RequestParams , fetchOptions ?: FetchOptions ) : Promise < Strapi5ResponseSingle < T > > => {
35
+ const findOne = < T > ( contentType : string , documentId ?: string | Strapi5RequestParams < T > , params ?: Strapi5RequestParams < T > , fetchOptions ?: FetchOptions ) : Promise < Strapi5ResponseSingle < T > > => {
36
36
if ( typeof documentId === 'object' ) {
37
37
params = documentId
38
38
documentId = undefined
@@ -48,10 +48,10 @@ export const useStrapi = <T>(): StrapiV5Client<T> => {
48
48
*
49
49
* @param {string } contentType - Content type's name pluralized
50
50
* @param {Record<string, any> } data - Form data
51
- * @param {Strapi5RequestParams } [params] - Query parameters
51
+ * @param {Strapi5RequestParams<T> } [params] - Query parameters
52
52
* @returns Promise<T>
53
53
*/
54
- const create = < T > ( contentType : string , data : Partial < T > , params : Strapi5RequestParams = { } ) : Promise < Strapi5ResponseSingle < T > > => {
54
+ const create = < T > ( contentType : string , data : Partial < T > , params : Strapi5RequestParams < T > = { } ) : Promise < Strapi5ResponseSingle < T > > => {
55
55
return client ( `/${ contentType } ` , { method : 'POST' , body : { data } , params } )
56
56
}
57
57
@@ -61,10 +61,10 @@ export const useStrapi = <T>(): StrapiV5Client<T> => {
61
61
* @param {string } contentType - Content type's name pluralized
62
62
* @param {string } documentId - ID of entry to be updated
63
63
* @param {Record<string, any> } data - Form data
64
- * @param {Strapi5RequestParams } [params] - Query parameters
64
+ * @param {Strapi5RequestParams<T> } [params] - Query parameters
65
65
* @returns Promise<T>
66
66
*/
67
- const update = < T > ( contentType : string , documentId : string | Partial < T > , data ?: Partial < T > , params : Strapi5RequestParams = { } ) : Promise < Strapi5ResponseSingle < T > > => {
67
+ const update = < T > ( contentType : string , documentId : string | Partial < T > , data ?: Partial < T > , params : Strapi5RequestParams < T > = { } ) : Promise < Strapi5ResponseSingle < T > > => {
68
68
if ( typeof documentId === 'object' ) {
69
69
data = documentId
70
70
documentId = undefined
0 commit comments