@spoosh/core 0.14.1 → 0.15.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/dist/index.d.mts +60 -25
- package/dist/index.d.ts +60 -25
- package/dist/index.js +193 -159
- package/dist/index.mjs +193 -159
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -215,7 +215,6 @@ type CacheEntryWithKey<TData = unknown, TError = unknown> = {
|
|
|
215
215
|
key: string;
|
|
216
216
|
entry: CacheEntry<TData, TError>;
|
|
217
217
|
};
|
|
218
|
-
declare function createInitialState<TData, TError>(): OperationState<TData, TError>;
|
|
219
218
|
type StateManager = {
|
|
220
219
|
createQueryKey: (params: {
|
|
221
220
|
path: string;
|
|
@@ -249,8 +248,11 @@ type StateManager = {
|
|
|
249
248
|
onDataChange: (callback: DataChangeCallback) => () => void;
|
|
250
249
|
clear: () => void;
|
|
251
250
|
};
|
|
251
|
+
|
|
252
252
|
declare function createStateManager(): StateManager;
|
|
253
253
|
|
|
254
|
+
declare function createInitialState<TData, TError>(): OperationState<TData, TError>;
|
|
255
|
+
|
|
254
256
|
/**
|
|
255
257
|
* Devtool-related types for tracing and debugging.
|
|
256
258
|
* These types are used by the devtool plugin and plugins that emit trace events.
|
|
@@ -435,7 +437,7 @@ interface EventTracer {
|
|
|
435
437
|
emit(msg: string, options?: EventOptions): void;
|
|
436
438
|
}
|
|
437
439
|
|
|
438
|
-
type OperationType = "read" | "write" | "
|
|
440
|
+
type OperationType = "read" | "write" | "pages" | "queue";
|
|
439
441
|
type LifecyclePhase = "onMount" | "onUnmount" | "onUpdate";
|
|
440
442
|
type OperationState<TData = unknown, TError = unknown> = {
|
|
441
443
|
data: TData | undefined;
|
|
@@ -492,7 +494,7 @@ type PluginContextBase = {
|
|
|
492
494
|
eventEmitter: EventEmitter;
|
|
493
495
|
/** Access other plugins' exported APIs */
|
|
494
496
|
plugins: PluginAccessor;
|
|
495
|
-
/** Plugin-specific options passed from hooks (useRead/useWrite/
|
|
497
|
+
/** Plugin-specific options passed from hooks (useRead/useWrite/usePages) */
|
|
496
498
|
pluginOptions?: unknown;
|
|
497
499
|
/** Force a network request even if cached data exists. Used by plugins to communicate intent. */
|
|
498
500
|
forceRefetch?: boolean;
|
|
@@ -598,7 +600,7 @@ type PluginLifecycle = {
|
|
|
598
600
|
type PluginTypeConfig = {
|
|
599
601
|
readOptions?: object;
|
|
600
602
|
writeOptions?: object;
|
|
601
|
-
|
|
603
|
+
pagesOptions?: object;
|
|
602
604
|
writeTriggerOptions?: object;
|
|
603
605
|
queueOptions?: object;
|
|
604
606
|
queueTriggerOptions?: object;
|
|
@@ -1027,8 +1029,8 @@ type ExtractReadOptions<T> = T extends SpooshPlugin<infer Types> ? Types extends
|
|
|
1027
1029
|
type ExtractWriteOptions<T> = T extends SpooshPlugin<infer Types> ? Types extends {
|
|
1028
1030
|
writeOptions: infer W;
|
|
1029
1031
|
} ? W : object : object;
|
|
1030
|
-
type
|
|
1031
|
-
|
|
1032
|
+
type ExtractPagesOptions<T> = T extends SpooshPlugin<infer Types> ? Types extends {
|
|
1033
|
+
pagesOptions: infer I;
|
|
1032
1034
|
} ? I : object : object;
|
|
1033
1035
|
type ExtractWriteTriggerOptions<T> = T extends SpooshPlugin<infer Types> ? Types extends {
|
|
1034
1036
|
writeTriggerOptions: infer W;
|
|
@@ -1055,7 +1057,7 @@ type UnionToIntersection<U> = (U extends unknown ? (x: U) => void : never) exten
|
|
|
1055
1057
|
type MergePluginOptions<TPlugins extends readonly SpooshPlugin<PluginTypeConfig>[]> = {
|
|
1056
1058
|
read: UnionToIntersection<ExtractReadOptions<TPlugins[number]>>;
|
|
1057
1059
|
write: UnionToIntersection<ExtractWriteOptions<TPlugins[number]>>;
|
|
1058
|
-
|
|
1060
|
+
pages: UnionToIntersection<ExtractPagesOptions<TPlugins[number]>>;
|
|
1059
1061
|
writeTrigger: UnionToIntersection<ExtractWriteTriggerOptions<TPlugins[number]>>;
|
|
1060
1062
|
queue: UnionToIntersection<ExtractQueueOptions<TPlugins[number]>>;
|
|
1061
1063
|
queueTrigger: UnionToIntersection<ExtractQueueTriggerOptions<TPlugins[number]>>;
|
|
@@ -1490,6 +1492,22 @@ type SpooshInstance<TSchema = unknown, TDefaultError = unknown, TPlugins extends
|
|
|
1490
1492
|
};
|
|
1491
1493
|
};
|
|
1492
1494
|
|
|
1495
|
+
type ExtractTriggerQuery<I> = I extends {
|
|
1496
|
+
query: infer Q;
|
|
1497
|
+
} ? {
|
|
1498
|
+
query?: Q;
|
|
1499
|
+
} : unknown;
|
|
1500
|
+
type ExtractTriggerBody<I> = I extends {
|
|
1501
|
+
body: infer B;
|
|
1502
|
+
} ? {
|
|
1503
|
+
body?: B;
|
|
1504
|
+
} : unknown;
|
|
1505
|
+
type ExtractTriggerParams<I> = I extends {
|
|
1506
|
+
params: infer P;
|
|
1507
|
+
} ? {
|
|
1508
|
+
params?: P;
|
|
1509
|
+
} : unknown;
|
|
1510
|
+
|
|
1493
1511
|
/**
|
|
1494
1512
|
* Class-based builder for creating Spoosh instances with type-safe plugin inference.
|
|
1495
1513
|
*
|
|
@@ -2001,6 +2019,7 @@ type CreateOperationOptions<TData, TError> = {
|
|
|
2001
2019
|
/** Unique identifier for the hook instance. Persists across queryKey changes. */
|
|
2002
2020
|
instanceId?: string;
|
|
2003
2021
|
};
|
|
2022
|
+
|
|
2004
2023
|
declare function createOperationController<TData, TError>(options: CreateOperationOptions<TData, TError>): OperationController<TData, TError>;
|
|
2005
2024
|
|
|
2006
2025
|
type InfiniteRequestOptions = {
|
|
@@ -2008,27 +2027,43 @@ type InfiniteRequestOptions = {
|
|
|
2008
2027
|
params?: Record<string, string | number>;
|
|
2009
2028
|
body?: unknown;
|
|
2010
2029
|
};
|
|
2011
|
-
type
|
|
2012
|
-
|
|
2013
|
-
|
|
2030
|
+
type InfinitePageStatus = "pending" | "loading" | "success" | "error" | "stale";
|
|
2031
|
+
interface InfinitePage<TData, TError, TMeta> {
|
|
2032
|
+
status: InfinitePageStatus;
|
|
2033
|
+
data?: TData;
|
|
2034
|
+
error?: TError;
|
|
2035
|
+
meta?: TMeta;
|
|
2036
|
+
input?: InfiniteRequestOptions;
|
|
2037
|
+
}
|
|
2038
|
+
type InfiniteNextContext<TData, TError, TRequest, TMeta> = {
|
|
2039
|
+
lastPage: InfinitePage<TData, TError, TMeta> | undefined;
|
|
2040
|
+
pages: InfinitePage<TData, TError, TMeta>[];
|
|
2041
|
+
request: TRequest;
|
|
2042
|
+
};
|
|
2043
|
+
type InfinitePrevContext<TData, TError, TRequest, TMeta> = {
|
|
2044
|
+
firstPage: InfinitePage<TData, TError, TMeta> | undefined;
|
|
2045
|
+
pages: InfinitePage<TData, TError, TMeta>[];
|
|
2014
2046
|
request: TRequest;
|
|
2015
2047
|
};
|
|
2016
2048
|
type FetchDirection = "next" | "prev";
|
|
2017
|
-
type
|
|
2049
|
+
type InfiniteTriggerOptions = Partial<InfiniteRequestOptions> & {
|
|
2050
|
+
/** Bypass cache and force refetch. Default: true */
|
|
2051
|
+
force?: boolean;
|
|
2052
|
+
};
|
|
2053
|
+
type InfiniteReadState<TData, TItem, TError, TMeta = Record<string, unknown>> = {
|
|
2018
2054
|
data: TItem[] | undefined;
|
|
2019
|
-
|
|
2020
|
-
allRequests: InfiniteRequestOptions[] | undefined;
|
|
2055
|
+
pages: InfinitePage<TData, TError, TMeta>[];
|
|
2021
2056
|
canFetchNext: boolean;
|
|
2022
2057
|
canFetchPrev: boolean;
|
|
2023
2058
|
error: TError | undefined;
|
|
2024
2059
|
};
|
|
2025
|
-
type InfiniteReadController<TData, TItem, TError
|
|
2026
|
-
getState: () => InfiniteReadState<TData, TItem, TError>;
|
|
2060
|
+
type InfiniteReadController<TData, TItem, TError, TMeta = Record<string, unknown>> = {
|
|
2061
|
+
getState: () => InfiniteReadState<TData, TItem, TError, TMeta>;
|
|
2027
2062
|
getFetchingDirection: () => FetchDirection | null;
|
|
2028
2063
|
subscribe: (callback: () => void) => () => void;
|
|
2029
2064
|
fetchNext: () => Promise<void>;
|
|
2030
2065
|
fetchPrev: () => Promise<void>;
|
|
2031
|
-
|
|
2066
|
+
trigger: (options?: InfiniteTriggerOptions) => Promise<void>;
|
|
2032
2067
|
abort: () => void;
|
|
2033
2068
|
mount: () => void;
|
|
2034
2069
|
unmount: () => void;
|
|
@@ -2036,17 +2071,16 @@ type InfiniteReadController<TData, TItem, TError> = {
|
|
|
2036
2071
|
getContext: () => PluginContext;
|
|
2037
2072
|
setPluginOptions: (options: unknown) => void;
|
|
2038
2073
|
};
|
|
2039
|
-
type CreateInfiniteReadOptions<TData, TItem, TError, TRequest
|
|
2074
|
+
type CreateInfiniteReadOptions<TData, TItem, TError, TRequest, TMeta = Record<string, unknown>> = {
|
|
2040
2075
|
path: string;
|
|
2041
2076
|
method: HttpMethod;
|
|
2042
2077
|
tags: string[];
|
|
2043
2078
|
initialRequest: InfiniteRequestOptions;
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
merger: (responses: TData[]) => TItem[];
|
|
2079
|
+
canFetchNext?: (ctx: InfiniteNextContext<TData, TError, TRequest, TMeta>) => boolean;
|
|
2080
|
+
canFetchPrev?: (ctx: InfinitePrevContext<TData, TError, TRequest, TMeta>) => boolean;
|
|
2081
|
+
nextPageRequest?: (ctx: InfiniteNextContext<TData, TError, TRequest, TMeta>) => Partial<TRequest>;
|
|
2082
|
+
prevPageRequest?: (ctx: InfinitePrevContext<TData, TError, TRequest, TMeta>) => Partial<TRequest>;
|
|
2083
|
+
merger: (pages: InfinitePage<TData, TError, TMeta>[]) => TItem[];
|
|
2050
2084
|
stateManager: StateManager;
|
|
2051
2085
|
eventEmitter: EventEmitter;
|
|
2052
2086
|
pluginExecutor: PluginExecutor;
|
|
@@ -2054,7 +2088,8 @@ type CreateInfiniteReadOptions<TData, TItem, TError, TRequest> = {
|
|
|
2054
2088
|
/** Unique identifier for the hook instance. Persists across queryKey changes. */
|
|
2055
2089
|
instanceId?: string;
|
|
2056
2090
|
};
|
|
2057
|
-
|
|
2091
|
+
|
|
2092
|
+
declare function createInfiniteReadController<TData, TItem, TError, TRequest extends InfiniteRequestOptions = InfiniteRequestOptions, TMeta = Record<string, unknown>>(options: CreateInfiniteReadOptions<TData, TItem, TError, TRequest, TMeta>): InfiniteReadController<TData, TItem, TError, TMeta>;
|
|
2058
2093
|
|
|
2059
2094
|
/**
|
|
2060
2095
|
* Status of an item in the queue.
|
|
@@ -2177,4 +2212,4 @@ declare class Semaphore {
|
|
|
2177
2212
|
getWaitingCount(): number;
|
|
2178
2213
|
}
|
|
2179
2214
|
|
|
2180
|
-
export { type AnyRequestOptions, type ApiSchema, type BuiltInEvents, type CacheEntry, type CacheEntryWithKey, type CapturedCall, type ComputeRequestOptions, type CoreRequestOptionsBase, type CreateInfiniteReadOptions, type CreateOperationOptions, type DataAwareCallback, type DataAwareTransform, type DevtoolEvents, type EventEmitter, type EventListener, type EventOptions, type EventTracer, type ExtractBody$1 as ExtractBody, type ExtractData, type ExtractError, type ExtractMethodOptions, type ExtractParamNames, type ExtractQuery$1 as ExtractQuery, type FetchDirection, type FetchExecutor, type FindMatchingKey, HTTP_METHODS, type HasParams, type HasReadMethod, type HasWriteMethod, type HeadersInitOrGetter, type HttpMethod, type HttpMethodKey, type InfiniteReadController, type InfiniteReadState, type InfiniteRequestOptions, type InstanceApiContext, type InstanceApiResolvers, type InstancePluginExecutor, type LifecyclePhase, type MergePluginInstanceApi, type MergePluginOptions, type MergePluginResults, type MethodOptionsMap, type OperationController, type OperationState, type OperationType, type
|
|
2215
|
+
export { type AnyRequestOptions, type ApiSchema, type BuiltInEvents, type CacheEntry, type CacheEntryWithKey, type CapturedCall, type ComputeRequestOptions, type CoreRequestOptionsBase, type CreateInfiniteReadOptions, type CreateOperationOptions, type DataAwareCallback, type DataAwareTransform, type DataChangeCallback, type DevtoolEvents, type EventEmitter, type EventListener, type EventOptions, type EventTracer, type ExecuteOptions, type ExtractBody$1 as ExtractBody, type ExtractData, type ExtractError, type ExtractMethodOptions, type ExtractParamNames, type ExtractQuery$1 as ExtractQuery, type ExtractTriggerBody, type ExtractTriggerParams, type ExtractTriggerQuery, type FetchDirection, type FetchExecutor, type FindMatchingKey, HTTP_METHODS, type HasParams, type HasReadMethod, type HasWriteMethod, type HeadersInitOrGetter, type HttpMethod, type HttpMethodKey, type InfiniteNextContext, type InfinitePage, type InfinitePageStatus, type InfinitePrevContext, type InfiniteReadController, type InfiniteReadState, type InfiniteRequestOptions, type InfiniteTriggerOptions, type InstanceApiContext, type InstanceApiResolvers, type InstancePluginExecutor, type LifecyclePhase, type MergePluginInstanceApi, type MergePluginOptions, type MergePluginResults, type MethodOptionsMap, type OperationController, type OperationState, type OperationType, type PluginAccessor, type PluginArray, type PluginContext, type PluginContextBase, type PluginContextExtensions, type PluginContextInput, type PluginExecutor, type PluginExportsRegistry, type PluginFactory, type PluginHandler, type PluginLifecycle, type PluginMiddleware, type PluginRegistry, type PluginRequestOptions, type PluginResolvers, type PluginResponseHandler, type PluginResultResolvers, type PluginTypeConfig, type PluginUpdateHandler, type QueueController, type QueueControllerConfig, type QueueControllerContext, type QueueItem, type QueueItemStatus, type QueueSelectorClient, type QueueStats, type QueueTriggerInput, type ReadClient, type ReadPaths, type ReadSchemaHelper, type RefetchEvent, type RequestCompleteEvent, type RequestOptions$1 as RequestOptions, type RequestTracer, type ResolveInstanceApi, type ResolveResultTypes, type ResolveSchemaTypes, type ResolveTypes, type ResolverContext, type SchemaPaths, type SelectedEndpoint, type SelectorFunction, type SelectorResult, Semaphore, type SetupContext, type Simplify, Spoosh, type SpooshBody, type SpooshClient, type SpooshConfig, type SpooshInstance, type SpooshOptions, type SpooshOptionsInput, type SpooshPlugin, type SpooshResponse, type SpooshSchema, type StandaloneEvent, type StateManager, type StripPrefix, type Subscriber, type TagMode, type TagOptions, type Trace, type TraceColor, type TraceEvent, type TraceInfo, type TraceListener, type TraceOptions, type TraceStage, type Transport, type TransportOption, type TransportOptionsMap, type TransportResponse, type WriteClient, type WriteMethod, type WritePaths, type WriteSchemaHelper, type WriteSelectorClient, __DEV__, buildUrl, clone, containsFile, createClient, createEventEmitter, createInfiniteReadController, createInitialState, createOperationController, createPluginExecutor, createPluginRegistry, createProxyHandler, createQueueController, createSelectorProxy, createStateManager, createTracer, executeFetch, extractMethodFromSelector, extractPathFromSelector, fetchTransport, form, generateTags, getContentType, isAbortError, isJsonBody, isNetworkError, isSpooshBody, json, mergeHeaders, objectToFormData, objectToUrlEncoded, removeHeaderKeys, resolveHeadersToRecord, resolvePath, resolvePathString, resolveRequestBody, resolveTags, setHeaders, sortObjectKeys, urlencoded, xhrTransport };
|
package/dist/index.d.ts
CHANGED
|
@@ -215,7 +215,6 @@ type CacheEntryWithKey<TData = unknown, TError = unknown> = {
|
|
|
215
215
|
key: string;
|
|
216
216
|
entry: CacheEntry<TData, TError>;
|
|
217
217
|
};
|
|
218
|
-
declare function createInitialState<TData, TError>(): OperationState<TData, TError>;
|
|
219
218
|
type StateManager = {
|
|
220
219
|
createQueryKey: (params: {
|
|
221
220
|
path: string;
|
|
@@ -249,8 +248,11 @@ type StateManager = {
|
|
|
249
248
|
onDataChange: (callback: DataChangeCallback) => () => void;
|
|
250
249
|
clear: () => void;
|
|
251
250
|
};
|
|
251
|
+
|
|
252
252
|
declare function createStateManager(): StateManager;
|
|
253
253
|
|
|
254
|
+
declare function createInitialState<TData, TError>(): OperationState<TData, TError>;
|
|
255
|
+
|
|
254
256
|
/**
|
|
255
257
|
* Devtool-related types for tracing and debugging.
|
|
256
258
|
* These types are used by the devtool plugin and plugins that emit trace events.
|
|
@@ -435,7 +437,7 @@ interface EventTracer {
|
|
|
435
437
|
emit(msg: string, options?: EventOptions): void;
|
|
436
438
|
}
|
|
437
439
|
|
|
438
|
-
type OperationType = "read" | "write" | "
|
|
440
|
+
type OperationType = "read" | "write" | "pages" | "queue";
|
|
439
441
|
type LifecyclePhase = "onMount" | "onUnmount" | "onUpdate";
|
|
440
442
|
type OperationState<TData = unknown, TError = unknown> = {
|
|
441
443
|
data: TData | undefined;
|
|
@@ -492,7 +494,7 @@ type PluginContextBase = {
|
|
|
492
494
|
eventEmitter: EventEmitter;
|
|
493
495
|
/** Access other plugins' exported APIs */
|
|
494
496
|
plugins: PluginAccessor;
|
|
495
|
-
/** Plugin-specific options passed from hooks (useRead/useWrite/
|
|
497
|
+
/** Plugin-specific options passed from hooks (useRead/useWrite/usePages) */
|
|
496
498
|
pluginOptions?: unknown;
|
|
497
499
|
/** Force a network request even if cached data exists. Used by plugins to communicate intent. */
|
|
498
500
|
forceRefetch?: boolean;
|
|
@@ -598,7 +600,7 @@ type PluginLifecycle = {
|
|
|
598
600
|
type PluginTypeConfig = {
|
|
599
601
|
readOptions?: object;
|
|
600
602
|
writeOptions?: object;
|
|
601
|
-
|
|
603
|
+
pagesOptions?: object;
|
|
602
604
|
writeTriggerOptions?: object;
|
|
603
605
|
queueOptions?: object;
|
|
604
606
|
queueTriggerOptions?: object;
|
|
@@ -1027,8 +1029,8 @@ type ExtractReadOptions<T> = T extends SpooshPlugin<infer Types> ? Types extends
|
|
|
1027
1029
|
type ExtractWriteOptions<T> = T extends SpooshPlugin<infer Types> ? Types extends {
|
|
1028
1030
|
writeOptions: infer W;
|
|
1029
1031
|
} ? W : object : object;
|
|
1030
|
-
type
|
|
1031
|
-
|
|
1032
|
+
type ExtractPagesOptions<T> = T extends SpooshPlugin<infer Types> ? Types extends {
|
|
1033
|
+
pagesOptions: infer I;
|
|
1032
1034
|
} ? I : object : object;
|
|
1033
1035
|
type ExtractWriteTriggerOptions<T> = T extends SpooshPlugin<infer Types> ? Types extends {
|
|
1034
1036
|
writeTriggerOptions: infer W;
|
|
@@ -1055,7 +1057,7 @@ type UnionToIntersection<U> = (U extends unknown ? (x: U) => void : never) exten
|
|
|
1055
1057
|
type MergePluginOptions<TPlugins extends readonly SpooshPlugin<PluginTypeConfig>[]> = {
|
|
1056
1058
|
read: UnionToIntersection<ExtractReadOptions<TPlugins[number]>>;
|
|
1057
1059
|
write: UnionToIntersection<ExtractWriteOptions<TPlugins[number]>>;
|
|
1058
|
-
|
|
1060
|
+
pages: UnionToIntersection<ExtractPagesOptions<TPlugins[number]>>;
|
|
1059
1061
|
writeTrigger: UnionToIntersection<ExtractWriteTriggerOptions<TPlugins[number]>>;
|
|
1060
1062
|
queue: UnionToIntersection<ExtractQueueOptions<TPlugins[number]>>;
|
|
1061
1063
|
queueTrigger: UnionToIntersection<ExtractQueueTriggerOptions<TPlugins[number]>>;
|
|
@@ -1490,6 +1492,22 @@ type SpooshInstance<TSchema = unknown, TDefaultError = unknown, TPlugins extends
|
|
|
1490
1492
|
};
|
|
1491
1493
|
};
|
|
1492
1494
|
|
|
1495
|
+
type ExtractTriggerQuery<I> = I extends {
|
|
1496
|
+
query: infer Q;
|
|
1497
|
+
} ? {
|
|
1498
|
+
query?: Q;
|
|
1499
|
+
} : unknown;
|
|
1500
|
+
type ExtractTriggerBody<I> = I extends {
|
|
1501
|
+
body: infer B;
|
|
1502
|
+
} ? {
|
|
1503
|
+
body?: B;
|
|
1504
|
+
} : unknown;
|
|
1505
|
+
type ExtractTriggerParams<I> = I extends {
|
|
1506
|
+
params: infer P;
|
|
1507
|
+
} ? {
|
|
1508
|
+
params?: P;
|
|
1509
|
+
} : unknown;
|
|
1510
|
+
|
|
1493
1511
|
/**
|
|
1494
1512
|
* Class-based builder for creating Spoosh instances with type-safe plugin inference.
|
|
1495
1513
|
*
|
|
@@ -2001,6 +2019,7 @@ type CreateOperationOptions<TData, TError> = {
|
|
|
2001
2019
|
/** Unique identifier for the hook instance. Persists across queryKey changes. */
|
|
2002
2020
|
instanceId?: string;
|
|
2003
2021
|
};
|
|
2022
|
+
|
|
2004
2023
|
declare function createOperationController<TData, TError>(options: CreateOperationOptions<TData, TError>): OperationController<TData, TError>;
|
|
2005
2024
|
|
|
2006
2025
|
type InfiniteRequestOptions = {
|
|
@@ -2008,27 +2027,43 @@ type InfiniteRequestOptions = {
|
|
|
2008
2027
|
params?: Record<string, string | number>;
|
|
2009
2028
|
body?: unknown;
|
|
2010
2029
|
};
|
|
2011
|
-
type
|
|
2012
|
-
|
|
2013
|
-
|
|
2030
|
+
type InfinitePageStatus = "pending" | "loading" | "success" | "error" | "stale";
|
|
2031
|
+
interface InfinitePage<TData, TError, TMeta> {
|
|
2032
|
+
status: InfinitePageStatus;
|
|
2033
|
+
data?: TData;
|
|
2034
|
+
error?: TError;
|
|
2035
|
+
meta?: TMeta;
|
|
2036
|
+
input?: InfiniteRequestOptions;
|
|
2037
|
+
}
|
|
2038
|
+
type InfiniteNextContext<TData, TError, TRequest, TMeta> = {
|
|
2039
|
+
lastPage: InfinitePage<TData, TError, TMeta> | undefined;
|
|
2040
|
+
pages: InfinitePage<TData, TError, TMeta>[];
|
|
2041
|
+
request: TRequest;
|
|
2042
|
+
};
|
|
2043
|
+
type InfinitePrevContext<TData, TError, TRequest, TMeta> = {
|
|
2044
|
+
firstPage: InfinitePage<TData, TError, TMeta> | undefined;
|
|
2045
|
+
pages: InfinitePage<TData, TError, TMeta>[];
|
|
2014
2046
|
request: TRequest;
|
|
2015
2047
|
};
|
|
2016
2048
|
type FetchDirection = "next" | "prev";
|
|
2017
|
-
type
|
|
2049
|
+
type InfiniteTriggerOptions = Partial<InfiniteRequestOptions> & {
|
|
2050
|
+
/** Bypass cache and force refetch. Default: true */
|
|
2051
|
+
force?: boolean;
|
|
2052
|
+
};
|
|
2053
|
+
type InfiniteReadState<TData, TItem, TError, TMeta = Record<string, unknown>> = {
|
|
2018
2054
|
data: TItem[] | undefined;
|
|
2019
|
-
|
|
2020
|
-
allRequests: InfiniteRequestOptions[] | undefined;
|
|
2055
|
+
pages: InfinitePage<TData, TError, TMeta>[];
|
|
2021
2056
|
canFetchNext: boolean;
|
|
2022
2057
|
canFetchPrev: boolean;
|
|
2023
2058
|
error: TError | undefined;
|
|
2024
2059
|
};
|
|
2025
|
-
type InfiniteReadController<TData, TItem, TError
|
|
2026
|
-
getState: () => InfiniteReadState<TData, TItem, TError>;
|
|
2060
|
+
type InfiniteReadController<TData, TItem, TError, TMeta = Record<string, unknown>> = {
|
|
2061
|
+
getState: () => InfiniteReadState<TData, TItem, TError, TMeta>;
|
|
2027
2062
|
getFetchingDirection: () => FetchDirection | null;
|
|
2028
2063
|
subscribe: (callback: () => void) => () => void;
|
|
2029
2064
|
fetchNext: () => Promise<void>;
|
|
2030
2065
|
fetchPrev: () => Promise<void>;
|
|
2031
|
-
|
|
2066
|
+
trigger: (options?: InfiniteTriggerOptions) => Promise<void>;
|
|
2032
2067
|
abort: () => void;
|
|
2033
2068
|
mount: () => void;
|
|
2034
2069
|
unmount: () => void;
|
|
@@ -2036,17 +2071,16 @@ type InfiniteReadController<TData, TItem, TError> = {
|
|
|
2036
2071
|
getContext: () => PluginContext;
|
|
2037
2072
|
setPluginOptions: (options: unknown) => void;
|
|
2038
2073
|
};
|
|
2039
|
-
type CreateInfiniteReadOptions<TData, TItem, TError, TRequest
|
|
2074
|
+
type CreateInfiniteReadOptions<TData, TItem, TError, TRequest, TMeta = Record<string, unknown>> = {
|
|
2040
2075
|
path: string;
|
|
2041
2076
|
method: HttpMethod;
|
|
2042
2077
|
tags: string[];
|
|
2043
2078
|
initialRequest: InfiniteRequestOptions;
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
merger: (responses: TData[]) => TItem[];
|
|
2079
|
+
canFetchNext?: (ctx: InfiniteNextContext<TData, TError, TRequest, TMeta>) => boolean;
|
|
2080
|
+
canFetchPrev?: (ctx: InfinitePrevContext<TData, TError, TRequest, TMeta>) => boolean;
|
|
2081
|
+
nextPageRequest?: (ctx: InfiniteNextContext<TData, TError, TRequest, TMeta>) => Partial<TRequest>;
|
|
2082
|
+
prevPageRequest?: (ctx: InfinitePrevContext<TData, TError, TRequest, TMeta>) => Partial<TRequest>;
|
|
2083
|
+
merger: (pages: InfinitePage<TData, TError, TMeta>[]) => TItem[];
|
|
2050
2084
|
stateManager: StateManager;
|
|
2051
2085
|
eventEmitter: EventEmitter;
|
|
2052
2086
|
pluginExecutor: PluginExecutor;
|
|
@@ -2054,7 +2088,8 @@ type CreateInfiniteReadOptions<TData, TItem, TError, TRequest> = {
|
|
|
2054
2088
|
/** Unique identifier for the hook instance. Persists across queryKey changes. */
|
|
2055
2089
|
instanceId?: string;
|
|
2056
2090
|
};
|
|
2057
|
-
|
|
2091
|
+
|
|
2092
|
+
declare function createInfiniteReadController<TData, TItem, TError, TRequest extends InfiniteRequestOptions = InfiniteRequestOptions, TMeta = Record<string, unknown>>(options: CreateInfiniteReadOptions<TData, TItem, TError, TRequest, TMeta>): InfiniteReadController<TData, TItem, TError, TMeta>;
|
|
2058
2093
|
|
|
2059
2094
|
/**
|
|
2060
2095
|
* Status of an item in the queue.
|
|
@@ -2177,4 +2212,4 @@ declare class Semaphore {
|
|
|
2177
2212
|
getWaitingCount(): number;
|
|
2178
2213
|
}
|
|
2179
2214
|
|
|
2180
|
-
export { type AnyRequestOptions, type ApiSchema, type BuiltInEvents, type CacheEntry, type CacheEntryWithKey, type CapturedCall, type ComputeRequestOptions, type CoreRequestOptionsBase, type CreateInfiniteReadOptions, type CreateOperationOptions, type DataAwareCallback, type DataAwareTransform, type DevtoolEvents, type EventEmitter, type EventListener, type EventOptions, type EventTracer, type ExtractBody$1 as ExtractBody, type ExtractData, type ExtractError, type ExtractMethodOptions, type ExtractParamNames, type ExtractQuery$1 as ExtractQuery, type FetchDirection, type FetchExecutor, type FindMatchingKey, HTTP_METHODS, type HasParams, type HasReadMethod, type HasWriteMethod, type HeadersInitOrGetter, type HttpMethod, type HttpMethodKey, type InfiniteReadController, type InfiniteReadState, type InfiniteRequestOptions, type InstanceApiContext, type InstanceApiResolvers, type InstancePluginExecutor, type LifecyclePhase, type MergePluginInstanceApi, type MergePluginOptions, type MergePluginResults, type MethodOptionsMap, type OperationController, type OperationState, type OperationType, type
|
|
2215
|
+
export { type AnyRequestOptions, type ApiSchema, type BuiltInEvents, type CacheEntry, type CacheEntryWithKey, type CapturedCall, type ComputeRequestOptions, type CoreRequestOptionsBase, type CreateInfiniteReadOptions, type CreateOperationOptions, type DataAwareCallback, type DataAwareTransform, type DataChangeCallback, type DevtoolEvents, type EventEmitter, type EventListener, type EventOptions, type EventTracer, type ExecuteOptions, type ExtractBody$1 as ExtractBody, type ExtractData, type ExtractError, type ExtractMethodOptions, type ExtractParamNames, type ExtractQuery$1 as ExtractQuery, type ExtractTriggerBody, type ExtractTriggerParams, type ExtractTriggerQuery, type FetchDirection, type FetchExecutor, type FindMatchingKey, HTTP_METHODS, type HasParams, type HasReadMethod, type HasWriteMethod, type HeadersInitOrGetter, type HttpMethod, type HttpMethodKey, type InfiniteNextContext, type InfinitePage, type InfinitePageStatus, type InfinitePrevContext, type InfiniteReadController, type InfiniteReadState, type InfiniteRequestOptions, type InfiniteTriggerOptions, type InstanceApiContext, type InstanceApiResolvers, type InstancePluginExecutor, type LifecyclePhase, type MergePluginInstanceApi, type MergePluginOptions, type MergePluginResults, type MethodOptionsMap, type OperationController, type OperationState, type OperationType, type PluginAccessor, type PluginArray, type PluginContext, type PluginContextBase, type PluginContextExtensions, type PluginContextInput, type PluginExecutor, type PluginExportsRegistry, type PluginFactory, type PluginHandler, type PluginLifecycle, type PluginMiddleware, type PluginRegistry, type PluginRequestOptions, type PluginResolvers, type PluginResponseHandler, type PluginResultResolvers, type PluginTypeConfig, type PluginUpdateHandler, type QueueController, type QueueControllerConfig, type QueueControllerContext, type QueueItem, type QueueItemStatus, type QueueSelectorClient, type QueueStats, type QueueTriggerInput, type ReadClient, type ReadPaths, type ReadSchemaHelper, type RefetchEvent, type RequestCompleteEvent, type RequestOptions$1 as RequestOptions, type RequestTracer, type ResolveInstanceApi, type ResolveResultTypes, type ResolveSchemaTypes, type ResolveTypes, type ResolverContext, type SchemaPaths, type SelectedEndpoint, type SelectorFunction, type SelectorResult, Semaphore, type SetupContext, type Simplify, Spoosh, type SpooshBody, type SpooshClient, type SpooshConfig, type SpooshInstance, type SpooshOptions, type SpooshOptionsInput, type SpooshPlugin, type SpooshResponse, type SpooshSchema, type StandaloneEvent, type StateManager, type StripPrefix, type Subscriber, type TagMode, type TagOptions, type Trace, type TraceColor, type TraceEvent, type TraceInfo, type TraceListener, type TraceOptions, type TraceStage, type Transport, type TransportOption, type TransportOptionsMap, type TransportResponse, type WriteClient, type WriteMethod, type WritePaths, type WriteSchemaHelper, type WriteSelectorClient, __DEV__, buildUrl, clone, containsFile, createClient, createEventEmitter, createInfiniteReadController, createInitialState, createOperationController, createPluginExecutor, createPluginRegistry, createProxyHandler, createQueueController, createSelectorProxy, createStateManager, createTracer, executeFetch, extractMethodFromSelector, extractPathFromSelector, fetchTransport, form, generateTags, getContentType, isAbortError, isJsonBody, isNetworkError, isSpooshBody, json, mergeHeaders, objectToFormData, objectToUrlEncoded, removeHeaderKeys, resolveHeadersToRecord, resolvePath, resolvePathString, resolveRequestBody, resolveTags, setHeaders, sortObjectKeys, urlencoded, xhrTransport };
|