@adonisjs/session 7.5.0 → 8.0.0-next.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.
Files changed (60) hide show
  1. package/build/{chunk-TZLOND27.js → chunk-DFXWYDMY.js} +21 -3
  2. package/build/chunk-HAD4PFFM.js +229 -0
  3. package/build/{chunk-WUWXIKIB.js → chunk-MVBWJOEG.js} +54 -14
  4. package/build/{chunk-ZVSEMDIC.js → chunk-SBOMJK4T.js} +1 -2
  5. package/build/{chunk-OCQGCVXK.js → chunk-SHD6OX52.js} +169 -75
  6. package/build/chunk-Y566BNUT.js +113 -0
  7. package/build/{cookie-WBWYVEDW.js → cookie-YBBGLCO5.js} +38 -6
  8. package/build/{dynamodb-3PG52TE3.js → dynamodb-PLZABBFD.js} +54 -8
  9. package/build/factories/main.d.ts +1 -1
  10. package/build/factories/main.js +5 -6
  11. package/build/factories/session_middleware_factory.d.ts +2 -2
  12. package/build/{file-B6QKOZXW.js → file-CCJ5ESE2.js} +49 -14
  13. package/build/index.d.ts +6 -6
  14. package/build/index.js +4 -5
  15. package/build/providers/session_provider.d.ts +1 -1
  16. package/build/providers/session_provider.js +5 -6
  17. package/build/{redis-CAY24YIA.js → redis-NXJWWWVB.js} +39 -8
  18. package/build/src/client.d.ts +46 -10
  19. package/build/src/client.js +3 -4
  20. package/build/src/define_config.d.ts +37 -4
  21. package/build/src/errors.d.ts +20 -4
  22. package/build/src/plugins/edge.d.ts +12 -2
  23. package/build/src/plugins/edge.js +1 -2
  24. package/build/src/plugins/japa/api_client.d.ts +22 -4
  25. package/build/src/plugins/japa/api_client.js +5 -5
  26. package/build/src/plugins/japa/browser_client.d.ts +18 -4
  27. package/build/src/plugins/japa/browser_client.js +5 -5
  28. package/build/src/session.d.ts +171 -58
  29. package/build/src/session_middleware.d.ts +28 -5
  30. package/build/src/session_middleware.js +4 -5
  31. package/build/src/stores/cookie.d.ts +41 -7
  32. package/build/src/stores/dynamodb.d.ts +44 -8
  33. package/build/src/stores/file.d.ts +34 -8
  34. package/build/src/stores/memory.d.ts +34 -5
  35. package/build/src/stores/redis.d.ts +37 -7
  36. package/build/src/types.d.ts +155 -34
  37. package/build/src/types.js +0 -1
  38. package/build/src/values_store.d.ts +113 -21
  39. package/package.json +47 -44
  40. package/build/chunk-GB5FBZCV.js +0 -85
  41. package/build/chunk-GB5FBZCV.js.map +0 -1
  42. package/build/chunk-OCQGCVXK.js.map +0 -1
  43. package/build/chunk-TE5JP3SX.js +0 -151
  44. package/build/chunk-TE5JP3SX.js.map +0 -1
  45. package/build/chunk-TZLOND27.js.map +0 -1
  46. package/build/chunk-WUWXIKIB.js.map +0 -1
  47. package/build/chunk-ZVSEMDIC.js.map +0 -1
  48. package/build/cookie-WBWYVEDW.js.map +0 -1
  49. package/build/dynamodb-3PG52TE3.js.map +0 -1
  50. package/build/factories/main.js.map +0 -1
  51. package/build/file-B6QKOZXW.js.map +0 -1
  52. package/build/index.js.map +0 -1
  53. package/build/providers/session_provider.js.map +0 -1
  54. package/build/redis-CAY24YIA.js.map +0 -1
  55. package/build/src/client.js.map +0 -1
  56. package/build/src/plugins/edge.js.map +0 -1
  57. package/build/src/plugins/japa/api_client.js.map +0 -1
  58. package/build/src/plugins/japa/browser_client.js.map +0 -1
  59. package/build/src/session_middleware.js.map +0 -1
  60. package/build/src/types.js.map +0 -1
