chizu 0.2.72 → 0.4.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.
@@ -1,77 +0,0 @@
1
- import { Filter, CacheId, ChanneledCacheId } from '../types/index.ts';
2
- export type { CacheId, ChanneledCacheId };
3
- /**
4
- * Creates a typed cache entry identifier for use with `context.actions.cacheable`
5
- * and `context.actions.invalidate`.
6
- *
7
- * Each call produces a unique identity. The first type parameter `T` binds the
8
- * entry to a specific value type, ensuring that `cacheable` callbacks return the
9
- * correct type.
10
- *
11
- * When called with only `T`, the entry is unchanneled — a single cache slot.
12
- * When called with `T` and `C`, the entry is channeled — independent cache
13
- * slots per channel value.
14
- *
15
- * @template T - The cached value type.
16
- * @template C - The channel type, constrained to `Filter`.
17
- * @returns A cache entry identifier for use with `cacheable` and `invalidate`.
18
- *
19
- * @example
20
- * ```ts
21
- * import { Entry } from "chizu";
22
- *
23
- * class CacheStore {
24
- * // Unchanneled — single cache slot
25
- * static Pairs = Entry<CryptoPair[]>();
26
- *
27
- * // Channeled &mdash; independent slot per UserId
28
- * static User = Entry<User, { UserId: number }>();
29
- * }
30
- *
31
- * // Unchanneled usage
32
- * await context.actions.cacheable(CacheStore.Pairs, 30_000, async () => ...);
33
- *
34
- * // Channeled usage
35
- * await context.actions.cacheable(CacheStore.User({ UserId: 5 }), 60_000, async () => ...);
36
- *
37
- * // Invalidate
38
- * context.actions.invalidate(CacheStore.Pairs);
39
- * context.actions.invalidate(CacheStore.User({ UserId: 5 }));
40
- * ```
41
- */
42
- export declare function Entry<T>(): CacheId<T>;
43
- export declare function Entry<T, C extends Filter>(): CacheId<T, C>;
44
- /**
45
- * Extracts the identity symbol from a plain or channeled cache entry.
46
- */
47
- export declare function getCacheSymbol(entry: CacheId | ChanneledCacheId): symbol;
48
- /**
49
- * Type guard that returns `true` when the entry is a channeled cache identifier.
50
- */
51
- export declare function isChanneledCacheId(entry: CacheId | ChanneledCacheId): entry is ChanneledCacheId;
52
- /**
53
- * Serialises a channel object into a deterministic string key.
54
- * Keys are sorted alphabetically for deterministic output.
55
- * Returns an empty string for unchanneled operations.
56
- */
57
- export declare function serializeChannel(channel?: Filter): string;
58
- /**
59
- * Builds the cache Map key from an entry identifier.
60
- * Combines the symbol description (unique per Entry call) with the
61
- * serialised channel string for channeled entries.
62
- */
63
- export declare function getCacheKey(entry: CacheId | ChanneledCacheId): string;
64
- /**
65
- * Unwraps one layer of `Option` or `Result` from a value.
66
- *
67
- * - `Some(value)` (non-null/undefined) &rarr; `{ ok: true, value }`
68
- * - `None` (null/undefined) &rarr; `{ ok: false }`
69
- * - `Ok(value)` (TAG 0) &rarr; `{ ok: true, value: _0 }`
70
- * - `Error(value)` (TAG 1) &rarr; `{ ok: false }`
71
- */
72
- export declare function unwrap(result: unknown): {
73
- ok: true;
74
- value: unknown;
75
- } | {
76
- ok: false;
77
- };