@hyper-fetch/core 7.0.1 → 7.0.2
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/dist/browser/index.js +3 -0
- package/dist/browser/index.js.map +2 -2
- package/dist/index.d.ts +14 -13
- package/dist/index.js +3 -0
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/src/client/client.ts +5 -10
- package/src/request/request.ts +10 -6
- package/src/request/request.types.ts +2 -2
- package/src/types/helpers.types.ts +6 -1
- package/src/types/request.types.ts +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ type NonNullableKeys<T> = {
|
|
|
14
14
|
type RequiredKeys<T> = {
|
|
15
15
|
[P in keyof T]-?: Exclude<T[P], EmptyTypes>;
|
|
16
16
|
};
|
|
17
|
-
type TypeWithDefaults<Types extends Record<string, any>, Key extends keyof Types, Value> = Key extends keyof Types ? Exclude<Types[Key],
|
|
17
|
+
type TypeWithDefaults<Types extends Record<string, any>, Key extends keyof Types, Value, ExcludedTypes = void | never> = Key extends keyof Types ? Exclude<Types[Key], ExcludedTypes> extends never ? Value : Exclude<Types[Key], ExcludedTypes> : Value;
|
|
18
18
|
type SyncOrAsync<T> = T | Promise<T>;
|
|
19
19
|
|
|
20
20
|
type HttpMethodsType = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
@@ -51,7 +51,7 @@ type ExtractQueryParamsType<T> = T extends Request<any, any, infer Q, any, any,
|
|
|
51
51
|
type ExtractErrorType<T> = T extends Request<any, any, any, infer G, any, infer C, any, any, any> ? G | ExtractClientGlobalError<C> : never;
|
|
52
52
|
type ExtractGlobalErrorType<T> = T extends Request<any, any, any, any, any, infer C, any, any, any> ? ExtractClientGlobalError<C> : never;
|
|
53
53
|
type ExtractLocalErrorType<T> = T extends Request<any, any, any, infer E, any, any, any, any, any> ? E : never;
|
|
54
|
-
type ExtractParamsType<T> = T extends Request<any, any, any, any, infer E, any, any, any, any> ? E extends string ?
|
|
54
|
+
type ExtractParamsType<T> = T extends Request<any, any, any, any, infer E, any, any, any, any> ? E extends string ? ExtractUrlParams<E> : never : never;
|
|
55
55
|
type ExtractEndpointType<T> = T extends Request<any, any, any, any, infer E, any, any, any, any> ? E : never;
|
|
56
56
|
type ExtractClientType<T> = T extends Request<any, any, any, any, any, infer C, any, any, any> ? C : never;
|
|
57
57
|
type ExtractAdapterType<T> = T extends Request<any, any, any, any, any, infer C, any, any, any> ? ExtractClientAdapterType<C> : never;
|
|
@@ -615,12 +615,12 @@ type MockResponseType<Response, Error, AdapterType extends AdapterInstance> = Pa
|
|
|
615
615
|
declare class Request<Response, Payload, QueryParams, LocalError, Endpoint extends string, Client extends ClientInstance, HasPayload extends true | false = false, HasParams extends true | false = false, HasQuery extends true | false = false> {
|
|
616
616
|
readonly client: Client;
|
|
617
617
|
readonly requestOptions: RequestOptionsType<Endpoint, ExtractAdapterOptionsType<ExtractClientAdapterType<Client>>, ExtractAdapterMethodType<ExtractClientAdapterType<Client>>>;
|
|
618
|
-
readonly initialRequestConfiguration?: RequestConfigurationType<Payload, Endpoint extends string ?
|
|
618
|
+
readonly initialRequestConfiguration?: RequestConfigurationType<Payload, Endpoint extends string ? ExtractUrlParams<Endpoint> : never, QueryParams, Endpoint, ExtractAdapterOptionsType<ExtractClientAdapterType<Client>>, ExtractAdapterMethodType<ExtractClientAdapterType<Client>>> | undefined;
|
|
619
619
|
endpoint: Endpoint;
|
|
620
620
|
headers?: HeadersInit;
|
|
621
621
|
auth: boolean;
|
|
622
622
|
method: ExtractAdapterMethodType<ExtractClientAdapterType<Client>>;
|
|
623
|
-
params:
|
|
623
|
+
params: ExtractUrlParams<Endpoint> | EmptyTypes;
|
|
624
624
|
payload: PayloadType<Payload>;
|
|
625
625
|
queryParams: QueryParams | EmptyTypes;
|
|
626
626
|
options?: ExtractAdapterOptionsType<ExtractClientAdapterType<Client>> | undefined;
|
|
@@ -652,10 +652,13 @@ declare class Request<Response, Payload, QueryParams, LocalError, Endpoint exten
|
|
|
652
652
|
unstable_requestMapper?: RequestMapper<any, any>;
|
|
653
653
|
/** @internal */
|
|
654
654
|
unstable_responseMapper?: ResponseMapper<this, ResponseSuccessType<any, any> | ResponseErrorType<any, any>>;
|
|
655
|
+
unstable_hasParams: HasParams;
|
|
656
|
+
unstable_hasPayload: HasPayload;
|
|
657
|
+
unstable_hasQuery: HasQuery;
|
|
655
658
|
private updatedAbortKey;
|
|
656
659
|
private updatedCacheKey;
|
|
657
660
|
private updatedQueryKey;
|
|
658
|
-
constructor(client: Client, requestOptions: RequestOptionsType<Endpoint, ExtractAdapterOptionsType<ExtractClientAdapterType<Client>>, ExtractAdapterMethodType<ExtractClientAdapterType<Client>>>, initialRequestConfiguration?: RequestConfigurationType<Payload, Endpoint extends string ?
|
|
661
|
+
constructor(client: Client, requestOptions: RequestOptionsType<Endpoint, ExtractAdapterOptionsType<ExtractClientAdapterType<Client>>, ExtractAdapterMethodType<ExtractClientAdapterType<Client>>>, initialRequestConfiguration?: RequestConfigurationType<Payload, Endpoint extends string ? ExtractUrlParams<Endpoint> : never, QueryParams, Endpoint, ExtractAdapterOptionsType<ExtractClientAdapterType<Client>>, ExtractAdapterMethodType<ExtractClientAdapterType<Client>>> | undefined);
|
|
659
662
|
setHeaders: (headers: HeadersInit) => Request<Response, Payload, QueryParams, LocalError, Endpoint, Client, HasPayload, HasParams, HasQuery>;
|
|
660
663
|
setAuth: (auth: boolean) => Request<Response, Payload, QueryParams, LocalError, Endpoint, Client, HasPayload, HasParams, HasQuery>;
|
|
661
664
|
setParams: <P extends ExtractParamsType<this>>(params: P) => Request<Response, Payload, QueryParams, LocalError, Endpoint, Client, HasPayload, P extends null ? false : true, HasQuery>;
|
|
@@ -899,8 +902,8 @@ type RequestConfigurationType<Payload, Params, QueryParams, GenericEndpoint exte
|
|
|
899
902
|
} & Partial<NullableKeys<RequestOptionsType<GenericEndpoint, AdapterOptions, MethodsType>>>;
|
|
900
903
|
type ParamType = string | number;
|
|
901
904
|
type ParamsType = Record<string, ParamType>;
|
|
902
|
-
type
|
|
903
|
-
[k in Param | keyof
|
|
905
|
+
type ExtractUrlParams<T extends string> = string extends T ? EmptyTypes : T extends `${string}:${infer Param}/${infer Rest}` ? {
|
|
906
|
+
[k in Param | keyof ExtractUrlParams<Rest>]: ParamType;
|
|
904
907
|
} : T extends `${string}:${infer Param}` ? {
|
|
905
908
|
[k in Param]: ParamType;
|
|
906
909
|
} : EmptyTypes;
|
|
@@ -1775,16 +1778,14 @@ declare class Client$1<GlobalErrorType extends ClientErrorType = Error, Adapter
|
|
|
1775
1778
|
*
|
|
1776
1779
|
* @template Response Your response
|
|
1777
1780
|
*/
|
|
1778
|
-
createRequest: <RequestProperties extends RequestGenericType<ExtractAdapterQueryParamsType<Adapter>> = {
|
|
1779
|
-
error?: Error;
|
|
1780
|
-
}>(_USE_DOUBLE_INITIALIZATION?: never) => <EndpointType extends ExtractAdapterEndpointType<Adapter>, AdapterOptions extends ExtractAdapterOptionsType<Adapter>, MethodType extends ExtractAdapterMethodType<Adapter>>(params: RequestOptionsType<EndpointType, AdapterOptions, MethodType>) => Request<TypeWithDefaults<RequestProperties, "response", undefined>, TypeWithDefaults<RequestProperties, "payload", undefined>, TypeWithDefaults<RequestProperties, "queryParams", ExtractAdapterDefaultQueryParamsType<Adapter>>, TypeWithDefaults<RequestProperties, "error", GlobalErrorType>, TypeWithDefaults<RequestProperties, "endpoint", EndpointType> extends string ? TypeWithDefaults<RequestProperties, "endpoint", EndpointType> : any, Client$1<GlobalErrorType, ExtractUnionAdapter<Adapter, {
|
|
1781
|
+
createRequest: <RequestProperties extends RequestGenericType<ExtractAdapterQueryParamsType<Adapter>> = {}>(_USE_DOUBLE_INITIALIZATION?: never) => <EndpointType extends ExtractAdapterEndpointType<Adapter>, AdapterOptions extends ExtractAdapterOptionsType<Adapter>, MethodType extends ExtractAdapterMethodType<Adapter>>(params: RequestOptionsType<EndpointType, AdapterOptions, MethodType>) => Request<TypeWithDefaults<RequestProperties, "response", undefined>, TypeWithDefaults<RequestProperties, "payload", undefined>, TypeWithDefaults<RequestProperties, "queryParams", ExtractAdapterDefaultQueryParamsType<Adapter>, never>, TypeWithDefaults<RequestProperties, "error", GlobalErrorType>, TypeWithDefaults<RequestProperties, "endpoint", EndpointType> extends string ? TypeWithDefaults<RequestProperties, "endpoint", EndpointType> : any, Client$1<GlobalErrorType, ExtractUnionAdapter<Adapter, {
|
|
1781
1782
|
method: MethodType;
|
|
1782
1783
|
options: AdapterOptions;
|
|
1783
|
-
queryParams: TypeWithDefaults<RequestProperties, "queryParams", ExtractAdapterDefaultQueryParamsType<Adapter
|
|
1784
|
+
queryParams: TypeWithDefaults<RequestProperties, "queryParams", ExtractAdapterDefaultQueryParamsType<Adapter>, never>;
|
|
1784
1785
|
}> extends EmptyTypes ? Adapter : ExtractUnionAdapter<Adapter, {
|
|
1785
1786
|
method: MethodType;
|
|
1786
1787
|
options: AdapterOptions;
|
|
1787
|
-
queryParams: TypeWithDefaults<RequestProperties, "queryParams", ExtractAdapterDefaultQueryParamsType<Adapter
|
|
1788
|
+
queryParams: TypeWithDefaults<RequestProperties, "queryParams", ExtractAdapterDefaultQueryParamsType<Adapter>, never>;
|
|
1788
1789
|
}>>, false, false, false>;
|
|
1789
1790
|
}
|
|
1790
1791
|
|
|
@@ -2046,4 +2047,4 @@ declare enum HttpMethods {
|
|
|
2046
2047
|
DELETE = "DELETE"
|
|
2047
2048
|
}
|
|
2048
2049
|
|
|
2049
|
-
export { AbortError, Adapter, type AdapterFetcherType, type AdapterGenericType, type AdapterInstance, type AdapterPayloadMappingType, AppEvents, AppManager, type AppManagerOptionsType, type BufferEncoding, Cache, type CacheAsyncStorageType, type CacheInitialData, type CacheOptionsType, type CacheSetState, type CacheStorageType, type CacheValueType, Client$1 as Client, type ClientErrorType, type ClientGenericType, type ClientInstance, type ClientInstanceProperties, type ClientOptionsType, type DeclareAdapterType, type DefaultEndpointMapper, type DefaultHeaderMapper, type DefaultMapperType, type DefaultPayloadMapper, type DefaultQueryParamsMapper, DeletedError, Dispatcher, DispatcherMode, type DispatcherOptionsType, type DispatcherStorageType, type EmptyTypes, type EndpointMapper, EventEmitter, type ExtendRequest, type ExtractAdapterDefaultQueryParamsType, type ExtractAdapterEndpointMapperType, type ExtractAdapterEndpointType, type ExtractAdapterExtraType, type ExtractAdapterHeaderMapperType, type ExtractAdapterMethodType, type ExtractAdapterOptionsType, type ExtractAdapterPayloadMapperType, type ExtractAdapterQueryParamsMapperType, type ExtractAdapterQueryParamsType, type ExtractAdapterResolvedType, type ExtractAdapterStatusType, type ExtractAdapterType, type ExtractClientAdapterType, type ExtractClientGlobalError, type ExtractClientType, type ExtractEndpointType, type ExtractErrorType, type ExtractGlobalErrorType, type ExtractHasParamsType, type ExtractHasPayloadType, type ExtractHasQueryParamsType, type ExtractLocalErrorType, type ExtractParamsType, type ExtractPayloadType, type ExtractQueryParamsType, type ExtractResponseType, type
|
|
2050
|
+
export { AbortError, Adapter, type AdapterFetcherType, type AdapterGenericType, type AdapterInstance, type AdapterPayloadMappingType, AppEvents, AppManager, type AppManagerOptionsType, type BufferEncoding, Cache, type CacheAsyncStorageType, type CacheInitialData, type CacheOptionsType, type CacheSetState, type CacheStorageType, type CacheValueType, Client$1 as Client, type ClientErrorType, type ClientGenericType, type ClientInstance, type ClientInstanceProperties, type ClientOptionsType, type DeclareAdapterType, type DefaultEndpointMapper, type DefaultHeaderMapper, type DefaultMapperType, type DefaultPayloadMapper, type DefaultQueryParamsMapper, DeletedError, Dispatcher, DispatcherMode, type DispatcherOptionsType, type DispatcherStorageType, type EmptyTypes, type EndpointMapper, EventEmitter, type ExtendRequest, type ExtractAdapterDefaultQueryParamsType, type ExtractAdapterEndpointMapperType, type ExtractAdapterEndpointType, type ExtractAdapterExtraType, type ExtractAdapterHeaderMapperType, type ExtractAdapterMethodType, type ExtractAdapterOptionsType, type ExtractAdapterPayloadMapperType, type ExtractAdapterQueryParamsMapperType, type ExtractAdapterQueryParamsType, type ExtractAdapterResolvedType, type ExtractAdapterStatusType, type ExtractAdapterType, type ExtractClientAdapterType, type ExtractClientGlobalError, type ExtractClientType, type ExtractEndpointType, type ExtractErrorType, type ExtractGlobalErrorType, type ExtractHasParamsType, type ExtractHasPayloadType, type ExtractHasQueryParamsType, type ExtractLocalErrorType, type ExtractParamsType, type ExtractPayloadType, type ExtractQueryParamsType, type ExtractResponseType, type ExtractUnionAdapter, type ExtractUrlParams, type FetchParamsType, type FetchPayloadType, type FetchQueryParamsType, type HeaderMappingType, HttpAdapter, type HttpAdapterExtraType, type HttpAdapterHeadersProps, type HttpAdapterOptionsType, type HttpAdapterRequest, type HttpAdapterType, HttpMethods, type HttpMethodsType, type HttpStatusType, type HydrateDataType, type HydrationOptions, type LogData, type LogDataTypes, type LogLevel, type LogRequestEventType, type LogResponseEventType, type LogSystemEventType, type LoggerArgs, LoggerManager, type LoggerMethods, type LoggerOptionsType, type LoggerType, type MockResponseType, type MockerConfigType, type ModifyQueryParamsCallbackType, type NonNullableKeys, type NullableKeys, type NullableType, type ParamType, type ParamsType, type PayloadMapperType, type PayloadType, Plugin, type PluginInstance, type PluginLifecycle, type PluginMethodParameters, type PluginMethods, type PluginOptionsType, type PluginRequest, type Prettify, type ProgressDataType, type ProgressEventType, type ProgressType, type QueryParamType, type QueryParamValuesType, type QueryParamsMapper, type QueryParamsType, type QueryStringifyOptionsType, type QueueDataType, type QueueItemType, Request, type RequestCacheType, type RequestConfigurationType, type RequestDeduplicatedEventType, type RequestDynamicSendOptionsType, type RequestEventType, type RequestGenericType, type RequestInstance, type RequestInstanceProperties, type RequestInterceptorType, type RequestJSON, type RequestLoadingEventType, RequestManager, type RequestMapper, type RequestOptionsType, RequestProcessingError, type RequestProgressEventType, type RequestRemovedEventType, type RequestResponseEventType, type RequestResponseType, type RequestSendActionsType, type RequestSendOptionsType, type RequestSendType, type RequiredKeys, type ResponseDetailsType, type ResponseErrorType, type ResponseInterceptorType, type ResponseMapper, type ResponseSuccessType, type ResponseType, type RunningRequestValueType, type SyncOrAsync, Time, TimeoutError, type TypeWithDefaults, UnexpectedError, appManagerInitialOptions, canRetryRequest, createClient, defaultMapper, defaultTimeout, getAbortByAbortKey, getAbortByIdKey, getAbortKey, getAdapterBindings, getAdapterHeaders, getAdapterOnError, getAdapterPayload, getAppManagerEvents, getCacheByKey, getCacheData, getCacheEvents, getCacheKey, getDeleteByKey, getDeleteKey, getDispatcherChangeByKey, getDispatcherChangeKey, getDispatcherDrainedByKey, getDispatcherDrainedKey, getDispatcherEvents, getDispatcherStatusByKey, getDispatcherStatusKey, getDownloadProgressByIdKey, getDownloadProgressByQueryKey, getDownloadProgressKey, getErrorMessage, getInvalidateByKey, getInvalidateKey, getIsEqualTimestamp, getLoadingByCacheKey, getLoadingByIdKey, getLoadingByQueryKey, getLoadingKey, getProgressData, getProgressValue, getRemoveByIdKey, getRemoveByQueryKey, getRemoveKey, getRequestDeduplicatedByCacheKey, getRequestDeduplicatedByIdKey, getRequestDeduplicatedByQueryKey, getRequestDeduplicatedKey, getRequestDispatcher, getRequestEta, getRequestKey, getRequestManagerEvents, getRequestStarByQueryKey, getRequestStartByIdKey, getRequestStartKey, getRequestType, getResponseByCacheKey, getResponseByIdKey, getResponseHeaders, getResponseKey, getResponseStartByIdKey, getResponseStartByQueryKey, getResponseStartKey, getSimpleKey, getTime, getUniqueRequestId, getUploadProgressByIdKey, getUploadProgressByQueryKey, getUploadProgressKey, handleResponse, hasDocument, hasWindow, interceptRequest, interceptResponse, logLevelOrder, logger, loggerColors, loggerStyles, mocker, onDocumentEvent, onWindowEvent, parseErrorResponse, parseResponse, sendRequest, stringifyDefaultOptions, stringifyKey, stringifyQueryParams, stringifyValue, xhrExtra };
|
package/dist/index.js
CHANGED
|
@@ -379,6 +379,9 @@ var _Request = class _Request {
|
|
|
379
379
|
__publicField(this, "unstable_requestMapper");
|
|
380
380
|
/** @internal */
|
|
381
381
|
__publicField(this, "unstable_responseMapper");
|
|
382
|
+
__publicField(this, "unstable_hasParams", false);
|
|
383
|
+
__publicField(this, "unstable_hasPayload", false);
|
|
384
|
+
__publicField(this, "unstable_hasQuery", false);
|
|
382
385
|
__publicField(this, "updatedAbortKey");
|
|
383
386
|
__publicField(this, "updatedCacheKey");
|
|
384
387
|
__publicField(this, "updatedQueryKey");
|