@@ -6,34 +6,60 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
- import type { FileStoreConfig, SessionData, SessionStoreContract } from '../types.js';
9
+ import type { FileStoreConfig, SessionData, SessionStoreContract } from '../types.ts';
10
10
  /**
11
- * File store writes the session data on the file system as. Each session
12
- * id gets its own file.
11
+ * File store writes the session data on the file system. Each session
12
+ * id gets its own file for storage.
13
13
  *
14
+ * @example
15
+ * const fileStore = new FileStore({
16
+ * location: './tmp/sessions'
17
+ * }, '2 hours')
14
18
  */
15
19
  export declare class FileStore implements SessionStoreContract {
16
20
  #private;
17
21
  /**
18
- * @param {FileStoreConfig} config
19
- * @param {string|number} The age must be in seconds or a time expression
22
+ * Creates a new file store instance
23
+ *
24
+ * @param config - File store configuration
25
+ * @param age - Session age in seconds or time expression (e.g. '2 hours')
20
26
  */
21
27
  constructor(config: FileStoreConfig, age: string | number);
22
28
  /**
23
- * Reads the session data from the disk.
29
+ * Reads the session data from the disk
30
+ *
31
+ * @param sessionId - Session identifier
32
+ *
33
+ * @example
34
+ * const data = await store.read('sess_abc123')
24
35
  */
25
36
  read(sessionId: string): Promise<SessionData | null>;
26
37
  /**
27
38
  * Writes the session data to the disk as a string
39
+ *
40
+ * @param sessionId - Session identifier
41
+ * @param values - Session data to store
42
+ *
43
+ * @example
44
+ * await store.write('sess_abc123', { userId: 123 })
28
45
  */
29
46
  write(sessionId: string, values: SessionData): Promise<void>;
30
47
  /**
31
48
  * Removes the session file from the disk
49
+ *
50
+ * @param sessionId - Session identifier
51
+ *
52
+ * @example
53
+ * await store.destroy('sess_abc123')
32
54
  */
33
55
  destroy(sessionId: string): Promise<void>;
34
56
  /**
35
- * Updates the session expiry by rewriting it to the
36
- * persistence store
57
+ * Updates the session expiry by updating the file's modification time
58
+ *
59
+ * @param sessionId - Session identifier
60
+ *
61
+ * @example
62
+ * await store.touch('sess_abc123')
37
63
  */
38
64
  touch(sessionId: string): Promise<void>;
39
65
  }
@@ -6,23 +6,52 @@
6
6
  * For the full copyright and license information, please view the LICENSE
7
7
  * file that was distributed with this source code.
8
8
  */
9
- import type { SessionData, SessionStoreContract } from '../types.js';
9
+ import type { SessionData, SessionStoreContract } from '../types.ts';
10
10
  /**
11
11
  * Memory store is meant to be used for writing tests.
12
+ * All session data is stored in memory and will be lost when the process restarts.
13
+ *
14
+ * @example
15
+ * const memoryStore = new MemoryStore()
16
+ * memoryStore.write('sess_abc123', { userId: 123 })
12
17
  */
13
18
  export declare class MemoryStore implements SessionStoreContract {
19
+ /**
20
+ * Static map to store all session data in memory
21
+ */
14
22
  static sessions: Map<string, SessionData>;
15
23
  /**
16
- * Read session id value from the memory
24
+ * Reads session value from memory
25
+ *
26
+ * @param sessionId - Session identifier
27
+ *
28
+ * @example
29
+ * const data = store.read('sess_abc123')
17
30
  */
18
31
  read(sessionId: string): SessionData | null;
19
32
  /**
20
- * Save in memory value for a given session id
33
+ * Saves session value in memory for a given session id
34
+ *
35
+ * @param sessionId - Session identifier
36
+ * @param values - Session data to store
37
+ *
38
+ * @example
39
+ * store.write('sess_abc123', { userId: 123, theme: 'dark' })
21
40
  */
22
41
  write(sessionId: string, values: SessionData): void;
23
42
  /**
24
- * Cleanup for a single session
43
+ * Removes a single session from memory
44
+ *
45
+ * @param sessionId - Session identifier to remove
46
+ *
47
+ * @example
48
+ * store.destroy('sess_abc123')
25
49
  */
26
50
  destroy(sessionId: string): void;
27
- touch(): void;
51
+ /**
52
+ * No-op for memory store as there's no expiry mechanism
53
+ *
54
+ * @param sessionId - Session identifier (unused)
55
+ */
56
+ touch(_?: string): void;
28
57
  }
