memorio 4.9.10 → 4.9.31
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/AGENTS.md +126 -126
- package/README.md +241 -100
- package/examples/basic.ts +1 -1
- package/examples/cross-platform-guards.ts +57 -57
- package/examples/multi-tenant-context.ts +44 -44
- package/examples/react-observer.tsx +63 -63
- package/examples/semantic-memory.ts +60 -60
- package/examples/session-advanced.ts +1 -1
- package/examples/sqlite-batched-writes.ts +57 -57
- package/examples/store-advanced.ts +1 -1
- package/index.cjs +74 -44
- package/index.js +74 -44
- package/llms.txt +13 -5
- package/modules/redux.cjs +2677 -0
- package/modules/redux.cjs.map +1 -0
- package/modules/redux.d.ts +119 -0
- package/modules/redux.js +2669 -0
- package/modules/redux.js.map +1 -0
- package/package.json +9 -3
- package/types/memorio.d.ts +1 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MEMORIO REDUX ADAPTER TYPES (hand-written, mirrors modules/redux.ts)
|
|
3
|
+
*
|
|
4
|
+
* `memorio/redux` is an OPTIONAL integration layer. It does not import `redux`
|
|
5
|
+
* or React; Redux-like stores are accepted by structural typing, so `redux`
|
|
6
|
+
* is never a dependency of Memorio (#4, #13).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { MemoryEntry, MemoryType, MemoryScope } from '../types/memory'
|
|
10
|
+
|
|
11
|
+
export interface MemorioReduxAction {
|
|
12
|
+
type: unknown
|
|
13
|
+
[key: string]: unknown
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface MemorioReduxStoreLike<
|
|
17
|
+
S = unknown,
|
|
18
|
+
A extends MemorioReduxAction = MemorioReduxAction
|
|
19
|
+
> {
|
|
20
|
+
getState(): S
|
|
21
|
+
subscribe(listener: () => void): () => void
|
|
22
|
+
dispatch(action: A): unknown
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type MemorioReduxMiddleware<
|
|
26
|
+
S = unknown,
|
|
27
|
+
A extends MemorioReduxAction = MemorioReduxAction
|
|
28
|
+
> = (
|
|
29
|
+
api: { getState: () => S; dispatch: (action: A) => unknown }
|
|
30
|
+
) => (next: (action: A) => any) => (action: A) => any
|
|
31
|
+
|
|
32
|
+
export interface MemorioMapping<S = any> {
|
|
33
|
+
selector: (state: S) => unknown
|
|
34
|
+
type?: MemoryType
|
|
35
|
+
confidence?: number
|
|
36
|
+
scope?: MemoryScope
|
|
37
|
+
ttl?: number | null
|
|
38
|
+
tags?: string | string[]
|
|
39
|
+
source?: string
|
|
40
|
+
ignoreActions?: unknown[]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface MemorioReduxOptions<
|
|
44
|
+
S = any,
|
|
45
|
+
A extends MemorioReduxAction = MemorioReduxAction
|
|
46
|
+
> {
|
|
47
|
+
mappings?: Record<string, MemorioMapping<S> | ((state: S) => unknown)>
|
|
48
|
+
whitelist?: unknown[]
|
|
49
|
+
blacklist?: unknown[]
|
|
50
|
+
failSoft?: boolean
|
|
51
|
+
onError?: (err: unknown, context: 'persist' | 'hydrate') => void
|
|
52
|
+
debug?: boolean
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface MemorioMiddlewareHandle<
|
|
56
|
+
S = unknown,
|
|
57
|
+
A extends MemorioReduxAction = MemorioReduxAction
|
|
58
|
+
> {
|
|
59
|
+
middleware: MemorioReduxMiddleware<S, A>
|
|
60
|
+
cache: Record<string, unknown>
|
|
61
|
+
setHydrating: (v: boolean) => void
|
|
62
|
+
flush: () => Promise<void>
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface MemorioReduxBridge<
|
|
66
|
+
S = unknown,
|
|
67
|
+
A extends MemorioReduxAction = MemorioReduxAction
|
|
68
|
+
> {
|
|
69
|
+
readonly middleware: MemorioReduxMiddleware<S, A>
|
|
70
|
+
hydrate: (
|
|
71
|
+
store: MemorioReduxStoreLike<S, A>,
|
|
72
|
+
opts?: { onHydration?: (values: Record<string, unknown>) => void }
|
|
73
|
+
) => Promise<{ values: Record<string, unknown>; ok: boolean }>
|
|
74
|
+
flush: () => Promise<void>
|
|
75
|
+
disconnect: () => void
|
|
76
|
+
readonly cache: Record<string, unknown>
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface HydrateOptions<S>
|
|
80
|
+
extends Pick<MemorioReduxOptions<S>, 'failSoft' | 'onError' | 'debug'> {
|
|
81
|
+
onHydration?: (values: Record<string, unknown>) => void
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface HydrationResult {
|
|
85
|
+
values: Record<string, unknown>
|
|
86
|
+
ok: boolean
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface HydrateBridge<S> {
|
|
90
|
+
cache: Record<string, unknown>
|
|
91
|
+
setHydrating: (v: boolean) => void
|
|
92
|
+
getState: () => S
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export declare function createMemorioMiddleware<
|
|
96
|
+
S = any,
|
|
97
|
+
A extends MemorioReduxAction = MemorioReduxAction
|
|
98
|
+
>(opts?: MemorioReduxOptions<S, A>): MemorioMiddlewareHandle<S, A>
|
|
99
|
+
|
|
100
|
+
export declare function hydrateMemorio<S>(
|
|
101
|
+
mappings: Record<string, MemorioMapping<S> | ((state: S) => unknown)>,
|
|
102
|
+
opts?: HydrateOptions<S>,
|
|
103
|
+
bridge?: HydrateBridge<S>
|
|
104
|
+
): Promise<HydrationResult>
|
|
105
|
+
|
|
106
|
+
export declare function createMemorioReduxBridge<
|
|
107
|
+
S = any,
|
|
108
|
+
A extends MemorioReduxAction = MemorioReduxAction
|
|
109
|
+
>(opts?: MemorioReduxOptions<S, A>): MemorioReduxBridge<S, A>
|
|
110
|
+
|
|
111
|
+
export declare function normalizeMappings<S>(mappings: MemorioReduxOptions<S>['mappings']): Record<string, MemorioMapping<S>>
|
|
112
|
+
export declare function selectValues<S>(state: S, mappings: Record<string, MemorioMapping<S>>): Record<string, unknown>
|
|
113
|
+
export declare function deepEqual(a: unknown, b: unknown): boolean
|
|
114
|
+
export declare function shouldIgnoreAction(action: MemorioReduxAction, opts: MemorioReduxOptions, mapping?: MemorioMapping): boolean
|
|
115
|
+
export declare function actionType(action: MemorioReduxAction): unknown
|
|
116
|
+
|
|
117
|
+
export { type MemoryEntry, type MemoryType, type MemoryScope }
|
|
118
|
+
|
|
119
|
+
export default createMemorioReduxBridge
|