UNPKG

2.11 kBTypeScriptView Raw
1/**
2 * An interface handling three level attributes: request, session and persistence.
3 */
4export interface AttributesManager {
5 /**
6 * Provides request attributes for the request life cycle.
7 * @returns {Object.<string, any>}
8 */
9 getRequestAttributes(): {
10 [key: string]: any;
11 };
12 /**
13 * Provides session attributes extracted from request envelope.
14 * @returns {Object.<string, any>}
15 */
16 getSessionAttributes<T = {
17 [key: string]: any;
18 }>(): T;
19 /**
20 * Provides persistent attributes retrieved and cached from persistence adapter, provide false to useSessionCache to ignore values cached from previous invocations.
21 * @param {boolean} [useSessionCache=true]
22 * @returns {Promise<Object.<string, any>>}
23 */
24 getPersistentAttributes(useSessionCache?: boolean, defaultAttributes?: {
25 [key: string]: any;
26 }): Promise<{
27 [key: string]: any;
28 }>;
29 /**
30 * Overwrites the request attributes value.
31 * @param {Object.<string, any>} requestAttributes
32 * @returns {void}
33 */
34 setRequestAttributes(requestAttributes: {
35 [key: string]: any;
36 }): void;
37 /**
38 * Overwrites the session attributes value.
39 * @param {Object.<string, any>} sessionAttributes
40 * @returns {void}
41 */
42 setSessionAttributes(sessionAttributes: {
43 [key: string]: any;
44 }): void;
45 /**
46 * Overwrites and caches the persistent attributes value. Note no persistence layer calls are being made in this function.
47 * @param {Object.<string, any>} persistentAttributes
48 * @returns {void}
49 */
50 setPersistentAttributes(persistentAttributes: {
51 [key: string]: any;
52 }): void;
53 /**
54 * Save persistent attributes to the persistence layer if a persistence adapter is provided.
55 * @return {Promise<void>}
56 */
57 savePersistentAttributes(): Promise<void>;
58 /**
59 * Delete persistent attributes from the persistent layer if a persistence adapter is provided.
60 * @return {Promise<void>}
61 */
62 deletePersistentAttributes?(): Promise<void>;
63}