@@ -7,28 +7,58 @@
7
7
  * file that was distributed with this source code.
8
8
  */
9
9
  import type { Connection } from '@adonisjs/redis/types';
10
- import type { SessionStoreContract, SessionData } from '../types.js';
10
+ import type { SessionStoreContract, SessionData } from '../types.ts';
11
11
  /**
12
- * File store to read/write session to filesystem
12
+ * Redis store to read/write session data to Redis server.
13
+ * Provides fast, scalable session storage with automatic expiry.
14
+ *
15
+ * @example
16
+ * const redisStore = new RedisStore(redisConnection, '2 hours')
13
17
  */
14
18
  export declare class RedisStore implements SessionStoreContract {
15
19
  #private;
20
+ /**
21
+ * Creates a new Redis store instance
22
+ *
23
+ * @param connection - Redis connection instance
24
+ * @param age - Session age in seconds or time expression (e.g. '2 hours')
25
+ */
16
26
  constructor(connection: Connection, age: string | number);
17
27
  /**
18
- * Returns file contents. A new file will be created if it's
19
- * missing.
28
+ * Reads session data from Redis
29
+ *
30
+ * @param sessionId - Session identifier
31
+ *
32
+ * @example
33
+ * const data = await store.read('sess_abc123')
20
34
  */
21
35
  read(sessionId: string): Promise<SessionData | null>;
22
36
  /**
23
- * Write session values to a file
37
+ * Writes session values to Redis with expiry
38
+ *
39
+ * @param sessionId - Session identifier
40
+ * @param values - Session data to store
41
+ *
42
+ * @example
43
+ * await store.write('sess_abc123', { userId: 123 })
24
44
  */
25
45
  write(sessionId: string, values: Object): Promise<void>;
26
46
  /**
27
- * Cleanup session file by removing it
47
+ * Removes session data from Redis
48
+ *
49
+ * @param sessionId - Session identifier to remove
50
+ *
51
+ * @example
52
+ * await store.destroy('sess_abc123')
28
53
  */
29
54
  destroy(sessionId: string): Promise<void>;
30
55
  /**
31
- * Updates the value expiry
56
+ * Updates the session expiry time in Redis
57
+ *
58
+ * @param sessionId - Session identifier
59
+ *
60
+ * @example
61
+ * await store.touch('sess_abc123')
32
62
  */
33
63
  touch(sessionId: string): Promise<void>;
34
64
  }
@@ -1,98 +1,219 @@
1
- import { HttpContext } from '@adonisjs/core/http';
2
- import { RedisConnections } from '@adonisjs/redis/types';
1
+ import { type HttpContext } from '@adonisjs/core/http';
2
+ import { type RedisConnections } from '@adonisjs/redis/types';
3
3
  import type { CookieOptions } from '@adonisjs/core/types/http';
4
4
  import type { DynamoDBClient, DynamoDBClientConfig } from '@aws-sdk/client-dynamodb';
5
5
  /**
6
- * The values allowed by the `session.put` method
6
+ * Union type of all values that can be stored in session data.
7
+ * These types are JSON serializable and safe for session storage.
8
+ *
9
+ * @example
10
+ * // All valid session values
11
+ * const stringVal: AllowedSessionValues = 'hello'
12
+ * const numberVal: AllowedSessionValues = 42
13
+ * const boolVal: AllowedSessionValues = true
14
+ * const objectVal: AllowedSessionValues = { key: 'value' }
15
+ * const dateVal: AllowedSessionValues = new Date()
16
+ * const arrayVal: AllowedSessionValues = [1, 2, 3]
7
17
  */
