@hyper-fetch/core 7.1.2 → 7.2.1
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 +30 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/index.d.ts +6 -2
- package/dist/index.js +31 -1
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/src/adapter/adapter.types.ts +2 -0
- package/src/client/client.create.ts +3 -1
- package/src/index.ts +1 -0
- package/src/request/request.ts +1 -1
- package/src/request/request.utils.ts +4 -6
- package/src/sdk/index.ts +1 -0
- package/src/sdk/sdk.ts +44 -0
package/dist/index.d.ts
CHANGED
|
@@ -1235,7 +1235,7 @@ declare const getSimpleKey: (request: RequestInstance | RequestJSON<RequestInsta
|
|
|
1235
1235
|
*/
|
|
1236
1236
|
declare const getRequestKey: (request: RequestInstance | RequestJSON<RequestInstance>, useInitialValues?: boolean) => string;
|
|
1237
1237
|
declare const getRequestDispatcher: <Request extends RequestInstance>(request: Request, dispatcherType?: "auto" | "fetch" | "submit") => [Dispatcher<ExtractAdapterType<Request>>, isFetchDispatcher: boolean];
|
|
1238
|
-
declare const sendRequest: <Request extends RequestInstance>(request: Request, options?: RequestSendOptionsType<Request>) => Promise<
|
|
1238
|
+
declare const sendRequest: <Request extends RequestInstance>(request: Request, options?: RequestSendOptionsType<Request>) => Promise<RequestResponseType<Request>>;
|
|
1239
1239
|
|
|
1240
1240
|
declare const getUniqueRequestId: (request: Pick<RequestInstance, "queryKey">) => string;
|
|
1241
1241
|
|
|
@@ -2052,6 +2052,10 @@ type PluginMethods<Client extends ClientInstance> = {
|
|
|
2052
2052
|
};
|
|
2053
2053
|
type PluginMethodParameters<Key extends keyof PluginMethods<Client>, Client extends ClientInstance> = Parameters<NonNullable<PluginMethods<Client>[Key]>>[0];
|
|
2054
2054
|
|
|
2055
|
+
type RecursiveSchemaType = Record<string, // for example users / $userId / posts / $postId
|
|
2056
|
+
any>;
|
|
2057
|
+
declare const createSdk: <Client extends ClientInstance, RecursiveSchema extends RecursiveSchemaType>(client: Client) => RecursiveSchema;
|
|
2058
|
+
|
|
2055
2059
|
declare enum Time {
|
|
2056
2060
|
SEC = 1000,
|
|
2057
2061
|
MIN = 60000,
|
|
@@ -2072,4 +2076,4 @@ declare enum HttpMethods {
|
|
|
2072
2076
|
DELETE = "DELETE"
|
|
2073
2077
|
}
|
|
2074
2078
|
|
|
2075
|
-
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 };
|
|
2079
|
+
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, type RecursiveSchemaType, 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, createSdk, 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
|
@@ -106,6 +106,7 @@ __export(src_exports, {
|
|
|
106
106
|
appManagerInitialOptions: () => appManagerInitialOptions,
|
|
107
107
|
canRetryRequest: () => canRetryRequest,
|
|
108
108
|
createClient: () => createClient,
|
|
109
|
+
createSdk: () => createSdk,
|
|
109
110
|
defaultMapper: () => defaultMapper,
|
|
110
111
|
defaultTimeout: () => defaultTimeout,
|
|
111
112
|
getAbortByAbortKey: () => getAbortByAbortKey,
|
|
@@ -499,7 +500,7 @@ var _Request = class _Request {
|
|
|
499
500
|
let stringEndpoint = String(endpoint);
|
|
500
501
|
if (params) {
|
|
501
502
|
Object.entries(params).forEach(([key, value]) => {
|
|
502
|
-
stringEndpoint =
|
|
503
|
+
stringEndpoint = stringEndpoint.replace(new RegExp(`:${key}`, "g"), String(value));
|
|
503
504
|
});
|
|
504
505
|
}
|
|
505
506
|
return stringEndpoint;
|
|
@@ -3842,6 +3843,34 @@ function createClient(options) {
|
|
|
3842
3843
|
options
|
|
3843
3844
|
);
|
|
3844
3845
|
}
|
|
3846
|
+
|
|
3847
|
+
// src/sdk/sdk.ts
|
|
3848
|
+
var createRecursiveProxy = (client, path) => {
|
|
3849
|
+
return new Proxy(() => {
|
|
3850
|
+
}, {
|
|
3851
|
+
get: (_target, key) => {
|
|
3852
|
+
if (typeof key === "symbol" || key === "inspect") {
|
|
3853
|
+
return void 0;
|
|
3854
|
+
}
|
|
3855
|
+
const endpoint = `/${path.join("/")}`;
|
|
3856
|
+
const method = key.toUpperCase();
|
|
3857
|
+
const request = client.createRequest()({ endpoint, method });
|
|
3858
|
+
const newPath = [...path, key.startsWith("$") ? `:${key.slice(1)}` : key];
|
|
3859
|
+
const deeperProxy = createRecursiveProxy(client, newPath);
|
|
3860
|
+
return new Proxy(request, {
|
|
3861
|
+
get: (reqTarget, reqKey) => {
|
|
3862
|
+
if (reqKey in reqTarget) {
|
|
3863
|
+
return reqTarget[reqKey];
|
|
3864
|
+
}
|
|
3865
|
+
return deeperProxy[reqKey];
|
|
3866
|
+
}
|
|
3867
|
+
});
|
|
3868
|
+
}
|
|
3869
|
+
});
|
|
3870
|
+
};
|
|
3871
|
+
var createSdk = (client) => {
|
|
3872
|
+
return createRecursiveProxy(client, []);
|
|
3873
|
+
};
|
|
3845
3874
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3846
3875
|
0 && (module.exports = {
|
|
3847
3876
|
AbortError,
|
|
@@ -3867,6 +3896,7 @@ function createClient(options) {
|
|
|
3867
3896
|
appManagerInitialOptions,
|
|
3868
3897
|
canRetryRequest,
|
|
3869
3898
|
createClient,
|
|
3899
|
+
createSdk,
|
|
3870
3900
|
defaultMapper,
|
|
3871
3901
|
defaultTimeout,
|
|
3872
3902
|
getAbortByAbortKey,
|