@biglogic/rgs 3.7.3 → 3.7.6

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.
Files changed (50) hide show
  1. package/COPYRIGHT.md +4 -0
  2. package/FUNDING.yml +12 -0
  3. package/SECURITY.md +13 -0
  4. package/advanced.d.ts +9 -0
  5. package/core/advanced.d.ts +5 -0
  6. package/core/async.d.ts +8 -0
  7. package/core/env.d.ts +4 -0
  8. package/core/hooks.d.ts +17 -0
  9. package/core/minimal.d.ts +8 -0
  10. package/core/minimal.js +19 -0
  11. package/core/persistence.d.ts +23 -0
  12. package/core/plugins.d.ts +8 -0
  13. package/core/reactivity.d.ts +19 -0
  14. package/core/security.d.ts +56 -0
  15. package/core/store.d.ts +7 -0
  16. package/core/sync.d.ts +76 -0
  17. package/core/types.d.ts +164 -0
  18. package/core/utils.d.ts +2 -0
  19. package/docs/README.md +470 -0
  20. package/docs/SUMMARY.md +64 -0
  21. package/docs/_config.yml +1 -0
  22. package/docs/api.md +381 -0
  23. package/docs/chapters/01-philosophy.md +54 -0
  24. package/docs/chapters/02-getting-started.md +68 -0
  25. package/docs/chapters/03-the-magnetar-way.md +69 -0
  26. package/docs/chapters/04-persistence-and-safety.md +125 -0
  27. package/docs/chapters/05-plugin-sdk.md +290 -0
  28. package/docs/chapters/05-plugins-and-extensibility.md +190 -0
  29. package/docs/chapters/06-case-studies.md +69 -0
  30. package/docs/chapters/07-faq.md +53 -0
  31. package/docs/chapters/08-migration-guide.md +284 -0
  32. package/docs/chapters/09-security-architecture.md +50 -0
  33. package/docs/chapters/10-local-first-sync.md +146 -0
  34. package/docs/qa.md +47 -0
  35. package/index.d.ts +41 -0
  36. package/index.js +2100 -0
  37. package/package.json +74 -91
  38. package/plugins/index.d.ts +15 -0
  39. package/plugins/official/analytics.plugin.d.ts +9 -0
  40. package/plugins/official/cloud-sync.plugin.d.ts +22 -0
  41. package/plugins/official/debug.plugin.d.ts +2 -0
  42. package/plugins/official/devtools.plugin.d.ts +4 -0
  43. package/plugins/official/guard.plugin.d.ts +2 -0
  44. package/plugins/official/immer.plugin.d.ts +2 -0
  45. package/plugins/official/indexeddb.plugin.d.ts +7 -0
  46. package/plugins/official/schema.plugin.d.ts +2 -0
  47. package/plugins/official/snapshot.plugin.d.ts +2 -0
  48. package/plugins/official/sync.plugin.d.ts +4 -0
  49. package/plugins/official/undo-redo.plugin.d.ts +4 -0
  50. package/rgs-extension.vsix +0 -0
