@sasjs/adapter 4.9.1 → 4.9.2

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/package.json CHANGED
@@ -84,5 +84,5 @@
84
84
  "https": "1.0.0",
85
85
  "tough-cookie": "4.1.3"
86
86
  },
87
- "version": "4.9.1"
87
+ "version": "4.9.2"
88
88
  }
@@ -25,7 +25,7 @@ import { prefixMessage } from '@sasjs/utils/error'
25
25
  import { pollJobState } from './api/viya/pollJobState'
26
26
  import { getTokens } from './auth/getTokens'
27
27
  import { uploadTables } from './api/viya/uploadTables'
28
- import { executeScript } from './api/viya/executeScript'
28
+ import { executeOnComputeApi } from './api/viya/executeOnComputeApi'
29
29
  import { getAccessTokenForViya } from './auth/getAccessTokenForViya'
30
30
  import { refreshTokensForViya } from './auth/refreshTokensForViya'
31
31
 
@@ -293,7 +293,7 @@ export class SASViyaApiClient {
293
293
  printPid = false,
294
294
  variables?: MacroVar
295
295
  ): Promise<any> {
296
- return executeScript(
296
+ return executeOnComputeApi(
297
297
  this.requestClient,
298
298
  this.sessionManager,
299
299
  this.rootFolderName,
@@ -15,8 +15,12 @@ import { formatDataForRequest } from '../../utils/formatDataForRequest'
15
15
  import { pollJobState, JobState } from './pollJobState'
16
16
  import { uploadTables } from './uploadTables'
17
17
 
18
+ interface JobRequestBody {
19
+ [key: string]: number | string | string[]
20
+ }
21
+
18
22
  /**
19
- * Executes code on the current SAS Viya server.
23
+ * Executes SAS program on the current SAS Viya server using Compute API.
20
24
  * @param jobPath - the path to the file being submitted for execution.
21
25
  * @param linesOfCode - an array of code lines to execute.
22
26
  * @param contextName - the context to execute the code in.
@@ -29,7 +33,7 @@ import { uploadTables } from './uploadTables'
29
33
  * @param printPid - a boolean that indicates whether the function should print (PID) of the started job.
30
34
  * @param variables - an object that represents macro variables.
31
35
  */
32
- export async function executeScript(
36
+ export async function executeOnComputeApi(
33
37
  requestClient: RequestClient,
34
38
  sessionManager: SessionManager,
35
39
  rootFolderName: string,
@@ -46,6 +50,7 @@ export async function executeScript(
46
50
  variables?: MacroVar
47
51
  ): Promise<any> {
48
52
  let access_token = (authConfig || {}).access_token
53
+
49
54
  if (authConfig) {
50
55
  ;({ access_token } = await getTokens(requestClient, authConfig))
51
56
  }
@@ -85,20 +90,6 @@ export async function executeScript(
85
90
  }
86
91
  }
87
92
 
88
- const jobArguments: { [key: string]: any } = {
89
- _contextName: contextName,
90
- _OMITJSONLISTING: true,
91
- _OMITJSONLOG: true,
92
- _OMITSESSIONRESULTS: true,
93
- _OMITTEXTLISTING: true,
94
- _OMITTEXTLOG: true
95
- }
96
-
97
- if (debug) {
98
- jobArguments['_OMITTEXTLOG'] = false
99
- jobArguments['_OMITSESSIONRESULTS'] = false
100
- }
101
-
102
93
  let fileName
103
94
 
104
95
  if (isRelativePath(jobPath)) {
@@ -107,6 +98,7 @@ export async function executeScript(
107
98
  }`
108
99
  } else {
109
100
  const jobPathParts = jobPath.split('/')
101
+
110
102
  fileName = jobPathParts.pop()
111
103
  }
112
104
 
@@ -118,7 +110,6 @@ export async function executeScript(
118
110
  }
119
111
 
120
112
  if (variables) jobVariables = { ...jobVariables, ...variables }
121
-
122
113
  if (debug) jobVariables = { ...jobVariables, _DEBUG: 131 }
123
114
 
124
115
  let files: any[] = []
@@ -145,12 +136,12 @@ export async function executeScript(
145
136
  }
146
137
 
147
138
  // Execute job in session
148
- const jobRequestBody = {
149
- name: fileName,
139
+ const jobRequestBody: JobRequestBody = {
140
+ name: fileName || 'Default Job Name',
150
141
  description: 'Powered by SASjs',
151
142
  code: linesOfCode,
152
143
  variables: jobVariables,
153
- arguments: jobArguments
144
+ version: 2
154
145
  }
155
146
 
156
147
  const { result: postedJob, etag } = await requestClient
@@ -279,7 +270,7 @@ export async function executeScript(
279
270
  const error = e as HttpError
280
271
 
281
272
  if (error.status === 404) {
282
- return executeScript(
273
+ return executeOnComputeApi(
283
274
  requestClient,
284
275
  sessionManager,
285
276
  rootFolderName,