8
18
  export type AllowedSessionValues = string | boolean | number | object | Date | Array<any>;
19
+ /**
20
+ * Shape of session data as a record of key-value pairs.
21
+ * The session data must be JSON serializable for persistence.
22
+ *
23
+ * @example
24
+ * const sessionData: SessionData = {
25
+ * userId: 123,
26
+ * username: 'john_doe',
27
+ * preferences: { theme: 'dark', language: 'en' },
28
+ * loginAt: new Date(),
29
+ * roles: ['user', 'editor']
30
+ * }
31
+ */
9
32
  export type SessionData = Record<string, AllowedSessionValues>;
10
33
  /**
11
- * Session stores must implement the session store contract.
34
+ * Contract interface that every session store implementation must follow.
35
+ * Defines the basic CRUD operations for session data persistence.
36
+ *
37
+ * @example
38
+ * class CustomStore implements SessionStoreContract {
39
+ * async read(sessionId: string) {
40
+ * // Read session data from your storage
41
+ * return await this.storage.get(sessionId)
42
+ * }
43
+ *
44
+ * async write(sessionId: string, data: SessionData) {
45
+ * // Write session data to your storage
46
+ * await this.storage.set(sessionId, data)
47
+ * }
48
+ *
49
+ * async destroy(sessionId: string) {
50
+ * // Remove session data from storage
51
+ * await this.storage.delete(sessionId)
52
+ * }
53
+ *
54
+ * async touch(sessionId: string) {
55
+ * // Update expiry/last accessed time
56
+ * await this.storage.touch(sessionId)
57
+ * }
58
+ * }
12
59
  */
13
60
  export interface SessionStoreContract {
14
61
  /**
15
- * The read method is used to read the data from the persistence
16
- * store and return it back as an object
62
+ * Reads session data for a given session ID from the persistence store
63
+ *
64
+ * @param sessionId - Unique identifier for the session
17
65
  */
18
66
  read(sessionId: string): Promise<SessionData | null> | SessionData | null;
19
67
  /**
20
- * The write method is used to write the session data into the
21
- * persistence store.
68
+ * Writes session data for a given session ID to the persistence store
69
+ *
70
+ * @param sessionId - Unique identifier for the session
71
+ * @param data - Session data to store
22
72
  */
23
73
  write(sessionId: string, data: SessionData): Promise<void> | void;
24
74
  /**
25
- * The destroy method is used to destroy the session by removing
26
- * its data from the persistence store
75
+ * Removes session data for a given session ID from the persistence store
76
+ *
77
+ * @param sessionId - Unique identifier for the session to remove
27
78
  */
28
79
  destroy(sessionId: string): Promise<void> | void;
29
80
  /**
30
- * The touch method should update the lifetime of session id without
31
- * making changes to the session data.
81
+ * Updates the lifetime/expiry of a session without modifying the session data
82
+ *
83
+ * @param sessionId - Unique identifier for the session to touch
32
84
  */
33
85
  touch(sessionId: string): Promise<void> | void;
34
86
  }
35
87
  /**
36
- * Base configuration for managing sessions without
37
- * stores.
88
+ * Base configuration interface for session management.
89
+ * Used by the session manager and middleware to control session behavior.
90
+ *
91
+ * @example
92
+ * const config: SessionConfig = {
93
+ * enabled: true,
94
+ * cookieName: 'my_app_session',
95
+ * clearWithBrowser: false,
96
+ * age: '2 hours',
97
+ * cookie: {
98
+ * httpOnly: true,
99
+ * secure: true,
100
+ * sameSite: 'strict'
101
+ * }
102
+ * }
38
103
  */
