| 49 | * await session.commit() |
| 50 | */ |
| 51 | export class Session extends Macroable { |
| 52 | #store: SessionStoreContract | SessionStoreWithTaggingContract |
| 53 | #emitter: EmitterService |
| 54 | #ctx: HttpContext |
| 55 | #readonly: boolean = false |
| 56 | |
| 57 | /** |
| 58 | * Session values store that holds the actual session data |
| 59 | */ |
| 60 | #valuesStore?: ValuesStore |
| 61 | |
| 62 | /** |
| 63 | * Session id that will be committed as a cookie during the response |
| 64 | */ |
| 65 | #sessionId: string |
| 66 | |
| 67 | /** |
| 68 | * Session id read from the cookie during the HTTP request. |
| 69 | * May not exist during the first request or will differ from sessionId during regeneration. |
| 70 | */ |
| 71 | #sessionIdFromCookie?: string |
| 72 | |
| 73 | /** |
| 74 | * Store of flash messages that will be written during the HTTP request |
| 75 | */ |
| 76 | responseFlashMessages = new ValuesStore({}) |
| 77 | |
| 78 | /** |
| 79 | * Store of flash messages for the current HTTP request |
| 80 | */ |
| 81 | flashMessages = new ValuesStore({}) |
| 82 | |
| 83 | /** |
| 84 | * The key used for storing flash messages inside the session store |
| 85 | */ |
| 86 | flashKey: string = '__flash__' |
| 87 | |
| 88 | /** |
| 89 | * Gets the session id for the current HTTP request |
| 90 | */ |
| 91 | get sessionId() { |
| 92 | return this.#sessionId |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * Returns true if a fresh session was created during the request |
| 97 | */ |
| 98 | get fresh(): boolean { |
| 99 | return this.#sessionIdFromCookie === undefined |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * Returns true if the session is in readonly state |
| 104 | */ |
| 105 | get readonly() { |
| 106 | return this.#readonly |
| 107 | } |
| 108 |
nothing calls this directly
no outgoing calls
no test coverage detected