@data-client/rest 0.9.9 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -3
- package/dist/index.js +13 -7
- package/dist/index.umd.min.js +1 -1
- package/legacy/NetworkError.js +1 -1
- package/legacy/OptionsToFunction.js +1 -1
- package/legacy/RestEndpoint.js +7 -2
- package/legacy/RestEndpointTypeHelp.js +1 -1
- package/legacy/RestEndpointTypes.js +1 -1
- package/legacy/RestHelpers.js +1 -1
- package/legacy/createResource.js +7 -8
- package/legacy/extractCollection.js +1 -1
- package/legacy/extractObject.js +1 -1
- package/legacy/hookifyResource.js +1 -1
- package/legacy/index.js +2 -1
- package/legacy/mapCollection.js +1 -1
- package/legacy/next/index.js +1 -1
- package/legacy/paginatedCollections.js +1 -1
- package/legacy/paramsToString.js +1 -1
- package/legacy/paramsToString.native.js +1 -1
- package/legacy/pathTypes.js +1 -1
- package/legacy/resourceExtendable.js +1 -1
- package/legacy/resourceExtensionTypes.js +1 -1
- package/legacy/resourceTypes.js +1 -1
- package/legacy/test-fixtures.js +1 -1
- package/legacy/utiltypes.js +1 -1
- package/lib/NetworkError.js +1 -1
- package/lib/OptionsToFunction.d.ts.map +1 -1
- package/lib/OptionsToFunction.js +1 -1
- package/lib/RestEndpoint.js +7 -2
- package/lib/RestEndpointTypeHelp.js +1 -1
- package/lib/RestEndpointTypes.d.ts +32 -8
- package/lib/RestEndpointTypes.d.ts.map +1 -1
- package/lib/RestEndpointTypes.js +1 -1
- package/lib/RestHelpers.js +1 -1
- package/lib/createResource.d.ts.map +1 -1
- package/lib/createResource.js +7 -8
- package/lib/extractCollection.js +1 -1
- package/lib/extractObject.js +1 -1
- package/lib/hookifyResource.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/mapCollection.d.ts.map +1 -1
- package/lib/mapCollection.js +1 -1
- package/lib/next/index.js +1 -1
- package/lib/paginatedCollections.js +1 -1
- package/lib/paramsToString.d.ts +1 -1
- package/lib/paramsToString.d.ts.map +1 -1
- package/lib/paramsToString.js +1 -1
- package/lib/paramsToString.native.d.ts +1 -1
- package/lib/paramsToString.native.d.ts.map +1 -1
- package/lib/paramsToString.native.js +1 -1
- package/lib/pathTypes.js +1 -1
- package/lib/resourceExtendable.js +1 -1
- package/lib/resourceExtensionTypes.js +1 -1
- package/lib/resourceTypes.d.ts +4 -8
- package/lib/resourceTypes.d.ts.map +1 -1
- package/lib/resourceTypes.js +1 -1
- package/lib/test-fixtures.js +1 -1
- package/lib/utiltypes.js +1 -1
- package/package.json +2 -2
- package/src/OptionsToFunction.ts +44 -42
- package/src/RestEndpoint.js +6 -1
- package/src/RestEndpointTypes.ts +128 -110
- package/src/__tests__/RestEndpoint.ts +54 -2
- package/src/__tests__/createResource.test.ts +42 -2
- package/src/createResource.ts +7 -12
- package/src/index.ts +1 -0
- package/src/mapCollection.ts +5 -4
- package/src/paramsToString.native.ts +6 -1
- package/src/paramsToString.ts +7 -2
- package/src/resourceTypes.ts +16 -15
- package/ts4.0/RestEndpointTypes.d.ts +38 -8
- package/ts4.0/index.d.ts +1 -0
- package/ts4.0/paramsToString.d.ts +1 -1
- package/ts4.0/paramsToString.native.d.ts +1 -1
- package/ts4.0/resourceTypes.d.ts +4 -8
- package/ts4.1/RestEndpointTypes.d.ts +38 -8
- package/ts4.1/index.d.ts +1 -0
- package/ts4.1/paramsToString.d.ts +1 -1
- package/ts4.1/paramsToString.native.d.ts +1 -1
- package/ts4.1/resourceTypes.d.ts +4 -8
|
@@ -24,24 +24,46 @@ export interface RestInstanceBase<F extends FetchFunction = FetchFunction, S ext
|
|
|
24
24
|
*/
|
|
25
25
|
readonly urlPrefix: string;
|
|
26
26
|
readonly requestInit: RequestInit;
|
|
27
|
-
/**
|
|
27
|
+
/** HTTP request method
|
|
28
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#method
|
|
29
|
+
*/
|
|
28
30
|
readonly method: (O & {
|
|
29
31
|
method: string;
|
|
30
32
|
})['method'];
|
|
31
33
|
readonly signal: AbortSignal | undefined;
|
|
34
|
+
/** @see https://dataclient.io/rest/api/RestEndpoint#paginationField */
|
|
32
35
|
readonly paginationField?: string;
|
|
36
|
+
/** Builds the URL to fetch
|
|
37
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#url
|
|
38
|
+
*/
|
|
33
39
|
url(...args: Parameters<F>): string;
|
|
34
|
-
/**
|
|
40
|
+
/** Encode the searchParams component of the url
|
|
41
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#searchToString
|
|
42
|
+
*/
|
|
43
|
+
searchToString(searchParams: Record<string, any>): string;
|
|
44
|
+
/** Prepares RequestInit used in fetch. This is sent to fetchResponse()
|
|
45
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#getRequestInit
|
|
46
|
+
*/
|
|
35
47
|
getRequestInit(this: any, body?: RequestInit['body'] | Record<string, unknown>): Promise<RequestInit> | RequestInit;
|
|
36
|
-
/**
|
|
48
|
+
/** Called by getRequestInit to determine HTTP Headers
|
|
49
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#getHeaders
|
|
50
|
+
*/
|
|
37
51
|
getHeaders(headers: HeadersInit): Promise<HeadersInit> | HeadersInit;
|
|
38
|
-
/**
|
|
52
|
+
/** Performs the fetch call
|
|
53
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#fetchResponse
|
|
54
|
+
*/
|
|
39
55
|
fetchResponse(input: RequestInfo, init: RequestInit): Promise<Response>;
|
|
40
|
-
/**
|
|
56
|
+
/** Takes the Response and parses via .text() or .json()
|
|
57
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#parseResponse
|
|
58
|
+
*/
|
|
41
59
|
parseResponse(response: Response): Promise<any>;
|
|
42
|
-
/**
|
|
60
|
+
/** Perform any transforms with the parsed result.
|
|
61
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#process
|
|
62
|
+
*/
|
|
43
63
|
process(value: any, ...args: Parameters<F>): ResolveType<F>;
|
|
44
|
-
/**
|
|
64
|
+
/** Returns true if the provided (fetch) key matches this endpoint.
|
|
65
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#testKey
|
|
66
|
+
*/
|
|
45
67
|
testKey(key: string): boolean;
|
|
46
68
|
/** Creates a child endpoint that inherits from this while overriding provided `options`.
|
|
47
69
|
* @see https://dataclient.io/rest/api/RestEndpoint#extend
|
|
@@ -221,7 +243,7 @@ export type RestType<UrlParams = any, Body = any, S extends Schema | undefined =
|
|
|
221
243
|
} = {
|
|
222
244
|
path: string;
|
|
223
245
|
paginationField: string;
|
|
224
|
-
}> = IfTypeScriptLooseNull<RestInstance<
|
|
246
|
+
}> = IfTypeScriptLooseNull<RestInstance<RestFetch<UrlParams, Body, R>, S, M, O>, Body extends {} ? RestTypeWithBody<UrlParams, S, M, Body, R, O> : RestTypeNoBody<UrlParams, S, M, R, O>>;
|
|
225
247
|
export type RestTypeWithBody<UrlParams = any, S extends Schema | undefined = Schema | undefined, M extends true | undefined = true | undefined, Body = any, R = any, O extends {
|
|
226
248
|
path: string;
|
|
227
249
|
body?: any;
|
|
@@ -242,6 +264,14 @@ export type RestTypeNoBody<UrlParams = any, S extends Schema | undefined = Schem
|
|
|
242
264
|
export type RestFetch<UrlParams, Body = {}, Resolve = any> = IfTypeScriptLooseNull<ParamFetchNoBody<UrlParams, Resolve> | ParamFetchWithBody<UrlParams, Body, Resolve>, Body extends {} ? ParamFetchWithBody<UrlParams, Body, Resolve> : ParamFetchNoBody<UrlParams, Resolve>>;
|
|
243
265
|
export type ParamFetchWithBody<P, B = {}, R = any> = P extends undefined ? (this: EndpointInstanceInterface, body: B) => Promise<R> : {} extends P ? keyof P extends never ? (this: EndpointInstanceInterface, body: B) => Promise<R> : ((this: EndpointInstanceInterface, params: P, body: B) => Promise<R>) | ((this: EndpointInstanceInterface, body: B) => Promise<R>) : (this: EndpointInstanceInterface, params: P, body: B) => Promise<R>;
|
|
244
266
|
export type ParamFetchNoBody<P, R = any> = P extends undefined ? (this: EndpointInstanceInterface) => Promise<R> : {} extends P ? keyof P extends never ? (this: EndpointInstanceInterface) => Promise<R> : ((this: EndpointInstanceInterface, params: P) => Promise<R>) | ((this: EndpointInstanceInterface) => Promise<R>) : (this: EndpointInstanceInterface, params: P) => Promise<R>;
|
|
267
|
+
export type ParamToArgs<P> = P extends undefined ? [
|
|
268
|
+
] : {} extends P ? keyof P extends never ? [
|
|
269
|
+
] : [
|
|
270
|
+
] | [
|
|
271
|
+
P
|
|
272
|
+
] : [
|
|
273
|
+
P
|
|
274
|
+
];
|
|
245
275
|
type IfTypeScriptLooseNull<Y, N> = 1 | undefined extends 1 ? Y : N;
|
|
246
276
|
export type KeyofRestEndpoint = keyof RestInstance;
|
|
247
277
|
export type FromFallBack<K extends keyof E, O, E> = K extends keyof O ? O[K] : E[K];
|
package/ts4.0/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as RestEndpoint } from './RestEndpoint.js';
|
|
2
2
|
export type { GetEndpoint, MutateEndpoint, Defaults, RestGenerics, FetchGet, FetchMutate, RestFetch, RestType, RestInstance, KeyofRestEndpoint, RestEndpointConstructorOptions, AddEndpoint, PaginationFieldEndpoint, PaginationEndpoint, } from './RestEndpoint.js';
|
|
3
|
+
export { getUrlBase, getUrlTokens } from './RestHelpers.js';
|
|
3
4
|
export { default as createResource } from './createResource.js';
|
|
4
5
|
export type { Resource } from './resourceTypes.js';
|
|
5
6
|
export type { ResourceOptions, ResourceGenerics } from './resourceTypes.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export default function paramsToString(searchParams
|
|
1
|
+
export default function paramsToString(searchParams?: string | URLSearchParams | Record<string, string> | string[][] | undefined): string;
|
|
2
2
|
//# sourceMappingURL=paramsToString.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export default function paramsToString(searchParams
|
|
1
|
+
export default function paramsToString(searchParams?: string | URLSearchParams | Record<string, string> | string[][] | undefined): string;
|
|
2
2
|
//# sourceMappingURL=paramsToString.native.d.ts.map
|
package/ts4.0/resourceTypes.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Collection, schema } from '@data-client/endpoint';
|
|
2
2
|
import type { Schema } from '@data-client/endpoint';
|
|
3
3
|
import type { Denormalize } from '@data-client/endpoint';
|
|
4
|
-
import type { PathArgs, ResourcePath, ShortenPath } from './pathTypes.js';
|
|
4
|
+
import type { KeysToArgs, PathArgs, ResourcePath, ShortenPath } from './pathTypes.js';
|
|
5
5
|
import { Extendable } from './resourceExtendable.js';
|
|
6
|
-
import RestEndpoint, { GetEndpoint, MutateEndpoint, RestInstanceBase, RestTypeNoBody } from './RestEndpoint.js';
|
|
6
|
+
import RestEndpoint, { GetEndpoint, MutateEndpoint, ParamToArgs, RestInstanceBase, RestTypeNoBody } from './RestEndpoint.js';
|
|
7
7
|
/** The typed (generic) options for a Resource */
|
|
8
8
|
export interface ResourceGenerics {
|
|
9
9
|
/** @see https://dataclient.io/rest/api/createResource#path */
|
|
@@ -68,18 +68,14 @@ export interface Resource<O extends ResourceGenerics = {
|
|
|
68
68
|
path: ShortenPath<O['path']>;
|
|
69
69
|
schema: schema.Collection<[
|
|
70
70
|
O['schema']
|
|
71
|
-
], [
|
|
72
|
-
'searchParams' extends keyof O ? O['searchParams'] extends undefined ? PathArgs<ShortenPath<O['path']>> : O['searchParams'] & PathArgs<ShortenPath<O['path']>> : PathArgs<ShortenPath<O['path']>>
|
|
73
|
-
]>;
|
|
71
|
+
], ParamToArgs<O['searchParams'] extends undefined ? KeysToArgs<ShortenPath<O['path']>> : O['searchParams'] & PathArgs<ShortenPath<O['path']>>>>;
|
|
74
72
|
body: 'body' extends keyof O ? O['body'] : Partial<Denormalize<O['schema']>>;
|
|
75
73
|
searchParams: O['searchParams'];
|
|
76
74
|
} & Pick<O, 'paginationField'>> : GetEndpoint<{
|
|
77
75
|
path: ShortenPath<O['path']>;
|
|
78
76
|
schema: schema.Collection<[
|
|
79
77
|
O['schema']
|
|
80
|
-
], [
|
|
81
|
-
'searchParams' extends keyof O ? O['searchParams'] extends undefined ? PathArgs<ShortenPath<O['path']>> : O['searchParams'] & PathArgs<ShortenPath<O['path']>> : PathArgs<ShortenPath<O['path']>>
|
|
82
|
-
]>;
|
|
78
|
+
], ParamToArgs<(Record<string, number | string | boolean> | undefined) & PathArgs<ShortenPath<O['path']>>>>;
|
|
83
79
|
body: 'body' extends keyof O ? O['body'] : Partial<Denormalize<O['schema']>>;
|
|
84
80
|
searchParams: Record<string, number | string | boolean> | undefined;
|
|
85
81
|
} & Pick<O, 'paginationField'>>;
|
|
@@ -24,24 +24,46 @@ export interface RestInstanceBase<F extends FetchFunction = FetchFunction, S ext
|
|
|
24
24
|
*/
|
|
25
25
|
readonly urlPrefix: string;
|
|
26
26
|
readonly requestInit: RequestInit;
|
|
27
|
-
/**
|
|
27
|
+
/** HTTP request method
|
|
28
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#method
|
|
29
|
+
*/
|
|
28
30
|
readonly method: (O & {
|
|
29
31
|
method: string;
|
|
30
32
|
})['method'];
|
|
31
33
|
readonly signal: AbortSignal | undefined;
|
|
34
|
+
/** @see https://dataclient.io/rest/api/RestEndpoint#paginationField */
|
|
32
35
|
readonly paginationField?: string;
|
|
36
|
+
/** Builds the URL to fetch
|
|
37
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#url
|
|
38
|
+
*/
|
|
33
39
|
url(...args: Parameters<F>): string;
|
|
34
|
-
/**
|
|
40
|
+
/** Encode the searchParams component of the url
|
|
41
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#searchToString
|
|
42
|
+
*/
|
|
43
|
+
searchToString(searchParams: Record<string, any>): string;
|
|
44
|
+
/** Prepares RequestInit used in fetch. This is sent to fetchResponse()
|
|
45
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#getRequestInit
|
|
46
|
+
*/
|
|
35
47
|
getRequestInit(this: any, body?: RequestInit['body'] | Record<string, unknown>): Promise<RequestInit> | RequestInit;
|
|
36
|
-
/**
|
|
48
|
+
/** Called by getRequestInit to determine HTTP Headers
|
|
49
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#getHeaders
|
|
50
|
+
*/
|
|
37
51
|
getHeaders(headers: HeadersInit): Promise<HeadersInit> | HeadersInit;
|
|
38
|
-
/**
|
|
52
|
+
/** Performs the fetch call
|
|
53
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#fetchResponse
|
|
54
|
+
*/
|
|
39
55
|
fetchResponse(input: RequestInfo, init: RequestInit): Promise<Response>;
|
|
40
|
-
/**
|
|
56
|
+
/** Takes the Response and parses via .text() or .json()
|
|
57
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#parseResponse
|
|
58
|
+
*/
|
|
41
59
|
parseResponse(response: Response): Promise<any>;
|
|
42
|
-
/**
|
|
60
|
+
/** Perform any transforms with the parsed result.
|
|
61
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#process
|
|
62
|
+
*/
|
|
43
63
|
process(value: any, ...args: Parameters<F>): ResolveType<F>;
|
|
44
|
-
/**
|
|
64
|
+
/** Returns true if the provided (fetch) key matches this endpoint.
|
|
65
|
+
* @see https://dataclient.io/rest/api/RestEndpoint#testKey
|
|
66
|
+
*/
|
|
45
67
|
testKey(key: string): boolean;
|
|
46
68
|
/** Creates a child endpoint that inherits from this while overriding provided `options`.
|
|
47
69
|
* @see https://dataclient.io/rest/api/RestEndpoint#extend
|
|
@@ -221,7 +243,7 @@ export type RestType<UrlParams = any, Body = any, S extends Schema | undefined =
|
|
|
221
243
|
} = {
|
|
222
244
|
path: string;
|
|
223
245
|
paginationField: string;
|
|
224
|
-
}> = IfTypeScriptLooseNull<RestInstance<
|
|
246
|
+
}> = IfTypeScriptLooseNull<RestInstance<RestFetch<UrlParams, Body, R>, S, M, O>, Body extends {} ? RestTypeWithBody<UrlParams, S, M, Body, R, O> : RestTypeNoBody<UrlParams, S, M, R, O>>;
|
|
225
247
|
export type RestTypeWithBody<UrlParams = any, S extends Schema | undefined = Schema | undefined, M extends true | undefined = true | undefined, Body = any, R = any, O extends {
|
|
226
248
|
path: string;
|
|
227
249
|
body?: any;
|
|
@@ -242,6 +264,14 @@ export type RestTypeNoBody<UrlParams = any, S extends Schema | undefined = Schem
|
|
|
242
264
|
export type RestFetch<UrlParams, Body = {}, Resolve = any> = IfTypeScriptLooseNull<ParamFetchNoBody<UrlParams, Resolve> | ParamFetchWithBody<UrlParams, Body, Resolve>, Body extends {} ? ParamFetchWithBody<UrlParams, Body, Resolve> : ParamFetchNoBody<UrlParams, Resolve>>;
|
|
243
265
|
export type ParamFetchWithBody<P, B = {}, R = any> = P extends undefined ? (this: EndpointInstanceInterface, body: B) => Promise<R> : {} extends P ? keyof P extends never ? (this: EndpointInstanceInterface, body: B) => Promise<R> : ((this: EndpointInstanceInterface, params: P, body: B) => Promise<R>) | ((this: EndpointInstanceInterface, body: B) => Promise<R>) : (this: EndpointInstanceInterface, params: P, body: B) => Promise<R>;
|
|
244
266
|
export type ParamFetchNoBody<P, R = any> = P extends undefined ? (this: EndpointInstanceInterface) => Promise<R> : {} extends P ? keyof P extends never ? (this: EndpointInstanceInterface) => Promise<R> : ((this: EndpointInstanceInterface, params: P) => Promise<R>) | ((this: EndpointInstanceInterface) => Promise<R>) : (this: EndpointInstanceInterface, params: P) => Promise<R>;
|
|
267
|
+
export type ParamToArgs<P> = P extends undefined ? [
|
|
268
|
+
] : {} extends P ? keyof P extends never ? [
|
|
269
|
+
] : [
|
|
270
|
+
] | [
|
|
271
|
+
P
|
|
272
|
+
] : [
|
|
273
|
+
P
|
|
274
|
+
];
|
|
245
275
|
type IfTypeScriptLooseNull<Y, N> = 1 | undefined extends 1 ? Y : N;
|
|
246
276
|
export type KeyofRestEndpoint = keyof RestInstance;
|
|
247
277
|
export type FromFallBack<K extends keyof E, O, E> = K extends keyof O ? O[K] : E[K];
|
package/ts4.1/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as RestEndpoint } from './RestEndpoint.js';
|
|
2
2
|
export type { GetEndpoint, MutateEndpoint, Defaults, RestGenerics, FetchGet, FetchMutate, RestFetch, RestType, RestInstance, KeyofRestEndpoint, RestEndpointConstructorOptions, AddEndpoint, PaginationFieldEndpoint, PaginationEndpoint, } from './RestEndpoint.js';
|
|
3
|
+
export { getUrlBase, getUrlTokens } from './RestHelpers.js';
|
|
3
4
|
export { default as createResource } from './createResource.js';
|
|
4
5
|
export type { Resource } from './resourceTypes.js';
|
|
5
6
|
export type { ResourceOptions, ResourceGenerics } from './resourceTypes.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export default function paramsToString(searchParams
|
|
1
|
+
export default function paramsToString(searchParams?: string | URLSearchParams | Record<string, string> | string[][] | undefined): string;
|
|
2
2
|
//# sourceMappingURL=paramsToString.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export default function paramsToString(searchParams
|
|
1
|
+
export default function paramsToString(searchParams?: string | URLSearchParams | Record<string, string> | string[][] | undefined): string;
|
|
2
2
|
//# sourceMappingURL=paramsToString.native.d.ts.map
|
package/ts4.1/resourceTypes.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Collection, schema } from '@data-client/endpoint';
|
|
2
2
|
import type { Schema } from '@data-client/endpoint';
|
|
3
3
|
import type { Denormalize } from '@data-client/endpoint';
|
|
4
|
-
import type { PathArgs, ResourcePath, ShortenPath } from './pathTypes.js';
|
|
4
|
+
import type { KeysToArgs, PathArgs, ResourcePath, ShortenPath } from './pathTypes.js';
|
|
5
5
|
import { Extendable } from './resourceExtendable.js';
|
|
6
|
-
import RestEndpoint, { GetEndpoint, MutateEndpoint, RestInstanceBase, RestTypeNoBody } from './RestEndpoint.js';
|
|
6
|
+
import RestEndpoint, { GetEndpoint, MutateEndpoint, ParamToArgs, RestInstanceBase, RestTypeNoBody } from './RestEndpoint.js';
|
|
7
7
|
/** The typed (generic) options for a Resource */
|
|
8
8
|
export interface ResourceGenerics {
|
|
9
9
|
/** @see https://dataclient.io/rest/api/createResource#path */
|
|
@@ -68,18 +68,14 @@ export interface Resource<O extends ResourceGenerics = {
|
|
|
68
68
|
path: ShortenPath<O['path']>;
|
|
69
69
|
schema: schema.Collection<[
|
|
70
70
|
O['schema']
|
|
71
|
-
], [
|
|
72
|
-
'searchParams' extends keyof O ? O['searchParams'] extends undefined ? PathArgs<ShortenPath<O['path']>> : O['searchParams'] & PathArgs<ShortenPath<O['path']>> : PathArgs<ShortenPath<O['path']>>
|
|
73
|
-
]>;
|
|
71
|
+
], ParamToArgs<O['searchParams'] extends undefined ? KeysToArgs<ShortenPath<O['path']>> : O['searchParams'] & PathArgs<ShortenPath<O['path']>>>>;
|
|
74
72
|
body: 'body' extends keyof O ? O['body'] : Partial<Denormalize<O['schema']>>;
|
|
75
73
|
searchParams: O['searchParams'];
|
|
76
74
|
} & Pick<O, 'paginationField'>> : GetEndpoint<{
|
|
77
75
|
path: ShortenPath<O['path']>;
|
|
78
76
|
schema: schema.Collection<[
|
|
79
77
|
O['schema']
|
|
80
|
-
], [
|
|
81
|
-
'searchParams' extends keyof O ? O['searchParams'] extends undefined ? PathArgs<ShortenPath<O['path']>> : O['searchParams'] & PathArgs<ShortenPath<O['path']>> : PathArgs<ShortenPath<O['path']>>
|
|
82
|
-
]>;
|
|
78
|
+
], ParamToArgs<(Record<string, number | string | boolean> | undefined) & PathArgs<ShortenPath<O['path']>>>>;
|
|
83
79
|
body: 'body' extends keyof O ? O['body'] : Partial<Denormalize<O['schema']>>;
|
|
84
80
|
searchParams: Record<string, number | string | boolean> | undefined;
|
|
85
81
|
} & Pick<O, 'paginationField'>>;
|