@sasjs/adapter 5.1.1 → 5.1.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.
Files changed (50) hide show
  1. package/ContextManager.js +2 -2
  2. package/README.md +14 -0
  3. package/SAS9ApiClient.d.ts +2 -3
  4. package/SAS9ApiClient.js +2 -2
  5. package/SASViyaApiClient.d.ts +0 -1
  6. package/SASViyaApiClient.js +11 -11
  7. package/SASjs.d.ts +6 -2
  8. package/SASjs.js +23 -23
  9. package/SASjsApiClient.d.ts +4 -4
  10. package/SASjsApiClient.js +2 -2
  11. package/SessionManager.js +1 -1
  12. package/api/viya/executeOnComputeApi.js +9 -10
  13. package/api/viya/pollJobState.js +3 -3
  14. package/api/viya/saveLog.js +1 -2
  15. package/api/viya/uploadTables.js +1 -2
  16. package/auth/AuthManager.js +2 -2
  17. package/auth/getAccessTokenForSasjs.js +1 -2
  18. package/auth/getAccessTokenForViya.js +1 -2
  19. package/auth/getTokens.js +3 -4
  20. package/auth/openWebPage.js +3 -4
  21. package/auth/refreshTokensForSasjs.js +1 -2
  22. package/auth/refreshTokensForViya.js +1 -2
  23. package/auth/verifySas9Login.js +1 -2
  24. package/auth/verifySasViyaLogin.js +3 -3
  25. package/dist/minified_sas9.js +103 -43
  26. package/dist/sasjs-adapter.js +7309 -7767
  27. package/job-execution/JesJobExecutor.js +2 -2
  28. package/job-execution/Sas9JobExecutor.d.ts +5 -1
  29. package/job-execution/Sas9JobExecutor.js +5 -0
  30. package/job-execution/SasjsJobExecutor.js +2 -2
  31. package/job-execution/WebJobExecutor.js +3 -3
  32. package/minified/sas9/SASjs.js +6 -6
  33. package/minified/sas9/WebJobExecutor.js +2 -2
  34. package/package.json +18 -17
  35. package/request/RequestClient.d.ts +1 -2
  36. package/request/RequestClient.js +10 -10
  37. package/request/Sas9RequestClient.d.ts +22 -5
  38. package/request/Sas9RequestClient.js +90 -22
  39. package/types/SASjsConfig.d.ts +0 -1
  40. package/types/SASjsConfig.js +1 -1
  41. package/types/Session.js +1 -1
  42. package/types/WriteStream.d.ts +0 -2
  43. package/types/errors/UnsafeRedirectError.d.ts +15 -0
  44. package/types/errors/UnsafeRedirectError.js +24 -0
  45. package/types/errors/index.d.ts +1 -0
  46. package/types/errors/index.js +1 -0
  47. package/utils/appendExtraResponseAttributes.js +1 -2
  48. package/utils/asyncForEach.js +1 -2
  49. package/utils/isIeOrEdge.js +1 -2
  50. package/utils/validateInput.d.ts +1 -1
package/ContextManager.js CHANGED
@@ -137,8 +137,8 @@ class ContextManager {
137
137
  return context;
138
138
  });
139
139
  }
