@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
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  debug_default
3
- } from "./chunk-ZVSEMDIC.js";
3
+ } from "./chunk-SBOMJK4T.js";
4
4
 
5
5
  // src/stores/dynamodb.ts
6
- import string from "@poppinss/utils/string";
6
+ import string from "@adonisjs/core/helpers/string";
7
7
  import { MessageBuilder } from "@adonisjs/core/helpers";
8
8
  import { marshall, unmarshall } from "@aws-sdk/util-dynamodb";
9
9
  import {
@@ -13,12 +13,39 @@ import {
13
13
  UpdateItemCommand
14
14
  } from "@aws-sdk/client-dynamodb";
15
15
  var DynamoDBStore = class {
16
+ /**
17
+ * DynamoDB client instance
18
+ */
16
19
  #client;
20
+ /**
21
+ * DynamoDB table name
22
+ */
17
23
  #tableName;
24
+ /**
25
+ * Attribute name for the session key
26
+ */
18
27
  #keyAttribute;
28
+ /**
29
+ * Time-to-live in seconds for session expiry
30
+ */
19
31
  #ttlSeconds;
32
+ /**
33
+ * Attribute name for the session value
34
+ */
20
35
  #valueAttribute = "value";
36
+ /**
37
+ * Attribute name for the expiry timestamp
38
+ */
21
39
  #expiresAtAttribute = "expires_at";
40
+ /**
41
+ * Creates a new DynamoDB store instance
42
+ *
43
+ * @param client - DynamoDB client instance
44
+ * @param age - Session age in seconds or time expression (e.g. '2 hours')
45
+ * @param options - Configuration options
46
+ * @param options.tableName - DynamoDB table name (defaults to "Session")
47
+ * @param options.keyAttribute - Key attribute name (defaults to "key")
48
+ */
22
49
  constructor(client, age, options) {
23
50
  this.#client = client;
24
51
  this.#tableName = options?.tableName ?? "Session";
@@ -27,8 +54,12 @@ var DynamoDBStore = class {
27
54
  debug_default("initiating dynamodb store");
28
55
  }
29
56
  /**
30
- * Returns session data. A new item will be created if it's
31
- * missing.
57
+ * Reads session data from DynamoDB
58
+ *
59
+ * @param sessionId - Session identifier
60
+ *
61
+ * @example
62
+ * const data = await store.read('sess_abc123')
32
63
  */
33
64
  async read(sessionId) {
34
65
  debug_default("dynamodb store: reading session data %s", sessionId);
@@ -56,7 +87,13 @@ var DynamoDBStore = class {
56
87
  }
57
88
  }
58
89
  /**
59
- * Write session values to DynamoDB
90
+ * Writes session values to DynamoDB with expiry
91
+ *
92
+ * @param sessionId - Session identifier
93
+ * @param values - Session data to store
94
+ *
95
+ * @example
96
+ * await store.write('sess_abc123', { userId: 123 })
60
97
  */
61
98
  async write(sessionId, values) {
62
99
  debug_default("dynamodb store: writing session data %s, %O", sessionId, values);
@@ -72,7 +109,12 @@ var DynamoDBStore = class {
72
109
  await this.#client.send(command);
73
110
  }
74
111
  /**
75
- * Cleanup session item by removing it
112
+ * Removes session data from DynamoDB
113
+ *
114
+ * @param sessionId - Session identifier to remove
115
+ *
116
+ * @example
117
+ * await store.destroy('sess_abc123')
76
118
  */
77
119
  async destroy(sessionId) {
78
120
  debug_default("dynamodb store: destroying session data %s", sessionId);
@@ -83,7 +125,12 @@ var DynamoDBStore = class {
83
125
  await this.#client.send(command);
84
126
  }
85
127
  /**
86
- * Updates the value expiry
128
+ * Updates the session expiry time in DynamoDB
129
+ *
130
+ * @param sessionId - Session identifier
131
+ *
132
+ * @example
133
+ * await store.touch('sess_abc123')
87
134
  */
88
135
  async touch(sessionId) {
89
136
  debug_default("dynamodb store: touching session data %s", sessionId);
@@ -104,4 +151,3 @@ var DynamoDBStore = class {
104
151
  export {
105
152
  DynamoDBStore
106
153
  };
107
- //# sourceMappingURL=dynamodb-3PG52TE3.js.map
@@ -1 +1 @@
1
- export { SessionMiddlewareFactory } from './session_middleware_factory.js';
1
+ export { SessionMiddlewareFactory } from './session_middleware_factory.ts';
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  defineConfig
3
- } from "../chunk-WUWXIKIB.js";
3
+ } from "../chunk-MVBWJOEG.js";
4
4
  import {
5
5
  SessionMiddleware
6
- } from "../chunk-TZLOND27.js";
7
- import "../chunk-OCQGCVXK.js";
8
- import "../chunk-TE5JP3SX.js";
9
- import "../chunk-ZVSEMDIC.js";
6
+ } from "../chunk-DFXWYDMY.js";
7
+ import "../chunk-SHD6OX52.js";
8
+ import "../chunk-HAD4PFFM.js";
9
+ import "../chunk-SBOMJK4T.js";
10
10
 
11
11
  // factories/session_middleware_factory.ts
12
12
  import { Emitter } from "@adonisjs/core/events";
@@ -47,4 +47,3 @@ var SessionMiddlewareFactory = class {
47
47
  export {
48
48
  SessionMiddlewareFactory
49
49
  };
50
- //# sourceMappingURL=main.js.map
@@ -1,7 +1,7 @@
1
1
  import { Emitter } from '@adonisjs/core/events';
2
2
  import type { EventsList } from '@adonisjs/core/types';
3
- import SessionMiddleware from '../src/session_middleware.js';
4
- import type { SessionConfig, SessionStoreFactory } from '../src/types.js';
3
+ import SessionMiddleware from '../src/session_middleware.ts';
4
+ import type { SessionConfig, SessionStoreFactory } from '../src/types.ts';
5
5
  /**
6
6
  * Exposes the API to create an instance of the session middleware
7
7
  * without additional plumbing
@@ -1,18 +1,26 @@
1
1
  import {
2
2
  debug_default
3
- } from "./chunk-ZVSEMDIC.js";
3
+ } from "./chunk-SBOMJK4T.js";
4
4
 
5
5
  // src/stores/file.ts
6
- import { dirname, join } from "node:path";
7
- import string from "@poppinss/utils/string";
6
+ import { dirname, join } from "path";
7
+ import string from "@adonisjs/core/helpers/string";
8
8
  import { MessageBuilder } from "@adonisjs/core/helpers";
9
- import { access, mkdir, readFile, rm, writeFile, utimes, stat } from "node:fs/promises";
9
+ import { access, mkdir, readFile, rm, writeFile, utimes, stat } from "fs/promises";
10
10
  var FileStore = class {
11
+ /**
12
+ * File store configuration
13
+ */
11
14
  #config;
15
+ /**
16
+ * Session age/expiry time
17
+ */
12
18
  #age;
13
19
  /**
14
- * @param {FileStoreConfig} config
15
- * @param {string|number} The age must be in seconds or a time expression
20
+ * Creates a new file store instance
21
+ *
22
+ * @param config - File store configuration
23
+ * @param age - Session age in seconds or time expression (e.g. '2 hours')
16
24
  */
17
25
  constructor(config, age) {
18
26
  this.#config = config;
@@ -21,12 +29,16 @@ var FileStore = class {
21
29
  }
22
30
  /**
23
31
  * Returns an absolute path to the session id file
32
+ *
33
+ * @param sessionId - Session identifier
24
34
  */
25
35
  #getFilePath(sessionId) {
26
36
  return join(this.#config.location, `${sessionId}.txt`);
27
37
  }
28
38
  /**
29
- * Check if a file exists at a given path or not
39
+ * Checks if a file exists at a given path
40
+ *
41
+ * @param path - File path to check
30
42
  */
31
43
  async #pathExists(path) {
32
44
  try {
@@ -37,8 +49,9 @@ var FileStore = class {
37
49
  }
38
50
  }
39
51
  /**
40
- * Returns stats for a file and ignoring missing
41
- * files.
52
+ * Returns file stats, ignoring missing files
53
+ *
54
+ * @param path - File path to get stats for
42
55
  */
43
56
  async #stats(path) {
44
57
  try {
@@ -49,7 +62,10 @@ var FileStore = class {
49
62
  }
50
63
  }
51
64
  /**
52
- * Output file with contents to the given path
65
+ * Outputs file with contents to the given path, creating directories if needed
66
+ *
67
+ * @param path - File path to write to
68
+ * @param contents - File contents to write
53
69
  */
54
70
  async #outputFile(path, contents) {
55
71
  const pathDirname = dirname(path);
@@ -60,7 +76,12 @@ var FileStore = class {
60
76
  await writeFile(path, contents, "utf-8");
61
77
  }
62
78
  /**
63
- * Reads the session data from the disk.
79
+ * Reads the session data from the disk
80
+ *
81
+ * @param sessionId - Session identifier
82
+ *
83
+ * @example
84
+ * const data = await store.read('sess_abc123')
64
85
  */
65
86
  async read(sessionId) {
66
87
  const filePath = this.#getFilePath(sessionId);
@@ -87,6 +108,12 @@ var FileStore = class {
87
108
  }
88
109
  /**
89
110
  * Writes the session data to the disk as a string
111
+ *
112
+ * @param sessionId - Session identifier
113
+ * @param values - Session data to store
114
+ *
115
+ * @example
116
+ * await store.write('sess_abc123', { userId: 123 })
90
117
  */
91
118
  async write(sessionId, values) {
92
119
  debug_default("file store: writing session data %s: %O", sessionId, values);
@@ -96,14 +123,23 @@ var FileStore = class {
96
123
  }
97
124
  /**
98
125
  * Removes the session file from the disk
126
+ *
127
+ * @param sessionId - Session identifier
128
+ *
129
+ * @example
130
+ * await store.destroy('sess_abc123')
99
131
  */
100
132
  async destroy(sessionId) {
101
133
  debug_default("file store: destroying session data %s", sessionId);
102
134
  await rm(this.#getFilePath(sessionId), { force: true });
103
135
  }
104
136
  /**
105
- * Updates the session expiry by rewriting it to the
106
- * persistence store
137
+ * Updates the session expiry by updating the file's modification time
138
+ *
139
+ * @param sessionId - Session identifier
140
+ *
141
+ * @example
142
+ * await store.touch('sess_abc123')
107
143
  */
108
144
  async touch(sessionId) {
109
145
  debug_default("file store: touching session data %s", sessionId);
@@ -113,4 +149,3 @@ var FileStore = class {
113
149
  export {
114
150
  FileStore
115
151
  };
116
- //# sourceMappingURL=file-B6QKOZXW.js.map
package/build/index.d.ts CHANGED
@@ -6,9 +6,9 @@
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
- export * as errors from './src/errors.js';
10
- export { configure } from './configure.js';
11
- export { Session } from './src/session.js';
12
- export { stubsRoot } from './stubs/main.js';
13
- export { defineConfig, stores } from './src/define_config.js';
14
- export { ReadOnlyValuesStore, ValuesStore } from './src/values_store.js';
9
+ export * as errors from './src/errors.ts';
10
+ export { configure } from './configure.ts';
11
+ export { Session } from './src/session.ts';
12
+ export { stubsRoot } from './stubs/main.ts';
13
+ export { defineConfig, stores } from './src/define_config.ts';
14
+ export { ReadOnlyValuesStore, ValuesStore } from './src/values_store.ts';
package/build/index.js CHANGED
@@ -3,16 +3,16 @@ import {
3
3
  defineConfig,
4
4
  stores,
5
5
  stubsRoot
6
- } from "./chunk-WUWXIKIB.js";
6
+ } from "./chunk-MVBWJOEG.js";
7
7
  import {
8
8
  Session,
9
9
  errors_exports
10
- } from "./chunk-OCQGCVXK.js";
10
+ } from "./chunk-SHD6OX52.js";
11
11
  import {
12
12
  ReadOnlyValuesStore,
13
13
  ValuesStore
14
- } from "./chunk-TE5JP3SX.js";
15
- import "./chunk-ZVSEMDIC.js";
14
+ } from "./chunk-HAD4PFFM.js";
15
+ import "./chunk-SBOMJK4T.js";
16
16
  export {
17
17
  ReadOnlyValuesStore,
18
18
  Session,
@@ -23,4 +23,3 @@ export {
23
23
  stores,
24
24
  stubsRoot
25
25
  };
26
- //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
1
  import type { ApplicationService } from '@adonisjs/core/types';
2
- import type { Session } from '../src/session.js';
2
+ import type { Session } from '../src/session.ts';
3
3
  /**
4
4
  * Events emitted by the session class
5
5
  */
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  SessionMiddleware
3
- } from "../chunk-TZLOND27.js";
4
- import "../chunk-OCQGCVXK.js";
5
- import "../chunk-TE5JP3SX.js";
6
- import "../chunk-ZVSEMDIC.js";
3
+ } from "../chunk-DFXWYDMY.js";
4
+ import "../chunk-SHD6OX52.js";
5
+ import "../chunk-HAD4PFFM.js";
6
+ import "../chunk-SBOMJK4T.js";
7
7
 
8
8
  // providers/session_provider.ts
9
9
  import { configProvider } from "@adonisjs/core";
10
- import { RuntimeException } from "@poppinss/utils";
10
+ import { RuntimeException } from "@adonisjs/core/exceptions";
11
11
  var SessionProvider = class {
12
12
  constructor(app) {
13
13
  this.app = app;
@@ -49,4 +49,3 @@ var SessionProvider = class {
49
49
  export {
50
50
  SessionProvider as default
51
51
  };
52
- //# sourceMappingURL=session_provider.js.map
@@ -1,21 +1,37 @@
1
1
  import {
2
2
  debug_default
3
- } from "./chunk-ZVSEMDIC.js";
3
+ } from "./chunk-SBOMJK4T.js";
4
4
 
5
5
  // src/stores/redis.ts
6
- import string from "@poppinss/utils/string";
6
+ import string from "@adonisjs/core/helpers/string";
7
7
  import { MessageBuilder } from "@adonisjs/core/helpers";
8
8
  var RedisStore = class {
9
+ /**
10
+ * Redis connection instance
11
+ */
9
12
  #connection;
13
+ /**
14
+ * Time-to-live in seconds for session expiry
15
+ */
10
16
  #ttlSeconds;
17
+ /**
18
+ * Creates a new Redis store instance
19
+ *
20
+ * @param connection - Redis connection instance
21
+ * @param age - Session age in seconds or time expression (e.g. '2 hours')
22
+ */
11
23
  constructor(connection, age) {
12
24
  this.#connection = connection;
13
25
  this.#ttlSeconds = string.seconds.parse(age);
14
26
  debug_default("initiating redis store");
15
27
  }
16
28
  /**
17
- * Returns file contents. A new file will be created if it's
18
- * missing.
29
+ * Reads session data from Redis
30
+ *
31
+ * @param sessionId - Session identifier
32
+ *
33
+ * @example
34
+ * const data = await store.read('sess_abc123')
19
35
  */
20
36
  async read(sessionId) {
21
37
  debug_default("redis store: reading session data %s", sessionId);
@@ -30,7 +46,13 @@ var RedisStore = class {
30
46
  }
31
47
  }
32
48
  /**
33
- * Write session values to a file
49
+ * Writes session values to Redis with expiry
50
+ *
51
+ * @param sessionId - Session identifier
52
+ * @param values - Session data to store
53
+ *
54
+ * @example
55
+ * await store.write('sess_abc123', { userId: 123 })
34
56
  */
35
57
  async write(sessionId, values) {
36
58
  debug_default("redis store: writing session data %s, %O", sessionId, values);
@@ -38,14 +60,24 @@ var RedisStore = class {
38
60
  await this.#connection.setex(sessionId, this.#ttlSeconds, message);
39
61
  }
40
62
  /**
41
- * Cleanup session file by removing it
63
+ * Removes session data from Redis
64
+ *
65
+ * @param sessionId - Session identifier to remove
66
+ *
67
+ * @example
68
+ * await store.destroy('sess_abc123')
42
69
  */
43
70
  async destroy(sessionId) {
44
71
  debug_default("redis store: destroying session data %s", sessionId);
45
72
  await this.#connection.del(sessionId);
46
73
  }
47
74
  /**
48
- * Updates the value expiry
75
+ * Updates the session expiry time in Redis
76
+ *
77
+ * @param sessionId - Session identifier
78
+ *
79
+ * @example
80
+ * await store.touch('sess_abc123')
49
81
  */
50
82
  async touch(sessionId) {
51
83
  debug_default("redis store: touching session data %s", sessionId);
@@ -55,4 +87,3 @@ var RedisStore = class {
55
87
  export {
56
88
  RedisStore
57
89
  };
58
- //# sourceMappingURL=redis-CAY24YIA.js.map
@@ -1,37 +1,73 @@
1
- import type { SessionData, SessionStoreContract } from './types.js';
1
+ import type { SessionData, SessionStoreContract } from './types.ts';
2
2
  /**
3
- * Session client exposes the API to set session data as a client
3
+ * Session client exposes the API to set session data as a client.
4
+ * Useful for testing or programmatic session manipulation.
5
+ *
6
+ * @example
7
+ * const client = new SessionClient(store)
8
+ * client.merge({ userId: 123 })
9
+ * client.flash({ success: 'Login successful' })
10
+ * await client.commit()
4
11
  */
5
12
  export declare class SessionClient {
6
13
  #private;
7
14
  /**
8
- * Session key for setting flash messages
15
+ * Session key used for storing flash messages
9
16
  */
10
17
  flashKey: string;
11
18
  /**
12
- * Session to use when no explicit session id is
13
- * defined
19
+ * Session ID to use when no explicit session id is defined
20
+ */
21
+ sessionId: `${string}-${string}-${string}-${string}-${string}`;
22
+ /**
23
+ * Creates a new session client
24
+ *
25
+ * @param store - Session store contract implementation
14
26
  */
15
- sessionId: string;
16
27
  constructor(store: SessionStoreContract);
17
28
  /**
18
- * Merge session data
29
+ * Merges session data with existing values
30
+ *
31
+ * @param values - Session data to merge
32
+ *
33
+ * @example
34
+ * client.merge({ userId: 123, theme: 'dark' })
19
35
  */
20
36
  merge(values: SessionData): this;
21
37
  /**
22
- * Merge flash messages
38
+ * Merges flash messages with existing flash data
39
+ *
40
+ * @param values - Flash message data to merge
41
+ *
42
+ * @example
43
+ * client.flash({ success: 'Operation completed', info: 'Check your email' })
23
44
  */
24
45
  flash(values: SessionData): this;
25
46
  /**
26
- * Commits data to the session store.
47
+ * Commits data to the session store
48
+ *
49
+ * @example
50
+ * await client.commit() // Saves all changes to the store
27
51
  */
28
52
  commit(): Promise<void>;
29
53
  /**
30
- * Destroys the session data with the store
54
+ * Destroys the session data from the store
55
+ *
56
+ * @param sessionId - Optional session ID to destroy (defaults to current session)
57
+ *
58
+ * @example
59
+ * await client.destroy() // Destroy current session
60
+ * await client.destroy('abc123') // Destroy specific session
31
61
  */
32
62
  destroy(sessionId?: string): Promise<void>;
33
63
  /**
34
64
  * Loads session data from the session store
65
+ *
66
+ * @param sessionId - Optional session ID to load (defaults to current session)
67
+ *
68
+ * @example
69
+ * const { values, flashMessages } = await client.load()
70
+ * const data = await client.load('abc123') // Load specific session
35
71
  */
36
72
  load(sessionId?: string): Promise<{
37
73
  values: any;
@@ -1,9 +1,8 @@
1
1
  import {
2
2
  SessionClient
3
- } from "../chunk-GB5FBZCV.js";
4
- import "../chunk-TE5JP3SX.js";
5
- import "../chunk-ZVSEMDIC.js";
3
+ } from "../chunk-Y566BNUT.js";
4
+ import "../chunk-HAD4PFFM.js";
5
+ import "../chunk-SBOMJK4T.js";
6
6
  export {
7
7
  SessionClient
8
8
  };
9
- //# sourceMappingURL=client.js.map
@@ -1,8 +1,8 @@
1
1
  import type { ConfigProvider } from '@adonisjs/core/types';
2
2
  import type { CookieOptions } from '@adonisjs/core/types/http';
3
- import type { SessionConfig, FileStoreConfig, RedisStoreConfig, SessionStoreFactory, DynamoDBStoreConfig } from './types.js';
3
+ import type { SessionConfig, FileStoreConfig, RedisStoreConfig, SessionStoreFactory, DynamoDBStoreConfig } from './types.ts';
4
4
  /**
5
- * Resolved config with stores
5
+ * Resolved session configuration with all stores resolved
6
6
  */
7
7
  type ResolvedConfig<KnownStores extends Record<string, SessionStoreFactory>> = SessionConfig & {
8
8
  store: keyof KnownStores;
@@ -10,7 +10,24 @@ type ResolvedConfig<KnownStores extends Record<string, SessionStoreFactory>> = S
10
10
  cookie: Partial<CookieOptions>;
11
11
  };
12
12
  /**
13
- * Helper to normalize session config
13
+ * Defines and validates session configuration with store setup.
14
+ * Handles default values and store resolution.
15
+ *
16
+ * @param config - Session configuration with stores
17
+ *
18
+ * @example
19
+ * import { defineConfig, stores } from '@adonisjs/session'
20
+ *
21
+ * export default defineConfig({
22
+ * enabled: true,
23
+ * cookieName: 'adonis_session',
24
+ * age: '2 hours',
25
+ * store: 'cookie',
26
+ * stores: {
27
+ * cookie: stores.cookie(),
28
+ * redis: stores.redis({ connection: 'main' })
29
+ * }
30
+ * })
14
31
  */
15
32
  export declare function defineConfig<KnownStores extends Record<string, SessionStoreFactory | ConfigProvider<SessionStoreFactory>>>(config: Partial<SessionConfig> & {
16
33
  store: keyof KnownStores | 'memory';
@@ -19,7 +36,23 @@ export declare function defineConfig<KnownStores extends Record<string, SessionS
19
36
  [K in keyof KnownStores]: SessionStoreFactory;
20
37
  }>>;
21
38
  /**
22
- * Inbuilt stores to store the session data.
39
+ * Built-in session stores for different storage backends.
40
+ * Each store provides a different persistence mechanism for session data.
41
+ *
42
+ * @example
43
+ * import { stores } from '@adonisjs/session'
44
+ *
45
+ * // File store - stores on filesystem
46
+ * stores.file({ location: './tmp/sessions' })
47
+ *
48
+ * // Redis store - stores in Redis
49
+ * stores.redis({ connection: 'main' })
50
+ *
51
+ * // Cookie store - stores in encrypted cookies
52
+ * stores.cookie()
53
+ *
54
+ * // DynamoDB store - stores in AWS DynamoDB
55
+ * stores.dynamodb({ tableName: 'Sessions' })
23
56
  */
24
57
  export declare const stores: {
25
58
  file: (config: FileStoreConfig) => ConfigProvider<SessionStoreFactory>;
@@ -1,8 +1,24 @@
1
1
  /**
2
- * Raised when session store is not mutable
2
+ * Error thrown when attempting to mutate a readonly session store.
3
+ * This occurs when trying to write to a session that was initiated in readonly mode.
4
+ *
5
+ * @example
6
+ * // This will throw E_SESSION_NOT_MUTABLE
7
+ * await session.initiate(true) // readonly mode
8
+ * session.put('key', 'value') // Throws error
3
9
  */
4
- export declare const E_SESSION_NOT_MUTABLE: new (args?: any, options?: ErrorOptions) => import("@poppinss/utils").Exception;
10
+ export declare const E_SESSION_NOT_MUTABLE: new (args?: any, options?: ErrorOptions) => import("@adonisjs/core/exceptions").Exception;
5
11
  /**
6
- * Raised when session store has been initiated
12
+ * Error thrown when attempting to use session before it's been initiated.
13
+ * This usually means the session middleware hasn't been registered or called.
14
+ *
15
+ * @example
16
+ * // This will throw E_SESSION_NOT_READY
17
+ * const session = new Session(config, storeFactory, emitter, ctx)
18
+ * session.put('key', 'value') // Throws error - need to call initiate first
19
+ *
20
+ * // Correct usage:
21
+ * await session.initiate(false)
22
+ * session.put('key', 'value') // Works fine
7
23
  */
8
- export declare const E_SESSION_NOT_READY: new (args?: any, options?: ErrorOptions) => import("@poppinss/utils").Exception;
24
+ export declare const E_SESSION_NOT_READY: new (args?: any, options?: ErrorOptions) => import("@adonisjs/core/exceptions").Exception;
@@ -1,6 +1,16 @@
1
1
  import type { PluginFn } from 'edge.js/types';
2
2
  /**
3
- * The edge plugin for AdonisJS Session adds tags to read
4
- * flash messages
3
+ * The edge plugin for AdonisJS Session adds template tags to read flash messages.
4
+ * Provides @flashMessage, @inputError, @error, and @errors tags for templates.
5
+ *
6
+ * @example
7
+ * // Register the plugin with Edge
8
+ * import { edgePluginSession } from '@adonisjs/session/plugins/edge'
9
+ * edge.use(edgePluginSession)
10
+ *
11
+ * // Use in templates
12
+ * @flashMessage('success')
13
+ * <div class="alert alert-success">{{ $message }}</div>
14
+ * @end
5
15
  */
6
16
  export declare const edgePluginSession: PluginFn<undefined>;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  debug_default
3
- } from "../../chunk-ZVSEMDIC.js";
3
+ } from "../../chunk-SBOMJK4T.js";
4
4
 
5
5
  // src/plugins/edge.ts
6
6
  var edgePluginSession = (edge) => {
@@ -123,4 +123,3 @@ var edgePluginSession = (edge) => {
123
123
  export {
124
124
  edgePluginSession
125
125
  };
126
- //# sourceMappingURL=edge.js.map