@equinor/fusion-query
Advanced tools
Comparing version 0.1.2 to 0.2.2
@@ -25,3 +25,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
import * as uuid from 'uuid'; | ||
import { ReactiveObservable, } from '@equinor/fusion-observable'; | ||
import { ReactiveObservable } from '@equinor/fusion-observable'; | ||
import { filterAction } from '@equinor/fusion-observable/operators'; | ||
@@ -28,0 +28,0 @@ import { handleRequests, handleFailures } from './epics'; |
import type { PayloadAction } from '@equinor/fusion-observable'; | ||
import type { QueryCacheRecord } from './types'; | ||
export type QueryCacheActions<TType = unknown, TArgs = unknown> = { | ||
set: PayloadAction<'set', { | ||
set: PayloadAction<{ | ||
key: string; | ||
@@ -12,17 +12,17 @@ value: { | ||
}; | ||
}>; | ||
clear: PayloadAction<'clear', { | ||
}, 'set'>; | ||
clear: PayloadAction<{ | ||
key: string; | ||
}>; | ||
reset: PayloadAction<'reset', { | ||
}, 'clear'>; | ||
reset: PayloadAction<{ | ||
data?: Record<string, TType>; | ||
}>; | ||
invalidate: PayloadAction<'invalidate', { | ||
}, 'reset'>; | ||
invalidate: PayloadAction<{ | ||
key: string; | ||
}>; | ||
trim: PayloadAction<'trim', { | ||
}, 'invalidate'>; | ||
trim: PayloadAction<{ | ||
sort?: (a: QueryCacheRecord<TType, TArgs>, b: QueryCacheRecord<TType, TArgs>) => number; | ||
validate?: (item: QueryCacheRecord<TType, TArgs>) => boolean; | ||
size?: number; | ||
}>; | ||
}, 'trim'>; | ||
}; | ||
@@ -29,0 +29,0 @@ export type QueryCacheActionTypes<TType = unknown, TArgs = unknown> = { |
import { Observable } from 'rxjs'; | ||
import { ActionPayload, ReactiveObservable } from '@equinor/fusion-observable'; | ||
import { ActionPayloadType, ReactiveObservable } from '@equinor/fusion-observable'; | ||
import type { QueryCacheActions, QueryCacheActionTypes } from './actions'; | ||
@@ -7,3 +7,3 @@ import type { QueryCacheRecord, QueryCacheState, QueryCacheStateData } from './types'; | ||
initial?: QueryCacheStateData<TType, TArgs>; | ||
trimming?: ActionPayload<QueryCacheActions<TType, TArgs>['trim']>; | ||
trimming?: ActionPayloadType<QueryCacheActions<TType, TArgs>['trim']>; | ||
}; | ||
@@ -17,4 +17,4 @@ export declare class QueryCache<TType, TArgs> extends ReactiveObservable<QueryCacheState<TType, TArgs>, QueryCacheActionTypes<TType, TArgs>> { | ||
invalidate(key: string): void; | ||
trim(options: ActionPayload<QueryCacheActions<TType, TArgs>['trim']>): void; | ||
trim(options: ActionPayloadType<QueryCacheActions<TType, TArgs>['trim']>): void; | ||
} | ||
export default QueryCache; |
import { ActionError } from '@equinor/fusion-observable'; | ||
import type { Action, PayloadAction, PayloadMetaAction } from '@equinor/fusion-observable'; | ||
import type { Action, PayloadAction } from '@equinor/fusion-observable'; | ||
import type { QueryTaskValue, RetryOptions } from './types'; | ||
import { Subject } from 'rxjs'; | ||
export type RequestAction<TArgs = unknown, TResponse = unknown> = PayloadMetaAction<'request', TArgs, { | ||
export type RequestAction<TArgs = unknown, TResponse = unknown> = PayloadAction<TArgs, 'request', { | ||
transaction: string; | ||
@@ -12,16 +12,16 @@ controller: AbortController; | ||
}>; | ||
export type RetryAction<TArgs = unknown, TResponse = unknown> = PayloadAction<'retry', RequestAction<TArgs, TResponse>>; | ||
export type SuccessAction<TArgs = unknown, TResponse = unknown> = PayloadMetaAction<'success', TResponse, { | ||
export type RetryAction<TArgs = unknown, TResponse = unknown> = PayloadAction<RequestAction<TArgs, TResponse>, 'retry'>; | ||
export type SuccessAction<TArgs = unknown, TResponse = unknown> = PayloadAction<TResponse, 'success', { | ||
request: RequestAction<TArgs, TResponse>; | ||
}>; | ||
export type CancelAction = PayloadAction<'cancel', { | ||
export type CancelAction = PayloadAction<{ | ||
transaction: string; | ||
reason?: string; | ||
}>; | ||
export type FailureAction<TArgs = unknown, TResponse = unknown, TError extends Error = Error> = PayloadMetaAction<'failure', ActionError<Action, TError>, { | ||
}, 'cancel'>; | ||
export type FailureAction<TArgs = unknown, TResponse = unknown, TError extends Error = Error> = PayloadAction<ActionError<Action, TError>, 'failure', { | ||
request: RequestAction<TArgs, TResponse>; | ||
}>; | ||
export type ErrorAction<TArgs = unknown, TResponse = unknown, TError extends Error = Error> = PayloadMetaAction<'error', ActionError<Action, TError>, { | ||
export type ErrorAction<TArgs = unknown, TResponse = unknown, TError extends Error = Error> = PayloadAction<ActionError<Action, TError>, 'error', { | ||
request: RequestAction<TArgs, TResponse>; | ||
}>; | ||
export type ActionTypes<TType = unknown, TArgs = unknown, TFailure extends Error = Error, TError extends Error = Error> = CancelAction | ErrorAction<TArgs, TType, TError> | FailureAction<TArgs, TType, TFailure> | RequestAction<TArgs, TType> | RetryAction<TArgs, TType> | SuccessAction<TArgs, TType>; |
import { Observable, Subject, Subscription } from 'rxjs'; | ||
import { ActionMeta, ActionType, ExtractAction } from '@equinor/fusion-observable'; | ||
import { ActionType, ExtractAction } from '@equinor/fusion-observable'; | ||
import { ActionTypes, RequestAction } from './actions'; | ||
@@ -22,3 +22,3 @@ import { QueryClientError } from './QueryClientError'; | ||
constructor(queryFn: QueryFn<TType, TArgs>, options?: QueryClientCtorOptions); | ||
next(args?: TArgs, opt?: Partial<QueryClientOptions<TType, TArgs>>): ActionMeta<RequestAction<TArgs, TType>>; | ||
next(args?: TArgs, opt?: Partial<QueryClientOptions<TType, TArgs>>): RequestAction<TArgs, TType>['meta']; | ||
nextAsync(args?: TArgs, opt?: Partial<QueryClientOptions<TType, TArgs>>): Promise<QueryTaskCompleted<TType, TArgs>>; | ||
@@ -25,0 +25,0 @@ getTaskByTransaction(transaction: string): Subject<QueryTaskValue<TType, TArgs>> | undefined; |
{ | ||
"name": "@equinor/fusion-query", | ||
"version": "0.1.2", | ||
"version": "0.2.2", | ||
"description": "WIP", | ||
@@ -57,3 +57,3 @@ "private": false, | ||
"dependencies": { | ||
"@equinor/fusion-observable": "^2.0.1", | ||
"@equinor/fusion-observable": "^2.1.2", | ||
"immer": "^9.0.16", | ||
@@ -81,3 +81,3 @@ "rxjs": "^7.5.7", | ||
}, | ||
"gitHead": "9506dd4273dae255a292d734c93e53e7f5c62bbf" | ||
"gitHead": "7299bbb948f2e2a821a68af63ec6a95308900b67" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
144928