memorio 4.9.35 → 5.1.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/AGENTS.md +3 -3
- package/README.md +95 -516
- package/SECURITY.md +159 -33
- package/SUMMARY.md +59 -45
- package/adr/001-state-proxy-model.md +95 -0
- package/adr/002-observer-semantics.md +179 -0
- package/adr/003-deep-mutation-semantics.md +128 -0
- package/adr/004-array-mutation-semantics.md +127 -0
- package/adr/005-scheduler-contract.md +148 -0
- package/adr/006-context-isolation.md +91 -0
- package/adr/007-mutation-records.md +117 -0
- package/adr/008-transactions.md +105 -0
- package/adr/009-history-model.md +109 -0
- package/adr/README.md +46 -0
- package/adr/template.md +48 -0
- package/bin/cli.js +68 -0
- package/examples/basic.ts +115 -115
- package/examples/browser-vanilla.html +358 -358
- package/examples/cache.ts +72 -72
- package/examples/cross-platform-guards.ts +57 -57
- package/examples/history.ts +104 -0
- package/examples/idb.ts +109 -109
- package/examples/multi-tenant-context.ts +44 -44
- package/examples/node-server.ts +308 -308
- package/examples/observer.ts +60 -60
- package/examples/platform.ts +115 -115
- package/examples/react-app.tsx +362 -362
- package/examples/react-observer.tsx +63 -63
- package/examples/semantic-memory.ts +60 -60
- package/examples/session-advanced.ts +91 -91
- package/examples/sqlite-batched-writes.ts +57 -57
- package/examples/state-advanced.ts +89 -89
- package/examples/store-advanced.ts +117 -117
- package/examples/sync.ts +90 -0
- package/examples/typed-and-schema.ts +102 -100
- package/examples/useObserver.tsx +140 -141
- package/global.cjs +5733 -0
- package/global.d.ts +8 -0
- package/global.js +5667 -0
- package/index.cjs +2202 -1041
- package/index.d.ts +2 -0
- package/index.js +2178 -1040
- package/llms.txt +113 -8
- package/markdown/AUDIT-REPORT.md +134 -0
- package/markdown/CACHE.md +191 -0
- package/markdown/DEVTOOLS.md +128 -0
- package/markdown/DISPATCH.md +176 -0
- package/markdown/HISTORY.md +198 -0
- package/markdown/IDB.md +177 -0
- package/markdown/IMPORT.md +152 -0
- package/markdown/INSPECT.md +122 -0
- package/markdown/LOGGER.md +153 -0
- package/markdown/MEMORY-ATTACHMENT.md +95 -0
- package/markdown/MEMORY.md +161 -0
- package/markdown/OBSERVER.md +208 -0
- package/markdown/PLATFORM.md +277 -0
- package/markdown/REDUX.md +54 -0
- package/markdown/SCHEMA.md +175 -0
- package/markdown/SESSION.md +164 -0
- package/markdown/SQLITE.md +189 -0
- package/markdown/STATE.md +159 -0
- package/markdown/STORE.md +170 -0
- package/markdown/SYNC.md +318 -0
- package/markdown/TYPED.md +164 -0
- package/markdown/USEOBSERVER.md +256 -0
- package/modules/redux.cjs +701 -177
- package/modules/redux.cjs.map +1 -1
- package/modules/redux.js +701 -177
- package/modules/redux.js.map +1 -1
- package/package.json +26 -4
- package/types/broadcast.d.ts +61 -0
- package/types/computed.d.ts +96 -0
- package/types/encryption.d.ts +129 -0
- package/types/env.d.ts +19 -9
- package/types/exports.d.ts +29 -0
- package/types/history.d.ts +13 -1
- package/types/memorio.d.ts +25 -6
- package/types/mutation.d.ts +75 -0
- package/types/security.d.ts +67 -0
- package/types/session.d.ts +23 -5
- package/types/store.d.ts +19 -3
- package/vsix/memorio.vsix +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
memorio
|
|
3
|
+
Copyright (c) 2025 Dario Passariello <dariopassariello@gmail.com>
|
|
4
|
+
Licensed under MIT License, see
|
|
5
|
+
dario.passariello.ca
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
type Permission = 'read' | 'write' | 'delete' | 'admin'
|
|
9
|
+
|
|
10
|
+
interface AccessRule {
|
|
11
|
+
pattern: string | ((key: string, userId?: string) => boolean)
|
|
12
|
+
permissions: Permission[]
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type AccessRulesMap = Map<string | ((key: string, userId?: string) => boolean), Permission[]>
|
|
16
|
+
|
|
17
|
+
interface AuditEntry {
|
|
18
|
+
timestamp: number
|
|
19
|
+
action: 'set' | 'get' | 'delete' | 'hydrate' | 'remove' | 'clearAll'
|
|
20
|
+
key: string
|
|
21
|
+
userId?: string
|
|
22
|
+
success: boolean
|
|
23
|
+
error?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface ConsentRecord {
|
|
27
|
+
id: string
|
|
28
|
+
purpose: string
|
|
29
|
+
granted: boolean
|
|
30
|
+
timestamp: number
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
type ConsentsMap = Map<string, ConsentRecord[]>
|
|
34
|
+
|
|
35
|
+
interface _security {
|
|
36
|
+
safeRandomUUID: () => string
|
|
37
|
+
safeRegexTest: (pattern: string, key: string) => boolean
|
|
38
|
+
|
|
39
|
+
addAccessRule: (rules: AccessRulesMap, pattern: string | ((key: string, userId?: string) => boolean), perms: Permission[]) => AccessRulesMap
|
|
40
|
+
hasPermission: (rules: AccessRulesMap, key: string, action: Permission, userId?: string) => boolean
|
|
41
|
+
|
|
42
|
+
isAuditActive: () => boolean
|
|
43
|
+
setAuditLogger: (logger: (entry: AuditEntry) => void) => void
|
|
44
|
+
logAudit: (entry: Partial<AuditEntry>) => void
|
|
45
|
+
|
|
46
|
+
sanitizeValue: (value: unknown) => unknown
|
|
47
|
+
validateKey: (key: string) => boolean
|
|
48
|
+
|
|
49
|
+
recordConsent: (consents: ConsentsMap, userId: string, purpose: string, granted: boolean) => ConsentRecord
|
|
50
|
+
hasConsent: (consents: ConsentsMap, userId: string, purpose: string) => boolean
|
|
51
|
+
revokeConsent: (consents: ConsentsMap, userId: string, purpose: string) => ConsentRecord | null
|
|
52
|
+
getConsents: (consents: ConsentsMap, userId: string) => ConsentRecord[]
|
|
53
|
+
exportUserData: (consents: ConsentsMap, userId: string) => { userId: string; exportedAt: number; consents: ConsentRecord[] }
|
|
54
|
+
deleteUserData: (consents: ConsentsMap, userId: string) => { success: boolean; deletedConsents: number }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare var security: _security
|
|
58
|
+
type security = _security
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
Permission,
|
|
62
|
+
AccessRule,
|
|
63
|
+
AccessRulesMap,
|
|
64
|
+
AuditEntry,
|
|
65
|
+
ConsentRecord,
|
|
66
|
+
ConsentsMap
|
|
67
|
+
}
|
package/types/session.d.ts
CHANGED
|
@@ -10,24 +10,42 @@ interface _session {
|
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
12
|
* session.set("test","example") // or Array, Object, Number, Functions...
|
|
13
|
+
* session.set("test", value, { encrypt: key }) // encrypt at rest
|
|
13
14
|
*
|
|
14
15
|
* @since memorio 0.0.1
|
|
15
16
|
* @param name The String as name to define the session.
|
|
16
17
|
* @param param The information taht you want to session (Any).
|
|
17
|
-
* @
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
* @param opts Optional { encrypt: key } to encrypt before storage.
|
|
19
|
+
* @return boolean | Promise<boolean>
|
|
20
|
+
*/
|
|
21
|
+
set: (name: string, value: any, opts?: { encrypt?: any }) => boolean | Promise<boolean>
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Configure session-wide behavior.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* session.config({ encryptionKey: derivedKey })
|
|
28
|
+
* session.config({ onError: (err, ctx) => console.error(err, ctx) })
|
|
29
|
+
* session.config({ maxObjectSize: 5 * 1024 * 1024 })
|
|
30
|
+
* session.config({ maxTotalSize: 50 * 1024 * 1024 })
|
|
31
|
+
*
|
|
32
|
+
* @since memorio 5.0
|
|
33
|
+
* @param opts { encryptionKey, onError, maxObjectSize, maxTotalSize }
|
|
34
|
+
*/
|
|
35
|
+
config: (opts: { encryptionKey?: any; onError?: (err: unknown, ctx: { operation: string }) => void; maxObjectSize?: number; maxTotalSize?: number }) => void
|
|
20
36
|
|
|
21
37
|
/**
|
|
22
38
|
* Have back the data from a session.
|
|
23
39
|
*
|
|
24
40
|
* @example
|
|
25
41
|
* session.get("test")
|
|
42
|
+
* session.get("test", { decrypt: key }) // decrypt an encrypted envelope
|
|
26
43
|
*
|
|
27
44
|
* @since memorio 0.0.1
|
|
28
45
|
* @param name The String as name to define the session.
|
|
29
|
-
|
|
30
|
-
|
|
46
|
+
* @param opts Optional { decrypt: key } to decrypt an encrypted envelope.
|
|
47
|
+
*/
|
|
48
|
+
get: (name: string, opts?: { decrypt?: any }) => any
|
|
31
49
|
|
|
32
50
|
/**
|
|
33
51
|
* Delete an existing session:
|
package/types/store.d.ts
CHANGED
|
@@ -14,18 +14,34 @@ interface _store {
|
|
|
14
14
|
* @param value The information you want to store. Functions are blocked for security.
|
|
15
15
|
* @return void
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
set: (name: string, value: any, opts?: { encrypt?: any }) => boolean | Promise<boolean>
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Configure store-wide behavior.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* store.config({ encryptionKey: derivedKey })
|
|
24
|
+
* store.config({ onError: (err, ctx) => console.error(err, ctx) })
|
|
25
|
+
* store.config({ maxObjectSize: 5 * 1024 * 1024 })
|
|
26
|
+
* store.config({ maxTotalSize: 50 * 1024 * 1024 })
|
|
27
|
+
*
|
|
28
|
+
* @since memorio 5.0
|
|
29
|
+
* @param opts { encryptionKey, onError, maxObjectSize, maxTotalSize }
|
|
30
|
+
*/
|
|
31
|
+
config: (opts: { encryptionKey?: any; onError?: (err: unknown, ctx: { operation: string }) => void; maxObjectSize?: number; maxTotalSize?: number }) => void
|
|
18
32
|
|
|
19
33
|
/**
|
|
20
|
-
*
|
|
34
|
+
* Gets a value from storage.
|
|
21
35
|
*
|
|
22
36
|
* @example
|
|
23
37
|
* store.get("test")
|
|
38
|
+
* store.get("test", { decrypt: key }) // decrypt an encrypted envelope
|
|
24
39
|
*
|
|
25
40
|
* @since memorio 0.0.1
|
|
26
41
|
* @param name The String as name to define the store.
|
|
42
|
+
* @param opts Optional { decrypt: key } to decrypt an encrypted envelope.
|
|
27
43
|
*/
|
|
28
|
-
get: (name: string) => any
|
|
44
|
+
get: (name: string, opts?: { decrypt?: any }) => any
|
|
29
45
|
|
|
30
46
|
/**
|
|
31
47
|
* Delete an existing store:
|
|
Binary file
|