39
104
  export interface SessionConfig {
40
105
  /**
41
- * Enable/disable sessions temporarily
106
+ * Whether session management is enabled for the application
42
107
  */
43
108
  enabled: boolean;
44
109
  /**
45
- * The name of the cookie for storing the session id.
110
+ * Name of the cookie used to store the session ID
46
111
  */
47
112
  cookieName: string;
48
113
  /**
49
- * When set to true, the session id cookie will be removed
50
- * when the user closes the browser.
51
- *
52
- * However, the persisted data will continue to exist until
53
- * it gets expired.
114
+ * Whether to clear the session cookie when the browser is closed.
115
+ * When true, creates a session cookie that expires on browser close.
116
+ * Note: Persisted session data continues to exist until it expires.
54
117
  */
55
118
  clearWithBrowser: boolean;
56
119
  /**
57
- * How long the session data should be kept alive without any
58
- * activity.
59
- *
60
- * The session id cookie will also live for the same duration, unless
61
- * "clearWithBrowser" is enabled
62
- *
63
- * The value should be a time expression or a number in seconds
120
+ * Maximum age of the session data and session ID cookie.
121
+ * Session data is automatically cleaned up after this duration of inactivity.
122
+ * Value can be a time expression (e.g. '2 hours') or number of seconds.
123
+ * Cookie duration is also set to this value unless clearWithBrowser is enabled.
64
124
  */
65
125
  age: string | number;
66
126
  /**
67
- * Configuration used by the cookie driver and for storing the
68
- * session id cookie.
127
+ * Additional cookie options for the session ID cookie.
128
+ * Excludes maxAge and expires as they're controlled by age and clearWithBrowser.
69
129
  */
70
130
  cookie: Omit<Partial<CookieOptions>, 'maxAge' | 'expires'>;
71
131
  }
72
132
  /**
73
- * Configuration used by the file store.
133
+ * Configuration for file-based session storage.
134
+ * Sessions are stored as individual files on the filesystem.
135
+ *
136
+ * @example
137
+ * const fileConfig: FileStoreConfig = {
138
+ * location: './tmp/sessions'
139
+ * }
74
140
  */
75
141
  export type FileStoreConfig = {
142
+ /**
143
+ * Directory path where session files should be stored
144
+ */
76
145
  location: string;
77
146
  };
78
147
  /**
79
- * Configuration used by the redis store.
148
+ * Configuration for Redis-based session storage.
149
+ * Sessions are stored in a Redis database with automatic expiry.
150
+ *
151
+ * @example
152
+ * const redisConfig: RedisStoreConfig = {
153
+ * connection: 'main' // Redis connection name from config/redis.ts
154
+ * }
80
155
  */
81
156
  export type RedisStoreConfig = {
157
+ /**
158
+ * Name of the Redis connection to use (must match connection name in config/redis.ts)
159
+ */
82
160
  connection: keyof RedisConnections;
83
161
  };
84
162
  /**
85
- * Configuration used by the dynamodb store.
163
+ * Configuration for AWS DynamoDB-based session storage.
164
+ * Sessions are stored in a DynamoDB table with TTL support.
165
+ * Supports either providing a DynamoDB client instance or client configuration.
166
+ *
167
+ * @example
168
+ * // Using existing client
169
+ * const configWithClient: DynamoDBStoreConfig = {
170
+ * client: dynamoClient,
171
+ * tableName: 'UserSessions',
172
+ * keyAttribute: 'sessionId'
173
+ * }
174
+ *
175
+ * // Using client configuration
176
+ * const configWithClientConfig: DynamoDBStoreConfig = {
177
+ * clientConfig: {
178
+ * region: 'us-east-1',
179
+ * credentials: { ... }
180
+ * },
181
+ * tableName: 'Sessions'
182
+ * }
86
183
  */
87
184
  export type DynamoDBStoreConfig = ({
185
+ /**
186
+ * Pre-configured DynamoDB client instance
187
+ */
88
188
  client: DynamoDBClient;
89
189
  } | {
190
+ /**
191
+ * Configuration options for creating a new DynamoDB client
192
+ */
90
193
  clientConfig: DynamoDBClientConfig;
91
194
  }) & {
195
+ /**
196
+ * DynamoDB table name for storing sessions (defaults to "Session")
197
+ */
92
198
  tableName?: string;
199
+ /**
200
+ * Attribute name for the session ID in the table (defaults to "key")
201
+ */
93
202
  keyAttribute?: string;
94
203
  };
