@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
 
| 
         @@ -1,10 +1,11 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            "use strict";
         
     | 
| 
       2 
2 
     | 
    
         
             
            Object.defineProperty(exports, "__esModule", { value: true });
         
     | 
| 
       3 
3 
     | 
    
         
             
            exports.renderShinyReport = renderShinyReport;
         
     | 
| 
      
 4 
     | 
    
         
            +
            const tslib_1 = require("tslib");
         
     | 
| 
       4 
5 
     | 
    
         
             
            const env_1 = require("@things-factory/env");
         
     | 
| 
       5 
6 
     | 
    
         
             
            const config_resolver_1 = require("../utils/config-resolver");
         
     | 
| 
       6 
     | 
    
         
            -
            const  
     | 
| 
       7 
     | 
    
         
            -
            const debug =  
     | 
| 
      
 7 
     | 
    
         
            +
            const debug_1 = tslib_1.__importDefault(require("debug"));
         
     | 
| 
      
 8 
     | 
    
         
            +
            const debug = (0, debug_1.default)('things-factory:dataset:shiny-report');
         
     | 
| 
       8 
9 
     | 
    
         
             
            const dataReportConfig = env_1.config.get('dataReport');
         
     | 
| 
       9 
10 
     | 
    
         
             
            const { shiny: { endpoint: ENDPOINT, datasource: { database: DATABASE } } } = Object.assign({
         
     | 
| 
       10 
11 
     | 
    
         
             
                shiny: {
         
     | 
| 
         @@ -15,21 +16,15 @@ const { shiny: { endpoint: ENDPOINT, datasource: { database: DATABASE } } } = Ob 
     | 
|
| 
       15 
16 
     | 
    
         
             
            async function renderShinyReport(context) {
         
     | 
| 
       16 
17 
     | 
    
         
             
                debug('render:context', context);
         
     | 
| 
       17 
18 
     | 
    
         
             
                try {
         
     | 
| 
       18 
     | 
    
         
            -
                    const  
     | 
| 
       19 
     | 
    
         
            -
                    const  
     | 
| 
       20 
     | 
    
         
            -
                    const  
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                    // const jsonParams = JSON.stringify({ 
         
     | 
| 
       23 
     | 
    
         
            -
                    //   ...query, 
         
     | 
| 
       24 
     | 
    
         
            -
                    //   ...{ database: DATABASE,  
         
     | 
| 
       25 
     | 
    
         
            -
                    //   domain: domain?.subdomain }
         
     | 
| 
       26 
     | 
    
         
            -
                    // })
         
     | 
| 
      
 19 
     | 
    
         
            +
                    const cookies = new URLSearchParams(context.header.cookie.replace(/; /g, '&'));
         
     | 
| 
      
 20 
     | 
    
         
            +
                    const token = cookies.get('access_token');
         
     | 
| 
      
 21 
     | 
    
         
            +
                    const { state: { domain }, query, response } = context;
         
     | 
| 
      
 22 
     | 
    
         
            +
                    const urlParams = new URLSearchParams(Object.assign(Object.assign({ token }, query), { database: DATABASE, domain: domain === null || domain === void 0 ? void 0 : domain.subdomain })).toString();
         
     | 
| 
       27 
23 
     | 
    
         
             
                    const subpath = (query === null || query === void 0 ? void 0 : query.reportView) || '';
         
     | 
| 
       28 
24 
     | 
    
         
             
                    if (!subpath) {
         
     | 
| 
       29 
     | 
    
         
            -
                        return context.body = '';
         
     | 
| 
      
 25 
     | 
    
         
            +
                        return (context.body = '');
         
     | 
| 
       30 
26 
     | 
    
         
             
                    }
         
     | 
| 
       31 
27 
     | 
    
         
             
                    const url = (0, config_resolver_1.getEndpointUrl)(ENDPOINT, subpath);
         
     | 
| 
       32 
     | 
    
         
            -
                    // const reportUrl = `${protocol}${url}/?params=${jsonParams}`
         
     | 
| 
       33 
28 
     | 
    
         
             
                    const reportUrl = `${url}/?${urlParams}`;
         
     | 
| 
       34 
29 
     | 
    
         
             
                    response.redirect(reportUrl);
         
     | 
| 
       35 
30 
     | 
    
         
             
                }
         
     | 
| 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            {"version":3,"file":"shiny-report.js","sourceRoot":"","sources":["../../server/controllers/shiny-report.ts"],"names":[],"mappings":";; 
     | 
| 
      
 1 
     | 
    
         
            +
            {"version":3,"file":"shiny-report.js","sourceRoot":"","sources":["../../server/controllers/shiny-report.ts"],"names":[],"mappings":";;AAqBA,8CAgCC;;AArDD,6CAA4C;AAC5C,8DAAyD;AAEzD,0DAA4B;AAC5B,MAAM,KAAK,GAAG,IAAA,eAAQ,EAAC,qCAAqC,CAAC,CAAA;AAC7D,MAAM,gBAAgB,GAAG,YAAM,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;AACjD,MAAM,EACJ,KAAK,EAAE,EACL,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,EACnC,EACF,GAAG,MAAM,CAAC,MAAM,CACf;IACE,KAAK,EAAE;QACL,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,EAAE;KACf;CACF,EACD,gBAAgB,CACjB,CAAA;AAEM,KAAK,UAAU,iBAAiB,CAAC,OAAY;IAClD,KAAK,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAA;IAEhC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAA;QAC9E,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;QACzC,MAAM,EACJ,KAAK,EAAE,EAAE,MAAM,EAAE,EACjB,KAAK,EACL,QAAQ,EACT,GAAG,OAAO,CAAA;QAEX,MAAM,SAAS,GAAG,IAAI,eAAe,+BACnC,KAAK,IACF,KAAK,KACR,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,IACzB,CAAC,QAAQ,EAAE,CAAA;QAEb,MAAM,OAAO,GAAG,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,KAAI,EAAE,CAAA;QAEvC,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC,CAAA;QAC5B,CAAC;QAED,MAAM,GAAG,GAAG,IAAA,gCAAc,EAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;QAC7C,MAAM,SAAS,GAAG,GAAG,GAAG,KAAK,SAAS,EAAE,CAAA;QAExC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;IAC9B,CAAC;IAAC,OAAO,EAAE,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,GAAG,UAAU,EAAE,CAAC,OAAO,QAAQ,CAAA;IAC7C,CAAC;AACH,CAAC","sourcesContent":["import { config } from '@things-factory/env'\nimport { getEndpointUrl } from '../utils/config-resolver'\n\nimport debugLib from 'debug'\nconst debug = debugLib('things-factory:dataset:shiny-report')\nconst dataReportConfig = config.get('dataReport')\nconst {\n  shiny: {\n    endpoint: ENDPOINT,\n    datasource: { database: DATABASE }\n  }\n} = Object.assign(\n  {\n    shiny: {\n      endpoint: {},\n      datasource: {}\n    }\n  },\n  dataReportConfig\n)\n\nexport async function renderShinyReport(context: any) {\n  debug('render:context', context)\n\n  try {\n    const cookies = new URLSearchParams(context.header.cookie.replace(/; /g, '&'))\n    const token = cookies.get('access_token')\n    const {\n      state: { domain },\n      query,\n      response\n    } = context\n\n    const urlParams = new URLSearchParams({\n      token,\n      ...query,\n      database: DATABASE,\n      domain: domain?.subdomain\n    }).toString()\n\n    const subpath = query?.reportView || ''\n\n    if (!subpath) {\n      return (context.body = '')\n    }\n\n    const url = getEndpointUrl(ENDPOINT, subpath)\n    const reportUrl = `${url}/?${urlParams}`\n\n    response.redirect(reportUrl)\n  } catch (ex) {\n    context.body = `Error: ${ex.message} || ''`\n  }\n}\n"]}
         
     |