@sasjs/adapter 4.2.4 → 4.3.1

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.
@@ -185,6 +185,7 @@ export declare class SASViyaApiClient {
185
185
  getAccessToken(clientId: string, clientSecret: string, authCode: string): Promise<SasAuthResponse>;
186
186
  /**
187
187
  * Exchanges the refresh token for an access token for the given client.
188
+ * This method can only be used by Node.
188
189
  * @param clientId - the client ID to authenticate with.
189
190
  * @param clientSecret - the client secret to authenticate with.
190
191
  * @param refreshToken - the refresh token received from the server.
@@ -8,18 +8,104 @@ export declare class SessionManager {
8
8
  constructor(serverUrl: string, contextName: string, requestClient: RequestClient);
9
9
  private sessions;
10
10
  private currentContext;
11
+ private settingContext;
11
12
  private _debug;
12
13
  private printedSessionState;
13
14
  get debug(): boolean;
14
15
  set debug(value: boolean);
15
- getSession(accessToken?: string): Promise<Session | undefined>;
16
+ /**
17
+ * Checks if session is valid. Session is considered valid if time since it's creation is less than 'sessionInactiveTimeout' attribute.
18
+ * @param session - session object.
19
+ * @returns - boolean indicating if session is valid.
20
+ */
21
+ private isSessionValid;
22
+ /**
23
+ * Removes session from pool of hot sessions.
24
+ * @param session - session object.
25
+ * @returns - void.
26
+ */
27
+ private removeSessionFromPool;
28
+ /**
29
+ * Filters session pool to keep only valid sessions.
30
+ * @param session - session object.
31
+ * @returns - void.
32
+ */
33
+ private removeExpiredSessions;
34
+ /**
35
+ * Throws set of errors as a single error.
36
+ * @param errors - array of errors or string.
37
+ * @param prefix - an optional final error prefix.
38
+ * @returns - never.
39
+ */
40
+ private throwErrors;
41
+ /**
42
+ * Returns session.
43
+ * If there is a hot session available, it will be returned immediately and an asynchronous request to create new hot session will be submitted.
44
+ * If there is no available session, 2 session creation requests will be submitted. The session is returned once it is created and ready.
45
+ * @param accessToken - an optional access token.
46
+ * @returns - a promise which resolves with a session.
47
+ */
48
+ getSession(accessToken?: string): Promise<Session>;
49
+ /**
50
+ * Returns error message based on the response from SAS API.
51
+ * @param err - an optional access token.
52
+ * @param accessToken - an optional access token.
53
+ * @returns - an error message.
54
+ */
55
+ private getErrorMessage;
56
+ /**
57
+ * Deletes session.
58
+ * @param id - a session id.
59
+ * @param accessToken - an optional access token.
60
+ * @returns - a promise which resolves when session is deleted.
61
+ */
16
62
  clearSession(id: string, accessToken?: string): Promise<void>;
63
+ /**
64
+ * Creates sessions in amount equal to MAX_SESSION_COUNT.
65
+ * @param accessToken - an optional access token.
66
+ * @returns - a promise which resolves when required amount of sessions is created.
67
+ */
17
68
  private createSessions;
69
+ /**
70
+ * Waits for the current context to be set.
71
+ * @returns - a promise which resolves when current context is set.
72
+ */
73
+ private waitForCurrentContext;
74
+ /**
75
+ * Creates and waits for session to be ready.
76
+ * @param accessToken - an optional access token.
77
+ * @returns - a promise which resolves with a session.
78
+ */
18
79
  private createAndWaitForSession;
80
+ /**
81
+ * Sets current context.
82
+ * @param accessToken - an optional access token.
83
+ * @returns - a promise which resolves when current context is set.
84
+ */
19
85
  private setCurrentContext;
20
- private getHeaders;
86
+ /**
87
+ * Waits for session to be ready.
88
+ * @param session - a session object.
89
+ * @param etag - an etag that can be a string or null.
90
+ * @param accessToken - an optional access token.
91
+ * @returns - a promise which resolves with a session state.
92
+ */
21
93
  private waitForSession;
94
+ /**
95
+ * Gets session state.
96
+ * @param url - a URL to get session state.
97
+ * @param etag - an etag string.
98
+ * @param accessToken - an optional access token.
99
+ * @returns - a promise which resolves with a result string and response status.
100
+ */
22
101
  private getSessionState;
102
+ /**
103
+ * Gets variable.
104
+ * @param sessionId - a session id.
105
+ * @param variable - a variable string.
106
+ * @param accessToken - an optional access token.
107
+ * @returns - a promise which resolves with a result that confirms to SessionVariable interface, etag string and status code.
108
+ */
23
109
  getVariable(sessionId: string, variable: string, accessToken?: string): Promise<{
24
110
  result: SessionVariable;
25
111
  etag: string;
@@ -2,6 +2,7 @@ import { AuthConfig, ServerType } from '@sasjs/utils/types';
2
2
  import { RequestClient } from '../request/RequestClient';
3
3
  /**
4
4
  * Returns the auth configuration, refreshing the tokens if necessary.
5
+ * This function can only be used by Node, if a server type is SASVIYA.
5
6
  * @param requestClient - the pre-configured HTTP request client
6
7
  * @param authConfig - an object containing a client ID, secret, access token and refresh token
7
8
  * @param serverType - server type for which refreshing the tokens, defaults to SASVIYA
@@ -2,6 +2,7 @@ import { SasAuthResponse } from '@sasjs/utils/types';
2
2
  import { RequestClient } from '../request/RequestClient';
3
3
  /**
4
4
  * Exchanges the refresh token for an access token for the given client.
5
+ * This function can only be used by Node.
5
6
  * @param requestClient - the pre-configured HTTP request client
6
7
  * @param clientId - the client ID to authenticate with.
7
8
  * @param clientSecret - the client secret to authenticate with.