@sasjs/adapter 3.9.2 → 3.9.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.
package/package.json CHANGED
@@ -79,5 +79,5 @@
79
79
  "https": "1.0.0",
80
80
  "tough-cookie": "4.0.0"
81
81
  },
82
- "version": "3.9.2"
82
+ "version": "3.9.3"
83
83
  }
package/src/SASjs.ts CHANGED
@@ -916,8 +916,8 @@ export default class SASjs {
916
916
  return await this.sasJSApiClient?.deploy(dataJson, appLoc, authConfig)
917
917
  }
918
918
 
919
- public async executeJobSASjs(query: ExecutionQuery) {
920
- return await this.sasJSApiClient?.executeJob(query)
919
+ public async executeJobSASjs(query: ExecutionQuery, authConfig?: AuthConfig) {
920
+ return await this.sasJSApiClient?.executeJob(query, authConfig)
921
921
  }
922
922
 
923
923
  /**
@@ -43,7 +43,9 @@ export class SASjsApiClient {
43
43
  return Promise.resolve(result)
44
44
  }
45
45
 
46
- public async executeJob(query: ExecutionQuery) {
46
+ public async executeJob(query: ExecutionQuery, authConfig?: AuthConfig) {
47
+ const access_token = authConfig ? authConfig.access_token : undefined
48
+
47
49
  const { result } = await this.requestClient.post<{
48
50
  status: string
49
51
  message: string
@@ -51,7 +53,7 @@ export class SASjsApiClient {
51
53
  logPath?: string
52
54
  error?: {}
53
55
  _webout?: string
54
- }>('SASjsApi/stp/execute', query, undefined)
56
+ }>('SASjsApi/stp/execute', query, access_token)
55
57
 
56
58
  if (Object.keys(result).includes('_webout')) {
57
59
  result._webout = parseWeboutResponse(result._webout!)
@@ -21,6 +21,7 @@ import {
21
21
  } from '../utils'
22
22
  import { BaseJobExecutor } from './JobExecutor'
23
23
  import { parseWeboutResponse } from '../utils/parseWeboutResponse'
24
+ import { Server } from 'https'
24
25
 
25
26
  export interface WaitingRequstPromise {
26
27
  promise: Promise<any> | null
@@ -46,7 +47,7 @@ export class WebJobExecutor extends BaseJobExecutor {
46
47
  authConfig?: AuthConfig,
47
48
  extraResponseAttributes: ExtraResponseAttributes[] = []
48
49
  ) {
49
- const loginCallback = loginRequiredCallback || (() => Promise.resolve())
50
+ const loginCallback = loginRequiredCallback
50
51
  const program = isRelativePath(sasJob)
51
52
  ? config.appLoc
52
53
  ? config.appLoc.replace(/\/?$/, '/') + sasJob.replace(/^\//, '')
@@ -79,7 +80,7 @@ export class WebJobExecutor extends BaseJobExecutor {
79
80
  )
80
81
  })
81
82
 
82
- await loginCallback()
83
+ if (loginCallback) await loginCallback()
83
84
  } else {
84
85
  reject(new ErrorResponse(e?.message, e))
85
86
  }
@@ -220,6 +221,15 @@ export class WebJobExecutor extends BaseJobExecutor {
220
221
  }
221
222
 
222
223
  if (e instanceof LoginRequiredError) {
224
+ if (!loginRequiredCallback) {
225
+ reject(
226
+ new ErrorResponse(
227
+ 'Request is not authenticated. Make sure .env file exists with valid credentials.',
228
+ e
229
+ )
230
+ )
231
+ }
232
+
223
233
  this.appendWaitingRequest(() => {
224
234
  return this.execute(
225
235
  sasJob,
@@ -238,7 +248,7 @@ export class WebJobExecutor extends BaseJobExecutor {
238
248
  )
239
249
  })
240
250
 
241
- await loginCallback()
251
+ if (loginCallback) await loginCallback()
242
252
  } else {
243
253
  reject(new ErrorResponse(e?.message, e))
244
254
  }
@@ -132,7 +132,6 @@ export const convertToCSV = (
132
132
 
133
133
  if (formats && formats[fieldName] === 'best.') {
134
134
  if (value && !isSpecialMissing(value)) {
135
- console.log(`🤖[value]🤖`, value)
136
135
  throw new Error(
137
136
  `A Special missing value can only be a single character from 'A' to 'Z', '_', '.[a-z]', '._'`
138
137
  )