95
204
  /**
96
- * Factory function to instantiate session store
205
+ * Factory function type for creating session store instances.
206
+ * Used by the session manager to instantiate stores per HTTP request.
207
+ *
208
+ * @param ctx - HTTP context for the current request
209
+ * @param sessionConfig - Session configuration
210
+ *
211
+ * @example
212
+ * const storeFactory: SessionStoreFactory = (ctx, sessionConfig) => {
213
+ * return new CustomStore({
214
+ * connection: ctx.database,
215
+ * maxAge: sessionConfig.age
216
+ * })
217
+ * }
97
218
  */
98
219
  export type SessionStoreFactory = (ctx: HttpContext, sessionConfig: SessionConfig) => SessionStoreContract;
@@ -1 +0,0 @@
1
- //# sourceMappingURL=types.js.map
@@ -1,91 +1,183 @@
1
- import type { AllowedSessionValues, SessionData } from './types.js';
1
+ import type { AllowedSessionValues, SessionData } from './types.ts';
2
2
  /**
3
- * Readonly session store
3
+ * Readonly session store that provides read-only access to session values.
4
+ * Used for sharing session data with templates and other readonly contexts.
5
+ *
6
+ * @example
7
+ * const readOnlyStore = new ReadOnlyValuesStore({ user: 'john', theme: 'dark' })
8
+ * const user = readOnlyStore.get('user')
9
+ * const hasTheme = readOnlyStore.has('theme')
4
10
  */
5
11
  export declare class ReadOnlyValuesStore {
6
12
  /**
7
- * Underlying store values
13
+ * Underlying store values containing session data
8
14
  */
9
15
  protected values: SessionData;
10
16
  /**
11
- * Find if store is empty or not
17
+ * Returns true if the store is empty
12
18
  */
13
19
  get isEmpty(): boolean;
20
+ /**
21
+ * Creates a new readonly values store
22
+ *
23
+ * @param values - Initial session data or null
24
+ */
14
25
  constructor(values: SessionData | null);
15
26
  /**
16
- * Get value for a given key
27
+ * Gets value for a given key
28
+ *
29
+ * @param key - The key or key path to retrieve
30
+ * @param defaultValue - Default value if key doesn't exist
31
+ *
32
+ * @example
33
+ * store.get('username', 'guest')
34
+ * store.get(['user', 'preferences', 'theme'], 'light')
17
35
  */
18
36
  get(key: string | string[], defaultValue?: any): any;
19
37
  /**
20
- * A boolean to know if value exists. Extra guards to check
21
- * arrays for it's length as well.
38
+ * Checks if a value exists. Includes extra guards to check arrays for length.
39
+ *
40
+ * @param key - The key or key path to check
41
+ * @param checkForArraysLength - Whether to check array length (default: true)
42
+ *
43
+ * @example
44
+ * store.has('username') // Check if key exists
45
+ * store.has(['user', 'roles']) // Check nested key
46
+ * store.has('items', false) // Don't check array length
22
47
  */
23
48
  has(key: string | string[], checkForArraysLength?: boolean): boolean;
24
49
  /**
25
- * Get all values
50
+ * Gets all values from the store
51
+ *
52
+ * @example
53
+ * const allData = store.all()
26
54
  */
27
55
  all(): any;
28
56
  /**
29
57
  * Returns object representation of values
58
+ *
59
+ * @example
60
+ * const obj = store.toObject()
30
61
  */
31
62
  toObject(): any;
32
63
  /**
33
- * Returns the store values
64
+ * Returns the store values as JSON-serializable data
65
+ *
66
+ * @example
67
+ * const json = store.toJSON()
34
68
  */
35
69
  toJSON(): any;
36
70
  /**
37
71
  * Returns string representation of the store
72
+ *
73
+ * @example
74
+ * const str = store.toString()
38
75
  */
39
76
  toString(): string;
40
77
  }
