@hazae41/glacier
Advanced tools
Comparing version 2.0.0-104 to 2.0.0-105
@@ -7,3 +7,3 @@ import * as index from './mods/index.js'; | ||
export { HmacEncoder } from './mods/coders/crypto/hmac/hmac.js'; | ||
export { AsyncStorageError, CooldownError, Core, MissingFetcherError, MissingKeyError, QueryMetadata, TimeoutError, core } from './mods/core/core.js'; | ||
export { AsyncStorageError, CooldownError, Core, MissingFetcherError, MissingKeyError, TimeoutError, core } from './mods/core/core.js'; | ||
export { DEFAULT_EQUALS, DEFAULT_SERIALIZER } from './mods/defaults.js'; | ||
@@ -10,0 +10,0 @@ export { Equals, Equalser } from './mods/equals/equals.js'; |
@@ -1,6 +0,7 @@ | ||
import { Nullable, Option } from '@hazae41/option'; | ||
import { Mutex } from '@hazae41/mutex'; | ||
import { Nullable } from '@hazae41/option'; | ||
import { Result } from '@hazae41/result'; | ||
import { CustomEventTarget } from '../../libs/ortho/ortho.js'; | ||
import { Promiseable } from '../../libs/promises/promises.js'; | ||
import { Fetched } from '../fetched/fetched.js'; | ||
import { FetchedInit, Fetched } from '../fetched/fetched.js'; | ||
import { Mutator, Setter } from '../types/mutator.js'; | ||
@@ -35,11 +36,2 @@ import { QuerySettings } from '../types/settings.js'; | ||
} | ||
interface QueryMetadata<D, F> { | ||
cacheKey: string; | ||
counter: number; | ||
state?: State<D, F>; | ||
timeout?: NodeJS.Timeout; | ||
aborter?: AbortController; | ||
pending?: Promise<Result<State<D, F>, Error>>; | ||
optimizers: Map<string, Mutator<D, F>>; | ||
} | ||
declare class Core { | ||
@@ -53,3 +45,10 @@ #private; | ||
}>; | ||
readonly raw: Map<string, Option<RawState>>; | ||
readonly mutexes: Map<string, Mutex<void>>; | ||
readonly unstoreds: Map<string, State<any, any>>; | ||
readonly storeds: Map<string, RawState<any, any>>; | ||
readonly promises: Map<string, Promise<Result<State<any, any>, Error>>>; | ||
readonly aborters: Map<string, AbortController>; | ||
readonly timeouts: Map<string, NodeJS.Timeout>; | ||
readonly counters: Map<string, number>; | ||
readonly optimizers: Map<string, Map<string, Mutator<any, any>>>; | ||
constructor(); | ||
@@ -62,4 +61,4 @@ clean(): void; | ||
tryGet<K, D, F>(cacheKey: string, settings: QuerySettings<K, D, F>): Promise<Result<State<D, F>, Error>>; | ||
tryStore<K, D, F>(state: State<D, F>, settings: QuerySettings<K, D, F>): Promise<Result<Nullable<RawState>, Error>>; | ||
tryUnstore<K, D, F>(stored: Nullable<RawState>, settings: QuerySettings<K, D, F>): Promise<Result<State<D, F>, Error>>; | ||
tryStore<K, D, F>(state: State<D, F>, settings: QuerySettings<K, D, F>): Promise<Result<RawState, Error>>; | ||
tryUnstore<K, D, F>(stored: RawState, settings: QuerySettings<K, D, F>): Promise<Result<State<D, F>, Error>>; | ||
/** | ||
@@ -82,3 +81,3 @@ * Set full state and store it in storage | ||
/** | ||
* Apply fetched result to previous state, and update it | ||
* Merge real state with returned Some(fetched), if None do nothing | ||
* @param cacheKey | ||
@@ -92,11 +91,19 @@ * @param previous | ||
/** | ||
* Mutate real state to undefined (keep fake state) | ||
* Merge real state with given fetched | ||
* @param cacheKey | ||
* @param fetched | ||
* @param settings | ||
* @returns | ||
*/ | ||
tryReplace<K, D, F>(cacheKey: string, fetched: Nullable<FetchedInit<D, F>>, settings: QuerySettings<K, D, F>): Promise<Result<State<D, F>, Error>>; | ||
/** | ||
* Set real state to undefined | ||
* @param cacheKey | ||
* @param settings | ||
* @returns | ||
*/ | ||
tryDelete<K, D, F>(cacheKey: string, settings: QuerySettings<K, D, F>): Promise<Result<State<D, F>, Error>>; | ||
tryReoptimize<K, D, F>(cacheKey: string, settings: QuerySettings<K, D, F>): Promise<Result<State<D, F>, Error>>; | ||
tryOptimize<K, D, F>(cacheKey: string, uuid: string, optimizer: Mutator<D, F>, settings: QuerySettings<K, D, F>): Promise<Result<State<D, F>, Error>>; | ||
deoptimize(cacheKey: string, uuid: string): Promise<boolean>; | ||
deoptimize(cacheKey: string, uuid: string): Promise<void>; | ||
runWithTimeout<T>(callback: (signal: AbortSignal) => Promiseable<T>, aborter: AbortController, delay?: number): Promise<T>; | ||
@@ -121,2 +128,2 @@ /** | ||
export { AsyncStorageError, CooldownError, Core, MissingFetcherError, MissingKeyError, type QueryMetadata, TimeoutError, core }; | ||
export { AsyncStorageError, CooldownError, Core, MissingFetcherError, MissingKeyError, TimeoutError, core }; |
@@ -5,3 +5,3 @@ export { AsyncBicoder, AsyncEncoder, AsyncJson, AsyncPipeBicoder, AsyncPipeEncoder, Bicoder, Encoder, SyncBicoder, SyncEncoder, SyncIdentity, SyncJson, SyncPipeBicoder, SyncPipeEncoder } from './coders/coder.js'; | ||
export { HmacEncoder } from './coders/crypto/hmac/hmac.js'; | ||
export { AsyncStorageError, CooldownError, Core, MissingFetcherError, MissingKeyError, QueryMetadata, TimeoutError, core } from './core/core.js'; | ||
export { AsyncStorageError, CooldownError, Core, MissingFetcherError, MissingKeyError, TimeoutError, core } from './core/core.js'; | ||
export { DEFAULT_EQUALS, DEFAULT_SERIALIZER } from './defaults.js'; | ||
@@ -8,0 +8,0 @@ export { Equals, Equalser } from './equals/equals.js'; |
@@ -1,2 +0,1 @@ | ||
import { Nullable } from '@hazae41/option'; | ||
import { Result, Err, Ok } from '@hazae41/result'; | ||
@@ -41,4 +40,4 @@ import { Encoder, Bicoder } from '../../coders/coder.js'; | ||
tryCollect(): Promise<Err<IDBError> | Result<void, unknown>>; | ||
tryGet(cacheKey: string): Promise<Result<Nullable<RawState>, Error>>; | ||
trySetAndWait(cacheKey: string, state: Nullable<RawState>): Promise<Result<void, Error>>; | ||
tryGet(cacheKey: string): Promise<Result<RawState, Error>>; | ||
trySetAndWait(cacheKey: string, state: RawState): Promise<Result<void, Error>>; | ||
/** | ||
@@ -50,3 +49,3 @@ * Background queued set | ||
*/ | ||
trySet(cacheKey: string, state: Nullable<RawState>): Ok<void>; | ||
trySet(cacheKey: string, state: RawState): Ok<void>; | ||
tryDelete(cacheKey: string): Promise<Result<void, Error>>; | ||
@@ -53,0 +52,0 @@ } |
@@ -1,2 +0,1 @@ | ||
import { Nullable } from '@hazae41/option'; | ||
import { Result } from '@hazae41/result'; | ||
@@ -51,4 +50,4 @@ import { Encoder, Bicoder } from '../../coders/coder.js'; | ||
collect(): void; | ||
tryGet(cacheKey: string): Promise<Result<Nullable<RawState>, Error>>; | ||
trySet(cacheKey: string, state: Nullable<RawState>): Promise<Result<void, Error>>; | ||
tryGet(cacheKey: string): Promise<Result<RawState, Error>>; | ||
trySet(cacheKey: string, state: RawState): Promise<Result<void, Error>>; | ||
tryDelete(cacheKey: string): Promise<Result<void, Error>>; | ||
@@ -55,0 +54,0 @@ } |
@@ -1,4 +0,2 @@ | ||
import { Nullable } from '@hazae41/option'; | ||
import { Result } from '@hazae41/result'; | ||
import { CustomEventTarget } from '../../libs/ortho/ortho.js'; | ||
import { Promiseable } from '../../libs/promises/promises.js'; | ||
@@ -8,3 +6,2 @@ import { RawState } from '../types/state.js'; | ||
interface Storage { | ||
readonly onState?: CustomEventTarget<RawState>; | ||
/** | ||
@@ -16,3 +13,3 @@ * Get the data from the given key | ||
*/ | ||
tryGet?(cacheKey: string): Promiseable<Result<Nullable<RawState>, Error>>; | ||
tryGet?(cacheKey: string): Promiseable<Result<RawState, Error>>; | ||
/** | ||
@@ -25,5 +22,5 @@ * Set the given data to the given key | ||
*/ | ||
trySet?(cacheKey: string, value: Nullable<RawState>): Promiseable<Result<void, Error>>; | ||
trySet?(cacheKey: string, value: RawState): Promiseable<Result<void, Error>>; | ||
} | ||
export type { Storage }; |
import { DataInit, Data } from '../fetched/data.js'; | ||
import { FailInit, Fail } from '../fetched/fail.js'; | ||
type RawState<D = unknown, E = unknown> = RawState1<D, E> | RawState2<D, E>; | ||
type RawState<D = unknown, E = unknown> = RawState1<D, E> | RawState2<D, E> | null | undefined; | ||
interface RawState1<D = unknown, F = unknown> { | ||
@@ -6,0 +6,0 @@ version?: undefined; |
{ | ||
"type": "module", | ||
"name": "@hazae41/glacier", | ||
"version": "2.0.0-104", | ||
"version": "2.0.0-105", | ||
"author": "hazae41", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
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
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
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
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
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
636293
6472