@adonisjs/session 7.0.0-2 → 7.0.0-3
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/README.md +5 -8
- package/build/index.d.ts +5 -3
- package/build/index.js +5 -3
- package/build/providers/session_provider.d.ts +5 -8
- package/build/providers/session_provider.js +13 -35
- package/build/src/client.d.ts +13 -25
- package/build/src/client.js +24 -43
- package/build/src/debug.d.ts +3 -0
- package/build/src/debug.js +10 -0
- package/build/src/define_config.d.ts +6 -3
- package/build/src/define_config.js +34 -5
- package/build/src/drivers/cookie.d.ts +7 -9
- package/build/src/drivers/cookie.js +10 -6
- package/build/src/drivers/file.d.ts +11 -14
- package/build/src/drivers/file.js +64 -41
- package/build/src/drivers/memory.d.ts +4 -8
- package/build/src/drivers/memory.js +0 -3
- package/build/src/drivers/redis.d.ts +4 -6
- package/build/src/drivers/redis.js +24 -28
- package/build/src/drivers_collection.d.ts +22 -0
- package/build/src/drivers_collection.js +38 -0
- package/build/src/errors.d.ts +8 -0
- package/build/src/errors.js +17 -0
- package/build/src/helpers.d.ts +6 -0
- package/build/src/helpers.js +37 -0
- package/build/src/session.d.ts +86 -59
- package/build/src/session.js +221 -221
- package/build/src/session_middleware.d.ts +19 -5
- package/build/src/session_middleware.js +42 -6
- package/build/src/store.d.ts +17 -14
- package/build/src/store.js +33 -17
- package/build/src/types/extended.d.ts +19 -0
- package/build/src/types/main.d.ts +106 -0
- package/build/src/types/main.js +9 -0
- package/package.json +23 -20
- package/build/src/bindings/api_client.d.ts +0 -2
- package/build/src/bindings/api_client.js +0 -135
- package/build/src/bindings/http_context.d.ts +0 -5
- package/build/src/bindings/http_context.js +0 -17
- package/build/src/bindings/types.d.ts +0 -77
- package/build/src/session_manager.d.ts +0 -38
- package/build/src/session_manager.js +0 -149
- package/build/src/types.d.ts +0 -61
- package/build/src/types.js +0 -1
- /package/build/src/{bindings/types.js → types/extended.js} +0 -0
package/build/src/session.d.ts
CHANGED
|
@@ -1,132 +1,159 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { EmitterService } from '@adonisjs/core/types';
|
|
2
2
|
import type { HttpContext } from '@adonisjs/core/http';
|
|
3
3
|
import { Store } from './store.js';
|
|
4
|
+
import type { SessionData, SessionConfig, AllowedSessionValues, SessionDriverContract } from './types/main.js';
|
|
5
|
+
import { HttpError } from '@adonisjs/core/types/http';
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
+
* The session class exposes the API to read and write values to
|
|
8
|
+
* the session store.
|
|
9
|
+
*
|
|
10
|
+
* A session instance is isolated between requests but
|
|
11
|
+
* uses a centralized persistence store and
|
|
7
12
|
*/
|
|
8
13
|
export declare class Session {
|
|
9
14
|
#private;
|
|
10
15
|
/**
|
|
11
|
-
*
|
|
16
|
+
* Store of flash messages that be written during the
|
|
17
|
+
* HTTP request
|
|
12
18
|
*/
|
|
13
|
-
|
|
19
|
+
responseFlashMessages: Store;
|
|
14
20
|
/**
|
|
15
|
-
*
|
|
16
|
-
* sessions are those, whose session id is not present
|
|
17
|
-
* in cookie
|
|
21
|
+
* Store of flash messages for the current HTTP request.
|
|
18
22
|
*/
|
|
19
|
-
|
|
23
|
+
flashMessages: Store;
|
|
20
24
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
25
|
+
* The key to use for storing flash messages inside
|
|
26
|
+
* the session store.
|
|
23
27
|
*/
|
|
24
|
-
|
|
28
|
+
flashKey: string;
|
|
25
29
|
/**
|
|
26
|
-
* Session id for the
|
|
27
|
-
* generated when the cookie for the session id is missing
|
|
30
|
+
* Session id for the current HTTP request
|
|
28
31
|
*/
|
|
29
|
-
sessionId: string;
|
|
32
|
+
get sessionId(): string;
|
|
30
33
|
/**
|
|
31
|
-
* A
|
|
34
|
+
* A boolean to know if a fresh session is created during
|
|
35
|
+
* the request
|
|
32
36
|
*/
|
|
33
|
-
|
|
37
|
+
get fresh(): boolean;
|
|
34
38
|
/**
|
|
35
|
-
* A
|
|
36
|
-
*
|
|
37
|
-
* methods are used.
|
|
38
|
-
*
|
|
39
|
-
* The `others` object is expanded with each call.
|
|
39
|
+
* A boolean to know if session is in readonly
|
|
40
|
+
* state
|
|
40
41
|
*/
|
|
41
|
-
|
|
42
|
-
constructor(ctx: HttpContext, config: SessionConfig, driver: SessionDriverContract);
|
|
42
|
+
get readonly(): boolean;
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
45
|
-
* driver and feeding it to a store.
|
|
46
|
-
*
|
|
47
|
-
* Multiple calls to `initiate` results in a noop.
|
|
44
|
+
* A boolean to know if session store has been initiated
|
|
48
45
|
*/
|
|
49
|
-
|
|
46
|
+
get initiated(): boolean;
|
|
50
47
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
48
|
+
* A boolean to know if the session id has been re-generated
|
|
49
|
+
* during the current request
|
|
53
50
|
*/
|
|
54
|
-
|
|
51
|
+
get hasRegeneratedSession(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* A boolean to know if the session store is empty
|
|
54
|
+
*/
|
|
55
|
+
get isEmpty(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* A boolean to know if the session store has been
|
|
58
|
+
* modified
|
|
59
|
+
*/
|
|
60
|
+
get hasBeenModified(): boolean;
|
|
61
|
+
constructor(config: SessionConfig, driver: SessionDriverContract, emitter: EmitterService, ctx: HttpContext);
|
|
62
|
+
/**
|
|
63
|
+
* Initiates the session store. The method results in a noop
|
|
64
|
+
* when called multiple times
|
|
65
|
+
*/
|
|
66
|
+
initiate(readonly: boolean): Promise<void>;
|
|
55
67
|
/**
|
|
56
|
-
*
|
|
68
|
+
* Put a key-value pair to the session data store
|
|
57
69
|
*/
|
|
58
70
|
put(key: string, value: AllowedSessionValues): void;
|
|
59
71
|
/**
|
|
60
|
-
*
|
|
72
|
+
* Check if a key exists inside the datastore
|
|
61
73
|
*/
|
|
62
74
|
has(key: string): boolean;
|
|
63
75
|
/**
|
|
64
|
-
* Get value from the session.
|
|
65
|
-
*
|
|
76
|
+
* Get the value of a key from the session datastore.
|
|
77
|
+
* You can specify a default value to use, when key
|
|
78
|
+
* does not exists or has undefined value.
|
|
66
79
|
*/
|
|
67
80
|
get(key: string, defaultValue?: any): any;
|
|
68
81
|
/**
|
|
69
|
-
*
|
|
82
|
+
* Get everything from the session store
|
|
70
83
|
*/
|
|
71
84
|
all(): any;
|
|
72
85
|
/**
|
|
73
|
-
* Remove
|
|
86
|
+
* Remove a key from the session datastore
|
|
74
87
|
*/
|
|
75
88
|
forget(key: string): void;
|
|
76
89
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
90
|
+
* Read value for a key from the session datastore
|
|
91
|
+
* and remove it simultaneously.
|
|
79
92
|
*/
|
|
80
93
|
pull(key: string, defaultValue?: any): any;
|
|
81
94
|
/**
|
|
82
|
-
* Increment value
|
|
83
|
-
*
|
|
84
|
-
*
|
|
95
|
+
* Increment the value of a key inside the session
|
|
96
|
+
* store.
|
|
97
|
+
*
|
|
98
|
+
* A new key will be defined if does not exists already.
|
|
99
|
+
* The value of a new key will be 1
|
|
85
100
|
*/
|
|
86
101
|
increment(key: string, steps?: number): void;
|
|
87
102
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
103
|
+
* Increment the value of a key inside the session
|
|
104
|
+
* store.
|
|
105
|
+
*
|
|
106
|
+
* A new key will be defined if does not exists already.
|
|
107
|
+
* The value of a new key will be -1
|
|
91
108
|
*/
|
|
92
109
|
decrement(key: string, steps?: number): void;
|
|
93
110
|
/**
|
|
94
|
-
*
|
|
111
|
+
* Empty the session store
|
|
95
112
|
*/
|
|
96
113
|
clear(): void;
|
|
97
114
|
/**
|
|
98
|
-
*
|
|
115
|
+
* Flash validation error messages. Make sure the error
|
|
116
|
+
* is an instance of VineJS ValidationException
|
|
99
117
|
*/
|
|
100
|
-
|
|
101
|
-
[key: string]: AllowedSessionValues;
|
|
102
|
-
}, value?: AllowedSessionValues): void;
|
|
118
|
+
flashValidationErrors(error: HttpError): void;
|
|
103
119
|
/**
|
|
104
|
-
*
|
|
120
|
+
* Add a key-value pair to flash messages
|
|
121
|
+
*/
|
|
122
|
+
flash(key: string, value: AllowedSessionValues): void;
|
|
123
|
+
flash(keyValue: SessionData): void;
|
|
124
|
+
/**
|
|
125
|
+
* Flash form input data to the flash messages store
|
|
105
126
|
*/
|
|
106
127
|
flashAll(): void;
|
|
107
128
|
/**
|
|
108
|
-
* Flash
|
|
129
|
+
* Flash form input data (except some keys) to the flash messages store
|
|
109
130
|
*/
|
|
110
131
|
flashExcept(keys: string[]): void;
|
|
111
132
|
/**
|
|
112
|
-
* Flash only
|
|
133
|
+
* Flash form input data (only some keys) to the flash messages store
|
|
113
134
|
*/
|
|
114
135
|
flashOnly(keys: string[]): void;
|
|
115
136
|
/**
|
|
116
|
-
* Reflash
|
|
137
|
+
* Reflash messages from the last request in the current response
|
|
117
138
|
*/
|
|
118
139
|
reflash(): void;
|
|
119
140
|
/**
|
|
120
|
-
* Reflash
|
|
141
|
+
* Reflash messages (only some keys) from the last
|
|
142
|
+
* request in the current response
|
|
121
143
|
*/
|
|
122
144
|
reflashOnly(keys: string[]): void;
|
|
123
145
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
146
|
+
* Reflash messages (except some keys) from the last
|
|
147
|
+
* request in the current response
|
|
126
148
|
*/
|
|
127
149
|
reflashExcept(keys: string[]): void;
|
|
128
150
|
/**
|
|
129
|
-
*
|
|
151
|
+
* Re-generate the session id and migrate data to it.
|
|
152
|
+
*/
|
|
153
|
+
regenerate(): void;
|
|
154
|
+
/**
|
|
155
|
+
* Commit session changes. No more mutations will be
|
|
156
|
+
* allowed after commit.
|
|
130
157
|
*/
|
|
131
158
|
commit(): Promise<void>;
|
|
132
159
|
}
|