package/COPYRIGHT.md ADDED
@@ -0,0 +1,4 @@
1
+ # Copyright
2
+
3
+ Copyright (c), Dario Passariello. All rights reserved.
4
+ <https://dario.passariello.ca>
package/FUNDING.yml ADDED
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: passariello
4
+ patreon: passariello
5
+ ko_fi: passariello
6
+ liberapay: passariello
7
+ issuehunt: passariello
8
+ custom:
9
+ [
10
+ "https://dario.passariello.ca",
11
+ "https://www.indiegogo.com/individuals/28513718",
12
+ ]
package/SECURITY.md ADDED
@@ -0,0 +1,13 @@
1
+ # Security
2
+
3
+ Reactive Global State (RGS) implements enterprise-grade security including AES-256-GCM encryption, RBAC, and internal XSS sanitization as a secondary defense layer.
4
+
5
+ ## Reporting a Vulnerability
6
+
7
+ Please email [@passariello](https://github.com/passariello) or see <https://dario.passariello.ca/contact/> if you have a potential security vulnerability to report.
8
+
9
+ ## Recent Hardening
10
+
11
+ - Improved XSS sanitization patterns to block `data:`, `vbscript:`, and complex HTML tag combinations.
12
+ - Implemented removal of HTML entity obfuscation.
13
+ - Enhanced deep cloning to support `Map`/`Set` and circular references.
package/advanced.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { createStore, StorageAdapters } from "./core/store";
2
+ import type { IStore, StoreConfig, PersistOptions, CustomStorage } from "./core/types";
3
+ import * as Security from "./core/security";
4
+ export declare const createStoreWithStorage: <S extends Record<string, unknown>>(storage: CustomStorage, config?: StoreConfig<S>) => IStore<S>;
5
+ export declare const createMemoryStore: <S extends Record<string, unknown>>(config?: StoreConfig<S>) => IStore<S>;
6
+ export declare const createSessionStore: <S extends Record<string, unknown>>(config?: StoreConfig<S>) => IStore<S> | null;
7
+ export { createStore, StorageAdapters, Security };
8
+ export type { IStore, StoreConfig, PersistOptions, CustomStorage };
9
+ export type { EncryptionKey, AuditEntry, Permission, AccessRule, ConsentRecord } from "./core/security";
@@ -0,0 +1,5 @@
1
+ export { createAsyncStore } from "./async";
2
+ export { StorageAdapters } from "./store";
3
+ export { syncPlugin as SyncPlugin } from "../plugins/official/sync.plugin";
4
+ export { analyticsPlugin as AnalyticsPlugin } from "../plugins/official/analytics.plugin";
5
+ export type { AsyncState, Middleware, IPlugin, PluginContext } from "./types";
@@ -0,0 +1,8 @@
1
+ import type { IStore, AsyncState } from "./types";
2
+ export declare const createAsyncStore: <T>(resolver: () => Promise<T>, options?: {
3
+ key?: string;
4
+ persist?: boolean;
5
+ store?: IStore<Record<string, AsyncState<T>>>;
6
+ }) => IStore<Record<string, AsyncState<T>>> & {
7
+ execute: () => Promise<void>;
8
+ };
package/core/env.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ export declare const isProduction: () => boolean;
2
+ export declare const isDevelopment: () => boolean;
3
+ export declare const isBrowser: () => boolean;
4
+ export declare const isServer: () => boolean;
@@ -0,0 +1,17 @@
1
+ import type { IStore, StoreConfig, PersistOptions, StateUpdater } from "./types";
2
+ import { SyncEngine, SyncConfig, SyncState } from "./sync";
3
+ export declare const initState: <S extends Record<string, unknown>>(config?: StoreConfig<S>) => IStore<S>;
4
+ export declare const destroyState: () => void;
5
+ export declare const useIsStoreReady: (store?: IStore<Record<string, unknown>>) => boolean;
6
+ export declare const getStore: () => IStore<Record<string, unknown>> | null;
7
+ export declare function useStore<T, S extends Record<string, unknown> = Record<string, unknown>>(selector: (state: S) => T, store?: IStore<S>): T;
8
+ export declare function useStore<T = unknown, S extends Record<string, unknown> = Record<string, unknown>>(key: string, store?: IStore<S>): readonly [T | undefined, (val: T | StateUpdater<T>, options?: PersistOptions) => boolean];
9
+ export declare const initSync: (store: IStore<Record<string, unknown>>, config: SyncConfig) => SyncEngine<Record<string, unknown>>;
10
+ export declare const destroySync: (namespace: string) => void;
11
+ export declare function useSyncedState<T = unknown>(key: string, store?: IStore<Record<string, unknown>>): readonly [
12
+ T | undefined,
13
+ (val: T | StateUpdater<T>, options?: PersistOptions) => boolean,
14
+ SyncState
15
+ ];
16
+ export declare const useSyncStatus: () => SyncState;
17
+ export declare const triggerSync: (namespace?: string) => Promise<void>;
@@ -0,0 +1,8 @@
1
+ type Listener = () => void;
2
+ interface Store<T extends Record<string, unknown>> {
3
+ get<K extends keyof T>(key: K): T[K];
4
+ set<K extends keyof T>(key: K, value: T[K]): void;
5
+ subscribe(listener: Listener): () => void;
6
+ }
7
+ declare const createStore: <T extends Record<string, unknown>>(initialState: T) => Store<T>;
8
+ export { createStore, type Store };
@@ -0,0 +1,19 @@
1
+ // core/minimal.ts
2
+ var createStore = (initialState) => {
3
+ let state = { ...initialState };
4
+ const listeners = /* @__PURE__ */ new Set();
5
+ return {
6
+ get: (key) => state[key],
7
+ set: (key, value) => {
8
+ state = { ...state, [key]: value };
9
+ listeners.forEach((l) => l());
10
+ },
11
+ subscribe: (listener) => {
12
+ listeners.add(listener);
13
+ return () => listeners.delete(listener);
14
+ }
15
+ };
16
+ };
17
+ export {
18
+ createStore
19
+ };
@@ -0,0 +1,23 @@
1
+ import { StorageAdapters } from "./store";
2
+ import * as Security from "./security";
3
+ import type { StoreConfig, PersistOptions } from "./types";
4
+ export interface PersistenceContext {
5
+ store: Map<string, unknown>;
6
+ versions: Map<string, number>;
7
+ sizes: Map<string, number>;
8
+ totalSize: number;
9
+ storage: ReturnType<typeof StorageAdapters.local>;
10
+ config: StoreConfig<Record<string, unknown>>;
11
+ diskQueue: Map<string, {
12
+ value: unknown;
13
+ options: PersistOptions;
14
+ }>;
15
+ encryptionKey: Security.EncryptionKey | null;
16
+ audit: (action: 'set' | 'get' | 'delete' | 'hydrate', key: string, success: boolean, error?: string) => void;
17
+ onError?: (error: Error, metadata?: Record<string, unknown>) => void;
18
+ silent: boolean;
19
+ debounceTime: number;
20
+ currentVersion: number;
21
+ }
22
+ export declare const flushDisk: (ctx: PersistenceContext) => Promise<void>;
23
+ export declare const hydrateStore: (ctx: PersistenceContext, calculateSize: (val: unknown) => number, emit: () => void) => Promise<void>;
@@ -0,0 +1,8 @@
1
+ import { IStore, PluginHookName, PluginContext, IPlugin } from "./types";
2
+ export interface PluginManagerContext<S extends Record<string, unknown>> {
3
+ plugins: Map<string, IPlugin<S>>;
4
+ onError?: (error: Error, metadata?: Record<string, unknown>) => void;
5
+ silent: boolean;
6
+ }
7
+ export declare const runHook: <S extends Record<string, unknown>>(ctx: PluginManagerContext<S>, name: PluginHookName, hookContext: PluginContext<S>) => void;
8
+ export declare const installPlugin: <S extends Record<string, unknown>>(ctx: PluginManagerContext<S>, plugin: IPlugin<S>, storeInstance: IStore<S>) => void;
@@ -0,0 +1,19 @@
1
+ import { ComputedSelector, WatcherCallback, StoreSubscriber } from "./types";
2
+ export interface ReactivityContext {
3
+ computed: Map<string, {
4
+ selector: ComputedSelector<unknown>;
5
+ lastValue: unknown;
6
+ deps: Set<string>;
7
+ }>;
8
+ computedDeps: Map<string, Set<string>>;
9
+ watchers: Map<string, Set<WatcherCallback<unknown>>>;
10
+ listeners: Set<StoreSubscriber>;
11
+ keyListeners: Map<string, Set<StoreSubscriber>>;
12
+ versions: Map<string, number>;
13
+ storeInstance: unknown;
14
+ immer: boolean;
15
+ onError?: (error: Error, metadata?: Record<string, unknown>) => void;
16
+ silent: boolean;
17
+ }
18
+ export declare const updateComputed: (ctx: ReactivityContext, key: string, emit: (k?: string) => void) => void;
19
+ export declare const emitChange: (ctx: ReactivityContext, changedKey?: string, isTransaction?: boolean, setPendingEmit?: (v: boolean) => void, emit?: (k?: string) => void) => void;
@@ -0,0 +1,56 @@
1
+ export declare const isCryptoAvailable: boolean;
2
+ export declare const deriveKeyFromPassword: (password: string, salt: Uint8Array, iterations?: number) => Promise<EncryptionKey>;
3
+ export declare const generateSalt: (length?: number) => Uint8Array;
4
+ export interface EncryptionKey {
5
+ key: CryptoKey;
6
+ iv: Uint8Array;
7
+ }
8
+ export declare const generateEncryptionKey: () => Promise<EncryptionKey>;
9
+ export declare const exportKey: (encryptionKey: EncryptionKey) => Promise<{
10
+ key: string;
11
+ iv: string;
12
+ }>;
13
+ export declare const importKey: (keyData: string, ivData: string) => Promise<EncryptionKey>;
14
+ export declare const encrypt: (data: unknown, encryptionKey: EncryptionKey) => Promise<string>;
15
+ export declare const decrypt: <T>(encryptedData: string, encryptionKey: EncryptionKey) => Promise<T>;
16
+ export interface AuditEntry {
17
+ timestamp: number;
18
+ action: 'set' | 'get' | 'delete' | 'hydrate';
19
+ key: string;
20
+ userId?: string;
21
+ success: boolean;
22
+ error?: string;
23
+ }
24
+ export declare const setAuditLogger: (logger: (entry: AuditEntry) => void) => void;
25
+ export declare const isAuditActive: () => boolean;
26
+ export declare const logAudit: (entry: AuditEntry) => void;
27
+ export type Permission = 'read' | 'write' | 'delete' | 'admin';
28
+ export interface AccessRule {
29
+ pattern: string | ((key: string, userId?: string) => boolean);
30
+ permissions: Permission[];
31
+ }
32
+ export type AccessRulesMap = Map<string | ((key: string, userId?: string) => boolean), Permission[]>;
33
+ export declare const addAccessRule: (rules: AccessRulesMap, pattern: string | ((key: string, userId?: string) => boolean), perms: Permission[]) => void;
34
+ export declare const hasPermission: (rules: AccessRulesMap, key: string, action: Permission, _userId?: string) => boolean;
35
+ export declare const sanitizeValue: (value: unknown) => unknown;
36
+ export declare const validateKey: (key: string) => boolean;
37
+ export interface ConsentRecord {
38
+ id: string;
39
+ purpose: string;
40
+ granted: boolean;
41
+ timestamp: number;
42
+ }
43
+ export type ConsentsMap = Map<string, ConsentRecord[]>;
44
+ export declare const recordConsent: (consents: ConsentsMap, userId: string, purpose: string, granted: boolean) => ConsentRecord;
45
+ export declare const hasConsent: (consents: ConsentsMap, userId: string, purpose: string) => boolean;
46
+ export declare const revokeConsent: (consents: ConsentsMap, userId: string, purpose: string) => ConsentRecord | null;
47
+ export declare const getConsents: (consents: ConsentsMap, userId: string) => ConsentRecord[];
48
+ export declare const exportUserData: (consents: ConsentsMap, userId: string) => {
49
+ userId: string;
50
+ exportedAt: number;
51
+ consents: ConsentRecord[];
52
+ };
53
+ export declare const deleteUserData: (consents: ConsentsMap, userId: string) => {
54
+ success: boolean;
55
+ deletedConsents: number;
56
+ };
@@ -0,0 +1,7 @@
1
+ import type { IStore, StoreConfig, CustomStorage } from './types';
2
+ export declare const StorageAdapters: {
3
+ local: () => CustomStorage | null;
4
+ session: () => CustomStorage | null;
5
+ memory: () => CustomStorage;
6
+ };
7
+ export declare const createStore: <S extends Record<string, unknown> = Record<string, unknown>>(config?: StoreConfig<S>) => IStore<S>;
package/core/sync.d.ts ADDED
@@ -0,0 +1,76 @@
1
+ import { IStore } from "./types";
2
+ export type SyncStrategy = 'last-write-wins' | 'merge' | 'crdt' | 'server-wins' | 'client-wins';
3
+ export interface SyncConfig {
4
+ endpoint: string;
5
+ authToken?: string | (() => string | null);
6
+ strategy?: SyncStrategy;
7
+ autoSyncInterval?: number;
8
+ syncOnReconnect?: boolean;
9
+ debounceTime?: number;
10
+ fetch?: typeof fetch;
11
+ onSync?: (result: SyncResult) => void;
12
+ onConflict?: (conflict: ConflictInfo) => ConflictResolution;
13
+ maxRetries?: number;
14
+ }
15
+ export interface SyncResult {
16
+ success: boolean;
17
+ syncedKeys: string[];
18
+ conflicts: ConflictInfo[];
19
+ errors: string[];
20
+ timestamp: number;
21
+ duration: number;
22
+ }
23
+ export interface ConflictInfo {
24
+ key: string;
25
+ localValue: unknown;
26
+ remoteValue: unknown;
27
+ localVersion: number;
28
+ remoteVersion: number;
29
+ timestamp: number;
30
+ }
31
+ export type ConflictResolution = {
32
+ action: 'accept-local';
33
+ } | {
34
+ action: 'accept-remote';
35
+ } | {
36
+ action: 'merge';
37
+ value: unknown;
38
+ } | {
39
+ action: 'discard';
40
+ };
41
+ export interface SyncState {
42
+ isOnline: boolean;
43
+ isSyncing: boolean;
44
+ lastSyncTimestamp: number | null;
45
+ pendingChanges: number;
46
+ conflicts: number;
47
+ }
48
+ export declare class SyncEngine<S extends Record<string, unknown> = Record<string, unknown>> {
49
+ private store;
50
+ private config;
51
+ private pendingQueue;
52
+ private remoteVersions;
53
+ private syncTimer;
54
+ private onlineStatusListeners;
55
+ private syncStateListeners;
56
+ private _isOnline;
57
+ private _isSyncing;
58
+ constructor(store: IStore<S>, config: SyncConfig);
59
+ private _getAuthToken;
60
+ private _setupOnlineListener;
61
+ private _setupStoreListener;
62
+ private _startAutoSync;
63
+ private _notifyOnlineChange;
64
+ private _notifyStateChange;
65
+ queueChange(key: string, value: unknown): void;
66
+ sync(): Promise<SyncResult>;
67
+ private _fetchRemoteVersions;
68
+ private _pushChange;
69
+ private _resolveConflict;
70
+ getState(): SyncState;
71
+ onOnlineChange(callback: (online: boolean) => void): () => void;
72
+ onStateChange(callback: (state: SyncState) => void): () => void;
73
+ flush(): Promise<SyncResult>;
74
+ destroy(): void;
75
+ }
76
+ export declare const createSyncEngine: <S extends Record<string, unknown>>(store: IStore<S>, config: SyncConfig) => SyncEngine<S>;
@@ -0,0 +1,164 @@
1
+ import type { EncryptionKey, AuditEntry, Permission, AccessRule } from './security';
2
+ import type { SyncConfig } from './sync';
3
+ export interface PersistOptions {
4
+ persist?: boolean;
5
+ secure?: boolean;
6
+ encoded?: boolean;
7
+ encrypted?: boolean;
8
+ ttl?: number;
9
+ }
10
+ export interface StoreMetadata {
11
+ version: number;
12
+ lastUpdated: number;
13
+ }
14
+ export type StoreSubscriber = () => void;
15
+ export type Middleware<T = unknown> = (key: string, value: T, meta: StoreMetadata) => void;
16
+ export type StateUpdater<T> = (draft: T) => void | T;
17
+ export type ComputedSelector<T> = (get: <V>(key: string) => V | null) => T;
18
+ export type WatcherCallback<T> = (value: T | null) => void;
19
+ export interface PluginMethod<T = unknown> {
20
+ (...args: unknown[]): T;
21
+ }
22
+ export type PluginMethods<T extends Record<string, PluginMethod>> = T;
23
+ export type PluginHookName = 'onInit' | 'onInstall' | 'onSet' | 'onGet' | 'onRemove' | 'onDestroy' | 'onTransaction' | 'onBeforeSet' | 'onAfterSet';
24
+ export interface PluginContext<S extends Record<string, unknown> = Record<string, unknown>> {
25
+ store: IStore<S>;
26
+ key?: string;
27
+ value?: unknown;
28
+ version?: number;
29
+ }
30
+ export interface IPlugin<S extends Record<string, unknown> = Record<string, unknown>> {
31
+ name: string;
32
+ hooks: {
33
+ [K in PluginHookName]?: (context: PluginContext<S>) => void | Promise<void>;
34
+ };
35
+ }
36
+ export declare const createTypedPlugin: <T extends Record<string, PluginMethod>>(name: string, methods: T) => IPlugin & {
37
+ methods: T;
38
+ };
39
+ export interface IStore<S extends Record<string, unknown> = Record<string, unknown>> {
40
+ set<K extends keyof S>(key: K, valOrUp: S[K] | StateUpdater<S[K]>, options?: PersistOptions): boolean;
41
+ get<K extends keyof S>(key: K): S[K] | null;
42
+ set<T = unknown>(key: string, valOrUp: T | StateUpdater<T>, options?: PersistOptions): boolean;
43
+ get<T = unknown>(key: string): T | null;
44
+ compute<T = unknown>(key: string, selector: ComputedSelector<T>): T;
45
+ watch<K extends keyof S>(key: K, callback: WatcherCallback<S[K]>): () => void;
46
+ watch<T = unknown>(key: string, callback: WatcherCallback<T>): () => void;
47
+ remove(key: keyof S | string): boolean;
48
+ delete(key: keyof S | string): boolean;
49
+ deleteAll(): boolean;
50
+ list(): Record<string, unknown>;
51
+ use(m: Middleware): void;
52
+ transaction(fn: () => void): void;
53
+ destroy(): void;
54
+ _addPlugin(plugin: IPlugin<S>): void;
55
+ _removePlugin(name: string): void;
56
+ _subscribe(cb: StoreSubscriber, key?: string): () => void;
57
+ _getVersion(key: string): number;
58
+ _setSilently(key: string, value: unknown): void;
59
+ _registerMethod(pluginName: string, methodName: string, fn: (...args: unknown[]) => unknown): void;
60
+ getSnapshot(): S;
61
+ addAccessRule(pattern: string | ((key: string, userId?: string) => boolean), permissions: Permission[]): void;
62
+ hasPermission(key: string, action: Permission, userId?: string): boolean;
63
+ recordConsent(userId: string, purpose: string, granted: boolean): import('./security').ConsentRecord;
64
+ hasConsent(userId: string, purpose: string): boolean;
65
+ getConsents(userId: string): import('./security').ConsentRecord[];
66
+ revokeConsent(userId: string, purpose: string): import('./security').ConsentRecord | null;
67
+ exportUserData(userId: string): {
68
+ userId: string;
69
+ exportedAt: number;
70
+ consents: import('./security').ConsentRecord[];
71
+ };
72
+ deleteUserData(userId: string): {
73
+ success: boolean;
74
+ deletedConsents: number;
75
+ };
76
+ readonly isReady: boolean;
77
+ readonly namespace: string;
78
+ readonly userId?: string;
79
+ whenReady(): Promise<void>;
80
+ readonly plugins: GStatePlugins;
81
+ }
82
+ export interface GStatePlugins {
83
+ security: {
84
+ addAccessRule: (pattern: string | ((key: string, userId?: string) => boolean), permissions: Permission[]) => void;
85
+ recordConsent: (userId: string, purpose: string, granted: boolean) => import('./security').ConsentRecord;
86
+ hasConsent: (userId: string, purpose: string) => boolean;
87
+ getConsents: (userId: string) => import('./security').ConsentRecord[];
88
+ revokeConsent: (userId: string, purpose: string) => import('./security').ConsentRecord | null;
89
+ exportUserData: (userId: string) => {
90
+ userId: string;
91
+ exportedAt: number;
92
+ consents: import('./security').ConsentRecord[];
93
+ };
94
+ deleteUserData: (userId: string) => {
95
+ success: boolean;
96
+ deletedConsents: number;
97
+ };
98
+ };
99
+ undoRedo: {
100
+ undo: () => boolean;
101
+ redo: () => boolean;
102
+ canUndo: () => boolean;
103
+ canRedo: () => boolean;
104
+ };
105
+ immer: {
106
+ setWithProduce: <T>(key: string, updater: (draft: T) => void) => boolean;
107
+ };
108
+ cloudSync: {
109
+ sync: () => Promise<{
110
+ status: string;
111
+ stats: import('../plugins/official/cloud-sync.plugin').SyncStats;
112
+ }>;
113
+ getStats: () => import('../plugins/official/cloud-sync.plugin').SyncStats;
114
+ };
115
+ sync: {
116
+ flush: () => Promise<import('../core/sync').SyncResult>;
117
+ getState: () => import('../core/sync').SyncState;
118
+ onStateChange: (callback: (state: import('../core/sync').SyncState) => void) => () => void;
119
+ };
120
+ logger: Record<string, never>;
121
+ [key: string]: unknown;
122
+ }
123
+ export interface StoreConfig<S extends Record<string, unknown> = Record<string, unknown>> {
124
+ namespace?: string;
125
+ version?: number;
126
+ silent?: boolean;
127
+ debounceTime?: number;
128
+ storage?: CustomStorage | Storage;
129
+ migrate?: (oldState: Record<string, unknown>, oldVersion: number) => S;
130
+ persistByDefault?: boolean;
131
+ persistence?: boolean;
132
+ persist?: boolean;
133
+ onError?: (error: Error, context: {
134
+ operation: string;
135
+ key?: string;
136
+ }) => void;
137
+ maxObjectSize?: number;
138
+ maxTotalSize?: number;
139
+ encryptionKey?: EncryptionKey;
140
+ auditEnabled?: boolean;
141
+ userId?: string;
142
+ validateInput?: boolean;
143
+ encoded?: boolean;
144
+ accessRules?: Array<{
145
+ pattern: string | ((key: string, userId?: string) => boolean);
146
+ permissions: Permission[];
147
+ }>;
148
+ immer?: boolean;
149
+ sync?: SyncConfig;
150
+ }
151
+ export interface CustomStorage {
152
+ getItem(key: string): string | null;
153
+ setItem(key: string, value: string): void;
154
+ removeItem(key: string): void;
155
+ key(index: number): string | null;
156
+ length: number;
157
+ }
158
+ export interface AsyncState<T> {
159
+ data: T | null;
160
+ loading: boolean;
161
+ error: Error | null;
162
+ updatedAt: number | null;
163
+ }
164
+ export type { EncryptionKey, AuditEntry, Permission, AccessRule };
@@ -0,0 +1,2 @@
1
+ export declare const deepClone: <T>(obj: T) => T;
2
+ export declare const isEqual: (a: unknown, b: unknown) => boolean;