140
- createLauncherContext(contextName, description, launchType = 'direct', accessToken) {
141
- return __awaiter(this, void 0, void 0, function* () {
140
+ createLauncherContext(contextName_1, description_1) {
141
+ return __awaiter(this, arguments, void 0, function* (contextName, description, launchType = 'direct', accessToken) {
142
142
  if (!contextName) {
143
143
  throw new Error('Context name is required.');
144
144
  }
package/README.md CHANGED
@@ -116,6 +116,20 @@ sasJs.logIn('USERNAME','PASSWORD'
116
116
 
117
117
  More examples of using authentication, and more, can be found in the [SASjs Seed Apps](https://github.com/search?q=topic%3Asasjs-app+org%3Asasjs+fork%3Atrue) on github.
118
118
 
119
+ ### SAS 9 credentials (deprecated)
120
+
121
+ Earlier versions logged into SAS 9 by passing a username and password, which were appended to the `_program` URL as `_username` and `_password`. This is deprecated.
122
+
123
+ It puts the credentials in a query string - where they are recorded by server logs, proxies, and anything else that logs request URLs - and SAS 9 only accepts them when the platform is configured to allow URL credentials, so it never worked without a server-side change. There is no drop-in replacement for the mechanism itself, and it will be removed in a future major version.
124
+
125
+ It surfaces in three places:
126
+
127
+ - `authConfigSas9` on `executeScript()`
128
+ - the `userName` and `password` arguments of `SAS9ApiClient.executeScript()`
129
+ - `username` and `password` in the job-execution config for `serverType: 'SAS9'`
130
+
131
+ Using it logs a single deprecation warning per process.
132
+
119
133
  ### Request / Response
120
134
 
121
135
  A simple request can be sent to SAS in the following fashion:
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type * as https from 'https';
3
2
  /**
4
3
  * A client for interfacing with the SAS9 REST API.
@@ -23,8 +22,8 @@ export declare class SAS9ApiClient {
23
22
  /**
24
23
  * Executes code on a SAS9 server.
25
24
  * @param linesOfCode - an array of code lines to execute.
26
- * @param userName - the user name to log into the current SAS server.
27
- * @param password - the password to log into the current SAS server.
25
+ * @param userName - the user name to log into the current SAS server. Deprecated with the SAS 9 username / password login - see the "SAS 9 credentials" note in the README.
26
+ * @param password - the password to log into the current SAS server. Deprecated with the SAS 9 username / password login - see the "SAS 9 credentials" note in the README.
28
27
  */
29
28
  executeScript(linesOfCode: string[], userName: string, password: string): Promise<string>;
30
29
  }
package/SAS9ApiClient.js CHANGED
@@ -48,8 +48,8 @@ class SAS9ApiClient {
48
48
  /**
49
49
  * Executes code on a SAS9 server.
50
50
  * @param linesOfCode - an array of code lines to execute.
51
- * @param userName - the user name to log into the current SAS server.
52
- * @param password - the password to log into the current SAS server.
51
+ * @param userName - the user name to log into the current SAS server. Deprecated with the SAS 9 username / password login - see the "SAS 9 credentials" note in the README.
52
+ * @param password - the password to log into the current SAS server. Deprecated with the SAS 9 username / password login - see the "SAS 9 credentials" note in the README.
53
53
  */
54
54
  executeScript(linesOfCode, userName, password) {
55
55
  return __awaiter(this, void 0, void 0, function* () {
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { Job, Session, Context, ContextAllAttributes, Folder, File, EditContextInput, PollOptions } from './types';
3
2
  import { SasAuthResponse, MacroVar, AuthConfig } from '@sasjs/utils/types';
4
3
  import { RequestClient } from './request/RequestClient';
@@ -180,8 +180,8 @@ class SASViyaApiClient {
180
180
  * @param launchType - launch type of the context to be created.
181
181
  * @param accessToken - an access token for an authorized user.
182
182
  */
183
- createLauncherContext(contextName, description, launchType = 'direct', accessToken) {
184
- return __awaiter(this, void 0, void 0, function* () {
183
+ createLauncherContext(contextName_1, description_1) {
184
+ return __awaiter(this, arguments, void 0, function* (contextName, description, launchType = 'direct', accessToken) {
185
185
  return yield this.contextManager.createLauncherContext(contextName, description, launchType, accessToken);
186
186
  });
187
187
  }
@@ -221,8 +221,8 @@ class SASViyaApiClient {
221
221
  * @param variables - an object that represents macro variables.
222
222
  * @param onTokensRefreshed - optional callback invoked with the rotated token pair after a successful internal refresh, so consumers that persist tokens can store the new pair.
223
223
  */
224
- executeScript(jobPath, linesOfCode, contextName, authConfig, data = null, debug = false, expectWebout = false, waitForResult = true, pollOptions, printPid = false, variables, onTokensRefreshed) {
225
- return __awaiter(this, void 0, void 0, function* () {
224
+ executeScript(jobPath_1, linesOfCode_1, contextName_1, authConfig_1) {
225
+ return __awaiter(this, arguments, void 0, function* (jobPath, linesOfCode, contextName, authConfig, data = null, debug = false, expectWebout = false, waitForResult = true, pollOptions, printPid = false, variables, onTokensRefreshed) {
226
226
  return (0, executeOnComputeApi_1.executeOnComputeApi)(this.requestClient, this.sessionManager, this.rootFolderName, jobPath, linesOfCode, contextName, authConfig, data, debug, expectWebout, waitForResult, pollOptions, printPid, variables, onTokensRefreshed);
227
227
  });
228
228
  }
@@ -291,8 +291,8 @@ class SASViyaApiClient {
291
291
  * @param accessToken - an access token for authorizing the request.
292
292
  */
293
293
  createFile(fileName, contentBuffer, parentFolderPath, parentFolderUri, accessToken) {
294
- var _a;
295
294
  return __awaiter(this, void 0, void 0, function* () {
295
+ var _a;
296
296
  if (!parentFolderPath && !parentFolderUri) {
297
297
  throw new Error('Path or URI of the parent folder is required.');
298
298
  }
@@ -554,8 +554,8 @@ class SASViyaApiClient {
554
554
  * @param printPid - a boolean that indicates whether the function should print (PID) of the started job.
555
555
  * @param variables - an object that represents macro variables.
556
556
  */
557
- executeComputeJob(sasJob, contextName, debug, data, authConfig, waitForResult = true, expectWebout = false, pollOptions, printPid = false, variables, onTokensRefreshed) {
558
- return __awaiter(this, void 0, void 0, function* () {
557
+ executeComputeJob(sasJob_1, contextName_1, debug_1, data_1, authConfig_1) {
558
+ return __awaiter(this, arguments, void 0, function* (sasJob, contextName, debug, data, authConfig, waitForResult = true, expectWebout = false, pollOptions, printPid = false, variables, onTokensRefreshed) {
559
559
  let access_token = (authConfig || {}).access_token;
560
560
  if (authConfig) {
561
561
  ;
@@ -612,8 +612,8 @@ class SASViyaApiClient {
612
612
  * @param onTokensRefreshed - optional callback invoked with the rotated token pair after a successful internal refresh, so consumers that persist tokens can store the new pair.
613
613
  */
614
614
  executeJob(sasJob, contextName, debug, data, authConfig, onTokensRefreshed) {
615
- var _a, _b, _c;
616
615
  return __awaiter(this, void 0, void 0, function* () {
616
+ var _a, _b, _c;
617
617
  let access_token = (authConfig || {}).access_token;
618
618
  if (authConfig) {
619
619
  ;
@@ -766,8 +766,8 @@ class SASViyaApiClient {
766
766
  });
767
767
  }
768
768
  getFileUri(folderPath, fileName, accessToken) {
769
- var _a;
770
769
  return __awaiter(this, void 0, void 0, function* () {
770
+ var _a;
771
771
  const folderMembers = yield this.listFolder(folderPath, accessToken, 1000, {
772
772
  returnDetails: true
773
773
  }).catch((err) => {
@@ -824,8 +824,8 @@ class SASViyaApiClient {
824
824
  * @param {Object} [options] - Additional options.
825
825
  * @param {boolean} [options.returnDetails=false] - when set to true, the function will return an array of objects with member details, otherwise it will return an array of member names.
826
826
  */
827
- listFolder(sourceFolder, accessToken, limit = 20, options) {
828
- return __awaiter(this, void 0, void 0, function* () {
827
+ listFolder(sourceFolder_1, accessToken_1) {
828
+ return __awaiter(this, arguments, void 0, function* (sourceFolder, accessToken, limit = 20, options) {
829
829
  // checks if 'sourceFolder' is already a URI
830
830
  const sourceFolderUri = (0, utils_1.isUri)(sourceFolder)
831
831
  ? sourceFolder
package/SASjs.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { SASjsConfig, UploadFile, EditContextInput, PollOptions, VerboseMode, LoginOptions, LoginResult, ExecutionQuery, Tables } from './types';
3
2
  import { SASViyaApiClient } from './SASViyaApiClient';
4
3
  import { SASjsAuthResponse } from './SASjsApiClient';
@@ -11,6 +10,11 @@ interface ExecuteScriptParams {
11
10
  contextName?: string;
12
11
  runTime?: string;
13
12
  authConfig?: AuthConfig;
13
+ /**
14
+ * @deprecated The credentials are appended to the `_program` query string,
15
+ * which SAS 9 only accepts when the platform is configured to allow URL
16
+ * credentials. See the "SAS 9 credentials" note in the README.
17
+ */
14
18
  authConfigSas9?: AuthConfigSas9;
15
19
  debug?: boolean;
16
20
  onTokensRefreshed?: OnTokensRefreshed;
@@ -42,7 +46,7 @@ export default class SASjs {
42
46
  * @param contextName - (required for server type sas viya) context name on which code will be run on the server.
43
47
  * @param runTime - (required for server type sasjs) a string to represent runTime for code execution.
44
48
  * @param authConfig - (optional) a valid client, secret, refresh and access tokens that are authorised to execute scripts.
45
- * @param authConfigSas9 - (required for server type sas9) a valid username and password that are authorised to execute scripts.
49
+ * @param authConfigSas9 - (required for server type sas9) a valid username and password that are authorised to execute scripts. Deprecated: the credentials are appended to the `_program` query string, which SAS 9 only accepts when the platform is configured to allow URL credentials. See the "SAS 9 credentials" note in the README.
46
50
  * @param debug - (optional) if true, global debug config will be overriden
47
51
  * @param onTokensRefreshed - (optional, SAS Viya only) callback invoked with the rotated token pair after a successful internal refresh, so consumers that persist tokens can store the new pair.
48
52
  */
package/SASjs.js CHANGED
@@ -80,13 +80,13 @@ class SASjs {
80
80
  * @param contextName - (required for server type sas viya) context name on which code will be run on the server.
81
81
  * @param runTime - (required for server type sasjs) a string to represent runTime for code execution.
82
82
  * @param authConfig - (optional) a valid client, secret, refresh and access tokens that are authorised to execute scripts.
83
- * @param authConfigSas9 - (required for server type sas9) a valid username and password that are authorised to execute scripts.
83
+ * @param authConfigSas9 - (required for server type sas9) a valid username and password that are authorised to execute scripts. Deprecated: the credentials are appended to the `_program` query string, which SAS 9 only accepts when the platform is configured to allow URL credentials. See the "SAS 9 credentials" note in the README.
84
84
  * @param debug - (optional) if true, global debug config will be overriden
85
85
  * @param onTokensRefreshed - (optional, SAS Viya only) callback invoked with the rotated token pair after a successful internal refresh, so consumers that persist tokens can store the new pair.
86
86
  */
87
- executeScript({ linesOfCode, fileName, contextName, runTime, authConfig, authConfigSas9, debug, onTokensRefreshed }) {
88
- var _a, _b;
89
- return __awaiter(this, void 0, void 0, function* () {
87
+ executeScript(_a) {
88
+ return __awaiter(this, arguments, void 0, function* ({ linesOfCode, fileName, contextName, runTime, authConfig, authConfigSas9, debug, onTokensRefreshed }) {
89
+ var _b, _c;
90
90
  this.isMethodSupported('executeScript', [
91
91
  types_2.ServerType.Sas9,
92
92
  types_2.ServerType.Sasjs,
@@ -95,10 +95,10 @@ class SASjs {
95
95
  if (this.sasjsConfig.serverType === types_2.ServerType.Sas9) {
96
96
  if (!authConfigSas9)
97
97
  throw new Error('Auth config for sas9 is not provided');
98
- return yield ((_a = this.sas9ApiClient) === null || _a === void 0 ? void 0 : _a.executeScript(linesOfCode, authConfigSas9.userName, authConfigSas9.password));
98
+ return yield ((_b = this.sas9ApiClient) === null || _b === void 0 ? void 0 : _b.executeScript(linesOfCode, authConfigSas9.userName, authConfigSas9.password));
99
99
  }
100
100
  if (this.sasjsConfig.serverType === types_2.ServerType.Sasjs) {
101
- return yield ((_b = this.sasJSApiClient) === null || _b === void 0 ? void 0 : _b.executeScript(linesOfCode.join('\n'), runTime, authConfig));
101
+ return yield ((_c = this.sasJSApiClient) === null || _c === void 0 ? void 0 : _c.executeScript(linesOfCode.join('\n'), runTime, authConfig));
102
102
  }
103
103
  if (this.sasjsConfig.serverType === types_2.ServerType.SasViya) {
104
104
  contextName = contextName || this.sasjsConfig.contextName;
@@ -120,8 +120,8 @@ class SASjs {
120
120
  * @returns a promise that resolves into job execution result and log.
121
121
  */
122
122
  executeJob(query, appLoc, authConfig) {
123
- var _a;
124
123
  return __awaiter(this, void 0, void 0, function* () {
124
+ var _a;
125
125
  this.isMethodSupported('executeScript', [types_2.ServerType.Sasjs]);
126
126
  return yield ((_a = this.sasJSApiClient) === null || _a === void 0 ? void 0 : _a.executeJob(query, appLoc, authConfig));
127
127
  });
@@ -320,8 +320,8 @@ class SASjs {
320
320
  * @param accessToken - an access token for authorizing the request.
321
321
  */
322
322
  deleteFolder(folderPath, accessToken) {
323
- var _a;
324
323
  return __awaiter(this, void 0, void 0, function* () {
324
+ var _a;
325
325
  this.isMethodSupported('deleteFolder', [types_2.ServerType.SasViya]);
326
326
  return yield ((_a = this.sasViyaApiClient) === null || _a === void 0 ? void 0 : _a.deleteFolder(folderPath, accessToken));
327
327
  });
@@ -332,9 +332,9 @@ class SASjs {
332
332
  * @param accessToken - an access token for authorizing the request.
333
333
  * @param returnDetails - when set to true, the function will return an array of objects with member details, otherwise it will return an array of member names.
334
334
  */
335
- listFolder(sourceFolder, accessToken, limit, returnDetails = false) {
336
- var _a;
337
- return __awaiter(this, void 0, void 0, function* () {
335
+ listFolder(sourceFolder_1, accessToken_1, limit_1) {
336
+ return __awaiter(this, arguments, void 0, function* (sourceFolder, accessToken, limit, returnDetails = false) {
337
+ var _a;
338
338
  this.isMethodSupported('listFolder', [types_2.ServerType.SasViya]);
339
339
  return yield ((_a = this.sasViyaApiClient) === null || _a === void 0 ? void 0 : _a.listFolder(sourceFolder, accessToken, limit, {
340
340
  returnDetails
@@ -349,8 +349,8 @@ class SASjs {
349
349
  * @param accessToken - an access token for authorizing the request.
350
350
  */
351
351
  moveFolder(sourceFolder, targetParentFolder, targetFolderName, accessToken) {
352
- var _a;
353
352
  return __awaiter(this, void 0, void 0, function* () {
353
+ var _a;
354
354
  this.isMethodSupported('moveFolder', [types_2.ServerType.SasViya]);
355
355
  return yield ((_a = this.sasViyaApiClient) === null || _a === void 0 ? void 0 : _a.moveFolder(sourceFolder, targetParentFolder, targetFolderName, accessToken));
356
356
  });
@@ -458,8 +458,8 @@ class SASjs {
458
458
  * @param password - a string representing the password.
459
459
  * @param clientId - a string representing the client ID.
460
460
  */
461
- logIn(username, password, clientId, options = {}) {
462
- return __awaiter(this, void 0, void 0, function* () {
461
+ logIn(username_1, password_1, clientId_1) {
462
+ return __awaiter(this, arguments, void 0, function* (username, password, clientId, options = {}) {
463
463
  if (this.sasjsConfig.loginMechanism === types_1.LoginMechanism.Default) {
464
464
  if (!username || !password)
465
465
  throw new Error('A username and password are required when using the default login mechanism.');
@@ -491,8 +491,8 @@ class SASjs {
491
491
  * user is not logged in (eg to display a login form). The request will be
492
492
  * resubmitted after successful login.
493
493
  */
494
- uploadFile(sasJob, files, params, config = {}, loginRequiredCallback) {
495
- return __awaiter(this, void 0, void 0, function* () {
494
+ uploadFile(sasJob_1, files_1, params_1) {
495
+ return __awaiter(this, arguments, void 0, function* (sasJob, files, params, config = {}, loginRequiredCallback) {
496
496
  config = Object.assign(Object.assign({}, this.sasjsConfig), config);
497
497
  const data = { files, params };
498
498
  return yield this.fileUploader.execute(sasJob, data, config, loginRequiredCallback);
@@ -525,8 +525,8 @@ class SASjs {
525
525
  * to provide extra attributes (same names as those values) to be added in response
526
526
  * Supported values are declared in ExtraResponseAttributes type.
527
527
  */
528
- request(sasJob, data, config = {}, loginRequiredCallback, authConfig, extraResponseAttributes = []) {
529
- return __awaiter(this, void 0, void 0, function* () {
528
+ request(sasJob_1, data_1) {
529
+ return __awaiter(this, arguments, void 0, function* (sasJob, data, config = {}, loginRequiredCallback, authConfig, extraResponseAttributes = []) {
530
530
  config = Object.assign(Object.assign({}, this.sasjsConfig), config);
531
531
  const validationResult = (0, utils_1.validateInput)(data);
532
532
  // status is true if the data passes validation checks above
@@ -571,8 +571,8 @@ class SASjs {
571
571
  * using this function from the command line.
572
572
  * @param isForced - flag that indicates if target folder already exists, it and all subfolders have to be deleted.
573
573
  */
574
- deployServicePack(serviceJson, appLoc, serverUrl, accessToken, isForced = false) {
575
- return __awaiter(this, void 0, void 0, function* () {
574
+ deployServicePack(serviceJson_1, appLoc_1, serverUrl_1, accessToken_1) {
575
+ return __awaiter(this, arguments, void 0, function* (serviceJson, appLoc, serverUrl, accessToken, isForced = false) {
576
576
  this.isMethodSupported('deployServicePack', [types_2.ServerType.SasViya]);
577
577
  let sasApiClient = null;
578
578
  if (serverUrl || appLoc) {
@@ -627,9 +627,9 @@ class SASjs {
627
627
  * @param verboseMode - boolean or a string equal to 'bleached' to enable verbose mode (log every HTTP response).
628
628
  * @param onTokensRefreshed - (optional, SAS Viya only) callback invoked with the rotated token pair after a successful internal refresh, so consumers that persist tokens can store the new pair.
629
629
  */
630
- startComputeJob(sasJob, data, config = {}, authConfig, waitForResult, pollOptions, printPid = false, variables, verboseMode, onTokensRefreshed) {
631
- var _a, _b, _c, _d;
632
- return __awaiter(this, void 0, void 0, function* () {
630
+ startComputeJob(sasJob_1, data_1) {
631
+ return __awaiter(this, arguments, void 0, function* (sasJob, data, config = {}, authConfig, waitForResult, pollOptions, printPid = false, variables, verboseMode, onTokensRefreshed) {
632
+ var _a, _b, _c, _d;
633
633
  config = Object.assign(Object.assign({}, this.sasjsConfig), config);
634
634
  this.isMethodSupported('startComputeJob', [types_2.ServerType.SasViya]);
635
635
  if (!config.contextName) {
@@ -24,8 +24,8 @@ export declare class SASjsApiClient {
24
24
  deploy(dataJson: ServicePackSASjs, appLoc: string, authConfig?: AuthConfig): Promise<{
25
25
  status: string;
26
26
  message: string;
27
- streamServiceName?: string | undefined;
28
- example?: {} | undefined;
27
+ streamServiceName?: string;
28
+ example?: {};
29
29
  }>;
30
30
  /**
31
31
  * Creates/updates files within SASjs drive using uploaded json compressed file.
@@ -38,8 +38,8 @@ export declare class SASjsApiClient {
38
38
  deployZipFile(zipFilePath: string, authConfig?: AuthConfig): Promise<{
39
39
  status: string;
40
40
  message: string;
41
- streamServiceName?: string | undefined;
42
- example?: {} | undefined;
41
+ streamServiceName?: string;
42
+ example?: {};
43
43
  }>;
44
44
  executeJob(query: ExecutionQuery, appLoc: string, authConfig?: AuthConfig): Promise<{
45
45
  result: any;
package/SASjsApiClient.js CHANGED
@@ -89,8 +89,8 @@ class SASjsApiClient {
89
89
  * @param runTime - a string to representing runTime for code execution
90
90
  * @param authConfig - an object for authentication.
91
91
  */
92
- executeScript(code, runTime = 'sas', authConfig) {
93
- return __awaiter(this, void 0, void 0, function* () {
92
+ executeScript(code_1) {
93
+ return __awaiter(this, arguments, void 0, function* (code, runTime = 'sas', authConfig) {
94
94
  const access_token = yield this.getAccessTokenForRequest(authConfig);
95
95
  const executionResult = { log: '' };
96
96
  yield this.requestClient
package/SessionManager.js CHANGED
@@ -268,8 +268,8 @@ class SessionManager {
268
268
  * @returns - a promise which resolves with a session state.
269
269
  */
270
270
  waitForSession(session, etag, accessToken) {
271
- var _a;
272
271
  return __awaiter(this, void 0, void 0, function* () {
272
+ var _a;
273
273
  let { state: sessionState } = session;
274
274
  const { stateUrl } = session;
275
275
  const logger = (0, host_1.getLogger)();
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.executeOnComputeApi = void 0;
12
+ exports.executeOnComputeApi = executeOnComputeApi;
13
13
  const time_1 = require("@sasjs/utils/time");
14
14
  const types_1 = require("@sasjs/utils/types");
15
15
  const error_1 = require("@sasjs/utils/error");
@@ -35,9 +35,9 @@ const host_1 = require("../../utils/host");
35
35
  * @param variables - an object that represents macro variables.
36
36
  * @param onTokensRefreshed - optional callback invoked with the rotated token pair after a successful internal refresh, so consumers that persist tokens can store the new pair.
37
37
  */
38
- function executeOnComputeApi(requestClient, sessionManager, rootFolderName, jobPath, linesOfCode, contextName, authConfig, data = null, debug = false, expectWebout = false, waitForResult = true, pollOptions, printPid = false, variables, onTokensRefreshed) {
39
- var _a, _b;
40
- return __awaiter(this, void 0, void 0, function* () {
38
+ function executeOnComputeApi(requestClient_1, sessionManager_1, rootFolderName_1, jobPath_1, linesOfCode_1, contextName_1, authConfig_1) {
39
+ return __awaiter(this, arguments, void 0, function* (requestClient, sessionManager, rootFolderName, jobPath, linesOfCode, contextName, authConfig, data = null, debug = false, expectWebout = false, waitForResult = true, pollOptions, printPid = false, variables, onTokensRefreshed) {
40
+ var _a, _b;
41
41
  let access_token = (authConfig || {}).access_token;
42
42
  if (authConfig) {
43
43
  ;
@@ -124,11 +124,11 @@ function executeOnComputeApi(requestClient, sessionManager, rootFolderName, jobP
124
124
  session,
125
125
  sessionManager
126
126
  }, onTokensRefreshed).catch((err) => __awaiter(this, void 0, void 0, function* () {
127
- var _c, _d;
128
- const error = (_c = err === null || err === void 0 ? void 0 : err.response) === null || _c === void 0 ? void 0 : _c.data;
127
+ var _a, _b;
128
+ const error = (_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.data;
129
129
  const result = /err=[0-9]*,/.exec(error);
130
130
  const errorCode = '5113';
131
- if (((_d = result === null || result === void 0 ? void 0 : result[0]) === null || _d === void 0 ? void 0 : _d.slice(4, -1)) === errorCode) {
131
+ if (((_b = result === null || result === void 0 ? void 0 : result[0]) === null || _b === void 0 ? void 0 : _b.slice(4, -1)) === errorCode) {
132
132
  const logCount = 1000000;
133
133
  const sessionLogUrl = postedJob.links.find((l) => l.rel === 'up').href + '/log';
134
134
  err.log = yield (0, utils_1.fetchLogByChunks)(requestClient, access_token, sessionLogUrl, logCount);
@@ -161,11 +161,11 @@ function executeOnComputeApi(requestClient, sessionManager, rootFolderName, jobP
161
161
  jobResult = yield requestClient
162
162
  .get(resultLink, access_token, 'text/plain')
163
163
  .catch((e) => __awaiter(this, void 0, void 0, function* () {
164
- var _e, _f;
164
+ var _a, _b;
165
165
  if (e instanceof __1.NotFoundError) {
166
166
  if (logLink) {
167
167
  const logUrl = `${logLink.href}/content`;
168
- const logCount = (_f = (_e = currentJob.logStatistics) === null || _e === void 0 ? void 0 : _e.lineCount) !== null && _f !== void 0 ? _f : 1000000;
168
+ const logCount = (_b = (_a = currentJob.logStatistics) === null || _a === void 0 ? void 0 : _a.lineCount) !== null && _b !== void 0 ? _b : 1000000;
169
169
  log = yield (0, utils_1.fetchLogByChunks)(requestClient, access_token, logUrl, logCount);
170
170
  return Promise.reject({
171
171
  status: 500,
@@ -195,4 +195,3 @@ function executeOnComputeApi(requestClient, sessionManager, rootFolderName, jobP
195
195
  }
196
196
  });
197
197
  }
198
- exports.executeOnComputeApi = executeOnComputeApi;
@@ -9,7 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.doPoll = exports.pollJobState = exports.JobState = void 0;
12
+ exports.doPoll = exports.JobState = void 0;
13
+ exports.pollJobState = pollJobState;
13
14
  const types_1 = require("@sasjs/utils/types");
14
15
  const getTokens_1 = require("../../auth/getTokens");
15
16
  const errors_1 = require("../../types/errors");
@@ -25,7 +26,7 @@ var JobState;
25
26
  JobState["NoState"] = "";
26
27
  JobState["Failed"] = "failed";
27
28
  JobState["Error"] = "error";
28
- })(JobState = exports.JobState || (exports.JobState = {}));
29
+ })(JobState || (exports.JobState = JobState = {}));
29
30
  /**
30
31
  * Polls job status using default or provided poll options.
31
32
  * @param requestClient - the pre-configured HTTP request client.
@@ -119,7 +120,6 @@ function pollJobState(requestClient, postedJob, debug, authConfig, pollOptions,
119
120
  return currentState;
120
121
  });
121
122
  }
122
- exports.pollJobState = pollJobState;
123
123
  const getJobState = (requestClient, job, currentState, debug, authConfig, onTokensRefreshed) => __awaiter(void 0, void 0, void 0, function* () {
124
124
  const stateLink = job.links.find((l) => l.rel === 'state');
125
125
  if (needsRetry(currentState)) {
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.saveLog = void 0;
12
+ exports.saveLog = saveLog;
13
13
  const utils_1 = require("../../utils");
14
14
  const writeStream_1 = require("./writeStream");
15
15
  const host_1 = require("../../utils/host");
@@ -42,4 +42,3 @@ function saveLog(job, requestClient, startLine, endLine, logFileStream, accessTo
42
42
  yield (0, writeStream_1.writeStream)(logFileStream, log || '');
43
43
  });
44
44
  }
45
- exports.saveLog = saveLog;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.uploadTables = void 0;
12
+ exports.uploadTables = uploadTables;
13
13
  const error_1 = require("@sasjs/utils/error");
14
14
  const convertToCsv_1 = require("../../utils/convertToCsv");
15
15
  /**
@@ -42,4 +42,3 @@ function uploadTables(requestClient, data, accessToken) {
42
42
  return uploadedFiles;
43
43
  });
44
44
  }
45
- exports.uploadTables = uploadTables;
@@ -81,8 +81,8 @@ class AuthManager {
81
81
  * Opens Pop up window to SAS Login screen.
82
82
  * And checks if user has finished login process.
83
83
  */
84
- redirectedLogIn({ onLoggedOut }) {
85
- return __awaiter(this, void 0, void 0, function* () {
84
+ redirectedLogIn(_a) {
85
+ return __awaiter(this, arguments, void 0, function* ({ onLoggedOut }) {
86
86
  const { isLoggedIn: isLoggedInAlready, userName: currentSessionUserName, userLongName: currentSessionUserLongName } = yield this.fetchUserName();
87
87
  if (isLoggedInAlready) {
88
88
  const logger = (0, host_1.getLogger)();
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getAccessTokenForSasjs = void 0;
12
+ exports.getAccessTokenForSasjs = getAccessTokenForSasjs;
13
13
  const error_1 = require("@sasjs/utils/error");
14
14
  const getTokenRequestErrorPrefix_1 = require("./getTokenRequestErrorPrefix");
15
15
  const types_1 = require("@sasjs/utils/types");
@@ -40,4 +40,3 @@ function getAccessTokenForSasjs(requestClient, clientId, authCode) {
40
40
  });
41
41
  });
42
42
  }
43
- exports.getAccessTokenForSasjs = getAccessTokenForSasjs;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getAccessTokenForViya = void 0;
12
+ exports.getAccessTokenForViya = getAccessTokenForViya;
13
13
  const types_1 = require("@sasjs/utils/types");
14
14
  const error_1 = require("@sasjs/utils/error");
15
15
  const errors_1 = require("../types/errors");
@@ -51,4 +51,3 @@ function getAccessTokenForViya(requestClient, clientId, clientSecret, authCode)
51
51
  return authResponse;
52
52
  });
53
53
  }
54
- exports.getAccessTokenForViya = getAccessTokenForViya;
package/auth/getTokens.js CHANGED
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getTokens = void 0;
12
+ exports.getTokens = getTokens;
13
13
  const auth_1 = require("@sasjs/utils/auth");
14
14
  const types_1 = require("@sasjs/utils/types");
15
15
  const refreshTokensForViya_1 = require("./refreshTokensForViya");
@@ -24,8 +24,8 @@ const host_1 = require("../utils/host");
24
24
  * @param onTokensRefreshed - optional callback invoked with the rotated token
25
25
  * pair after a successful internal refresh.
26
26
  */
27
- function getTokens(requestClient, authConfig, serverType = types_1.ServerType.SasViya, onTokensRefreshed) {
28
- return __awaiter(this, void 0, void 0, function* () {
27
+ function getTokens(requestClient_1, authConfig_1) {
28
+ return __awaiter(this, arguments, void 0, function* (requestClient, authConfig, serverType = types_1.ServerType.SasViya, onTokensRefreshed) {
29
29
  const logger = (0, host_1.getLogger)();
30
30
  // Note: client/secret are NOT mutated. The sas.cli public-client fallback
31
31
  // is applied only to the refresh call itself, so a caller that round-trips
@@ -107,4 +107,3 @@ function getTokens(requestClient, authConfig, serverType = types_1.ServerType.Sa
107
107
  return { access_token, refresh_token, client, secret };
108
108
  });
109
109
  }
110
- exports.getTokens = getTokens;
@@ -9,11 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.openWebPage = void 0;
12
+ exports.openWebPage = openWebPage;
13
13
  const loginPrompt_1 = require("../utils/loginPrompt");
14
14
  const defaultWindowFeatures = { width: 500, height: 600 };
15
- function openWebPage(url, windowName = '', WindowFeatures = defaultWindowFeatures, onLoggedOut) {
16
- return __awaiter(this, void 0, void 0, function* () {
15
+ function openWebPage(url_1) {
16
+ return __awaiter(this, arguments, void 0, function* (url, windowName = '', WindowFeatures = defaultWindowFeatures, onLoggedOut) {
17
17
  const { width, height } = WindowFeatures;
18
18
  const left = screen.width / 2 - width / 2;
19
19
  const top = screen.height / 2 - height / 2;
@@ -28,4 +28,3 @@ function openWebPage(url, windowName = '', WindowFeatures = defaultWindowFeature
28
28
  return loginPopup;
29
29
  });
30
30
  }
31
- exports.openWebPage = openWebPage;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.refreshTokensForSasjs = void 0;
12
+ exports.refreshTokensForSasjs = refreshTokensForSasjs;
13
13
  const error_1 = require("@sasjs/utils/error");
14
14
  const getTokenRequestErrorPrefix_1 = require("./getTokenRequestErrorPrefix");
15
15
  const types_1 = require("@sasjs/utils/types");
@@ -39,4 +39,3 @@ function refreshTokensForSasjs(requestClient, refreshToken) {
39
39
  return authResponse;
40
40
  });
41
41
  }
42
- exports.refreshTokensForSasjs = refreshTokensForSasjs;
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.refreshTokensForViya = void 0;
15
+ exports.refreshTokensForViya = refreshTokensForViya;
16
16
  const types_1 = require("@sasjs/utils/types");
17
17
  const error_1 = require("@sasjs/utils/error");
18
18
  const form_data_1 = __importDefault(require("form-data"));
@@ -50,4 +50,3 @@ function refreshTokensForViya(requestClient, clientId, clientSecret, refreshToke
50
50
  return authResponse;
51
51
  });
52
52
  }
53
- exports.refreshTokensForViya = refreshTokensForViya;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.verifySas9Login = void 0;
12
+ exports.verifySas9Login = verifySas9Login;
13
13
  const utils_1 = require("../utils");
14
14
  const _1 = require("./");
15
15
  function verifySas9Login(loginPopup) {
@@ -29,4 +29,3 @@ function verifySas9Login(loginPopup) {
29
29
  return { isLoggedIn };
30
30
  });
31
31
  }
32
- exports.verifySas9Login = verifySas9Login;
@@ -9,12 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.isLoggedInSASVIYA = exports.verifySasViyaLogin = void 0;
12
+ exports.isLoggedInSASVIYA = void 0;
13
+ exports.verifySasViyaLogin = verifySasViyaLogin;
13
14
  const utils_1 = require("../utils");
14
15
  const _1 = require("./");
15
16
  function verifySasViyaLogin(loginPopup) {
16
- var _a, _b;
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
+ var _a, _b;
18
19
  let isLoggedIn = false;
19
20
  let startTime = new Date();
20
21
  let elapsedSeconds = 0;
@@ -39,6 +40,5 @@ function verifySasViyaLogin(loginPopup) {
39
40
  return { isLoggedIn: isLoggedIn && isAuthorized };
40
41
  });
41
42
  }
42
- exports.verifySasViyaLogin = verifySasViyaLogin;
43
43
  const isLoggedInSASVIYA = () => document.cookie.includes('Current-User') && document.cookie.includes('userId');
44
44
  exports.isLoggedInSASVIYA = isLoggedInSASVIYA;