@frontmcp/utils 0.7.2 → 0.8.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.
@@ -0,0 +1,47 @@
1
+ /**
2
+ * TypedStorage Types
3
+ *
4
+ * Type definitions for the TypedStorage wrapper that provides
5
+ * type-safe JSON serialization on top of StorageAdapter.
6
+ */
7
+ import type { SetOptions } from './types';
8
+ import type { z } from 'zod';
9
+ /**
10
+ * Options for TypedStorage wrapper
11
+ */
12
+ export interface TypedStorageOptions<T> {
13
+ /**
14
+ * Optional Zod schema for validation on read.
15
+ * If provided, values will be validated after deserialization.
16
+ */
17
+ schema?: z.ZodType<T>;
18
+ /**
19
+ * Whether to throw an error when data fails validation.
20
+ * If false (default), returns null for invalid data.
21
+ * @default false
22
+ */
23
+ throwOnInvalid?: boolean;
24
+ /**
25
+ * Custom serialization function.
26
+ * @default JSON.stringify
27
+ */
28
+ serialize?: (value: T) => string;
29
+ /**
30
+ * Custom deserialization function.
31
+ * @default JSON.parse
32
+ */
33
+ deserialize?: (raw: string) => unknown;
34
+ }
35
+ /**
36
+ * Options for typed set operations.
37
+ * Re-export for convenience.
38
+ */
39
+ export type TypedSetOptions = SetOptions;
40
+ /**
41
+ * Entry for batch set operations with typed values.
42
+ */
43
+ export interface TypedSetEntry<T> {
44
+ key: string;
45
+ value: T;
46
+ options?: TypedSetOptions;
47
+ }