@things-factory/dataset 7.0.24 → 7.0.28

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/dataset",
3
- "version": "7.0.24",
3
+ "version": "7.0.28",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "things-factory": true,
@@ -40,21 +40,21 @@
40
40
  "@operato/shell": "^7.0.0",
41
41
  "@operato/styles": "^7.0.0",
42
42
  "@operato/utils": "^7.0.0",
43
- "@things-factory/auth-base": "^7.0.22",
44
- "@things-factory/aws-base": "^7.0.22",
45
- "@things-factory/board-service": "^7.0.23",
46
- "@things-factory/env": "^7.0.14",
47
- "@things-factory/integration-base": "^7.0.23",
48
- "@things-factory/organization": "^7.0.22",
49
- "@things-factory/personalization": "^7.0.22",
50
- "@things-factory/scheduler-client": "^7.0.22",
51
- "@things-factory/shell": "^7.0.19",
52
- "@things-factory/work-shift": "^7.0.22",
53
- "@things-factory/worklist": "^7.0.23",
43
+ "@things-factory/auth-base": "^7.0.28",
44
+ "@things-factory/aws-base": "^7.0.28",
45
+ "@things-factory/board-service": "^7.0.28",
46
+ "@things-factory/env": "^7.0.28",
47
+ "@things-factory/integration-base": "^7.0.28",
48
+ "@things-factory/organization": "^7.0.28",
49
+ "@things-factory/personalization": "^7.0.28",
50
+ "@things-factory/scheduler-client": "^7.0.28",
51
+ "@things-factory/shell": "^7.0.28",
52
+ "@things-factory/work-shift": "^7.0.28",
53
+ "@things-factory/worklist": "^7.0.28",
54
54
  "cron-parser": "^4.3.0",
55
55
  "moment-timezone": "^0.5.45",
56
56
  "simple-statistics": "^7.8.3",
57
57
  "statistics": "^3.3.0"
58
58
  },
59
- "gitHead": "fbcc1bcca6ff68ef3c53330ca8b3e39f08570320"
59
+ "gitHead": "05a06c851e7fbdf76b3fdc039a0067d6c0439a25"
60
60
  }
@@ -1,60 +1,54 @@
1
- import FormData from 'form-data'
2
- import fetch from 'node-fetch'
3
1
  import { config } from '@things-factory/env'
4
2
  import { getEndpointUrl } from '../utils/config-resolver'
5
3
 
6
- const querystring = require('querystring')
7
- const debug = require('debug')('things-factory:dataset:shiny-report')
4
+ import debugLib from 'debug'
5
+ const debug = debugLib('things-factory:dataset:shiny-report')
8
6
  const dataReportConfig = config.get('dataReport')
9
7
  const {
10
8
  shiny: {
11
9
  endpoint: ENDPOINT,
12
10
  datasource: { database: DATABASE }
13
11
  }
14
- } = Object.assign({
15
- shiny: {
16
- endpoint: {},
17
- datasource: {}
18
- }}, dataReportConfig)
19
-
12
+ } = Object.assign(
13
+ {
14
+ shiny: {
15
+ endpoint: {},
16
+ datasource: {}
17
+ }
18
+ },
19
+ dataReportConfig
20
+ )
20
21
 
21
22
  export async function renderShinyReport(context: any) {
22
23
  debug('render:context', context)
23
-
24
+
24
25
  try {
25
- const { access_token: token } = querystring.parse(context.header.cookie, ';')
26
+ const cookies = new URLSearchParams(context.header.cookie.replace(/; /g, '&'))
27
+ const token = cookies.get('access_token')
26
28
  const {
27
29
  state: { domain },
28
30
  query,
29
- response,
31
+ response
30
32
  } = context
31
-
32
- const urlParams = querystring.stringify({
33
+
34
+ const urlParams = new URLSearchParams({
33
35
  token,
34
- ...query,
35
- ...{ database: DATABASE,
36
- domain: domain?.subdomain }
37
- })
38
-
39
- // const jsonParams = JSON.stringify({
40
- // ...query,
41
- // ...{ database: DATABASE,
42
- // domain: domain?.subdomain }
43
- // })
44
-
36
+ ...query,
37
+ database: DATABASE,
38
+ domain: domain?.subdomain
39
+ }).toString()
40
+
45
41
  const subpath = query?.reportView || ''
46
42
 
47
43
  if (!subpath) {
48
- return context.body = ''
44
+ return (context.body = '')
49
45
  }
50
46
 
51
47
  const url = getEndpointUrl(ENDPOINT, subpath)
52
- // const reportUrl = `${protocol}${url}/?params=${jsonParams}`
53
48
  const reportUrl = `${url}/?${urlParams}`
54
49
 
55
50
  response.redirect(reportUrl)
56
- } catch(ex) {
51
+ } catch (ex) {
57
52
  context.body = `Error: ${ex.message} || ''`
58
53
  }
59
-
60
54
  }