@flare-engine/storage 0.2.1 → 0.3.1
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/LICENSE +201 -21
- package/NOTICE +2 -0
- package/README.md +30 -12
- package/dist/index.d.mts +207 -196
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +207 -196
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +501 -506
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +492 -471
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -7
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/adapter.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Backend-agnostic async key/value storage contract.
|
|
3
4
|
*
|
|
@@ -6,87 +7,27 @@
|
|
|
6
7
|
* lets us unify sync backends (MMKV) and async backends (IndexedDB).
|
|
7
8
|
*/
|
|
8
9
|
interface StorageAdapter {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
/** Read a value. Resolves to `null` if the key is not present. */
|
|
11
|
+
get(key: string): Promise<string | null>;
|
|
12
|
+
/** Write a value. */
|
|
13
|
+
set(key: string, value: string): Promise<void>;
|
|
14
|
+
/** Delete a key. No-op if the key is not present. */
|
|
15
|
+
delete(key: string): Promise<void>;
|
|
16
|
+
/** List all keys currently stored. */
|
|
17
|
+
keys(): Promise<string[]>;
|
|
18
|
+
/** Remove every key. */
|
|
19
|
+
clear(): Promise<void>;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* In-memory adapter. Use as a default for tests, SSR, or reduced-persistence
|
|
23
|
-
* modes. State is lost when the process exits.
|
|
24
|
-
*/
|
|
25
|
-
declare function createMemoryAdapter(): StorageAdapter;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Minimal subset of `react-native-mmkv`'s `MMKV` class consumed by the adapter.
|
|
29
|
-
* Declared locally so this package does not take a peer dep on `react-native-mmkv`
|
|
30
|
-
* at type-check time — callers instantiate MMKV themselves and pass it in.
|
|
31
|
-
*/
|
|
32
|
-
interface MMKVLike {
|
|
33
|
-
getString(key: string): string | undefined;
|
|
34
|
-
set(key: string, value: string): void;
|
|
35
|
-
delete(key: string): void;
|
|
36
|
-
getAllKeys(): string[];
|
|
37
|
-
clearAll(): void;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Wrap a `react-native-mmkv` instance as a `StorageAdapter`. All operations are
|
|
41
|
-
* synchronous under the hood; promises resolve immediately.
|
|
42
|
-
*/
|
|
43
|
-
declare function createMmkvAdapter(mmkv: MMKVLike): StorageAdapter;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* IndexedDB-backed adapter for the web. Lazily opens the database on first use;
|
|
47
|
-
* each call opens a fresh transaction and the connection is kept open for the
|
|
48
|
-
* lifetime of the adapter.
|
|
49
|
-
*/
|
|
50
|
-
declare function createIndexedDbAdapter(dbName?: string, storeName?: string): StorageAdapter;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Tiny Zod-ish runtime schema for save data. Keeps the surface small:
|
|
54
|
-
* primitives, object, array, optional, literal, union. Enough for typed
|
|
55
|
-
* save games without pulling in a full validator.
|
|
56
|
-
*/
|
|
57
|
-
type ParseResult<T> = {
|
|
58
|
-
ok: true;
|
|
59
|
-
value: T;
|
|
60
|
-
} | {
|
|
61
|
-
ok: false;
|
|
62
|
-
error: string;
|
|
63
|
-
};
|
|
64
|
-
interface Schema<T> {
|
|
65
|
-
/** Throw on invalid input. */
|
|
66
|
-
parse(input: unknown): T;
|
|
67
|
-
/** Non-throwing parse. */
|
|
68
|
-
safeParse(input: unknown): ParseResult<T>;
|
|
69
|
-
}
|
|
70
|
-
type Infer<S> = S extends Schema<infer T> ? T : never;
|
|
71
|
-
declare const s: {
|
|
72
|
-
string(): Schema<string>;
|
|
73
|
-
number(): Schema<number>;
|
|
74
|
-
boolean(): Schema<boolean>;
|
|
75
|
-
literal<L extends string | number | boolean>(value: L): Schema<L>;
|
|
76
|
-
optional<T>(inner: Schema<T>): Schema<T | undefined>;
|
|
77
|
-
array<T>(item: Schema<T>): Schema<T[]>;
|
|
78
|
-
object<Shape extends Record<string, Schema<unknown>>>(shape: Shape): Schema<{ [K in keyof Shape]: Infer<Shape[K]>; }>;
|
|
79
|
-
union<T extends Schema<unknown>[]>(...options: T): Schema<Infer<T[number]>>;
|
|
80
|
-
};
|
|
81
|
-
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/migrations.d.ts
|
|
82
23
|
/**
|
|
83
24
|
* Forward-only versioned migration step. Each migration lifts data from
|
|
84
25
|
* `version - 1` to `version`. The runner applies every step whose version is
|
|
85
26
|
* greater than the stored version and less than or equal to the target.
|
|
86
27
|
*/
|
|
87
28
|
interface Migration {
|
|
88
|
-
|
|
89
|
-
|
|
29
|
+
version: number;
|
|
30
|
+
migrate: (old: unknown) => unknown;
|
|
90
31
|
}
|
|
91
32
|
/**
|
|
92
33
|
* Run every migration whose `version` is strictly greater than `from` and
|
|
@@ -95,11 +36,72 @@ interface Migration {
|
|
|
95
36
|
* is lower than the highest migration version while `from < to`.
|
|
96
37
|
*/
|
|
97
38
|
declare function runMigrations(data: unknown, from: number, to: number, migrations: readonly Migration[]): unknown;
|
|
98
|
-
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/document-store.d.ts
|
|
41
|
+
interface DocumentStoreOptions<T> {
|
|
42
|
+
adapter: StorageAdapter;
|
|
43
|
+
/** Storage key under which the document is persisted. */
|
|
44
|
+
key: string;
|
|
45
|
+
/** Current schema version. Positive integer. */
|
|
46
|
+
version: number;
|
|
47
|
+
/** Forward-only migrations, same contract as createStorage. */
|
|
48
|
+
migrations?: readonly Migration[];
|
|
49
|
+
/**
|
|
50
|
+
* Lenient parser called after migration. Expected to return a valid T for any
|
|
51
|
+
* input, including undefined (first-run / corrupt-data fallback). Must never
|
|
52
|
+
* throw — use san.* combinators or a manual fallback.
|
|
53
|
+
*/
|
|
54
|
+
parse: (raw: unknown) => T;
|
|
55
|
+
/**
|
|
56
|
+
* Called on first run (key absent in adapter) with the initial parsed doc.
|
|
57
|
+
* Return value is saved and returned by load(). Useful for seeding
|
|
58
|
+
* platform-detected defaults (locale, reduced-motion, etc.).
|
|
59
|
+
*/
|
|
60
|
+
onFirstRun?: (doc: T) => T;
|
|
61
|
+
}
|
|
62
|
+
interface DocumentStore<T> {
|
|
63
|
+
/**
|
|
64
|
+
* Load from adapter. On first run (or corrupt data) calls parse(undefined)
|
|
65
|
+
* then onFirstRun, persists the result, and returns it. On subsequent loads
|
|
66
|
+
* migrates the stored data forward then calls parse on the result.
|
|
67
|
+
*/
|
|
68
|
+
load(): Promise<T>;
|
|
69
|
+
/**
|
|
70
|
+
* Return the in-memory cached doc. Throws if load() has not been called yet.
|
|
71
|
+
*/
|
|
72
|
+
get(): T;
|
|
73
|
+
/** Persist doc to the adapter and update the in-memory cache. */
|
|
74
|
+
save(doc: T): Promise<void>;
|
|
75
|
+
/** Serialize the current in-memory doc as a self-contained JSON string. */
|
|
76
|
+
exportJSON(): string;
|
|
77
|
+
/**
|
|
78
|
+
* Replace in-memory doc and adapter contents from a previously exported
|
|
79
|
+
* JSON string. Returns the parsed doc after import.
|
|
80
|
+
*/
|
|
81
|
+
importJSON(json: string): Promise<T>;
|
|
82
|
+
}
|
|
83
|
+
declare function createDocumentStore<T>(options: DocumentStoreOptions<T>): DocumentStore<T>;
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/indexeddb-adapter.d.ts
|
|
86
|
+
/**
|
|
87
|
+
* IndexedDB-backed adapter for the web. Lazily opens the database on first use;
|
|
88
|
+
* each call opens a fresh transaction and the connection is kept open for the
|
|
89
|
+
* lifetime of the adapter.
|
|
90
|
+
*/
|
|
91
|
+
declare function createIndexedDbAdapter(dbName?: string, storeName?: string): StorageAdapter;
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/memory-adapter.d.ts
|
|
94
|
+
/**
|
|
95
|
+
* In-memory adapter. Use as a default for tests, SSR, or reduced-persistence
|
|
96
|
+
* modes. State is lost when the process exits.
|
|
97
|
+
*/
|
|
98
|
+
declare function createMemoryAdapter(): StorageAdapter;
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/migration-chain.d.ts
|
|
99
101
|
interface MigrationStep {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
from: number;
|
|
103
|
+
to: number;
|
|
104
|
+
migrate: (data: unknown) => unknown;
|
|
103
105
|
}
|
|
104
106
|
/**
|
|
105
107
|
* Converts an ordered array of step-wise migrations into a `Migration[]`
|
|
@@ -114,88 +116,27 @@ interface MigrationStep {
|
|
|
114
116
|
* // Pass to runMigrations(data, storedVersion, CURRENT_VERSION, migrations)
|
|
115
117
|
*/
|
|
116
118
|
declare function defineMigrationChain(steps: readonly MigrationStep[]): Migration[];
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
adapter: StorageAdapter;
|
|
120
|
-
/** Schema applied to every slot on load. */
|
|
121
|
-
schema: Schema<T>;
|
|
122
|
-
/** Current data version. Stored data below this is lifted via `migrations`. */
|
|
123
|
-
version: number;
|
|
124
|
-
/** Forward-only migrations from one version to the next. */
|
|
125
|
-
migrations?: readonly Migration[];
|
|
126
|
-
}
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/mmkv-adapter.d.ts
|
|
127
121
|
/**
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* validated against the schema.
|
|
122
|
+
* Minimal subset of `react-native-mmkv`'s `MMKV` class consumed by the adapter.
|
|
123
|
+
* Declared locally so this package does not take a peer dep on `react-native-mmkv`
|
|
124
|
+
* at type-check time — callers instantiate MMKV themselves and pass it in.
|
|
132
125
|
*/
|
|
133
|
-
interface
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
delete(key: string): Promise<void>;
|
|
140
|
-
/** Save data into a named slot. Schema-validated before write. */
|
|
141
|
-
saveSlot(name: string, data: T): Promise<void>;
|
|
142
|
-
/** Load a slot. Runs migrations then schema validation. `null` if missing. */
|
|
143
|
-
loadSlot(name: string): Promise<T | null>;
|
|
144
|
-
/** Delete a slot by name. */
|
|
145
|
-
deleteSlot(name: string): Promise<void>;
|
|
146
|
-
/** Names of all slots currently stored. */
|
|
147
|
-
listSlots(): Promise<string[]>;
|
|
148
|
-
/** Serialize every stored key/value (including version + slots) to JSON. */
|
|
149
|
-
exportJSON(): Promise<string>;
|
|
150
|
-
/** Clear storage and restore from a previously exported JSON payload. */
|
|
151
|
-
importJSON(json: string): Promise<void>;
|
|
152
|
-
}
|
|
153
|
-
declare function createStorage<T>(options: StorageOptions<T>): Storage<T>;
|
|
154
|
-
|
|
155
|
-
interface DocumentStoreOptions<T> {
|
|
156
|
-
adapter: StorageAdapter;
|
|
157
|
-
/** Storage key under which the document is persisted. */
|
|
158
|
-
key: string;
|
|
159
|
-
/** Current schema version. Positive integer. */
|
|
160
|
-
version: number;
|
|
161
|
-
/** Forward-only migrations, same contract as createStorage. */
|
|
162
|
-
migrations?: readonly Migration[];
|
|
163
|
-
/**
|
|
164
|
-
* Lenient parser called after migration. Expected to return a valid T for any
|
|
165
|
-
* input, including undefined (first-run / corrupt-data fallback). Must never
|
|
166
|
-
* throw — use san.* combinators or a manual fallback.
|
|
167
|
-
*/
|
|
168
|
-
parse: (raw: unknown) => T;
|
|
169
|
-
/**
|
|
170
|
-
* Called on first run (key absent in adapter) with the initial parsed doc.
|
|
171
|
-
* Return value is saved and returned by load(). Useful for seeding
|
|
172
|
-
* platform-detected defaults (locale, reduced-motion, etc.).
|
|
173
|
-
*/
|
|
174
|
-
onFirstRun?: (doc: T) => T;
|
|
175
|
-
}
|
|
176
|
-
interface DocumentStore<T> {
|
|
177
|
-
/**
|
|
178
|
-
* Load from adapter. On first run (or corrupt data) calls parse(undefined)
|
|
179
|
-
* then onFirstRun, persists the result, and returns it. On subsequent loads
|
|
180
|
-
* migrates the stored data forward then calls parse on the result.
|
|
181
|
-
*/
|
|
182
|
-
load(): Promise<T>;
|
|
183
|
-
/**
|
|
184
|
-
* Return the in-memory cached doc. Throws if load() has not been called yet.
|
|
185
|
-
*/
|
|
186
|
-
get(): T;
|
|
187
|
-
/** Persist doc to the adapter and update the in-memory cache. */
|
|
188
|
-
save(doc: T): Promise<void>;
|
|
189
|
-
/** Serialize the current in-memory doc as a self-contained JSON string. */
|
|
190
|
-
exportJSON(): string;
|
|
191
|
-
/**
|
|
192
|
-
* Replace in-memory doc and adapter contents from a previously exported
|
|
193
|
-
* JSON string. Returns the parsed doc after import.
|
|
194
|
-
*/
|
|
195
|
-
importJSON(json: string): Promise<T>;
|
|
126
|
+
interface MMKVLike {
|
|
127
|
+
getString(key: string): string | undefined;
|
|
128
|
+
set(key: string, value: string): void;
|
|
129
|
+
delete(key: string): void;
|
|
130
|
+
getAllKeys(): string[];
|
|
131
|
+
clearAll(): void;
|
|
196
132
|
}
|
|
197
|
-
|
|
198
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Wrap a `react-native-mmkv` instance as a `StorageAdapter`. All operations are
|
|
135
|
+
* synchronous under the hood; promises resolve immediately.
|
|
136
|
+
*/
|
|
137
|
+
declare function createMmkvAdapter(mmkv: MMKVLike): StorageAdapter;
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/sanitize.d.ts
|
|
199
140
|
/**
|
|
200
141
|
* Lenient field-drop validators for migrating real persisted data.
|
|
201
142
|
*
|
|
@@ -208,44 +149,114 @@ declare function createDocumentStore<T>(options: DocumentStoreOptions<T>): Docum
|
|
|
208
149
|
type Sanitizer<T> = (input: unknown) => T;
|
|
209
150
|
/** Namespace of sanitizer combinators. */
|
|
210
151
|
declare const san: {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
152
|
+
/** Returns input if it is a string, else returns `fallback`. */
|
|
153
|
+
readonly string: (fallback: string) => Sanitizer<string>;
|
|
154
|
+
/** Returns input if it is a finite number, else returns `fallback`. */
|
|
155
|
+
readonly number: (fallback: number) => Sanitizer<number>;
|
|
156
|
+
/** Returns input if it is a boolean, else returns `fallback`. */
|
|
157
|
+
readonly boolean: (fallback: boolean) => Sanitizer<boolean>;
|
|
158
|
+
/**
|
|
159
|
+
* Returns input if it is strictly equal to one of `options`, else returns
|
|
160
|
+
* `fallback`. `fallback` must be one of `options`.
|
|
161
|
+
*/
|
|
162
|
+
readonly literal: <L extends string | number | boolean>(options: readonly L[], fallback: L) => Sanitizer<L>;
|
|
163
|
+
/**
|
|
164
|
+
* Build a Sanitizer for a plain object shape. Each field's sanitizer is
|
|
165
|
+
* applied independently; fields not present in `shape` are dropped. If
|
|
166
|
+
* `input` is not a plain object, every field falls back to its default.
|
|
167
|
+
*/
|
|
168
|
+
readonly object: <Shape extends Record<string, Sanitizer<unknown>>>(shape: Shape) => Sanitizer<{ [K in keyof Shape]: ReturnType<Shape[K]>; }>;
|
|
169
|
+
/**
|
|
170
|
+
* Apply `item` to every element of an input array. Non-array input returns
|
|
171
|
+
* `[]`. All elements are transformed — none are dropped.
|
|
172
|
+
*/
|
|
173
|
+
readonly array: <T>(item: Sanitizer<T>) => Sanitizer<T[]>;
|
|
174
|
+
/**
|
|
175
|
+
* Filter an array by a type guard, dropping elements that fail the guard.
|
|
176
|
+
* Non-array input returns `[]`. This is the drop-invalid pattern used when
|
|
177
|
+
* deserializing sets of ids, enum values, or validated strings.
|
|
178
|
+
*/
|
|
179
|
+
readonly arrayOf: <T>(guard: (v: unknown) => v is T) => Sanitizer<T[]>;
|
|
180
|
+
/**
|
|
181
|
+
* Clamp a number to `[min, max]`. Non-number / non-finite input returns
|
|
182
|
+
* `fallback`. Applied as a standalone sanitizer or composed via `pipe`.
|
|
183
|
+
*/
|
|
184
|
+
readonly clamped: (fallback: number, min: number, max: number) => Sanitizer<number>;
|
|
185
|
+
/**
|
|
186
|
+
* Chain a sanitizer with a transform. Useful for post-process steps like
|
|
187
|
+
* Math.floor, deduplication, or forcing a minimum value.
|
|
188
|
+
*/
|
|
189
|
+
readonly pipe: <A, B>(sanitizer: Sanitizer<A>, transform: (v: A) => B) => Sanitizer<B>;
|
|
249
190
|
};
|
|
250
|
-
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/schema.d.ts
|
|
193
|
+
/**
|
|
194
|
+
* Tiny Zod-ish runtime schema for save data. Keeps the surface small:
|
|
195
|
+
* primitives, object, array, optional, literal, union. Enough for typed
|
|
196
|
+
* save games without pulling in a full validator.
|
|
197
|
+
*/
|
|
198
|
+
type ParseResult<T> = {
|
|
199
|
+
ok: true;
|
|
200
|
+
value: T;
|
|
201
|
+
} | {
|
|
202
|
+
ok: false;
|
|
203
|
+
error: string;
|
|
204
|
+
};
|
|
205
|
+
interface Schema<T> {
|
|
206
|
+
/** Throw on invalid input. */
|
|
207
|
+
parse(input: unknown): T;
|
|
208
|
+
/** Non-throwing parse. */
|
|
209
|
+
safeParse(input: unknown): ParseResult<T>;
|
|
210
|
+
}
|
|
211
|
+
type Infer<S> = S extends Schema<infer T> ? T : never;
|
|
212
|
+
declare const s: {
|
|
213
|
+
string(): Schema<string>;
|
|
214
|
+
number(): Schema<number>;
|
|
215
|
+
boolean(): Schema<boolean>;
|
|
216
|
+
literal<L extends string | number | boolean>(value: L): Schema<L>;
|
|
217
|
+
optional<T>(inner: Schema<T>): Schema<T | undefined>;
|
|
218
|
+
array<T>(item: Schema<T>): Schema<T[]>;
|
|
219
|
+
object<Shape extends Record<string, Schema<unknown>>>(shape: Shape): Schema<{ [K in keyof Shape]: Infer<Shape[K]>; }>;
|
|
220
|
+
union<T extends Schema<unknown>[]>(...options: T): Schema<Infer<T[number]>>;
|
|
221
|
+
};
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/storage.d.ts
|
|
224
|
+
interface StorageOptions<T> {
|
|
225
|
+
adapter: StorageAdapter;
|
|
226
|
+
/** Schema applied to every slot on load. */
|
|
227
|
+
schema: Schema<T>;
|
|
228
|
+
/** Current data version. Stored data below this is lifted via `migrations`. */
|
|
229
|
+
version: number;
|
|
230
|
+
/** Forward-only migrations from one version to the next. */
|
|
231
|
+
migrations?: readonly Migration[];
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Typed, versioned key/value storage with named save slots and JSON
|
|
235
|
+
* import/export. Values of type `T` are persisted as JSON strings under
|
|
236
|
+
* `slot:<name>` keys. On read, data is migrated forward to `version` and then
|
|
237
|
+
* validated against the schema.
|
|
238
|
+
*/
|
|
239
|
+
interface Storage<T> {
|
|
240
|
+
/** Low-level get. Bypasses schema + migrations. Returns `null` if missing. */
|
|
241
|
+
get(key: string): Promise<string | null>;
|
|
242
|
+
/** Low-level set. Bypasses schema + migrations. */
|
|
243
|
+
set(key: string, value: string): Promise<void>;
|
|
244
|
+
/** Low-level delete. */
|
|
245
|
+
delete(key: string): Promise<void>;
|
|
246
|
+
/** Save data into a named slot. Schema-validated before write. */
|
|
247
|
+
saveSlot(name: string, data: T): Promise<void>;
|
|
248
|
+
/** Load a slot. Runs migrations then schema validation. `null` if missing. */
|
|
249
|
+
loadSlot(name: string): Promise<T | null>;
|
|
250
|
+
/** Delete a slot by name. */
|
|
251
|
+
deleteSlot(name: string): Promise<void>;
|
|
252
|
+
/** Names of all slots currently stored. */
|
|
253
|
+
listSlots(): Promise<string[]>;
|
|
254
|
+
/** Serialize every stored key/value (including version + slots) to JSON. */
|
|
255
|
+
exportJSON(): Promise<string>;
|
|
256
|
+
/** Clear storage and restore from a previously exported JSON payload. */
|
|
257
|
+
importJSON(json: string): Promise<void>;
|
|
258
|
+
}
|
|
259
|
+
declare function createStorage<T>(options: StorageOptions<T>): Storage<T>;
|
|
260
|
+
//#endregion
|
|
251
261
|
export { type DocumentStore, type DocumentStoreOptions, type Infer, type MMKVLike, type Migration, type MigrationStep, type ParseResult, type Sanitizer, type Schema, type Storage, type StorageAdapter, type StorageOptions, createDocumentStore, createIndexedDbAdapter, createMemoryAdapter, createMmkvAdapter, createStorage, defineMigrationChain, runMigrations, s, san };
|
|
262
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/adapter.ts","../src/migrations.ts","../src/document-store.ts","../src/indexeddb-adapter.ts","../src/memory-adapter.ts","../src/migration-chain.ts","../src/mmkv-adapter.ts","../src/sanitize.ts","../src/schema.ts","../src/storage.ts"],"mappings":";;;;;;;;UAOiB;;EAEf,IAAI,cAAc;;EAElB,IAAI,aAAa,gBAAgB;;EAEjC,OAAO,cAAc;;EAErB,QAAQ;;EAER,SAAS;;;;;;;;;UCZM;EACf;EACA,UAAU;;;;;;;;iBASI,cACd,eACA,cACA,YACA,qBAAqB;;;UCdN,qBAAqB;EACpC,SAAS;;EAET;;EAEA;;EAEA,sBAAsB;;;;;;EAMtB,QAAQ,iBAAiB;;;;;;EAMzB,cAAc,KAAK,MAAM;;UAGV,cAAc;;;;;;EAM7B,QAAQ,QAAQ;;;;EAIhB,OAAO;;EAEP,KAAK,KAAK,IAAI;;EAEd;;;;;EAKA,WAAW,eAAe,QAAQ;;iBAmBpB,oBAAoB,GAAG,SAAS,qBAAqB,KAAK,cAAc;;;;;;;;iBCOxE,uBAAuB,iBAAyB,qBAAmB;;;;;;;iBCnEnE,uBAAuB;;;UCJtB;EACf;EACA;EACA,UAAU;;;;;;;;;;;;;;iBAeI,qBAAqB,gBAAgB,kBAAkB;;;;;;;;UCbtD;EACf,UAAU;EACV,IAAI,aAAa;EACjB,OAAO;EACP;EACA;;;;;;iBAOc,kBAAkB,MAAM,WAAW;;;;;;;;;;;;KCTvC,UAAU,MAAM,mBAAmB;;cAGlC;;yCAEe;;yCAKA;;2CAKE;;;;;qBAQpB,qCAAmC,kBAAoB,KAAG,UAAY,MAAI,UAAU;;;;;;oBASrF,cAAc,eAAe,qBAAmB,OAC9C,UACN,aAAa,WAAW,QAAQ,WAAW,MAAM;;;;;mBAoB9C,GAAC,MAAQ,UAAU,OAAK,UAAU;;;;;;qBAgBhC,GAAC,QAAU,eAAe,KAAK,MAAI,UAAU;;;;;uCAe7B,aAAa,gBAAgB;;;;;kBAWhD,GAAG,GAAC,WAAa,UAAU,IAAE,YAAc,GAAG,MAAM,MAAI,UAAU;;;;;;;;;KCpG7D,YAAY;EAAO;EAAU,OAAO;;EAAQ;EAAW;;UAElD,OAAO;;EAEtB,MAAM,iBAAiB;;EAEvB,UAAU,iBAAiB,YAAY;;KAG7B,MAAM,KAAK,UAAU,aAAa,KAAK;cA6CtC;YACD;YAGA;aAGC;UAGH,qCAAmC,OAAS,IAAI,OAAO;WAMtD,GAAC,OAAS,OAAO,KAAK,OAAO;QAOhC,GAAC,MAAQ,OAAO,KAAK,OAAO;SAa3B,cAAc,eAAe,kBAAgB,OAC3C,QACN,UAAU,WAAW,QAAQ,MAAM,MAAM;QAiBtC,UAAU,sBAAiB,SAAc,IAAI,OAAO,MAAM;;;;UC3GjD,eAAe;EAC9B,SAAS;;EAET,QAAQ,OAAO;;EAEf;;EAEA,sBAAsB;;;;;;;;UASP,QAAQ;;EAEvB,IAAI,cAAc;;EAElB,IAAI,aAAa,gBAAgB;;EAEjC,OAAO,cAAc;;EAGrB,SAAS,cAAc,MAAM,IAAI;;EAEjC,SAAS,eAAe,QAAQ;;EAEhC,WAAW,eAAe;;EAE1B,aAAa;;EAGb,cAAc;;EAEd,WAAW,eAAe;;iBAiBZ,cAAc,GAAG,SAAS,eAAe,KAAK,QAAQ"}
|