41
78
  /**
42
79
  * Session store encapsulates the session data and offers a
43
80
  * declarative API to mutate it.
81
+ *
82
+ * @example
83
+ * const store = new ValuesStore({ counter: 0 })
84
+ * store.set('username', 'john')
85
+ * store.increment('counter')
86
+ * const hasData = store.hasBeenModified
44
87
  */
45
88
  export declare class ValuesStore extends ReadOnlyValuesStore {
46
89
  #private;
90
+ /**
91
+ * Creates a new values store
92
+ *
93
+ * @param values - Initial session data or null
94
+ */
47
95
  constructor(values: SessionData | null);
48
96
  /**
49
- * Find if the store has been modified.
97
+ * Returns true if the store has been modified
50
98
  */
51
99
  get hasBeenModified(): boolean;
52
100
  /**
53
- * Set key/value pair
101
+ * Sets a key/value pair in the store
102
+ *
103
+ * @param key - The key or key path to set
104
+ * @param value - The value to set
105
+ *
106
+ * @example
107
+ * store.set('username', 'john')
108
+ * store.set(['user', 'preferences'], { theme: 'dark' })
54
109
  */
55
110
  set(key: string | string[], value: AllowedSessionValues): void;
56
111
  /**
57
- * Remove key
112
+ * Removes a key from the store
113
+ *
114
+ * @param key - The key or key path to remove
115
+ *
116
+ * @example
117
+ * store.unset('temp_data')
118
+ * store.unset(['user', 'cache'])
58
119
  */
59
120
  unset(key: string | string[]): void;
60
121
  /**
61
- * Pull value from the store. It is same as calling
62
- * store.get and then store.unset
122
+ * Pulls value from the store. Same as calling store.get then store.unset.
123
+ *
124
+ * @param key - The key or key path to pull
125
+ * @param defaultValue - Default value if key doesn't exist
126
+ *
127
+ * @example
128
+ * const message = store.pull('notification', 'No messages')
129
+ * const data = store.pull(['temp', 'data'])
63
130
  */
64
131
  pull(key: string | string[], defaultValue?: any): any;
65
132
  /**
66
- * Increment number. The method raises an error when
67
- * nderlying value is not a number
133
+ * Increments a numeric value. Raises an error when underlying value is not a number.
134
+ *
135
+ * @param key - The key or key path to increment
136
+ * @param steps - Number of steps to increment (default: 1)
137
+ *
138
+ * @example
139
+ * store.increment('page_views') // Increments by 1
140
+ * store.increment('score', 10) // Increments by 10
68
141
  */
69
142
  increment(key: string | string[], steps?: number): void;
70
143
  /**
71
- * Increment number. The method raises an error when
72
- * nderlying value is not a number
144
+ * Decrements a numeric value. Raises an error when underlying value is not a number.
145
+ *
146
+ * @param key - The key or key path to decrement
147
+ * @param steps - Number of steps to decrement (default: 1)
148
+ *
149
+ * @example
150
+ * store.decrement('attempts') // Decrements by 1
151
+ * store.decrement('credits', 5) // Decrements by 5
73
152
  */
74
153
  decrement(key: string | string[], steps?: number): void;
75
154
  /**
76
- * Overwrite existing store data with new values.
155
+ * Overwrites existing store data with new values
156
+ *
157
+ * @param values - New values to replace existing data
158
+ *
159
+ * @example
160
+ * store.update({ username: 'jane', theme: 'light' })
77
161
  */
78
162
  update(values: {
79
163
  [key: string]: any;
80
164
  }): void;
81
165
  /**
82
- * Update to merge values
166
+ * Merges values with existing store data
167
+ *
168
+ * @param values - Values to merge with existing data
169
+ *
170
+ * @example
171
+ * store.merge({ newField: 'value', existingField: 'updated' })
83
172
  */
84
173
  merge(values: {
85
174
  [key: string]: any;
86
175
  }): any;
87
176
  /**
88
- * Reset store by clearing it's values.
177
+ * Resets store by clearing all values
178
+ *
179
+ * @example
180
+ * store.clear() // Removes all data from store
89
181
  */
90
182
  clear(): void;
91
183
  }