@things-factory/dataset 7.0.23 → 7.0.26
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/client/pages/data-sample/data-sample-list-page.ts +1 -1
- package/dist-client/pages/data-sample/data-sample-list-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/shiny-report.js +8 -13
- package/dist-server/controllers/shiny-report.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/server/controllers/shiny-report.ts +24 -30
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/dataset",
|
3
|
-
"version": "7.0.
|
3
|
+
"version": "7.0.26",
|
4
4
|
"main": "dist-server/index.js",
|
5
5
|
"browser": "dist-client/index.js",
|
6
6
|
"things-factory": true,
|
@@ -56,5 +56,5 @@
|
|
56
56
|
"simple-statistics": "^7.8.3",
|
57
57
|
"statistics": "^3.3.0"
|
58
58
|
},
|
59
|
-
"gitHead": "
|
59
|
+
"gitHead": "a8c7831361a556ac922373a841dcff968409dfee"
|
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
|
-
|
7
|
-
const debug =
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
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 =
|
33
|
+
|
34
|
+
const urlParams = new URLSearchParams({
|
33
35
|
token,
|
34
|
-
...query,
|
35
|
-
|
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
|
}
|