@sasjs/adapter 3.2.1 → 3.3.0

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
@@ -80,5 +80,5 @@
80
80
  "https": "^1.0.0",
81
81
  "tough-cookie": "^4.0.0"
82
82
  },
83
- "version": "3.2.1"
83
+ "version": "3.3.0"
84
84
  }
@@ -168,7 +168,7 @@ export class SessionManager {
168
168
  ) {
169
169
  if (stateLink) {
170
170
  if (this.debug && !this.printedSessionState.printed) {
171
- logger.info('Polling session status...')
171
+ logger.info(`Polling: ${this.serverUrl + stateLink.href}`)
172
172
 
173
173
  this.printedSessionState.printed = true
174
174
  }
@@ -206,10 +206,11 @@ const doPoll = async (
206
206
 
207
207
  pollCount++
208
208
 
209
+ const jobHref = postedJob.links.find((l: Link) => l.rel === 'self')!.href
210
+
209
211
  if (pollOptions?.streamLog) {
210
- const jobUrl = postedJob.links.find((l: Link) => l.rel === 'self')
211
212
  const { result: job } = await requestClient.get<Job>(
212
- jobUrl!.href,
213
+ jobHref,
213
214
  authConfig?.access_token
214
215
  )
215
216
 
@@ -231,7 +232,7 @@ const doPoll = async (
231
232
  }
232
233
 
233
234
  if (debug && printedState !== state) {
234
- logger.info('Polling job status...')
235
+ logger.info(`Polling: ${requestClient.getBaseUrl() + jobHref}/state`)
235
236
  logger.info(`Current job state: ${state}`)
236
237
 
237
238
  printedState = state
@@ -195,9 +195,7 @@ export class RequestClient implements HttpClient {
195
195
  }
196
196
  ),
197
197
  debug
198
- ).catch((err) => {
199
- throw prefixMessage(err, 'Error while handling error. ')
200
- })
198
+ )
201
199
  })
202
200
  }
203
201
 
@@ -217,6 +215,7 @@ export class RequestClient implements HttpClient {
217
215
  .post<T>(url, data, { headers, withCredentials: true })
218
216
  .then((response) => {
219
217
  throwIfError(response)
218
+
220
219
  return this.parseResponse<T>(response)
221
220
  })
222
221
  .catch(async (e) => {
@@ -466,6 +465,8 @@ export class RequestClient implements HttpClient {
466
465
 
467
466
  if (e instanceof LoginRequiredError) {
468
467
  this.clearCsrfTokens()
468
+
469
+ throw e
469
470
  }
470
471
 
471
472
  if (response?.status === 403 || response?.status === 449) {
@@ -488,7 +489,8 @@ export class RequestClient implements HttpClient {
488
489
  else return
489
490
  }
490
491
 
491
- throw e
492
+ if (e.message) throw e
493
+ else throw prefixMessage(e, 'Error while handling error. ')
492
494
  }
493
495
 
494
496
  protected parseResponse<T>(response: AxiosResponse<any>) {
@@ -540,8 +542,9 @@ export class RequestClient implements HttpClient {
540
542
 
541
543
  this.httpClient = createAxiosInstance(baseUrl, httpsAgent)
542
544
 
543
- this.httpClient.defaults.validateStatus = (status) =>
544
- status >= 200 && status < 401
545
+ this.httpClient.defaults.validateStatus = (status) => {
546
+ return status >= 200 && status <= 401
547
+ }
545
548
  }
546
549
  }
547
550
 
@@ -18,6 +18,7 @@ app.get('/', function (req: any, res: any) {
18
18
 
19
19
  app.post('/SASLogon/oauth/token', function (req: any, res: any) {
20
20
  let valid = true
21
+
21
22
  // capture the encoded form data
22
23
  req.on('data', (data: any) => {
23
24
  const resData = data.toString()