@c9up/ream 0.1.32 → 0.1.33
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/dist/Application.d.ts +27 -0
- package/dist/Application.d.ts.map +1 -1
- package/dist/Application.js +29 -0
- package/dist/Application.js.map +1 -1
- package/dist/ErrorBoundary.d.ts.map +1 -1
- package/dist/ErrorBoundary.js +13 -1
- package/dist/ErrorBoundary.js.map +1 -1
- package/dist/HttpKernel.d.ts +8 -0
- package/dist/HttpKernel.d.ts.map +1 -1
- package/dist/HttpKernel.js +35 -12
- package/dist/HttpKernel.js.map +1 -1
- package/dist/Ignitor.d.ts +8 -0
- package/dist/Ignitor.d.ts.map +1 -1
- package/dist/Ignitor.js +39 -0
- package/dist/Ignitor.js.map +1 -1
- package/dist/bodyparser/BodyParserMiddleware.d.ts +11 -4
- package/dist/bodyparser/BodyParserMiddleware.d.ts.map +1 -1
- package/dist/bodyparser/BodyParserMiddleware.js +55 -43
- package/dist/bodyparser/BodyParserMiddleware.js.map +1 -1
- package/dist/bodyparser/qsParse.d.ts +52 -0
- package/dist/bodyparser/qsParse.d.ts.map +1 -0
- package/dist/bodyparser/qsParse.js +161 -0
- package/dist/bodyparser/qsParse.js.map +1 -0
- package/dist/bootstrap/hyper-server.d.ts.map +1 -1
- package/dist/bootstrap/hyper-server.js +2 -8
- package/dist/bootstrap/hyper-server.js.map +1 -1
- package/dist/container/Container.d.ts +41 -0
- package/dist/container/Container.d.ts.map +1 -1
- package/dist/container/Container.js +193 -26
- package/dist/container/Container.js.map +1 -1
- package/dist/container/ContainerResolver.d.ts +46 -0
- package/dist/container/ContainerResolver.d.ts.map +1 -0
- package/dist/container/ContainerResolver.js +60 -0
- package/dist/container/ContainerResolver.js.map +1 -0
- package/dist/container/ContextualBindingsBuilder.d.ts +20 -0
- package/dist/container/ContextualBindingsBuilder.d.ts.map +1 -0
- package/dist/container/ContextualBindingsBuilder.js +31 -0
- package/dist/container/ContextualBindingsBuilder.js.map +1 -0
- package/dist/container/types.d.ts +9 -6
- package/dist/container/types.d.ts.map +1 -1
- package/dist/decorators/Service.d.ts +1 -5
- package/dist/decorators/Service.d.ts.map +1 -1
- package/dist/decorators/Service.js +10 -1
- package/dist/decorators/Service.js.map +1 -1
- package/dist/events/Emitter.d.ts +66 -6
- package/dist/events/Emitter.d.ts.map +1 -1
- package/dist/events/Emitter.js +165 -28
- package/dist/events/Emitter.js.map +1 -1
- package/dist/graphql/GraphQLEngine.d.ts.map +1 -1
- package/dist/graphql/GraphQLEngine.js +5 -5
- package/dist/graphql/GraphQLEngine.js.map +1 -1
- package/dist/helpers/duration.d.ts +32 -0
- package/dist/helpers/duration.d.ts.map +1 -0
- package/dist/helpers/duration.js +74 -0
- package/dist/helpers/duration.js.map +1 -0
- package/dist/helpers/napi-loader.d.ts +10 -1
- package/dist/helpers/napi-loader.d.ts.map +1 -1
- package/dist/helpers/napi-loader.js +18 -3
- package/dist/helpers/napi-loader.js.map +1 -1
- package/dist/helpers/types.d.ts +1 -1
- package/dist/helpers/types.d.ts.map +1 -1
- package/dist/http/Exception.d.ts.map +1 -1
- package/dist/http/Exception.js +17 -5
- package/dist/http/Exception.js.map +1 -1
- package/dist/http/HttpContext.d.ts +16 -5
- package/dist/http/HttpContext.d.ts.map +1 -1
- package/dist/http/HttpContext.js +4 -2
- package/dist/http/HttpContext.js.map +1 -1
- package/dist/http/RedirectBuilder.d.ts +48 -2
- package/dist/http/RedirectBuilder.d.ts.map +1 -1
- package/dist/http/RedirectBuilder.js +95 -14
- package/dist/http/RedirectBuilder.js.map +1 -1
- package/dist/http/Request.d.ts +128 -8
- package/dist/http/Request.d.ts.map +1 -1
- package/dist/http/Request.js +259 -8
- package/dist/http/Request.js.map +1 -1
- package/dist/http/Response.d.ts +74 -3
- package/dist/http/Response.d.ts.map +1 -1
- package/dist/http/Response.js +177 -4
- package/dist/http/Response.js.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/router/Router.d.ts +36 -7
- package/dist/router/Router.d.ts.map +1 -1
- package/dist/router/Router.js +66 -22
- package/dist/router/Router.js.map +1 -1
- package/dist/security/CookieSigner.d.ts +35 -4
- package/dist/security/CookieSigner.d.ts.map +1 -1
- package/dist/security/CookieSigner.js +99 -10
- package/dist/security/CookieSigner.js.map +1 -1
- package/dist/server/Server.d.ts +2 -3
- package/dist/server/Server.d.ts.map +1 -1
- package/dist/server/Server.js +30 -13
- package/dist/server/Server.js.map +1 -1
- package/dist/session/ReadOnlyValuesStore.d.ts +24 -0
- package/dist/session/ReadOnlyValuesStore.d.ts.map +1 -0
- package/dist/session/ReadOnlyValuesStore.js +45 -0
- package/dist/session/ReadOnlyValuesStore.js.map +1 -0
- package/dist/session/Session.d.ts +181 -9
- package/dist/session/Session.d.ts.map +1 -1
- package/dist/session/Session.js +284 -33
- package/dist/session/Session.js.map +1 -1
- package/dist/session/SessionMiddleware.d.ts.map +1 -1
- package/dist/session/SessionMiddleware.js +87 -33
- package/dist/session/SessionMiddleware.js.map +1 -1
- package/dist/session/drivers/DatabaseDriver.d.ts +66 -0
- package/dist/session/drivers/DatabaseDriver.d.ts.map +1 -0
- package/dist/session/drivers/DatabaseDriver.js +132 -0
- package/dist/session/drivers/DatabaseDriver.js.map +1 -0
- package/dist/session/drivers/FileDriver.d.ts +22 -0
- package/dist/session/drivers/FileDriver.d.ts.map +1 -0
- package/dist/session/drivers/FileDriver.js +66 -0
- package/dist/session/drivers/FileDriver.js.map +1 -0
- package/dist/session/drivers/MemoryDriver.d.ts +10 -2
- package/dist/session/drivers/MemoryDriver.d.ts.map +1 -1
- package/dist/session/drivers/MemoryDriver.js +70 -0
- package/dist/session/drivers/MemoryDriver.js.map +1 -1
- package/dist/session/drivers/RedisDriver.d.ts +10 -2
- package/dist/session/drivers/RedisDriver.d.ts.map +1 -1
- package/dist/session/drivers/RedisDriver.js +58 -0
- package/dist/session/drivers/RedisDriver.js.map +1 -1
- package/dist/session/templateTags.d.ts +42 -0
- package/dist/session/templateTags.d.ts.map +1 -0
- package/dist/session/templateTags.js +101 -0
- package/dist/session/templateTags.js.map +1 -0
- package/dist/testing/RequestBuilder.d.ts +38 -1
- package/dist/testing/RequestBuilder.d.ts.map +1 -1
- package/dist/testing/RequestBuilder.js +40 -1
- package/dist/testing/RequestBuilder.js.map +1 -1
- package/dist/testing/TestClient.d.ts +3 -1
- package/dist/testing/TestClient.d.ts.map +1 -1
- package/dist/testing/TestClient.js +3 -1
- package/dist/testing/TestClient.js.map +1 -1
- package/dist/types/helpers.d.ts +1 -1
- package/dist/types/helpers.d.ts.map +1 -1
- package/dist/utils/Macroable.d.ts +14 -5
- package/dist/utils/Macroable.d.ts.map +1 -1
- package/dist/utils/Macroable.js +20 -18
- package/dist/utils/Macroable.js.map +1 -1
- package/events.win32-x64-msvc.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +1 -1
- package/scheduler.win32-x64-msvc.node +0 -0
- package/src/Application.ts +39 -0
- package/src/ErrorBoundary.ts +13 -1
- package/src/HttpKernel.ts +45 -19
- package/src/Ignitor.ts +39 -0
- package/src/bodyparser/BodyParserMiddleware.ts +66 -44
- package/src/bodyparser/qsParse.ts +179 -0
- package/src/bootstrap/hyper-server.ts +2 -9
- package/src/container/Container.ts +265 -25
- package/src/container/ContainerResolver.ts +84 -0
- package/src/container/ContextualBindingsBuilder.ts +41 -0
- package/src/container/types.ts +11 -7
- package/src/decorators/Service.ts +16 -3
- package/src/events/Emitter.ts +200 -25
- package/src/graphql/GraphQLEngine.ts +7 -8
- package/src/helpers/duration.ts +71 -0
- package/src/helpers/napi-loader.ts +19 -3
- package/src/helpers/types.ts +4 -1
- package/src/http/Exception.ts +17 -5
- package/src/http/HttpContext.ts +20 -5
- package/src/http/RedirectBuilder.ts +126 -11
- package/src/http/Request.ts +283 -13
- package/src/http/Response.ts +213 -6
- package/src/index.ts +17 -3
- package/src/router/Router.ts +98 -33
- package/src/security/CookieSigner.ts +102 -10
- package/src/server/Server.ts +36 -16
- package/src/session/ReadOnlyValuesStore.ts +52 -0
- package/src/session/Session.ts +364 -37
- package/src/session/SessionMiddleware.ts +93 -30
- package/src/session/drivers/DatabaseDriver.ts +184 -0
- package/src/session/drivers/FileDriver.ts +82 -0
- package/src/session/drivers/MemoryDriver.ts +75 -2
- package/src/session/drivers/RedisDriver.ts +77 -2
- package/src/session/templateTags.ts +124 -0
- package/src/testing/RequestBuilder.ts +76 -0
- package/src/testing/TestClient.ts +10 -2
- package/src/types/helpers.ts +4 -1
- package/src/utils/Macroable.ts +23 -8
- package/dist/utils/inflect.d.ts +0 -17
- package/dist/utils/inflect.d.ts.map +0 -1
- package/dist/utils/inflect.js +0 -32
- package/dist/utils/inflect.js.map +0 -1
- package/src/utils/inflect.ts +0 -29
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A read-only bag of values addressed by key or key PATH, shared with templates.
|
|
3
|
+
*
|
|
4
|
+
* This is the shape AdonisJS shares as `session` and `flashMessages`, and the
|
|
5
|
+
* shape its `@error` / `@errors` / `@inputError` tags read — `has(['errorsBag',
|
|
6
|
+
* field])` and `get('inputErrorsBag', {})`. A migrated template relies on it, so
|
|
7
|
+
* the path semantics have to match: a dotted string and an array address the
|
|
8
|
+
* same nested value.
|
|
9
|
+
*/
|
|
10
|
+
/** A key, a dotted key path, or the same path already split. */
|
|
11
|
+
export type ValuePath = string | readonly string[];
|
|
12
|
+
export declare class ReadOnlyValuesStore {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(values: Record<string, unknown> | null);
|
|
15
|
+
/** True when the bag holds nothing — `@if(flashMessages.isEmpty)`. */
|
|
16
|
+
get isEmpty(): boolean;
|
|
17
|
+
/** Every value, as a shallow copy so a template cannot mutate the store. */
|
|
18
|
+
all(): Record<string, unknown>;
|
|
19
|
+
/** The value at `path`, or `defaultValue` when any segment is missing. */
|
|
20
|
+
get(path: ValuePath, defaultValue?: unknown): unknown;
|
|
21
|
+
/** Whether `path` resolves to something other than `undefined`. */
|
|
22
|
+
has(path: ValuePath): boolean;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=ReadOnlyValuesStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReadOnlyValuesStore.d.ts","sourceRoot":"","sources":["../../src/session/ReadOnlyValuesStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,gEAAgE;AAChE,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,MAAM,EAAE,CAAA;AAMlD,qBAAa,mBAAmB;;gBAGlB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAIlD,sEAAsE;IACtE,IAAI,OAAO,IAAI,OAAO,CAErB;IAED,4EAA4E;IAC5E,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAI9B,0EAA0E;IAC1E,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO;IAYrD,mEAAmE;IACnE,GAAG,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO;CAG9B"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A read-only bag of values addressed by key or key PATH, shared with templates.
|
|
3
|
+
*
|
|
4
|
+
* This is the shape AdonisJS shares as `session` and `flashMessages`, and the
|
|
5
|
+
* shape its `@error` / `@errors` / `@inputError` tags read — `has(['errorsBag',
|
|
6
|
+
* field])` and `get('inputErrorsBag', {})`. A migrated template relies on it, so
|
|
7
|
+
* the path semantics have to match: a dotted string and an array address the
|
|
8
|
+
* same nested value.
|
|
9
|
+
*/
|
|
10
|
+
function segments(path) {
|
|
11
|
+
return Array.isArray(path) ? [...path] : String(path).split('.');
|
|
12
|
+
}
|
|
13
|
+
export class ReadOnlyValuesStore {
|
|
14
|
+
#values;
|
|
15
|
+
constructor(values) {
|
|
16
|
+
this.#values = values ?? {};
|
|
17
|
+
}
|
|
18
|
+
/** True when the bag holds nothing — `@if(flashMessages.isEmpty)`. */
|
|
19
|
+
get isEmpty() {
|
|
20
|
+
return Object.keys(this.#values).length === 0;
|
|
21
|
+
}
|
|
22
|
+
/** Every value, as a shallow copy so a template cannot mutate the store. */
|
|
23
|
+
all() {
|
|
24
|
+
return { ...this.#values };
|
|
25
|
+
}
|
|
26
|
+
/** The value at `path`, or `defaultValue` when any segment is missing. */
|
|
27
|
+
get(path, defaultValue) {
|
|
28
|
+
let current = this.#values;
|
|
29
|
+
for (const key of segments(path)) {
|
|
30
|
+
if (current === null || typeof current !== 'object')
|
|
31
|
+
return defaultValue;
|
|
32
|
+
// `Reflect.get` rather than indexing: a flashed key named `__proto__`
|
|
33
|
+
// must read an OWN property, never walk the prototype chain.
|
|
34
|
+
if (!Object.hasOwn(current, key))
|
|
35
|
+
return defaultValue;
|
|
36
|
+
current = Reflect.get(current, key);
|
|
37
|
+
}
|
|
38
|
+
return current === undefined ? defaultValue : current;
|
|
39
|
+
}
|
|
40
|
+
/** Whether `path` resolves to something other than `undefined`. */
|
|
41
|
+
has(path) {
|
|
42
|
+
return this.get(path) !== undefined;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=ReadOnlyValuesStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReadOnlyValuesStore.js","sourceRoot":"","sources":["../../src/session/ReadOnlyValuesStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,SAAS,QAAQ,CAAC,IAAe;IAC/B,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AAClE,CAAC;AAED,MAAM,OAAO,mBAAmB;IACrB,OAAO,CAAyB;IAEzC,YAAY,MAAsC;QAChD,IAAI,CAAC,OAAO,GAAG,MAAM,IAAI,EAAE,CAAA;IAC7B,CAAC;IAED,sEAAsE;IACtE,IAAI,OAAO;QACT,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAA;IAC/C,CAAC;IAED,4EAA4E;IAC5E,GAAG;QACD,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;IAC5B,CAAC;IAED,0EAA0E;IAC1E,GAAG,CAAC,IAAe,EAAE,YAAsB;QACzC,IAAI,OAAO,GAAY,IAAI,CAAC,OAAO,CAAA;QACnC,KAAK,MAAM,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ;gBAAE,OAAO,YAAY,CAAA;YACxE,sEAAsE;YACtE,6DAA6D;YAC7D,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC;gBAAE,OAAO,YAAY,CAAA;YACrD,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAA;QACrC,CAAC;QACD,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAA;IACvD,CAAC;IAED,mEAAmE;IACnE,GAAG,CAAC,IAAe;QACjB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS,CAAA;IACrC,CAAC;CACF"}
|
|
@@ -16,9 +16,61 @@ export interface SessionDriver {
|
|
|
16
16
|
destroy(sessionId: string): Promise<void>;
|
|
17
17
|
touch(sessionId: string, ttl: number): Promise<void>;
|
|
18
18
|
}
|
|
19
|
+
/** One session belonging to a tagged user (AdonisJS `TaggedSession`). */
|
|
20
|
+
export interface TaggedSession {
|
|
21
|
+
id: string;
|
|
22
|
+
data: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* A driver that can associate a session with a user, so every session a user
|
|
26
|
+
* holds can be listed or destroyed — "log me out everywhere", and "these are
|
|
27
|
+
* your active devices" (AdonisJS `SessionStoreWithTaggingContract`).
|
|
28
|
+
*
|
|
29
|
+
* Only the drivers that keep a queryable index can answer: memory, redis and
|
|
30
|
+
* database. The cookie driver holds no server-side state at all, and the file
|
|
31
|
+
* driver would have to scan the directory on every lookup.
|
|
32
|
+
*/
|
|
33
|
+
export interface SessionDriverWithTagging extends SessionDriver {
|
|
34
|
+
tag(sessionId: string, userId: string | number): Promise<void>;
|
|
35
|
+
untag(sessionId: string, userId: string | number): Promise<void>;
|
|
36
|
+
/** Every non-expired session tagged with this user. */
|
|
37
|
+
tagged(userId: string | number): Promise<TaggedSession[]>;
|
|
38
|
+
}
|
|
39
|
+
/** Whether a driver carries the tagging half of the contract. */
|
|
40
|
+
export declare function supportsTagging(driver: SessionDriver): driver is SessionDriverWithTagging;
|
|
19
41
|
export interface SessionConfig {
|
|
20
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Which store to use. AdonisJS names this key `store`; `driver` is ream's
|
|
44
|
+
* older spelling and both are accepted, so a migrated `config/session.ts`
|
|
45
|
+
* runs with its imports rewritten and nothing else.
|
|
46
|
+
*/
|
|
47
|
+
driver?: string;
|
|
48
|
+
/** AdonisJS spelling of {@link driver}. */
|
|
49
|
+
store?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Named stores, AdonisJS-style: `{ store: 'redis', stores: { redis: … } }`.
|
|
52
|
+
* The selected entry supplies the driver name and its options.
|
|
53
|
+
*/
|
|
54
|
+
stores?: Record<string, {
|
|
55
|
+
driver: string;
|
|
56
|
+
} & Record<string, unknown>>;
|
|
57
|
+
/** `file` driver only — the directory session files are written to. */
|
|
58
|
+
location?: string;
|
|
59
|
+
/** `database` driver only — the connection to store sessions on. */
|
|
60
|
+
dbConnection?: unknown;
|
|
61
|
+
/** `database` driver only — the table holding them (default `sessions`). */
|
|
62
|
+
tableName?: string;
|
|
63
|
+
/**
|
|
64
|
+
* `database` driver only — percent chance that a write also sweeps expired
|
|
65
|
+
* rows (AdonisJS `gcProbability`, default 2). `0` turns it off.
|
|
66
|
+
*/
|
|
67
|
+
gcProbability?: number;
|
|
21
68
|
cookieName?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Session lifetime. A bare number is SECONDS; a string carries a unit
|
|
71
|
+
* (`'2h'`), which is how AdonisJS writes it (`age: string | number`).
|
|
72
|
+
*/
|
|
73
|
+
age?: number | string;
|
|
22
74
|
maxAge?: number;
|
|
23
75
|
clearWithBrowser?: boolean;
|
|
24
76
|
/**
|
|
@@ -83,14 +135,75 @@ export declare class Session {
|
|
|
83
135
|
increment(key: string, amount?: number): void;
|
|
84
136
|
/** Decrement a numeric value. */
|
|
85
137
|
decrement(key: string, amount?: number): void;
|
|
86
|
-
/**
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
138
|
+
/**
|
|
139
|
+
* @internal Give the session read access to the request's ORIGINAL input.
|
|
140
|
+
*
|
|
141
|
+
* AdonisJS's session holds the HTTP context and reads `request.original()`;
|
|
142
|
+
* ream's Session stays free of it, so the middleware injects a reader. Absent
|
|
143
|
+
* (a session built outside a request), the input-flashing methods flash
|
|
144
|
+
* nothing rather than throwing.
|
|
145
|
+
*/
|
|
146
|
+
setInputReader(read: () => Record<string, unknown>): void;
|
|
147
|
+
/**
|
|
148
|
+
* Set flash data, available only on the next request.
|
|
149
|
+
*
|
|
150
|
+
* Takes a key and a value, or an object of both (AdonisJS accepts either).
|
|
151
|
+
*/
|
|
152
|
+
flash(key: string | Record<string, unknown>, value?: unknown): void;
|
|
153
|
+
/**
|
|
154
|
+
* Flash the whole request input for the next request (AdonisJS `flashAll`).
|
|
155
|
+
*
|
|
156
|
+
* Takes NO argument: it reads the request's original input itself, which is
|
|
157
|
+
* what makes `session.flashAll()` before a redirect-back repopulate a form.
|
|
158
|
+
*/
|
|
159
|
+
flashAll(): void;
|
|
160
|
+
/** Flash only these input keys (AdonisJS `flashOnly`). */
|
|
161
|
+
flashOnly(keys: string[]): void;
|
|
162
|
+
/**
|
|
163
|
+
* Flash the request input except these keys (AdonisJS `flashExcept`).
|
|
164
|
+
*
|
|
165
|
+
* session.flashExcept(['password', '_csrf'])
|
|
166
|
+
*/
|
|
167
|
+
flashExcept(keys: string[]): void;
|
|
168
|
+
/**
|
|
169
|
+
* Flash an error collection under `errorsBag` (AdonisJS `flashErrors`) —
|
|
170
|
+
* where the `@error` / `@errors` template tags read from.
|
|
171
|
+
*/
|
|
172
|
+
flashErrors(errors: Record<string, string | string[]>): void;
|
|
173
|
+
/**
|
|
174
|
+
* Flash a validation failure the way a form expects it (AdonisJS
|
|
175
|
+
* `flashValidationErrors`): the per-field messages under `inputErrorsBag`,
|
|
176
|
+
* a summary under `errorsBag`, and — unless told otherwise — the input, so
|
|
177
|
+
* the redisplayed form keeps what the user typed.
|
|
178
|
+
*/
|
|
179
|
+
flashValidationErrors(error: {
|
|
180
|
+
code?: string;
|
|
181
|
+
messages?: Array<{
|
|
182
|
+
field?: string;
|
|
183
|
+
message?: string;
|
|
184
|
+
}>;
|
|
185
|
+
}, withInput?: boolean): void;
|
|
186
|
+
/**
|
|
187
|
+
* Keep the PREVIOUS request's flash data for one more request (AdonisJS
|
|
188
|
+
* `reflash`) — what a redirect chain needs so a message survives the hop.
|
|
189
|
+
*/
|
|
190
|
+
reflash(): void;
|
|
191
|
+
/** Keep only these keys of the previous flash data (AdonisJS `reflashOnly`). */
|
|
192
|
+
reflashOnly(keys: string[]): void;
|
|
193
|
+
/** Keep the previous flash data except these keys (AdonisJS `reflashExcept`). */
|
|
194
|
+
reflashExcept(keys: string[]): void;
|
|
195
|
+
/**
|
|
196
|
+
* Remember where the user was heading (AdonisJS `setIntendedUrl`).
|
|
197
|
+
*
|
|
198
|
+
* An auth middleware stores it before redirecting to the login page, so the
|
|
199
|
+
* user lands back on the page they asked for instead of a generic dashboard.
|
|
200
|
+
*/
|
|
201
|
+
setIntendedUrl(url: string): void;
|
|
202
|
+
/** The remembered URL, or null. */
|
|
203
|
+
getIntendedUrl(): string | null;
|
|
204
|
+
/** Read it and forget it — the usual call right after a successful login. */
|
|
205
|
+
pullIntendedUrl(): string | null;
|
|
206
|
+
clearIntendedUrl(): void;
|
|
94
207
|
/** Get a flashed value from the previous request. */
|
|
95
208
|
flashMessages(): Record<string, unknown>;
|
|
96
209
|
/** Get a specific flash message from the previous request. */
|
|
@@ -98,5 +211,64 @@ export declare class Session {
|
|
|
98
211
|
/** Serialize for storage. Includes flash data for next request. */
|
|
99
212
|
toJSON(): Record<string, unknown>;
|
|
100
213
|
isDirty(): boolean;
|
|
214
|
+
/** AdonisJS spelling of {@link isDirty}. */
|
|
215
|
+
get hasBeenModified(): boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Whether this session was created during THIS request — no session cookie
|
|
218
|
+
* came in with it (AdonisJS `fresh`).
|
|
219
|
+
*/
|
|
220
|
+
get fresh(): boolean;
|
|
221
|
+
/**
|
|
222
|
+
* Whether the session holds nothing (AdonisJS `isEmpty`). Flash data counts:
|
|
223
|
+
* a session carrying only a flash message still has something to write.
|
|
224
|
+
*/
|
|
225
|
+
get isEmpty(): boolean;
|
|
226
|
+
/**
|
|
227
|
+
* Whether writes are refused (AdonisJS `readonly`). Always false here: ream
|
|
228
|
+
* has no read-only session mode, and reporting `true` would tell a caller
|
|
229
|
+
* its writes were dropped when they were not.
|
|
230
|
+
*/
|
|
231
|
+
get readonly(): boolean;
|
|
232
|
+
/**
|
|
233
|
+
* @internal Wire the store this session lives in. Called by
|
|
234
|
+
* `SessionMiddleware`; a session built by hand in a test has none, and
|
|
235
|
+
* {@link initiate} / {@link commit} then have nothing to do.
|
|
236
|
+
*/
|
|
237
|
+
setStore(driver: SessionDriver, options: {
|
|
238
|
+
fresh: boolean;
|
|
239
|
+
ttl: number;
|
|
240
|
+
}): void;
|
|
241
|
+
/**
|
|
242
|
+
* Load the session from its store (AdonisJS `initiate`).
|
|
243
|
+
*
|
|
244
|
+
* Idempotent, as upstream: calling it twice is a no-op, so a middleware that
|
|
245
|
+
* runs on a sub-request cannot wipe what the outer one already read.
|
|
246
|
+
*/
|
|
247
|
+
initiate(): Promise<void>;
|
|
248
|
+
/**
|
|
249
|
+
* Persist the session to its store (AdonisJS `commit`).
|
|
250
|
+
*
|
|
251
|
+
* - regenerated: write under the NEW id first, then drop the old entry, so a
|
|
252
|
+
* crash between the two leaves the user with a valid session under one id
|
|
253
|
+
* rather than none.
|
|
254
|
+
* - modified: write.
|
|
255
|
+
* - untouched but pre-existing: touch, to slide the expiry.
|
|
256
|
+
* - untouched and brand new: nothing. Writing here would hand out a session
|
|
257
|
+
* id pointing at a row nobody asked for.
|
|
258
|
+
*/
|
|
259
|
+
commit(): Promise<void>;
|
|
260
|
+
/**
|
|
261
|
+
* Whether the store behind this session can tag sessions with a user
|
|
262
|
+
* (AdonisJS `supportsTagging`). False under the cookie and file drivers.
|
|
263
|
+
*/
|
|
264
|
+
supportsTagging(): boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Associate this session with a user, so every session that user holds can
|
|
267
|
+
* be found later (AdonisJS `tag`) — what "log out from all my devices" and
|
|
268
|
+
* "your active sessions" are built on. Call it at login.
|
|
269
|
+
*/
|
|
270
|
+
tag(userId: string | number): Promise<void>;
|
|
271
|
+
/** Drop the association made by {@link tag} (AdonisJS `untag`). Call it at logout. */
|
|
272
|
+
untag(userId: string | number): Promise<void>;
|
|
101
273
|
}
|
|
102
274
|
//# sourceMappingURL=Session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Session.d.ts","sourceRoot":"","sources":["../../src/session/Session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAA;AAExE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