@budibase/server 2.7.16-alpha.0 → 2.7.18
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/builder/assets/{index.55a50076.js → index.8b4ed657.js} +342 -342
- package/builder/assets/{index.2e9069f3.css → index.d9b46807.css} +1 -1
- package/builder/bblogo.png +0 -0
- package/builder/fonts/remixicon.css +2317 -0
- package/builder/fonts/remixicon.eot +0 -0
- package/builder/fonts/remixicon.less +2319 -0
- package/builder/fonts/remixicon.svg +6835 -0
- package/builder/fonts/remixicon.symbol.svg +11356 -0
- package/builder/fonts/remixicon.ttf +0 -0
- package/builder/fonts/remixicon.woff +0 -0
- package/builder/fonts/remixicon.woff2 +0 -0
- package/builder/fonts/source-sans-pro/200-italic.css +69 -0
- package/builder/fonts/source-sans-pro/200.css +69 -0
- package/builder/fonts/source-sans-pro/300-italic.css +69 -0
- package/builder/fonts/source-sans-pro/300.css +69 -0
- package/builder/fonts/source-sans-pro/400-italic.css +69 -0
- package/builder/fonts/source-sans-pro/400.css +69 -0
- package/builder/fonts/source-sans-pro/600-italic.css +69 -0
- package/builder/fonts/source-sans-pro/600.css +69 -0
- package/builder/fonts/source-sans-pro/700-italic.css +69 -0
- package/builder/fonts/source-sans-pro/700.css +69 -0
- package/builder/fonts/source-sans-pro/900-italic.css +69 -0
- package/builder/fonts/source-sans-pro/900.css +69 -0
- package/builder/fonts/source-sans-pro/CHANGELOG.md +2 -0
- package/builder/fonts/source-sans-pro/LICENSE +93 -0
- package/builder/fonts/source-sans-pro/README.md +47 -0
- package/builder/fonts/source-sans-pro/cyrillic-200-italic.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-200.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-300-italic.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-300.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-400-italic.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-400.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-600-italic.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-600.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-700-italic.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-700.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-900-italic.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-900.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-ext-200-italic.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-ext-200.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-ext-300-italic.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-ext-300.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-ext-400-italic.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-ext-400.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-ext-600-italic.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-ext-600.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-ext-700-italic.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-ext-700.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-ext-900-italic.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-ext-900.css +8 -0
- package/builder/fonts/source-sans-pro/cyrillic-ext-italic.css +53 -0
- package/builder/fonts/source-sans-pro/cyrillic-ext.css +53 -0
- package/builder/fonts/source-sans-pro/cyrillic-italic.css +53 -0
- package/builder/fonts/source-sans-pro/cyrillic.css +53 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-200-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-200-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-200-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-200-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-300-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-300-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-300-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-300-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-400-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-400-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-400-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-400-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-600-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-600-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-600-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-600-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-700-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-700-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-700-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-700-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-900-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-900-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-900-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-900-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-200-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-200-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-200-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-200-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-300-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-300-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-300-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-300-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-400-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-400-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-400-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-400-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-600-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-600-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-600-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-600-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-700-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-700-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-700-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-700-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-900-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-900-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-900-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-cyrillic-ext-900-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-200-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-200-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-200-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-200-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-300-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-300-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-300-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-300-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-400-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-400-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-400-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-400-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-600-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-600-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-600-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-600-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-700-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-700-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-700-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-700-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-900-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-900-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-900-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-900-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-200-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-200-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-200-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-200-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-300-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-300-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-300-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-300-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-400-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-400-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-400-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-400-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-600-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-600-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-600-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-600-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-700-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-700-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-700-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-700-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-900-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-900-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-900-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-greek-ext-900-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-200-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-200-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-200-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-200-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-300-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-300-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-300-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-300-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-400-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-400-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-400-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-400-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-600-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-600-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-600-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-600-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-700-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-700-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-700-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-700-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-900-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-900-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-900-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-900-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-200-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-200-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-200-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-200-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-300-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-300-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-300-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-300-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-400-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-400-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-400-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-400-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-600-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-600-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-600-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-600-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-700-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-700-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-700-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-700-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-900-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-900-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-900-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-latin-ext-900-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-200-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-200-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-200-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-200-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-300-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-300-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-300-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-300-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-400-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-400-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-400-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-400-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-600-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-600-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-600-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-600-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-700-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-700-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-700-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-700-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-900-italic.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-900-italic.woff2 +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-900-normal.woff +0 -0
- package/builder/fonts/source-sans-pro/files/source-sans-pro-vietnamese-900-normal.woff2 +0 -0
- package/builder/fonts/source-sans-pro/greek-200-italic.css +8 -0
- package/builder/fonts/source-sans-pro/greek-200.css +8 -0
- package/builder/fonts/source-sans-pro/greek-300-italic.css +8 -0
- package/builder/fonts/source-sans-pro/greek-300.css +8 -0
- package/builder/fonts/source-sans-pro/greek-400-italic.css +8 -0
- package/builder/fonts/source-sans-pro/greek-400.css +8 -0
- package/builder/fonts/source-sans-pro/greek-600-italic.css +8 -0
- package/builder/fonts/source-sans-pro/greek-600.css +8 -0
- package/builder/fonts/source-sans-pro/greek-700-italic.css +8 -0
- package/builder/fonts/source-sans-pro/greek-700.css +8 -0
- package/builder/fonts/source-sans-pro/greek-900-italic.css +8 -0
- package/builder/fonts/source-sans-pro/greek-900.css +8 -0
- package/builder/fonts/source-sans-pro/greek-ext-200-italic.css +8 -0
- package/builder/fonts/source-sans-pro/greek-ext-200.css +8 -0
- package/builder/fonts/source-sans-pro/greek-ext-300-italic.css +8 -0
- package/builder/fonts/source-sans-pro/greek-ext-300.css +8 -0
- package/builder/fonts/source-sans-pro/greek-ext-400-italic.css +8 -0
- package/builder/fonts/source-sans-pro/greek-ext-400.css +8 -0
- package/builder/fonts/source-sans-pro/greek-ext-600-italic.css +8 -0
- package/builder/fonts/source-sans-pro/greek-ext-600.css +8 -0
- package/builder/fonts/source-sans-pro/greek-ext-700-italic.css +8 -0
- package/builder/fonts/source-sans-pro/greek-ext-700.css +8 -0
- package/builder/fonts/source-sans-pro/greek-ext-900-italic.css +8 -0
- package/builder/fonts/source-sans-pro/greek-ext-900.css +8 -0
- package/builder/fonts/source-sans-pro/greek-ext-italic.css +53 -0
- package/builder/fonts/source-sans-pro/greek-ext.css +53 -0
- package/builder/fonts/source-sans-pro/greek-italic.css +53 -0
- package/builder/fonts/source-sans-pro/greek.css +53 -0
- package/builder/fonts/source-sans-pro/index.css +69 -0
- package/builder/fonts/source-sans-pro/latin-200-italic.css +8 -0
- package/builder/fonts/source-sans-pro/latin-200.css +8 -0
- package/builder/fonts/source-sans-pro/latin-300-italic.css +8 -0
- package/builder/fonts/source-sans-pro/latin-300.css +8 -0
- package/builder/fonts/source-sans-pro/latin-400-italic.css +8 -0
- package/builder/fonts/source-sans-pro/latin-400.css +8 -0
- package/builder/fonts/source-sans-pro/latin-600-italic.css +8 -0
- package/builder/fonts/source-sans-pro/latin-600.css +8 -0
- package/builder/fonts/source-sans-pro/latin-700-italic.css +8 -0
- package/builder/fonts/source-sans-pro/latin-700.css +8 -0
- package/builder/fonts/source-sans-pro/latin-900-italic.css +8 -0
- package/builder/fonts/source-sans-pro/latin-900.css +8 -0
- package/builder/fonts/source-sans-pro/latin-ext-200-italic.css +8 -0
- package/builder/fonts/source-sans-pro/latin-ext-200.css +8 -0
- package/builder/fonts/source-sans-pro/latin-ext-300-italic.css +8 -0
- package/builder/fonts/source-sans-pro/latin-ext-300.css +8 -0
- package/builder/fonts/source-sans-pro/latin-ext-400-italic.css +8 -0
- package/builder/fonts/source-sans-pro/latin-ext-400.css +8 -0
- package/builder/fonts/source-sans-pro/latin-ext-600-italic.css +8 -0
- package/builder/fonts/source-sans-pro/latin-ext-600.css +8 -0
- package/builder/fonts/source-sans-pro/latin-ext-700-italic.css +8 -0
- package/builder/fonts/source-sans-pro/latin-ext-700.css +8 -0
- package/builder/fonts/source-sans-pro/latin-ext-900-italic.css +8 -0
- package/builder/fonts/source-sans-pro/latin-ext-900.css +8 -0
- package/builder/fonts/source-sans-pro/latin-ext-italic.css +53 -0
- package/builder/fonts/source-sans-pro/latin-ext.css +53 -0
- package/builder/fonts/source-sans-pro/latin-italic.css +53 -0
- package/builder/fonts/source-sans-pro/latin.css +53 -0
- package/builder/fonts/source-sans-pro/metadata.json +27 -0
- package/builder/fonts/source-sans-pro/package.json +30 -0
- package/builder/fonts/source-sans-pro/scss/metadata.scss +22 -0
- package/builder/fonts/source-sans-pro/scss/mixins.scss +184 -0
- package/builder/fonts/source-sans-pro/unicode.json +9 -0
- package/builder/fonts/source-sans-pro/vietnamese-200-italic.css +8 -0
- package/builder/fonts/source-sans-pro/vietnamese-200.css +8 -0
- package/builder/fonts/source-sans-pro/vietnamese-300-italic.css +8 -0
- package/builder/fonts/source-sans-pro/vietnamese-300.css +8 -0
- package/builder/fonts/source-sans-pro/vietnamese-400-italic.css +8 -0
- package/builder/fonts/source-sans-pro/vietnamese-400.css +8 -0
- package/builder/fonts/source-sans-pro/vietnamese-600-italic.css +8 -0
- package/builder/fonts/source-sans-pro/vietnamese-600.css +8 -0
- package/builder/fonts/source-sans-pro/vietnamese-700-italic.css +8 -0
- package/builder/fonts/source-sans-pro/vietnamese-700.css +8 -0
- package/builder/fonts/source-sans-pro/vietnamese-900-italic.css +8 -0
- package/builder/fonts/source-sans-pro/vietnamese-900.css +8 -0
- package/builder/fonts/source-sans-pro/vietnamese-italic.css +53 -0
- package/builder/fonts/source-sans-pro/vietnamese.css +53 -0
- package/builder/index.html +6 -5
- package/dist/{BudibaseApp-Y5NZEDTC.svelte → BudibaseApp-6SC4MY4W.svelte} +6 -11
- package/dist/automation.js +655 -862
- package/dist/automation.js.map +3 -3
- package/dist/index.js +970 -1185
- package/dist/index.js.map +3 -3
- package/dist/preview.hbs +4 -10
- package/dist/query.js +842 -998
- package/dist/query.js.map +3 -3
- package/package.json +11 -11
- package/src/api/controllers/backup.ts +8 -22
- package/src/api/controllers/datasource.ts +24 -41
- package/src/api/controllers/role.ts +5 -5
- package/src/api/controllers/routing.ts +3 -3
- package/src/api/controllers/row/ExternalRequest.ts +5 -1
- package/src/api/controllers/static/templates/BudibaseApp.svelte +6 -11
- package/src/api/controllers/static/templates/preview.hbs +4 -10
- package/src/api/routes/backup.ts +1 -1
- package/src/api/routes/tests/backup.spec.ts +2 -18
- package/src/automations/steps/sendSmtpEmail.ts +4 -55
- package/src/automations/tests/sendSmtpEmail.spec.js +71 -0
- package/src/events/docUpdates/syncUsers.ts +0 -4
- package/src/integrations/googlesheets.ts +18 -35
- package/src/integrations/mongodb.ts +2 -4
- package/src/integrations/mysql.ts +7 -2
- package/src/integrations/postgres.ts +1 -2
- package/src/integrations/tests/mysql.spec.ts +19 -1
- package/src/integrations/utils.ts +24 -0
- package/src/middleware/currentapp.ts +1 -1
- package/src/sdk/app/backups/exports.ts +5 -33
- package/src/sdk/app/backups/imports.ts +1 -21
- package/src/sdk/app/datasources/datasources.ts +0 -1
- package/src/utilities/workerRequests.ts +9 -20
- package/src/automations/tests/sendSmtpEmail.spec.ts +0 -74
package/dist/query.js
CHANGED
|
@@ -11,8 +11,8 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
11
11
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
12
|
};
|
|
13
13
|
var __export = (target, all) => {
|
|
14
|
-
for (var
|
|
15
|
-
__defProp(target,
|
|
14
|
+
for (var name2 in all)
|
|
15
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
16
16
|
};
|
|
17
17
|
var __copyProps = (to, from, except, desc) => {
|
|
18
18
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -563,13 +563,13 @@ var init_plan = __esm({
|
|
|
563
563
|
var isStaticQuota, isMonthlyQuota, isConstantQuota;
|
|
564
564
|
var init_quota = __esm({
|
|
565
565
|
"../types/src/sdk/licensing/quota.ts"() {
|
|
566
|
-
isStaticQuota = (quotaType, usageType,
|
|
566
|
+
isStaticQuota = (quotaType, usageType, name2) => {
|
|
567
567
|
return quotaType === "usage" /* USAGE */ && usageType === "static" /* STATIC */;
|
|
568
568
|
};
|
|
569
|
-
isMonthlyQuota = (quotaType, usageType,
|
|
569
|
+
isMonthlyQuota = (quotaType, usageType, name2) => {
|
|
570
570
|
return quotaType === "usage" /* USAGE */ && usageType === "monthly" /* MONTHLY */;
|
|
571
571
|
};
|
|
572
|
-
isConstantQuota = (quotaType,
|
|
572
|
+
isConstantQuota = (quotaType, name2) => {
|
|
573
573
|
return quotaType === "constant" /* CONSTANT */;
|
|
574
574
|
};
|
|
575
575
|
}
|
|
@@ -679,8 +679,8 @@ var init_locks = __esm({
|
|
|
679
679
|
var isDocument;
|
|
680
680
|
var init_db = __esm({
|
|
681
681
|
"../types/src/sdk/db.ts"() {
|
|
682
|
-
isDocument = (
|
|
683
|
-
return typeof
|
|
682
|
+
isDocument = (doc2) => {
|
|
683
|
+
return typeof doc2 === "object" && doc2._id && doc2._rev;
|
|
684
684
|
};
|
|
685
685
|
}
|
|
686
686
|
});
|
|
@@ -838,7 +838,6 @@ var init_automation2 = __esm({
|
|
|
838
838
|
AutomationIOType2["NUMBER"] = "number";
|
|
839
839
|
AutomationIOType2["ARRAY"] = "array";
|
|
840
840
|
AutomationIOType2["JSON"] = "json";
|
|
841
|
-
AutomationIOType2["DATE"] = "date";
|
|
842
841
|
return AutomationIOType2;
|
|
843
842
|
})(AutomationIOType || {});
|
|
844
843
|
AutomationCustomIOType = /* @__PURE__ */ ((AutomationCustomIOType2) => {
|
|
@@ -1955,27 +1954,27 @@ function init(opts) {
|
|
|
1955
1954
|
}
|
|
1956
1955
|
function getPouchDB(dbName, opts) {
|
|
1957
1956
|
checkInitialised();
|
|
1958
|
-
const
|
|
1959
|
-
const dbPut =
|
|
1960
|
-
|
|
1961
|
-
if (!
|
|
1962
|
-
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
return dbPut(
|
|
1957
|
+
const db2 = new Pouch(dbName, opts);
|
|
1958
|
+
const dbPut = db2.put;
|
|
1959
|
+
db2.put = async (doc2, options2 = {}) => {
|
|
1960
|
+
if (!doc2.createdAt) {
|
|
1961
|
+
doc2.createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1962
|
+
}
|
|
1963
|
+
doc2.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1964
|
+
return dbPut(doc2, options2);
|
|
1966
1965
|
};
|
|
1967
|
-
|
|
1968
|
-
const info = await
|
|
1966
|
+
db2.exists = async () => {
|
|
1967
|
+
const info = await db2.info();
|
|
1969
1968
|
return !info.error;
|
|
1970
1969
|
};
|
|
1971
|
-
return
|
|
1970
|
+
return db2;
|
|
1972
1971
|
}
|
|
1973
|
-
async function closePouchDB(
|
|
1974
|
-
if (!
|
|
1972
|
+
async function closePouchDB(db2) {
|
|
1973
|
+
if (!db2 || environment_default2.isTest()) {
|
|
1975
1974
|
return;
|
|
1976
1975
|
}
|
|
1977
1976
|
try {
|
|
1978
|
-
return await
|
|
1977
|
+
return await db2.close();
|
|
1979
1978
|
} catch (err) {
|
|
1980
1979
|
}
|
|
1981
1980
|
}
|
|
@@ -2126,14 +2125,14 @@ var init_DatabaseImpl = __esm({
|
|
|
2126
2125
|
}
|
|
2127
2126
|
}
|
|
2128
2127
|
async get(id) {
|
|
2129
|
-
const
|
|
2128
|
+
const db2 = await this.checkSetup();
|
|
2130
2129
|
if (!id) {
|
|
2131
2130
|
throw new Error("Unable to get doc without a valid _id.");
|
|
2132
2131
|
}
|
|
2133
|
-
return this.updateOutput(() =>
|
|
2132
|
+
return this.updateOutput(() => db2.get(id));
|
|
2134
2133
|
}
|
|
2135
|
-
async remove(idOrDoc,
|
|
2136
|
-
const
|
|
2134
|
+
async remove(idOrDoc, rev2) {
|
|
2135
|
+
const db2 = await this.checkSetup();
|
|
2137
2136
|
let _id;
|
|
2138
2137
|
let _rev;
|
|
2139
2138
|
if (isDocument(idOrDoc)) {
|
|
@@ -2141,12 +2140,12 @@ var init_DatabaseImpl = __esm({
|
|
|
2141
2140
|
_rev = idOrDoc._rev;
|
|
2142
2141
|
} else {
|
|
2143
2142
|
_id = idOrDoc;
|
|
2144
|
-
_rev =
|
|
2143
|
+
_rev = rev2;
|
|
2145
2144
|
}
|
|
2146
2145
|
if (!_id || !_rev) {
|
|
2147
2146
|
throw new Error("Unable to remove doc without a valid _id and _rev.");
|
|
2148
2147
|
}
|
|
2149
|
-
return this.updateOutput(() =>
|
|
2148
|
+
return this.updateOutput(() => db2.destroy(_id, _rev));
|
|
2150
2149
|
}
|
|
2151
2150
|
async post(document, opts) {
|
|
2152
2151
|
if (!document._id) {
|
|
@@ -2158,7 +2157,7 @@ var init_DatabaseImpl = __esm({
|
|
|
2158
2157
|
if (!document._id) {
|
|
2159
2158
|
throw new Error("Cannot store document without _id field.");
|
|
2160
2159
|
}
|
|
2161
|
-
const
|
|
2160
|
+
const db2 = await this.checkSetup();
|
|
2162
2161
|
if (!document.createdAt) {
|
|
2163
2162
|
document.createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
2164
2163
|
}
|
|
@@ -2175,20 +2174,20 @@ var init_DatabaseImpl = __esm({
|
|
|
2175
2174
|
}
|
|
2176
2175
|
}
|
|
2177
2176
|
}
|
|
2178
|
-
return this.updateOutput(() =>
|
|
2177
|
+
return this.updateOutput(() => db2.insert(document));
|
|
2179
2178
|
}
|
|
2180
2179
|
async bulkDocs(documents) {
|
|
2181
|
-
const
|
|
2182
|
-
return this.updateOutput(() =>
|
|
2180
|
+
const db2 = await this.checkSetup();
|
|
2181
|
+
return this.updateOutput(() => db2.bulk({ docs: documents }));
|
|
2183
2182
|
}
|
|
2184
2183
|
async allDocs(params2) {
|
|
2185
|
-
const
|
|
2186
|
-
return this.updateOutput(() =>
|
|
2184
|
+
const db2 = await this.checkSetup();
|
|
2185
|
+
return this.updateOutput(() => db2.list(params2));
|
|
2187
2186
|
}
|
|
2188
2187
|
async query(viewName, params2) {
|
|
2189
|
-
const
|
|
2188
|
+
const db2 = await this.checkSetup();
|
|
2190
2189
|
const [database, view] = viewName.split("/");
|
|
2191
|
-
return this.updateOutput(() =>
|
|
2190
|
+
return this.updateOutput(() => db2.view(database, view, params2));
|
|
2192
2191
|
}
|
|
2193
2192
|
async destroy() {
|
|
2194
2193
|
try {
|
|
@@ -2202,8 +2201,8 @@ var init_DatabaseImpl = __esm({
|
|
|
2202
2201
|
}
|
|
2203
2202
|
}
|
|
2204
2203
|
async compact() {
|
|
2205
|
-
const
|
|
2206
|
-
return this.updateOutput(() =>
|
|
2204
|
+
const db2 = await this.checkSetup();
|
|
2205
|
+
return this.updateOutput(() => db2.compact());
|
|
2207
2206
|
}
|
|
2208
2207
|
// All below functions are in-frequently called, just utilise PouchDB
|
|
2209
2208
|
// for them as it implements them better than we can
|
|
@@ -2246,8 +2245,8 @@ function getDB(dbName, opts) {
|
|
|
2246
2245
|
return new DatabaseImpl(dbName, opts);
|
|
2247
2246
|
}
|
|
2248
2247
|
async function doWithDB(dbName, cb, opts = {}) {
|
|
2249
|
-
const
|
|
2250
|
-
return await cb(
|
|
2248
|
+
const db2 = getDB(dbName, opts);
|
|
2249
|
+
return await cb(db2);
|
|
2251
2250
|
}
|
|
2252
2251
|
function allDbs() {
|
|
2253
2252
|
if (!environment_default2.isTest()) {
|
|
@@ -2595,11 +2594,11 @@ function getRedisOptions() {
|
|
|
2595
2594
|
}
|
|
2596
2595
|
return { opts, host, port: parseInt(port), redisProtocolUrl };
|
|
2597
2596
|
}
|
|
2598
|
-
function addDbPrefix(
|
|
2599
|
-
if (key.includes(
|
|
2597
|
+
function addDbPrefix(db2, key) {
|
|
2598
|
+
if (key.includes(db2)) {
|
|
2600
2599
|
return key;
|
|
2601
2600
|
}
|
|
2602
|
-
return `${
|
|
2601
|
+
return `${db2}${SEPARATOR2}${key}`;
|
|
2603
2602
|
}
|
|
2604
2603
|
function removeDbPrefix(key) {
|
|
2605
2604
|
let parts = key.split(SEPARATOR2);
|
|
@@ -2819,8 +2818,8 @@ var init_redis = __esm({
|
|
|
2819
2818
|
CONNECTED = true;
|
|
2820
2819
|
}
|
|
2821
2820
|
RedisWrapper = class {
|
|
2822
|
-
constructor(
|
|
2823
|
-
this._db =
|
|
2821
|
+
constructor(db2, selectDb = null) {
|
|
2822
|
+
this._db = db2;
|
|
2824
2823
|
this._select = selectDb || DEFAULT_SELECT_DB;
|
|
2825
2824
|
}
|
|
2826
2825
|
getClient() {
|
|
@@ -2840,8 +2839,8 @@ var init_redis = __esm({
|
|
|
2840
2839
|
this.getClient().disconnect();
|
|
2841
2840
|
}
|
|
2842
2841
|
async scan(key = "") {
|
|
2843
|
-
const
|
|
2844
|
-
key = `${
|
|
2842
|
+
const db2 = this._db;
|
|
2843
|
+
key = `${db2}${SEPARATOR2}${key}`;
|
|
2845
2844
|
let stream3;
|
|
2846
2845
|
if (CLUSTERED) {
|
|
2847
2846
|
let node = this.getClient().nodes("master");
|
|
@@ -2852,16 +2851,16 @@ var init_redis = __esm({
|
|
|
2852
2851
|
return promisifyStream(stream3, this.getClient());
|
|
2853
2852
|
}
|
|
2854
2853
|
async keys(pattern) {
|
|
2855
|
-
const
|
|
2856
|
-
return this.getClient().keys(addDbPrefix(
|
|
2854
|
+
const db2 = this._db;
|
|
2855
|
+
return this.getClient().keys(addDbPrefix(db2, pattern));
|
|
2857
2856
|
}
|
|
2858
2857
|
async exists(key) {
|
|
2859
|
-
const
|
|
2860
|
-
return await this.getClient().exists(addDbPrefix(
|
|
2858
|
+
const db2 = this._db;
|
|
2859
|
+
return await this.getClient().exists(addDbPrefix(db2, key));
|
|
2861
2860
|
}
|
|
2862
2861
|
async get(key) {
|
|
2863
|
-
const
|
|
2864
|
-
let response = await this.getClient().get(addDbPrefix(
|
|
2862
|
+
const db2 = this._db;
|
|
2863
|
+
let response = await this.getClient().get(addDbPrefix(db2, key));
|
|
2865
2864
|
if (response != null && response.key) {
|
|
2866
2865
|
response.key = key;
|
|
2867
2866
|
}
|
|
@@ -2872,11 +2871,11 @@ var init_redis = __esm({
|
|
|
2872
2871
|
}
|
|
2873
2872
|
}
|
|
2874
2873
|
async bulkGet(keys2) {
|
|
2875
|
-
const
|
|
2874
|
+
const db2 = this._db;
|
|
2876
2875
|
if (keys2.length === 0) {
|
|
2877
2876
|
return {};
|
|
2878
2877
|
}
|
|
2879
|
-
const prefixedKeys = keys2.map((key) => addDbPrefix(
|
|
2878
|
+
const prefixedKeys = keys2.map((key) => addDbPrefix(db2, key));
|
|
2880
2879
|
let response = await this.getClient().mget(prefixedKeys);
|
|
2881
2880
|
if (Array.isArray(response)) {
|
|
2882
2881
|
let final = {};
|
|
@@ -2899,29 +2898,29 @@ var init_redis = __esm({
|
|
|
2899
2898
|
}
|
|
2900
2899
|
}
|
|
2901
2900
|
async store(key, value, expirySeconds = null) {
|
|
2902
|
-
const
|
|
2901
|
+
const db2 = this._db;
|
|
2903
2902
|
if (typeof value === "object") {
|
|
2904
2903
|
value = JSON.stringify(value);
|
|
2905
2904
|
}
|
|
2906
|
-
const prefixedKey = addDbPrefix(
|
|
2905
|
+
const prefixedKey = addDbPrefix(db2, key);
|
|
2907
2906
|
await this.getClient().set(prefixedKey, value);
|
|
2908
2907
|
if (expirySeconds) {
|
|
2909
2908
|
await this.getClient().expire(prefixedKey, expirySeconds);
|
|
2910
2909
|
}
|
|
2911
2910
|
}
|
|
2912
2911
|
async getTTL(key) {
|
|
2913
|
-
const
|
|
2914
|
-
const prefixedKey = addDbPrefix(
|
|
2912
|
+
const db2 = this._db;
|
|
2913
|
+
const prefixedKey = addDbPrefix(db2, key);
|
|
2915
2914
|
return this.getClient().ttl(prefixedKey);
|
|
2916
2915
|
}
|
|
2917
2916
|
async setExpiry(key, expirySeconds) {
|
|
2918
|
-
const
|
|
2919
|
-
const prefixedKey = addDbPrefix(
|
|
2917
|
+
const db2 = this._db;
|
|
2918
|
+
const prefixedKey = addDbPrefix(db2, key);
|
|
2920
2919
|
await this.getClient().expire(prefixedKey, expirySeconds);
|
|
2921
2920
|
}
|
|
2922
2921
|
async delete(key) {
|
|
2923
|
-
const
|
|
2924
|
-
await this.getClient().del(addDbPrefix(
|
|
2922
|
+
const db2 = this._db;
|
|
2923
|
+
await this.getClient().del(addDbPrefix(db2, key));
|
|
2925
2924
|
}
|
|
2926
2925
|
async clear() {
|
|
2927
2926
|
let items = await this.scan();
|
|
@@ -3297,8 +3296,8 @@ function logAlert(message, e) {
|
|
|
3297
3296
|
}
|
|
3298
3297
|
console.error(`bb-alert: ${message}`, e);
|
|
3299
3298
|
}
|
|
3300
|
-
function logAlertWithInfo(message,
|
|
3301
|
-
message = `${message} - db: ${
|
|
3299
|
+
function logAlertWithInfo(message, db2, id, error) {
|
|
3300
|
+
message = `${message} - db: ${db2} - doc: ${id} - error: `;
|
|
3302
3301
|
logAlert(message, error);
|
|
3303
3302
|
}
|
|
3304
3303
|
function logWarn(message) {
|
|
@@ -3335,8 +3334,8 @@ var init_logging = __esm({
|
|
|
3335
3334
|
var require_Helper = __commonJS({
|
|
3336
3335
|
"../string-templates/src/helpers/Helper.js"(exports2, module2) {
|
|
3337
3336
|
var Helper = class {
|
|
3338
|
-
constructor(
|
|
3339
|
-
this.name =
|
|
3337
|
+
constructor(name2, fn, useValueFallback = true) {
|
|
3338
|
+
this.name = name2;
|
|
3340
3339
|
this.fn = fn;
|
|
3341
3340
|
this.useValueFallback = useValueFallback;
|
|
3342
3341
|
}
|
|
@@ -3505,18 +3504,18 @@ var require_external = __commonJS({
|
|
|
3505
3504
|
exports2.externalCollections = EXTERNAL_FUNCTION_COLLECTIONS;
|
|
3506
3505
|
exports2.addedHelpers = ADDED_HELPERS;
|
|
3507
3506
|
exports2.registerAll = (handlebars) => {
|
|
3508
|
-
for (let [
|
|
3509
|
-
handlebars.registerHelper(
|
|
3507
|
+
for (let [name2, helper] of Object.entries(ADDED_HELPERS)) {
|
|
3508
|
+
handlebars.registerHelper(name2, helper);
|
|
3510
3509
|
}
|
|
3511
3510
|
let externalNames = [];
|
|
3512
3511
|
for (let collection of EXTERNAL_FUNCTION_COLLECTIONS) {
|
|
3513
3512
|
let hbsHelperInfo = helpers[collection]();
|
|
3514
3513
|
for (let entry of Object.entries(hbsHelperInfo)) {
|
|
3515
|
-
const
|
|
3516
|
-
if (HelperFunctionBuiltin.indexOf(
|
|
3514
|
+
const name2 = entry[0];
|
|
3515
|
+
if (HelperFunctionBuiltin.indexOf(name2) !== -1 || externalNames.indexOf(name2) !== -1) {
|
|
3517
3516
|
continue;
|
|
3518
3517
|
}
|
|
3519
|
-
externalNames.push(
|
|
3518
|
+
externalNames.push(name2);
|
|
3520
3519
|
}
|
|
3521
3520
|
helpers[collection]({
|
|
3522
3521
|
handlebars
|
|
@@ -3525,11 +3524,11 @@ var require_external = __commonJS({
|
|
|
3525
3524
|
exports2.externalHelperNames = externalNames.concat(Object.keys(ADDED_HELPERS));
|
|
3526
3525
|
};
|
|
3527
3526
|
exports2.unregisterAll = (handlebars) => {
|
|
3528
|
-
for (let
|
|
3529
|
-
handlebars.unregisterHelper(
|
|
3527
|
+
for (let name2 of Object.keys(ADDED_HELPERS)) {
|
|
3528
|
+
handlebars.unregisterHelper(name2);
|
|
3530
3529
|
}
|
|
3531
|
-
for (let
|
|
3532
|
-
handlebars.unregisterHelper(
|
|
3530
|
+
for (let name2 of module2.exports.externalHelperNames) {
|
|
3531
|
+
handlebars.unregisterHelper(name2);
|
|
3533
3532
|
}
|
|
3534
3533
|
exports2.externalHelperNames = [];
|
|
3535
3534
|
};
|
|
@@ -3643,12 +3642,12 @@ var require_javascript = __commonJS({
|
|
|
3643
3642
|
throw new Error("JS disabled in environment.");
|
|
3644
3643
|
}
|
|
3645
3644
|
try {
|
|
3646
|
-
const
|
|
3645
|
+
const js2 = `function run(){${atob(handlebars)}};run();`;
|
|
3647
3646
|
const sandboxContext = {
|
|
3648
3647
|
$: (path2) => getContextValue(path2, cloneDeep7(context)),
|
|
3649
3648
|
helpers: getHelperList()
|
|
3650
3649
|
};
|
|
3651
|
-
const res = { data: runJS(
|
|
3650
|
+
const res = { data: runJS(js2, sandboxContext) };
|
|
3652
3651
|
return `{{${LITERAL_MARKER} js_result-${JSON.stringify(res)}}}`;
|
|
3653
3652
|
} catch (error) {
|
|
3654
3653
|
return "Error while executing JS";
|
|
@@ -3761,8 +3760,8 @@ var require_preprocessor = __commonJS({
|
|
|
3761
3760
|
FINALISE: "finalise"
|
|
3762
3761
|
};
|
|
3763
3762
|
var Preprocessor = class {
|
|
3764
|
-
constructor(
|
|
3765
|
-
this.name =
|
|
3763
|
+
constructor(name2, fn) {
|
|
3764
|
+
this.name = name2;
|
|
3766
3765
|
this.fn = fn;
|
|
3767
3766
|
}
|
|
3768
3767
|
process(fullString, statement, opts) {
|
|
@@ -3826,8 +3825,8 @@ var require_postprocessor = __commonJS({
|
|
|
3826
3825
|
CONVERT_LITERALS: "convert-literals"
|
|
3827
3826
|
};
|
|
3828
3827
|
var Postprocessor = class {
|
|
3829
|
-
constructor(
|
|
3830
|
-
this.name =
|
|
3828
|
+
constructor(name2, fn) {
|
|
3829
|
+
this.name = name2;
|
|
3831
3830
|
this.fn = fn;
|
|
3832
3831
|
}
|
|
3833
3832
|
process(statement) {
|
|
@@ -5469,10 +5468,10 @@ var require_src = __commonJS({
|
|
|
5469
5468
|
};
|
|
5470
5469
|
module2.exports.convertToJS = (hbs) => {
|
|
5471
5470
|
const blocks = exports2.findHBSBlocks(hbs);
|
|
5472
|
-
let
|
|
5471
|
+
let js2 = "return `", prevBlock = null;
|
|
5473
5472
|
const variables = {};
|
|
5474
5473
|
if (blocks.length === 0) {
|
|
5475
|
-
|
|
5474
|
+
js2 += hbs;
|
|
5476
5475
|
}
|
|
5477
5476
|
let count = 1;
|
|
5478
5477
|
for (let block of blocks) {
|
|
@@ -5484,15 +5483,15 @@ var require_src = __commonJS({
|
|
|
5484
5483
|
prevBlock = block;
|
|
5485
5484
|
const { variable, value } = convertHBSBlock(block, count++);
|
|
5486
5485
|
variables[variable] = value;
|
|
5487
|
-
|
|
5486
|
+
js2 += `${stringPart.split()}\${${variable}}`;
|
|
5488
5487
|
}
|
|
5489
5488
|
let varBlock = "";
|
|
5490
5489
|
for (let [variable, value] of Object.entries(variables)) {
|
|
5491
5490
|
varBlock += `const ${variable} = ${value};
|
|
5492
5491
|
`;
|
|
5493
5492
|
}
|
|
5494
|
-
|
|
5495
|
-
return `${varBlock}${
|
|
5493
|
+
js2 += "`;";
|
|
5494
|
+
return `${varBlock}${js2}`;
|
|
5496
5495
|
};
|
|
5497
5496
|
}
|
|
5498
5497
|
});
|
|
@@ -5519,12 +5518,12 @@ var require_src2 = __commonJS({
|
|
|
5519
5518
|
if (!process.env.NO_JS) {
|
|
5520
5519
|
const { VM: VM2 } = require("vm2");
|
|
5521
5520
|
const { setJSRunner } = require_javascript();
|
|
5522
|
-
setJSRunner((
|
|
5521
|
+
setJSRunner((js2, context) => {
|
|
5523
5522
|
const vm = new VM2({
|
|
5524
5523
|
sandbox: context,
|
|
5525
5524
|
timeout: 1e3
|
|
5526
5525
|
});
|
|
5527
|
-
return vm.run(
|
|
5526
|
+
return vm.run(js2);
|
|
5528
5527
|
});
|
|
5529
5528
|
}
|
|
5530
5529
|
}
|
|
@@ -5875,8 +5874,8 @@ async function lookupTenantId(userId) {
|
|
|
5875
5874
|
return user.tenantId;
|
|
5876
5875
|
}
|
|
5877
5876
|
async function getUserDoc(emailOrId) {
|
|
5878
|
-
const
|
|
5879
|
-
return
|
|
5877
|
+
const db2 = getPlatformDB();
|
|
5878
|
+
return db2.get(emailOrId);
|
|
5880
5879
|
}
|
|
5881
5880
|
function newUserIdDoc(id, tenantId) {
|
|
5882
5881
|
return {
|
|
@@ -5892,14 +5891,14 @@ function newUserEmailDoc(userId, email, tenantId) {
|
|
|
5892
5891
|
};
|
|
5893
5892
|
}
|
|
5894
5893
|
async function addUserDoc(emailOrId, newDocFn) {
|
|
5895
|
-
const
|
|
5894
|
+
const db2 = getPlatformDB();
|
|
5896
5895
|
let user;
|
|
5897
5896
|
try {
|
|
5898
|
-
await
|
|
5897
|
+
await db2.get(emailOrId);
|
|
5899
5898
|
} catch (e) {
|
|
5900
5899
|
if (e.status === 404) {
|
|
5901
5900
|
user = newDocFn();
|
|
5902
|
-
await
|
|
5901
|
+
await db2.put(user);
|
|
5903
5902
|
} else {
|
|
5904
5903
|
throw e;
|
|
5905
5904
|
}
|
|
@@ -5912,9 +5911,9 @@ async function addUser(tenantId, userId, email) {
|
|
|
5912
5911
|
]);
|
|
5913
5912
|
}
|
|
5914
5913
|
async function removeUser(user) {
|
|
5915
|
-
const
|
|
5914
|
+
const db2 = getPlatformDB();
|
|
5916
5915
|
const keys2 = [user._id, user.email];
|
|
5917
|
-
const userDocs = await
|
|
5916
|
+
const userDocs = await db2.allDocs({
|
|
5918
5917
|
keys: keys2,
|
|
5919
5918
|
include_docs: true
|
|
5920
5919
|
});
|
|
@@ -5924,7 +5923,7 @@ async function removeUser(user) {
|
|
|
5924
5923
|
_deleted: true
|
|
5925
5924
|
};
|
|
5926
5925
|
});
|
|
5927
|
-
await
|
|
5926
|
+
await db2.bulkDocs(toDelete);
|
|
5928
5927
|
}
|
|
5929
5928
|
|
|
5930
5929
|
// ../backend-core/src/platform/tenants.ts
|
|
@@ -6009,18 +6008,18 @@ async function newRedlock(opts = {}) {
|
|
|
6009
6008
|
}
|
|
6010
6009
|
function getLockName(opts) {
|
|
6011
6010
|
const prefix = opts.systemLock ? "system" : getTenantId();
|
|
6012
|
-
let
|
|
6011
|
+
let name2 = `lock:${prefix}_${opts.name}`;
|
|
6013
6012
|
if (opts.resource) {
|
|
6014
|
-
|
|
6013
|
+
name2 = name2 + `_${opts.resource}`;
|
|
6015
6014
|
}
|
|
6016
|
-
return
|
|
6015
|
+
return name2;
|
|
6017
6016
|
}
|
|
6018
6017
|
async function doWithLock(opts, task) {
|
|
6019
6018
|
const redlock = await getClient(opts.type, opts.customOptions);
|
|
6020
6019
|
let lock;
|
|
6021
6020
|
try {
|
|
6022
|
-
const
|
|
6023
|
-
lock = await redlock.lock(
|
|
6021
|
+
const name2 = getLockName(opts);
|
|
6022
|
+
lock = await redlock.lock(name2, opts.ttl);
|
|
6024
6023
|
const result = await task();
|
|
6025
6024
|
return { executed: true, result };
|
|
6026
6025
|
} catch (e) {
|
|
@@ -6130,8 +6129,8 @@ var getAccount = async (email) => {
|
|
|
6130
6129
|
// ../backend-core/src/cache/user.ts
|
|
6131
6130
|
var EXPIRY_SECONDS = 3600;
|
|
6132
6131
|
async function populateFromDB(userId, tenantId) {
|
|
6133
|
-
const
|
|
6134
|
-
const user = await
|
|
6132
|
+
const db2 = getTenantDB(tenantId);
|
|
6133
|
+
const user = await db2.get(userId);
|
|
6135
6134
|
user.budibaseAccess = true;
|
|
6136
6135
|
if (!environment_default2.SELF_HOSTED && !environment_default2.DISABLE_ACCOUNT_PORTAL) {
|
|
6137
6136
|
const account = await getAccount(user.email);
|
|
@@ -6320,8 +6319,8 @@ function generateRoleID(id) {
|
|
|
6320
6319
|
var generateDevInfoID = (userId) => {
|
|
6321
6320
|
return `${"devinfo" /* DEV_INFO */}${SEPARATOR}${userId}`;
|
|
6322
6321
|
};
|
|
6323
|
-
var generatePluginID = (
|
|
6324
|
-
return `${"plg" /* PLUGIN */}${SEPARATOR}${
|
|
6322
|
+
var generatePluginID = (name2) => {
|
|
6323
|
+
return `${"plg" /* PLUGIN */}${SEPARATOR}${name2}`;
|
|
6325
6324
|
};
|
|
6326
6325
|
|
|
6327
6326
|
// ../backend-core/src/docIds/params.ts
|
|
@@ -6406,8 +6405,8 @@ function getStartEndKeyURL(baseKey, tenantId) {
|
|
|
6406
6405
|
const tenancy2 = tenantId ? `${SEPARATOR}${tenantId}` : "";
|
|
6407
6406
|
return `startkey="${baseKey}${tenancy2}"&endkey="${baseKey}${tenancy2}${UNICODE_MAX}"`;
|
|
6408
6407
|
}
|
|
6409
|
-
var getPluginParams = (
|
|
6410
|
-
return getDocParams("plg" /* PLUGIN */,
|
|
6408
|
+
var getPluginParams = (pluginId2, otherProps = {}) => {
|
|
6409
|
+
return getDocParams("plg" /* PLUGIN */, pluginId2, otherProps);
|
|
6411
6410
|
};
|
|
6412
6411
|
|
|
6413
6412
|
// ../backend-core/src/db/utils.ts
|
|
@@ -6514,8 +6513,8 @@ function isSameAppID(appId1, appId2) {
|
|
|
6514
6513
|
async function dbExists(dbName) {
|
|
6515
6514
|
return doWithDB(
|
|
6516
6515
|
dbName,
|
|
6517
|
-
async (
|
|
6518
|
-
return await
|
|
6516
|
+
async (db2) => {
|
|
6517
|
+
return await db2.exists();
|
|
6519
6518
|
},
|
|
6520
6519
|
{ skip_setup: true }
|
|
6521
6520
|
);
|
|
@@ -6534,7 +6533,7 @@ function pagination(data, pageSize, {
|
|
|
6534
6533
|
const hasNextPage = data.length > pageSize;
|
|
6535
6534
|
let nextPage = void 0;
|
|
6536
6535
|
if (!getKey) {
|
|
6537
|
-
getKey = (
|
|
6536
|
+
getKey = (doc2) => property ? doc2 == null ? void 0 : doc2[property] : doc2 == null ? void 0 : doc2._id;
|
|
6538
6537
|
}
|
|
6539
6538
|
if (hasNextPage) {
|
|
6540
6539
|
nextPage = getKey(data[pageSize]);
|
|
@@ -6559,23 +6558,23 @@ function DesignDoc() {
|
|
|
6559
6558
|
views: {}
|
|
6560
6559
|
};
|
|
6561
6560
|
}
|
|
6562
|
-
async function removeDeprecated(
|
|
6561
|
+
async function removeDeprecated(db2, viewName) {
|
|
6563
6562
|
if (!DeprecatedViews[viewName]) {
|
|
6564
6563
|
return;
|
|
6565
6564
|
}
|
|
6566
6565
|
try {
|
|
6567
|
-
const designDoc = await
|
|
6566
|
+
const designDoc = await db2.get(DESIGN_DB);
|
|
6568
6567
|
for (let deprecatedNames of DeprecatedViews[viewName]) {
|
|
6569
6568
|
delete designDoc.views[deprecatedNames];
|
|
6570
6569
|
}
|
|
6571
|
-
await
|
|
6570
|
+
await db2.put(designDoc);
|
|
6572
6571
|
} catch (err) {
|
|
6573
6572
|
}
|
|
6574
6573
|
}
|
|
6575
|
-
async function createView(
|
|
6574
|
+
async function createView(db2, viewJs, viewName) {
|
|
6576
6575
|
let designDoc;
|
|
6577
6576
|
try {
|
|
6578
|
-
designDoc = await
|
|
6577
|
+
designDoc = await db2.get(DESIGN_DB);
|
|
6579
6578
|
} catch (err) {
|
|
6580
6579
|
designDoc = DesignDoc();
|
|
6581
6580
|
}
|
|
@@ -6587,26 +6586,26 @@ async function createView(db, viewJs, viewName) {
|
|
|
6587
6586
|
[viewName]: view
|
|
6588
6587
|
};
|
|
6589
6588
|
try {
|
|
6590
|
-
await
|
|
6589
|
+
await db2.put(designDoc);
|
|
6591
6590
|
} catch (err) {
|
|
6592
6591
|
if (err.status === 409) {
|
|
6593
|
-
return await createView(
|
|
6592
|
+
return await createView(db2, viewJs, viewName);
|
|
6594
6593
|
} else {
|
|
6595
6594
|
throw err;
|
|
6596
6595
|
}
|
|
6597
6596
|
}
|
|
6598
6597
|
}
|
|
6599
6598
|
var createNewUserEmailView = async () => {
|
|
6600
|
-
const
|
|
6599
|
+
const db2 = getGlobalDB();
|
|
6601
6600
|
const viewJs = `function(doc) {
|
|
6602
6601
|
if (doc._id.startsWith("${"us" /* USER */}${SEPARATOR}")) {
|
|
6603
6602
|
emit(doc.email.toLowerCase(), doc._id)
|
|
6604
6603
|
}
|
|
6605
6604
|
}`;
|
|
6606
|
-
await createView(
|
|
6605
|
+
await createView(db2, viewJs, "by_email2" /* USER_BY_EMAIL */);
|
|
6607
6606
|
};
|
|
6608
6607
|
var createUserAppView = async () => {
|
|
6609
|
-
const
|
|
6608
|
+
const db2 = getGlobalDB();
|
|
6610
6609
|
const viewJs = `function(doc) {
|
|
6611
6610
|
if (doc._id.startsWith("${"us" /* USER */}${SEPARATOR}") && doc.roles) {
|
|
6612
6611
|
for (let prodAppId of Object.keys(doc.roles)) {
|
|
@@ -6615,46 +6614,46 @@ var createUserAppView = async () => {
|
|
|
6615
6614
|
}
|
|
6616
6615
|
}
|
|
6617
6616
|
}`;
|
|
6618
|
-
await createView(
|
|
6617
|
+
await createView(db2, viewJs, "by_app" /* USER_BY_APP */);
|
|
6619
6618
|
};
|
|
6620
6619
|
var createApiKeyView = async () => {
|
|
6621
|
-
const
|
|
6620
|
+
const db2 = getGlobalDB();
|
|
6622
6621
|
const viewJs = `function(doc) {
|
|
6623
6622
|
if (doc._id.startsWith("${"devinfo" /* DEV_INFO */}") && doc.apiKey) {
|
|
6624
6623
|
emit(doc.apiKey, doc.userId)
|
|
6625
6624
|
}
|
|
6626
6625
|
}`;
|
|
6627
|
-
await createView(
|
|
6626
|
+
await createView(db2, viewJs, "by_api_key" /* BY_API_KEY */);
|
|
6628
6627
|
};
|
|
6629
6628
|
var createUserBuildersView = async () => {
|
|
6630
|
-
const
|
|
6629
|
+
const db2 = getGlobalDB();
|
|
6631
6630
|
const viewJs = `function(doc) {
|
|
6632
6631
|
if (doc.builder && doc.builder.global === true) {
|
|
6633
6632
|
emit(doc._id, doc._id)
|
|
6634
6633
|
}
|
|
6635
6634
|
}`;
|
|
6636
|
-
await createView(
|
|
6635
|
+
await createView(db2, viewJs, "by_builders" /* USER_BY_BUILDERS */);
|
|
6637
6636
|
};
|
|
6638
|
-
async function queryViewRaw(viewName, params2,
|
|
6637
|
+
async function queryViewRaw(viewName, params2, db2, createFunc, opts) {
|
|
6639
6638
|
try {
|
|
6640
|
-
const response = await
|
|
6639
|
+
const response = await db2.query(`database/${viewName}`, params2);
|
|
6641
6640
|
return response;
|
|
6642
6641
|
} catch (err) {
|
|
6643
6642
|
const pouchNotFound = err && err.name === "not_found";
|
|
6644
6643
|
const couchNotFound = err && err.status === 404;
|
|
6645
6644
|
if (pouchNotFound || couchNotFound) {
|
|
6646
|
-
await removeDeprecated(
|
|
6645
|
+
await removeDeprecated(db2, viewName);
|
|
6647
6646
|
await createFunc();
|
|
6648
|
-
return queryViewRaw(viewName, params2,
|
|
6647
|
+
return queryViewRaw(viewName, params2, db2, createFunc, opts);
|
|
6649
6648
|
} else if (err.status === 409) {
|
|
6650
|
-
return queryViewRaw(viewName, params2,
|
|
6649
|
+
return queryViewRaw(viewName, params2, db2, createFunc, opts);
|
|
6651
6650
|
} else {
|
|
6652
6651
|
throw err;
|
|
6653
6652
|
}
|
|
6654
6653
|
}
|
|
6655
6654
|
}
|
|
6656
|
-
var queryView = async (viewName, params2,
|
|
6657
|
-
const response = await queryViewRaw(viewName, params2,
|
|
6655
|
+
var queryView = async (viewName, params2, db2, createFunc, opts) => {
|
|
6656
|
+
const response = await queryViewRaw(viewName, params2, db2, createFunc, opts);
|
|
6658
6657
|
const rows2 = response.rows;
|
|
6659
6658
|
const docs = rows2.map(
|
|
6660
6659
|
(row) => params2.include_docs ? row.doc : row.value
|
|
@@ -6667,8 +6666,8 @@ var queryView = async (viewName, params2, db, createFunc, opts) => {
|
|
|
6667
6666
|
};
|
|
6668
6667
|
async function createPlatformView(viewJs, viewName) {
|
|
6669
6668
|
try {
|
|
6670
|
-
await doWithDB(StaticDatabases.PLATFORM_INFO.name, async (
|
|
6671
|
-
await createView(
|
|
6669
|
+
await doWithDB(StaticDatabases.PLATFORM_INFO.name, async (db2) => {
|
|
6670
|
+
await createView(db2, viewJs, viewName);
|
|
6672
6671
|
});
|
|
6673
6672
|
} catch (e) {
|
|
6674
6673
|
if (e.status === 409 && environment_default2.isTest()) {
|
|
@@ -6698,9 +6697,9 @@ var queryPlatformView = async (viewName, params2, opts) => {
|
|
|
6698
6697
|
["account_by_email" /* ACCOUNT_BY_EMAIL */]: createPlatformAccountEmailView,
|
|
6699
6698
|
["platform_users_lowercase" /* PLATFORM_USERS_LOWERCASE */]: createPlatformUserView
|
|
6700
6699
|
};
|
|
6701
|
-
return doWithDB(StaticDatabases.PLATFORM_INFO.name, async (
|
|
6700
|
+
return doWithDB(StaticDatabases.PLATFORM_INFO.name, async (db2) => {
|
|
6702
6701
|
const createFn = CreateFuncByName2[viewName];
|
|
6703
|
-
return queryView(viewName, params2,
|
|
6702
|
+
return queryView(viewName, params2, db2, createFn, opts);
|
|
6704
6703
|
});
|
|
6705
6704
|
};
|
|
6706
6705
|
var CreateFuncByName = {
|
|
@@ -6709,17 +6708,17 @@ var CreateFuncByName = {
|
|
|
6709
6708
|
["by_builders" /* USER_BY_BUILDERS */]: createUserBuildersView,
|
|
6710
6709
|
["by_app" /* USER_BY_APP */]: createUserAppView
|
|
6711
6710
|
};
|
|
6712
|
-
var queryGlobalView = async (viewName, params2,
|
|
6713
|
-
if (!
|
|
6714
|
-
|
|
6711
|
+
var queryGlobalView = async (viewName, params2, db2, opts) => {
|
|
6712
|
+
if (!db2) {
|
|
6713
|
+
db2 = getGlobalDB();
|
|
6715
6714
|
}
|
|
6716
6715
|
const createFn = CreateFuncByName[viewName];
|
|
6717
|
-
return queryView(viewName, params2,
|
|
6716
|
+
return queryView(viewName, params2, db2, createFn, opts);
|
|
6718
6717
|
};
|
|
6719
6718
|
async function queryGlobalViewRaw(viewName, params2, opts) {
|
|
6720
|
-
const
|
|
6719
|
+
const db2 = getGlobalDB();
|
|
6721
6720
|
const createFn = CreateFuncByName[viewName];
|
|
6722
|
-
return queryViewRaw(viewName, params2,
|
|
6721
|
+
return queryViewRaw(viewName, params2, db2, createFn, opts);
|
|
6723
6722
|
}
|
|
6724
6723
|
|
|
6725
6724
|
// ../backend-core/src/db/index.ts
|
|
@@ -6734,8 +6733,8 @@ var Replication = class {
|
|
|
6734
6733
|
* @param {String} source - the DB you want to replicate or rollback to
|
|
6735
6734
|
* @param {String} target - the DB you want to replicate to, or rollback from
|
|
6736
6735
|
*/
|
|
6737
|
-
constructor({ source, target }) {
|
|
6738
|
-
this.source = getPouchDB(
|
|
6736
|
+
constructor({ source: source2, target }) {
|
|
6737
|
+
this.source = getPouchDB(source2);
|
|
6739
6738
|
this.target = getPouchDB(target);
|
|
6740
6739
|
}
|
|
6741
6740
|
close() {
|
|
@@ -6770,8 +6769,8 @@ var Replication = class {
|
|
|
6770
6769
|
}
|
|
6771
6770
|
appReplicateOpts() {
|
|
6772
6771
|
return {
|
|
6773
|
-
filter: (
|
|
6774
|
-
return
|
|
6772
|
+
filter: (doc2) => {
|
|
6773
|
+
return doc2._id !== "app_metadata" /* APP_METADATA */;
|
|
6775
6774
|
}
|
|
6776
6775
|
};
|
|
6777
6776
|
}
|
|
@@ -6859,9 +6858,9 @@ var _QueryBuilder = class {
|
|
|
6859
6858
|
__privateSet(this, _indexBuilder, builderFn);
|
|
6860
6859
|
return this;
|
|
6861
6860
|
}
|
|
6862
|
-
setVersion(
|
|
6863
|
-
if (
|
|
6864
|
-
__privateSet(this, _version,
|
|
6861
|
+
setVersion(version2) {
|
|
6862
|
+
if (version2 != null) {
|
|
6863
|
+
__privateSet(this, _version, version2);
|
|
6865
6864
|
}
|
|
6866
6865
|
return this;
|
|
6867
6866
|
}
|
|
@@ -7354,10 +7353,10 @@ __export(searchIndexes_exports, {
|
|
|
7354
7353
|
init_src();
|
|
7355
7354
|
init_context2();
|
|
7356
7355
|
async function createUserIndex() {
|
|
7357
|
-
const
|
|
7356
|
+
const db2 = getGlobalDB();
|
|
7358
7357
|
let designDoc;
|
|
7359
7358
|
try {
|
|
7360
|
-
designDoc = await
|
|
7359
|
+
designDoc = await db2.get("_design/database");
|
|
7361
7360
|
} catch (err) {
|
|
7362
7361
|
if (err.status === 404) {
|
|
7363
7362
|
designDoc = { _id: "_design/database" };
|
|
@@ -7403,7 +7402,7 @@ async function createUserIndex() {
|
|
|
7403
7402
|
}
|
|
7404
7403
|
}
|
|
7405
7404
|
};
|
|
7406
|
-
await
|
|
7405
|
+
await db2.put(designDoc);
|
|
7407
7406
|
}
|
|
7408
7407
|
|
|
7409
7408
|
// ../backend-core/src/cache/appMetadata.ts
|
|
@@ -7414,42 +7413,42 @@ var EXPIRY_SECONDS2 = 3600;
|
|
|
7414
7413
|
async function populateFromDB2(appId) {
|
|
7415
7414
|
return doWithDB(
|
|
7416
7415
|
appId,
|
|
7417
|
-
(
|
|
7418
|
-
return
|
|
7416
|
+
(db2) => {
|
|
7417
|
+
return db2.get("app_metadata" /* APP_METADATA */);
|
|
7419
7418
|
},
|
|
7420
7419
|
{ skip_setup: true }
|
|
7421
7420
|
);
|
|
7422
7421
|
}
|
|
7423
|
-
function isInvalid(
|
|
7424
|
-
return !
|
|
7422
|
+
function isInvalid(metadata2) {
|
|
7423
|
+
return !metadata2 || metadata2.state === AppState.INVALID;
|
|
7425
7424
|
}
|
|
7426
7425
|
async function getAppMetadata(appId) {
|
|
7427
7426
|
const client3 = await getAppClient();
|
|
7428
|
-
let
|
|
7429
|
-
if (!
|
|
7427
|
+
let metadata2 = await client3.get(appId);
|
|
7428
|
+
if (!metadata2) {
|
|
7430
7429
|
let expiry = EXPIRY_SECONDS2;
|
|
7431
7430
|
try {
|
|
7432
|
-
|
|
7431
|
+
metadata2 = await populateFromDB2(appId);
|
|
7433
7432
|
} catch (err) {
|
|
7434
7433
|
if (err && err.status === 404) {
|
|
7435
|
-
|
|
7434
|
+
metadata2 = { state: AppState.INVALID };
|
|
7436
7435
|
expiry = void 0;
|
|
7437
7436
|
} else {
|
|
7438
7437
|
throw err;
|
|
7439
7438
|
}
|
|
7440
7439
|
}
|
|
7441
|
-
if (isInvalid(
|
|
7440
|
+
if (isInvalid(metadata2)) {
|
|
7442
7441
|
const temp = await client3.get(appId);
|
|
7443
7442
|
if (temp) {
|
|
7444
|
-
|
|
7443
|
+
metadata2 = temp;
|
|
7445
7444
|
}
|
|
7446
7445
|
}
|
|
7447
|
-
await client3.store(appId,
|
|
7446
|
+
await client3.store(appId, metadata2, expiry);
|
|
7448
7447
|
}
|
|
7449
|
-
if (isInvalid(
|
|
7448
|
+
if (isInvalid(metadata2)) {
|
|
7450
7449
|
throw { status: 404, message: "No app metadata found" };
|
|
7451
7450
|
}
|
|
7452
|
-
return
|
|
7451
|
+
return metadata2;
|
|
7453
7452
|
}
|
|
7454
7453
|
async function invalidateAppMetadata(appId, newMetadata) {
|
|
7455
7454
|
if (!appId) {
|
|
@@ -7480,21 +7479,21 @@ async function getCache() {
|
|
|
7480
7479
|
}
|
|
7481
7480
|
return CACHE;
|
|
7482
7481
|
}
|
|
7483
|
-
function makeCacheKey(
|
|
7484
|
-
return
|
|
7482
|
+
function makeCacheKey(db2, key) {
|
|
7483
|
+
return db2.name + key;
|
|
7485
7484
|
}
|
|
7486
|
-
function makeCacheItem(
|
|
7487
|
-
return { doc, lastWrite: lastWrite || Date.now() };
|
|
7485
|
+
function makeCacheItem(doc2, lastWrite = null) {
|
|
7486
|
+
return { doc: doc2, lastWrite: lastWrite || Date.now() };
|
|
7488
7487
|
}
|
|
7489
|
-
async function put(
|
|
7488
|
+
async function put(db2, doc2, writeRateMs = DEFAULT_WRITE_RATE_MS) {
|
|
7490
7489
|
const cache2 = await getCache();
|
|
7491
|
-
const key =
|
|
7490
|
+
const key = doc2._id;
|
|
7492
7491
|
let cacheItem;
|
|
7493
7492
|
if (key) {
|
|
7494
|
-
cacheItem = await cache2.get(makeCacheKey(
|
|
7493
|
+
cacheItem = await cache2.get(makeCacheKey(db2, key));
|
|
7495
7494
|
}
|
|
7496
7495
|
const updateDb = !cacheItem || cacheItem.lastWrite < Date.now() - writeRateMs;
|
|
7497
|
-
let output =
|
|
7496
|
+
let output = doc2;
|
|
7498
7497
|
if (updateDb) {
|
|
7499
7498
|
const lockResponse = await doWithLock(
|
|
7500
7499
|
{
|
|
@@ -7505,15 +7504,15 @@ async function put(db, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
|
|
|
7505
7504
|
},
|
|
7506
7505
|
async () => {
|
|
7507
7506
|
const writeDb = async (toWrite) => {
|
|
7508
|
-
const response = await
|
|
7507
|
+
const response = await db2.put(toWrite, { force: true });
|
|
7509
7508
|
output = {
|
|
7510
|
-
...
|
|
7509
|
+
...doc2,
|
|
7511
7510
|
_id: response.id,
|
|
7512
7511
|
_rev: response.rev
|
|
7513
7512
|
};
|
|
7514
7513
|
};
|
|
7515
7514
|
try {
|
|
7516
|
-
await writeDb(
|
|
7515
|
+
await writeDb(doc2);
|
|
7517
7516
|
} catch (err) {
|
|
7518
7517
|
if (err.status !== 409) {
|
|
7519
7518
|
throw err;
|
|
@@ -7529,47 +7528,47 @@ async function put(db, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
|
|
|
7529
7528
|
}
|
|
7530
7529
|
cacheItem = makeCacheItem(output, updateDb ? null : cacheItem == null ? void 0 : cacheItem.lastWrite);
|
|
7531
7530
|
if (output._id) {
|
|
7532
|
-
await cache2.store(makeCacheKey(
|
|
7531
|
+
await cache2.store(makeCacheKey(db2, output._id), cacheItem);
|
|
7533
7532
|
}
|
|
7534
7533
|
return { ok: true, id: output._id, rev: output._rev };
|
|
7535
7534
|
}
|
|
7536
|
-
async function get2(
|
|
7535
|
+
async function get2(db2, id) {
|
|
7537
7536
|
const cache2 = await getCache();
|
|
7538
|
-
const cacheKey = makeCacheKey(
|
|
7537
|
+
const cacheKey = makeCacheKey(db2, id);
|
|
7539
7538
|
let cacheItem = await cache2.get(cacheKey);
|
|
7540
7539
|
if (!cacheItem) {
|
|
7541
|
-
const
|
|
7542
|
-
cacheItem = makeCacheItem(
|
|
7540
|
+
const doc2 = await db2.get(id);
|
|
7541
|
+
cacheItem = makeCacheItem(doc2);
|
|
7543
7542
|
await cache2.store(cacheKey, cacheItem);
|
|
7544
7543
|
}
|
|
7545
7544
|
return cacheItem.doc;
|
|
7546
7545
|
}
|
|
7547
|
-
async function remove(
|
|
7546
|
+
async function remove(db2, docOrId, rev2) {
|
|
7548
7547
|
const cache2 = await getCache();
|
|
7549
7548
|
if (!docOrId) {
|
|
7550
7549
|
throw new Error("No ID/Rev provided.");
|
|
7551
7550
|
}
|
|
7552
7551
|
const id = typeof docOrId === "string" ? docOrId : docOrId._id;
|
|
7553
|
-
|
|
7552
|
+
rev2 = typeof docOrId === "string" ? rev2 : docOrId._rev;
|
|
7554
7553
|
try {
|
|
7555
|
-
await cache2.delete(makeCacheKey(
|
|
7554
|
+
await cache2.delete(makeCacheKey(db2, id));
|
|
7556
7555
|
} finally {
|
|
7557
|
-
await
|
|
7556
|
+
await db2.remove(id, rev2);
|
|
7558
7557
|
}
|
|
7559
7558
|
}
|
|
7560
7559
|
var Writethrough = class {
|
|
7561
|
-
constructor(
|
|
7562
|
-
this.db =
|
|
7560
|
+
constructor(db2, writeRateMs = DEFAULT_WRITE_RATE_MS) {
|
|
7561
|
+
this.db = db2;
|
|
7563
7562
|
this.writeRateMs = writeRateMs;
|
|
7564
7563
|
}
|
|
7565
|
-
async put(
|
|
7566
|
-
return put(this.db,
|
|
7564
|
+
async put(doc2) {
|
|
7565
|
+
return put(this.db, doc2, this.writeRateMs);
|
|
7567
7566
|
}
|
|
7568
7567
|
async get(id) {
|
|
7569
7568
|
return get2(this.db, id);
|
|
7570
7569
|
}
|
|
7571
|
-
async remove(docOrId,
|
|
7572
|
-
return remove(this.db, docOrId,
|
|
7570
|
+
async remove(docOrId, rev2) {
|
|
7571
|
+
return remove(this.db, docOrId, rev2);
|
|
7573
7572
|
}
|
|
7574
7573
|
};
|
|
7575
7574
|
|
|
@@ -7581,9 +7580,9 @@ function generateConfigID(type) {
|
|
|
7581
7580
|
return `${"config" /* CONFIG */}${SEPARATOR}${type}`;
|
|
7582
7581
|
}
|
|
7583
7582
|
async function getConfig(type) {
|
|
7584
|
-
const
|
|
7583
|
+
const db2 = getGlobalDB();
|
|
7585
7584
|
try {
|
|
7586
|
-
return await
|
|
7585
|
+
return await db2.get(generateConfigID(type));
|
|
7587
7586
|
} catch (e) {
|
|
7588
7587
|
if (e.status === 404) {
|
|
7589
7588
|
return;
|
|
@@ -7592,8 +7591,8 @@ async function getConfig(type) {
|
|
|
7592
7591
|
}
|
|
7593
7592
|
}
|
|
7594
7593
|
async function save(config) {
|
|
7595
|
-
const
|
|
7596
|
-
return
|
|
7594
|
+
const db2 = getGlobalDB();
|
|
7595
|
+
return db2.put(config);
|
|
7597
7596
|
}
|
|
7598
7597
|
async function getSettingsConfigDoc() {
|
|
7599
7598
|
let config = await getConfig("settings" /* SETTINGS */);
|
|
@@ -8042,7 +8041,7 @@ __export(utils_exports2, {
|
|
|
8042
8041
|
compare: () => compare,
|
|
8043
8042
|
getAppIdFromCtx: () => getAppIdFromCtx,
|
|
8044
8043
|
getCookie: () => getCookie,
|
|
8045
|
-
hash: () =>
|
|
8044
|
+
hash: () => hash2,
|
|
8046
8045
|
isAudited: () => isAudited,
|
|
8047
8046
|
isClient: () => isClient,
|
|
8048
8047
|
isPublicApiRequest: () => isPublicApiRequest,
|
|
@@ -8063,7 +8062,7 @@ init_environment2();
|
|
|
8063
8062
|
init_newid();
|
|
8064
8063
|
var bcrypt = environment_default2.JS_BCRYPT ? require("bcryptjs") : require("bcrypt");
|
|
8065
8064
|
var SALT_ROUNDS = environment_default2.SALT_ROUNDS || 10;
|
|
8066
|
-
async function
|
|
8065
|
+
async function hash2(data) {
|
|
8067
8066
|
const salt = await bcrypt.genSalt(SALT_ROUNDS);
|
|
8068
8067
|
return bcrypt.hash(data, salt);
|
|
8069
8068
|
}
|
|
@@ -8179,14 +8178,14 @@ function isValidInternalAPIKey(apiKey) {
|
|
|
8179
8178
|
}
|
|
8180
8179
|
return false;
|
|
8181
8180
|
}
|
|
8182
|
-
function getCookie(ctx,
|
|
8183
|
-
const cookie = ctx.cookies.get(
|
|
8181
|
+
function getCookie(ctx, name2) {
|
|
8182
|
+
const cookie = ctx.cookies.get(name2);
|
|
8184
8183
|
if (!cookie) {
|
|
8185
8184
|
return cookie;
|
|
8186
8185
|
}
|
|
8187
8186
|
return openJwt(cookie);
|
|
8188
8187
|
}
|
|
8189
|
-
function setCookie(ctx, value,
|
|
8188
|
+
function setCookie(ctx, value, name2 = "builder", opts = { sign: true }) {
|
|
8190
8189
|
if (value && opts && opts.sign) {
|
|
8191
8190
|
value = jwt.sign(value, environment_default2.JWT_SECRET);
|
|
8192
8191
|
}
|
|
@@ -8199,10 +8198,10 @@ function setCookie(ctx, value, name = "builder", opts = { sign: true }) {
|
|
|
8199
8198
|
if (environment_default2.COOKIE_DOMAIN) {
|
|
8200
8199
|
config.domain = environment_default2.COOKIE_DOMAIN;
|
|
8201
8200
|
}
|
|
8202
|
-
ctx.cookies.set(
|
|
8201
|
+
ctx.cookies.set(name2, value, config);
|
|
8203
8202
|
}
|
|
8204
|
-
function clearCookie(ctx,
|
|
8205
|
-
setCookie(ctx, null,
|
|
8203
|
+
function clearCookie(ctx, name2) {
|
|
8204
|
+
setCookie(ctx, null, name2);
|
|
8206
8205
|
}
|
|
8207
8206
|
function isClient(ctx) {
|
|
8208
8207
|
return ctx.headers["x-budibase-type" /* TYPE */] === "client";
|
|
@@ -8236,8 +8235,8 @@ var InMemoryQueue = class {
|
|
|
8236
8235
|
* @param {object|null} opts This is not used by the in memory queue as there is no real use
|
|
8237
8236
|
* case when in memory, but is the same API as Bull
|
|
8238
8237
|
*/
|
|
8239
|
-
constructor(
|
|
8240
|
-
this._name =
|
|
8238
|
+
constructor(name2, opts = null) {
|
|
8239
|
+
this._name = name2;
|
|
8241
8240
|
this._opts = opts;
|
|
8242
8241
|
this._messages = [];
|
|
8243
8242
|
this._emitter = new import_events2.default.EventEmitter();
|
|
@@ -8670,13 +8669,13 @@ var getInstallFromDB = async () => {
|
|
|
8670
8669
|
}
|
|
8671
8670
|
);
|
|
8672
8671
|
};
|
|
8673
|
-
var updateVersion = async (
|
|
8672
|
+
var updateVersion = async (version2) => {
|
|
8674
8673
|
try {
|
|
8675
8674
|
await doWithDB(
|
|
8676
8675
|
StaticDatabases.PLATFORM_INFO.name,
|
|
8677
8676
|
async (platformDb) => {
|
|
8678
8677
|
const install = await getInstall();
|
|
8679
|
-
install.version =
|
|
8678
|
+
install.version = version2;
|
|
8680
8679
|
await platformDb.put(install);
|
|
8681
8680
|
await bustCache("installation" /* INSTALLATION */);
|
|
8682
8681
|
}
|
|
@@ -8778,13 +8777,13 @@ var identifyInstallationGroup = async (installId, timestamp) => {
|
|
|
8778
8777
|
const id = installId;
|
|
8779
8778
|
const type = "installation" /* INSTALLATION */;
|
|
8780
8779
|
const hosting = getHostingFromEnv();
|
|
8781
|
-
const
|
|
8780
|
+
const version2 = environment_default2.VERSION;
|
|
8782
8781
|
const environment3 = getDeploymentEnvironment();
|
|
8783
8782
|
const group = {
|
|
8784
8783
|
id,
|
|
8785
8784
|
type,
|
|
8786
8785
|
hosting,
|
|
8787
|
-
version,
|
|
8786
|
+
version: version2,
|
|
8788
8787
|
environment: environment3
|
|
8789
8788
|
};
|
|
8790
8789
|
await identifyGroup(group, timestamp);
|
|
@@ -8909,7 +8908,7 @@ var getEventTenantId = async (tenantId) => {
|
|
|
8909
8908
|
var getUniqueTenantId = async (tenantId) => {
|
|
8910
8909
|
return doInTenant(tenantId, () => {
|
|
8911
8910
|
return withCache("uniqueTenantId" /* UNIQUE_TENANT_ID */, 86400 /* ONE_DAY */, async () => {
|
|
8912
|
-
const
|
|
8911
|
+
const db2 = getGlobalDB();
|
|
8913
8912
|
const config = await getSettingsConfigDoc();
|
|
8914
8913
|
let uniqueTenantId;
|
|
8915
8914
|
if (config.config.uniqueTenantId) {
|
|
@@ -8917,7 +8916,7 @@ var getUniqueTenantId = async (tenantId) => {
|
|
|
8917
8916
|
} else {
|
|
8918
8917
|
uniqueTenantId = `${newid()}_${tenantId}`;
|
|
8919
8918
|
config.config.uniqueTenantId = uniqueTenantId;
|
|
8920
|
-
await
|
|
8919
|
+
await db2.put(config);
|
|
8921
8920
|
return uniqueTenantId;
|
|
8922
8921
|
}
|
|
8923
8922
|
});
|
|
@@ -8957,10 +8956,10 @@ __export(backfill_exports, {
|
|
|
8957
8956
|
init_src();
|
|
8958
8957
|
init_context2();
|
|
8959
8958
|
var start = async (events2) => {
|
|
8960
|
-
const
|
|
8959
|
+
const metadata2 = {
|
|
8961
8960
|
eventWhitelist: events2
|
|
8962
8961
|
};
|
|
8963
|
-
return saveBackfillMetadata(
|
|
8962
|
+
return saveBackfillMetadata(metadata2);
|
|
8964
8963
|
};
|
|
8965
8964
|
var recordEvent2 = async (event, properties) => {
|
|
8966
8965
|
const eventKey2 = getEventKey(event, properties);
|
|
@@ -9270,11 +9269,11 @@ var app_default = {
|
|
|
9270
9269
|
|
|
9271
9270
|
// ../backend-core/src/events/publishers/auth.ts
|
|
9272
9271
|
init_src();
|
|
9273
|
-
async function login(
|
|
9272
|
+
async function login(source2, email) {
|
|
9274
9273
|
const identity = await identification_default.getCurrentIdentity();
|
|
9275
9274
|
const properties = {
|
|
9276
9275
|
userId: identity.id,
|
|
9277
|
-
source,
|
|
9276
|
+
source: source2,
|
|
9278
9277
|
audited: {
|
|
9279
9278
|
email
|
|
9280
9279
|
}
|
|
@@ -10063,9 +10062,9 @@ var view_default = {
|
|
|
10063
10062
|
|
|
10064
10063
|
// ../backend-core/src/events/publishers/installation.ts
|
|
10065
10064
|
init_src();
|
|
10066
|
-
async function versionChecked(
|
|
10065
|
+
async function versionChecked(version2) {
|
|
10067
10066
|
const properties = {
|
|
10068
|
-
currentVersion:
|
|
10067
|
+
currentVersion: version2
|
|
10069
10068
|
};
|
|
10070
10069
|
await publishEvent("installation:version:checked" /* INSTALLATION_VERSION_CHECKED */, properties);
|
|
10071
10070
|
}
|
|
@@ -10284,13 +10283,13 @@ async function appBackupRestored(backup) {
|
|
|
10284
10283
|
};
|
|
10285
10284
|
await publishEvent("app:backup:restored" /* APP_BACKUP_RESTORED */, properties);
|
|
10286
10285
|
}
|
|
10287
|
-
async function appBackupTriggered(appId, backupId, type, trigger,
|
|
10286
|
+
async function appBackupTriggered(appId, backupId, type, trigger, name2) {
|
|
10288
10287
|
const properties = {
|
|
10289
10288
|
appId,
|
|
10290
10289
|
backupId,
|
|
10291
10290
|
type,
|
|
10292
10291
|
trigger,
|
|
10293
|
-
name
|
|
10292
|
+
name: name2
|
|
10294
10293
|
};
|
|
10295
10294
|
await publishEvent("app:backup:triggered" /* APP_BACKUP_TRIGGERED */, properties);
|
|
10296
10295
|
}
|
|
@@ -10301,16 +10300,16 @@ var backup_default = {
|
|
|
10301
10300
|
|
|
10302
10301
|
// ../backend-core/src/events/publishers/environmentVariable.ts
|
|
10303
10302
|
init_src();
|
|
10304
|
-
async function created14(
|
|
10303
|
+
async function created14(name2, environments) {
|
|
10305
10304
|
const properties = {
|
|
10306
|
-
name,
|
|
10305
|
+
name: name2,
|
|
10307
10306
|
environments
|
|
10308
10307
|
};
|
|
10309
10308
|
await publishEvent("environment_variable:created" /* ENVIRONMENT_VARIABLE_CREATED */, properties);
|
|
10310
10309
|
}
|
|
10311
|
-
async function deleted14(
|
|
10310
|
+
async function deleted14(name2) {
|
|
10312
10311
|
const properties = {
|
|
10313
|
-
name
|
|
10312
|
+
name: name2
|
|
10314
10313
|
};
|
|
10315
10314
|
await publishEvent("environment_variable:deleted" /* ENVIRONMENT_VARIABLE_DELETED */, properties);
|
|
10316
10315
|
}
|
|
@@ -10431,8 +10430,8 @@ function removeUserPassword(users2) {
|
|
|
10431
10430
|
return users2;
|
|
10432
10431
|
}
|
|
10433
10432
|
var bulkGetGlobalUsersById = async (userIds, opts) => {
|
|
10434
|
-
const
|
|
10435
|
-
let users2 = (await
|
|
10433
|
+
const db2 = getGlobalDB();
|
|
10434
|
+
let users2 = (await db2.allDocs({
|
|
10436
10435
|
keys: userIds,
|
|
10437
10436
|
include_docs: true
|
|
10438
10437
|
})).rows.map((row) => row.doc);
|
|
@@ -10442,21 +10441,21 @@ var bulkGetGlobalUsersById = async (userIds, opts) => {
|
|
|
10442
10441
|
return users2;
|
|
10443
10442
|
};
|
|
10444
10443
|
var getAllUserIds = async () => {
|
|
10445
|
-
const
|
|
10444
|
+
const db2 = getGlobalDB();
|
|
10446
10445
|
const startKey = `${"us" /* USER */}${SEPARATOR}`;
|
|
10447
|
-
const response = await
|
|
10446
|
+
const response = await db2.allDocs({
|
|
10448
10447
|
startkey: startKey,
|
|
10449
10448
|
endkey: `${startKey}${UNICODE_MAX}`
|
|
10450
10449
|
});
|
|
10451
10450
|
return response.rows.map((row) => row.id);
|
|
10452
10451
|
};
|
|
10453
10452
|
var bulkUpdateGlobalUsers = async (users2) => {
|
|
10454
|
-
const
|
|
10455
|
-
return await
|
|
10453
|
+
const db2 = getGlobalDB();
|
|
10454
|
+
return await db2.bulkDocs(users2);
|
|
10456
10455
|
};
|
|
10457
10456
|
async function getById(id, opts) {
|
|
10458
|
-
const
|
|
10459
|
-
let user = await
|
|
10457
|
+
const db2 = getGlobalDB();
|
|
10458
|
+
let user = await db2.get(id);
|
|
10460
10459
|
if (opts == null ? void 0 : opts.cleanup) {
|
|
10461
10460
|
user = removeUserPassword(user);
|
|
10462
10461
|
}
|
|
@@ -10559,7 +10558,7 @@ var paginatedUsers = async ({
|
|
|
10559
10558
|
email,
|
|
10560
10559
|
appId
|
|
10561
10560
|
} = {}) => {
|
|
10562
|
-
const
|
|
10561
|
+
const db2 = getGlobalDB();
|
|
10563
10562
|
const opts = {
|
|
10564
10563
|
include_docs: true,
|
|
10565
10564
|
limit: PAGE_LIMIT + 1
|
|
@@ -10570,12 +10569,12 @@ var paginatedUsers = async ({
|
|
|
10570
10569
|
let userList, property = "_id", getKey;
|
|
10571
10570
|
if (appId) {
|
|
10572
10571
|
userList = await searchGlobalUsersByApp(appId, opts);
|
|
10573
|
-
getKey = (
|
|
10572
|
+
getKey = (doc2) => getGlobalUserByAppPage(appId, doc2);
|
|
10574
10573
|
} else if (email) {
|
|
10575
10574
|
userList = await searchGlobalUsersByEmail(email, opts);
|
|
10576
10575
|
property = "email";
|
|
10577
10576
|
} else {
|
|
10578
|
-
const response = await
|
|
10577
|
+
const response = await db2.allDocs(getGlobalUserParams(null, opts));
|
|
10579
10578
|
userList = response.rows.map((row) => row.doc);
|
|
10580
10579
|
}
|
|
10581
10580
|
return pagination(userList, PAGE_LIMIT, {
|
|
@@ -10696,10 +10695,10 @@ var EXTERNAL_BUILTIN_ROLE_IDS = [
|
|
|
10696
10695
|
BUILTIN_IDS.PUBLIC
|
|
10697
10696
|
];
|
|
10698
10697
|
var Role2 = class {
|
|
10699
|
-
constructor(id,
|
|
10698
|
+
constructor(id, name2, permissionId) {
|
|
10700
10699
|
this.permissions = {};
|
|
10701
10700
|
this._id = id;
|
|
10702
|
-
this.name =
|
|
10701
|
+
this.name = name2;
|
|
10703
10702
|
this.permissionId = permissionId;
|
|
10704
10703
|
}
|
|
10705
10704
|
addInheritance(inherits) {
|
|
@@ -10778,7 +10777,7 @@ function lowerBuiltinRoleID(roleId1, roleId2) {
|
|
|
10778
10777
|
}
|
|
10779
10778
|
return builtinRoleToNumber(roleId1) > builtinRoleToNumber(roleId2) ? roleId2 : roleId1;
|
|
10780
10779
|
}
|
|
10781
|
-
async function getRole(roleId
|
|
10780
|
+
async function getRole(roleId) {
|
|
10782
10781
|
if (!roleId) {
|
|
10783
10782
|
return void 0;
|
|
10784
10783
|
}
|
|
@@ -10789,14 +10788,11 @@ async function getRole(roleId, opts) {
|
|
|
10789
10788
|
);
|
|
10790
10789
|
}
|
|
10791
10790
|
try {
|
|
10792
|
-
const
|
|
10793
|
-
const dbRole = await
|
|
10791
|
+
const db2 = getAppDB();
|
|
10792
|
+
const dbRole = await db2.get(getDBRoleID(roleId));
|
|
10794
10793
|
role = Object.assign(role, dbRole);
|
|
10795
10794
|
role._id = getExternalRoleID(role._id);
|
|
10796
10795
|
} catch (err) {
|
|
10797
|
-
if (!isBuiltin(roleId) && (opts == null ? void 0 : opts.defaultPublic)) {
|
|
10798
|
-
return cloneDeep2(BUILTIN_ROLES.PUBLIC);
|
|
10799
|
-
}
|
|
10800
10796
|
if (Object.keys(role).length === 0) {
|
|
10801
10797
|
throw err;
|
|
10802
10798
|
}
|
|
@@ -10844,10 +10840,10 @@ async function getAllRoles(appId) {
|
|
|
10844
10840
|
}
|
|
10845
10841
|
return internal(appDB);
|
|
10846
10842
|
}
|
|
10847
|
-
async function internal(
|
|
10843
|
+
async function internal(db2) {
|
|
10848
10844
|
let roles = [];
|
|
10849
|
-
if (
|
|
10850
|
-
const body2 = await
|
|
10845
|
+
if (db2) {
|
|
10846
|
+
const body2 = await db2.allDocs(
|
|
10851
10847
|
getRoleParams(null, {
|
|
10852
10848
|
include_docs: true
|
|
10853
10849
|
})
|
|
@@ -11283,12 +11279,12 @@ async function syncUser(user, details) {
|
|
|
11283
11279
|
if (details.profile) {
|
|
11284
11280
|
const profile = details.profile;
|
|
11285
11281
|
if (profile.name) {
|
|
11286
|
-
const
|
|
11287
|
-
if (
|
|
11288
|
-
firstName =
|
|
11282
|
+
const name2 = profile.name;
|
|
11283
|
+
if (name2.givenName) {
|
|
11284
|
+
firstName = name2.givenName;
|
|
11289
11285
|
}
|
|
11290
|
-
if (
|
|
11291
|
-
lastName =
|
|
11286
|
+
if (name2.familyName) {
|
|
11287
|
+
lastName = name2.familyName;
|
|
11292
11288
|
}
|
|
11293
11289
|
}
|
|
11294
11290
|
pictureUrl = await getProfilePictureUrl(user, details);
|
|
@@ -11485,8 +11481,8 @@ async function preAuth(passport2, ctx, next) {
|
|
|
11485
11481
|
callbackUrl,
|
|
11486
11482
|
ssoSaveUserNoOp
|
|
11487
11483
|
);
|
|
11488
|
-
if (!ctx.query.appId) {
|
|
11489
|
-
ctx.throw(400, "appId query
|
|
11484
|
+
if (!ctx.query.appId || !ctx.query.datasourceId) {
|
|
11485
|
+
ctx.throw(400, "appId and datasourceId query params not present.");
|
|
11490
11486
|
}
|
|
11491
11487
|
return passport2.authenticate(strategy, {
|
|
11492
11488
|
scope: ["profile", "email", "https://www.googleapis.com/auth/spreadsheets"],
|
|
@@ -11506,7 +11502,7 @@ async function postAuth(passport2, ctx, next) {
|
|
|
11506
11502
|
clientSecret: config.clientSecret,
|
|
11507
11503
|
callbackURL: callbackUrl
|
|
11508
11504
|
},
|
|
11509
|
-
(accessToken, refreshToken,
|
|
11505
|
+
(accessToken, refreshToken, profile, done) => {
|
|
11510
11506
|
clearCookie(ctx, "budibase:datasourceauth" /* DatasourceAuth */);
|
|
11511
11507
|
done(null, { accessToken, refreshToken });
|
|
11512
11508
|
}
|
|
@@ -11514,14 +11510,22 @@ async function postAuth(passport2, ctx, next) {
|
|
|
11514
11510
|
{ successRedirect: "/", failureRedirect: "/error" },
|
|
11515
11511
|
async (err, tokens) => {
|
|
11516
11512
|
const baseUrl = `/builder/app/${authStateCookie.appId}/data`;
|
|
11517
|
-
|
|
11518
|
-
|
|
11519
|
-
|
|
11520
|
-
|
|
11521
|
-
|
|
11513
|
+
await doWithDB(authStateCookie.appId, async (db2) => {
|
|
11514
|
+
let datasource2;
|
|
11515
|
+
try {
|
|
11516
|
+
datasource2 = await db2.get(authStateCookie.datasourceId);
|
|
11517
|
+
} catch (err2) {
|
|
11518
|
+
if (err2.status === 404) {
|
|
11519
|
+
ctx.redirect(baseUrl);
|
|
11520
|
+
}
|
|
11522
11521
|
}
|
|
11523
|
-
|
|
11524
|
-
|
|
11522
|
+
if (!datasource2.config) {
|
|
11523
|
+
datasource2.config = {};
|
|
11524
|
+
}
|
|
11525
|
+
datasource2.config.auth = { type: "google", ...tokens };
|
|
11526
|
+
await db2.put(datasource2);
|
|
11527
|
+
ctx.redirect(`${baseUrl}/datasource/${authStateCookie.datasourceId}`);
|
|
11528
|
+
});
|
|
11525
11529
|
}
|
|
11526
11530
|
)(ctx, next);
|
|
11527
11531
|
}
|
|
@@ -11571,22 +11575,16 @@ var encryption_exports = {};
|
|
|
11571
11575
|
__export(encryption_exports, {
|
|
11572
11576
|
SecretOption: () => SecretOption,
|
|
11573
11577
|
decrypt: () => decrypt,
|
|
11574
|
-
decryptFile: () => decryptFile,
|
|
11575
11578
|
encrypt: () => encrypt,
|
|
11576
|
-
encryptFile: () => encryptFile,
|
|
11577
11579
|
getSecret: () => getSecret
|
|
11578
11580
|
});
|
|
11579
11581
|
var import_crypto = __toESM(require("crypto"));
|
|
11580
|
-
var import_fs2 = __toESM(require("fs"));
|
|
11581
|
-
var import_zlib = __toESM(require("zlib"));
|
|
11582
11582
|
init_environment2();
|
|
11583
|
-
var import_path2 = require("path");
|
|
11584
11583
|
var ALGO = "aes-256-ctr";
|
|
11585
11584
|
var SEPARATOR3 = "-";
|
|
11586
11585
|
var ITERATIONS = 1e4;
|
|
11586
|
+
var RANDOM_BYTES = 16;
|
|
11587
11587
|
var STRETCH_LENGTH = 32;
|
|
11588
|
-
var SALT_LENGTH = 16;
|
|
11589
|
-
var IV_LENGTH = 16;
|
|
11590
11588
|
var SecretOption = /* @__PURE__ */ ((SecretOption2) => {
|
|
11591
11589
|
SecretOption2["API"] = "api";
|
|
11592
11590
|
SecretOption2["ENCRYPTION"] = "encryption";
|
|
@@ -11610,11 +11608,11 @@ function getSecret(secretOption) {
|
|
|
11610
11608
|
}
|
|
11611
11609
|
return secret;
|
|
11612
11610
|
}
|
|
11613
|
-
function stretchString(
|
|
11614
|
-
return import_crypto.default.pbkdf2Sync(
|
|
11611
|
+
function stretchString(string, salt) {
|
|
11612
|
+
return import_crypto.default.pbkdf2Sync(string, salt, ITERATIONS, STRETCH_LENGTH, "sha512");
|
|
11615
11613
|
}
|
|
11616
11614
|
function encrypt(input, secretOption = "api" /* API */) {
|
|
11617
|
-
const salt = import_crypto.default.randomBytes(
|
|
11615
|
+
const salt = import_crypto.default.randomBytes(RANDOM_BYTES);
|
|
11618
11616
|
const stretched = stretchString(getSecret(secretOption), salt);
|
|
11619
11617
|
const cipher = import_crypto.default.createCipheriv(ALGO, stretched, salt);
|
|
11620
11618
|
const base = cipher.update(input);
|
|
@@ -11631,87 +11629,6 @@ function decrypt(input, secretOption = "api" /* API */) {
|
|
|
11631
11629
|
const final = decipher.final();
|
|
11632
11630
|
return Buffer.concat([base, final]).toString();
|
|
11633
11631
|
}
|
|
11634
|
-
async function encryptFile({ dir, filename }, secret) {
|
|
11635
|
-
const outputFileName = `${filename}.enc`;
|
|
11636
|
-
const filePath = (0, import_path2.join)(dir, filename);
|
|
11637
|
-
const inputFile = import_fs2.default.createReadStream(filePath);
|
|
11638
|
-
const outputFile = import_fs2.default.createWriteStream((0, import_path2.join)(dir, outputFileName));
|
|
11639
|
-
const salt = import_crypto.default.randomBytes(SALT_LENGTH);
|
|
11640
|
-
const iv = import_crypto.default.randomBytes(IV_LENGTH);
|
|
11641
|
-
const stretched = stretchString(secret, salt);
|
|
11642
|
-
const cipher = import_crypto.default.createCipheriv(ALGO, stretched, iv);
|
|
11643
|
-
outputFile.write(salt);
|
|
11644
|
-
outputFile.write(iv);
|
|
11645
|
-
inputFile.pipe(import_zlib.default.createGzip()).pipe(cipher).pipe(outputFile);
|
|
11646
|
-
return new Promise((r) => {
|
|
11647
|
-
outputFile.on("finish", () => {
|
|
11648
|
-
r({
|
|
11649
|
-
filename: outputFileName,
|
|
11650
|
-
dir
|
|
11651
|
-
});
|
|
11652
|
-
});
|
|
11653
|
-
});
|
|
11654
|
-
}
|
|
11655
|
-
async function getSaltAndIV(path2) {
|
|
11656
|
-
const fileStream = import_fs2.default.createReadStream(path2);
|
|
11657
|
-
const salt = await readBytes(fileStream, SALT_LENGTH);
|
|
11658
|
-
const iv = await readBytes(fileStream, IV_LENGTH);
|
|
11659
|
-
fileStream.close();
|
|
11660
|
-
return { salt, iv };
|
|
11661
|
-
}
|
|
11662
|
-
async function decryptFile(inputPath, outputPath, secret) {
|
|
11663
|
-
const { salt, iv } = await getSaltAndIV(inputPath);
|
|
11664
|
-
const inputFile = import_fs2.default.createReadStream(inputPath, {
|
|
11665
|
-
start: SALT_LENGTH + IV_LENGTH
|
|
11666
|
-
});
|
|
11667
|
-
const outputFile = import_fs2.default.createWriteStream(outputPath);
|
|
11668
|
-
const stretched = stretchString(secret, salt);
|
|
11669
|
-
const decipher = import_crypto.default.createDecipheriv(ALGO, stretched, iv);
|
|
11670
|
-
const unzip = import_zlib.default.createGunzip();
|
|
11671
|
-
inputFile.pipe(decipher).pipe(unzip).pipe(outputFile);
|
|
11672
|
-
return new Promise((res, rej) => {
|
|
11673
|
-
outputFile.on("finish", () => {
|
|
11674
|
-
outputFile.close();
|
|
11675
|
-
res();
|
|
11676
|
-
});
|
|
11677
|
-
inputFile.on("error", (e) => {
|
|
11678
|
-
outputFile.close();
|
|
11679
|
-
rej(e);
|
|
11680
|
-
});
|
|
11681
|
-
decipher.on("error", (e) => {
|
|
11682
|
-
outputFile.close();
|
|
11683
|
-
rej(e);
|
|
11684
|
-
});
|
|
11685
|
-
unzip.on("error", (e) => {
|
|
11686
|
-
outputFile.close();
|
|
11687
|
-
rej(e);
|
|
11688
|
-
});
|
|
11689
|
-
outputFile.on("error", (e) => {
|
|
11690
|
-
outputFile.close();
|
|
11691
|
-
rej(e);
|
|
11692
|
-
});
|
|
11693
|
-
});
|
|
11694
|
-
}
|
|
11695
|
-
function readBytes(stream3, length) {
|
|
11696
|
-
return new Promise((resolve3, reject) => {
|
|
11697
|
-
let bytesRead = 0;
|
|
11698
|
-
const data = [];
|
|
11699
|
-
stream3.on("readable", () => {
|
|
11700
|
-
let chunk;
|
|
11701
|
-
while ((chunk = stream3.read(length - bytesRead)) !== null) {
|
|
11702
|
-
data.push(chunk);
|
|
11703
|
-
bytesRead += chunk.length;
|
|
11704
|
-
}
|
|
11705
|
-
resolve3(Buffer.concat(data));
|
|
11706
|
-
});
|
|
11707
|
-
stream3.on("end", () => {
|
|
11708
|
-
reject(new Error("Insufficient data in the stream."));
|
|
11709
|
-
});
|
|
11710
|
-
stream3.on("error", (error) => {
|
|
11711
|
-
reject(error);
|
|
11712
|
-
});
|
|
11713
|
-
});
|
|
11714
|
-
}
|
|
11715
11632
|
|
|
11716
11633
|
// ../backend-core/src/middleware/authenticated.ts
|
|
11717
11634
|
init_identity();
|
|
@@ -11803,13 +11720,13 @@ async function checkApiKey(apiKey, populateUser) {
|
|
|
11803
11720
|
return doInTenant(tenantId, async () => {
|
|
11804
11721
|
let userId;
|
|
11805
11722
|
try {
|
|
11806
|
-
const
|
|
11723
|
+
const db2 = getGlobalDB();
|
|
11807
11724
|
userId = await queryGlobalView(
|
|
11808
11725
|
"by_api_key" /* BY_API_KEY */,
|
|
11809
11726
|
{
|
|
11810
11727
|
key: apiKey
|
|
11811
11728
|
},
|
|
11812
|
-
|
|
11729
|
+
db2
|
|
11813
11730
|
);
|
|
11814
11731
|
} catch (err) {
|
|
11815
11732
|
userId = void 0;
|
|
@@ -11830,7 +11747,7 @@ function authenticated_default(noAuthPatterns = [], opts = {
|
|
|
11830
11747
|
const noAuthOptions = noAuthPatterns ? buildMatcherRegex(noAuthPatterns) : [];
|
|
11831
11748
|
return async (ctx, next) => {
|
|
11832
11749
|
let publicEndpoint = false;
|
|
11833
|
-
const
|
|
11750
|
+
const version2 = ctx.request.headers["x-budibase-api-version" /* API_VER */];
|
|
11834
11751
|
const found = matches(ctx, noAuthOptions);
|
|
11835
11752
|
if (found) {
|
|
11836
11753
|
publicEndpoint = true;
|
|
@@ -11893,7 +11810,7 @@ function authenticated_default(noAuthPatterns = [], opts = {
|
|
|
11893
11810
|
if (!authenticated) {
|
|
11894
11811
|
authenticated = false;
|
|
11895
11812
|
}
|
|
11896
|
-
finalise(ctx, { authenticated, user, internal, version, publicEndpoint });
|
|
11813
|
+
finalise(ctx, { authenticated, user, internal, version: version2, publicEndpoint });
|
|
11897
11814
|
if (user && user.email) {
|
|
11898
11815
|
return doInUserContext(user, ctx, next);
|
|
11899
11816
|
} else {
|
|
@@ -11908,7 +11825,7 @@ function authenticated_default(noAuthPatterns = [], opts = {
|
|
|
11908
11825
|
ctx.throw(403, err.message);
|
|
11909
11826
|
}
|
|
11910
11827
|
if (opts && opts.publicAllowed || publicEndpoint) {
|
|
11911
|
-
finalise(ctx, { authenticated: false, version, publicEndpoint });
|
|
11828
|
+
finalise(ctx, { authenticated: false, version: version2, publicEndpoint });
|
|
11912
11829
|
return next();
|
|
11913
11830
|
} else {
|
|
11914
11831
|
ctx.throw(err.status || 403, err);
|
|
@@ -12265,8 +12182,8 @@ async function updateUserOAuth(userId, oAuthConfig) {
|
|
|
12265
12182
|
refreshToken: oAuthConfig.refreshToken
|
|
12266
12183
|
};
|
|
12267
12184
|
try {
|
|
12268
|
-
const
|
|
12269
|
-
const dbUser = await
|
|
12185
|
+
const db2 = getGlobalDB();
|
|
12186
|
+
const dbUser = await db2.get(userId);
|
|
12270
12187
|
if (typeof details.refreshToken !== "string") {
|
|
12271
12188
|
delete details.refreshToken;
|
|
12272
12189
|
}
|
|
@@ -12274,7 +12191,7 @@ async function updateUserOAuth(userId, oAuthConfig) {
|
|
|
12274
12191
|
...dbUser.oauth2,
|
|
12275
12192
|
...details
|
|
12276
12193
|
};
|
|
12277
|
-
await
|
|
12194
|
+
await db2.put(dbUser);
|
|
12278
12195
|
await invalidateUser(userId);
|
|
12279
12196
|
} catch (e) {
|
|
12280
12197
|
console.error("Could not update OAuth details for current user", e);
|
|
@@ -12469,16 +12386,16 @@ var import_aws_sdk = __toESM(require("aws-sdk"));
|
|
|
12469
12386
|
var import_stream = __toESM(require("stream"));
|
|
12470
12387
|
var import_node_fetch6 = __toESM(require("node-fetch"));
|
|
12471
12388
|
var import_tar_fs = __toESM(require("tar-fs"));
|
|
12472
|
-
var
|
|
12389
|
+
var import_zlib = __toESM(require("zlib"));
|
|
12473
12390
|
var import_util = require("util");
|
|
12474
|
-
var
|
|
12475
|
-
var
|
|
12391
|
+
var import_path3 = require("path");
|
|
12392
|
+
var import_fs3 = __toESM(require("fs"));
|
|
12476
12393
|
init_environment2();
|
|
12477
12394
|
|
|
12478
12395
|
// ../backend-core/src/objectStore/utils.ts
|
|
12479
|
-
var
|
|
12396
|
+
var import_path2 = require("path");
|
|
12480
12397
|
var import_os = require("os");
|
|
12481
|
-
var
|
|
12398
|
+
var import_fs2 = __toESM(require("fs"));
|
|
12482
12399
|
init_environment2();
|
|
12483
12400
|
var ObjectStoreBuckets = {
|
|
12484
12401
|
BACKUPS: environment_default2.BACKUPS_BUCKET_NAME,
|
|
@@ -12487,9 +12404,9 @@ var ObjectStoreBuckets = {
|
|
|
12487
12404
|
GLOBAL: environment_default2.GLOBAL_BUCKET_NAME,
|
|
12488
12405
|
PLUGINS: environment_default2.PLUGIN_BUCKET_NAME
|
|
12489
12406
|
};
|
|
12490
|
-
var bbTmp = (0,
|
|
12491
|
-
if (!
|
|
12492
|
-
|
|
12407
|
+
var bbTmp = (0, import_path2.join)((0, import_os.tmpdir)(), ".budibase");
|
|
12408
|
+
if (!import_fs2.default.existsSync(bbTmp)) {
|
|
12409
|
+
import_fs2.default.mkdirSync(bbTmp);
|
|
12493
12410
|
}
|
|
12494
12411
|
function budibaseTempDir() {
|
|
12495
12412
|
return bbTmp;
|
|
@@ -12574,10 +12491,10 @@ var upload = async ({
|
|
|
12574
12491
|
filename,
|
|
12575
12492
|
path: path2,
|
|
12576
12493
|
type,
|
|
12577
|
-
metadata
|
|
12494
|
+
metadata: metadata2
|
|
12578
12495
|
}) => {
|
|
12579
12496
|
const extension = filename.split(".").pop();
|
|
12580
|
-
const fileBytes =
|
|
12497
|
+
const fileBytes = import_fs3.default.readFileSync(path2);
|
|
12581
12498
|
const objectStore = ObjectStore(bucketName);
|
|
12582
12499
|
await makeSureBucketExists(objectStore, bucketName);
|
|
12583
12500
|
let contentType = type;
|
|
@@ -12590,13 +12507,13 @@ var upload = async ({
|
|
|
12590
12507
|
Body: fileBytes,
|
|
12591
12508
|
ContentType: contentType
|
|
12592
12509
|
};
|
|
12593
|
-
if (
|
|
12594
|
-
for (let key of Object.keys(
|
|
12595
|
-
if (!
|
|
12596
|
-
delete
|
|
12510
|
+
if (metadata2 && typeof metadata2 === "object") {
|
|
12511
|
+
for (let key of Object.keys(metadata2)) {
|
|
12512
|
+
if (!metadata2[key] || typeof metadata2[key] !== "string") {
|
|
12513
|
+
delete metadata2[key];
|
|
12597
12514
|
}
|
|
12598
12515
|
}
|
|
12599
|
-
config.Metadata =
|
|
12516
|
+
config.Metadata = metadata2;
|
|
12600
12517
|
}
|
|
12601
12518
|
return objectStore.upload(config).promise();
|
|
12602
12519
|
};
|
|
@@ -12679,13 +12596,13 @@ var retrieveToTmp = async (bucketName, filepath) => {
|
|
|
12679
12596
|
bucketName = sanitizeBucket(bucketName);
|
|
12680
12597
|
filepath = sanitizeKey(filepath);
|
|
12681
12598
|
const data = await retrieve(bucketName, filepath);
|
|
12682
|
-
const outputPath = (0,
|
|
12683
|
-
|
|
12599
|
+
const outputPath = (0, import_path3.join)(budibaseTempDir(), (0, import_uuid3.v4)());
|
|
12600
|
+
import_fs3.default.writeFileSync(outputPath, data);
|
|
12684
12601
|
return outputPath;
|
|
12685
12602
|
};
|
|
12686
12603
|
var retrieveDirectory = async (bucketName, path2) => {
|
|
12687
|
-
let writePath = (0,
|
|
12688
|
-
|
|
12604
|
+
let writePath = (0, import_path3.join)(budibaseTempDir(), (0, import_uuid3.v4)());
|
|
12605
|
+
import_fs3.default.mkdirSync(writePath);
|
|
12689
12606
|
const objects = await listAllObjects(bucketName, path2);
|
|
12690
12607
|
let fullObjects = await Promise.all(
|
|
12691
12608
|
objects.map((obj) => retrieve(bucketName, obj.Key))
|
|
@@ -12697,9 +12614,9 @@ var retrieveDirectory = async (bucketName, path2) => {
|
|
|
12697
12614
|
const possiblePath = filename.split("/");
|
|
12698
12615
|
if (possiblePath.length > 1) {
|
|
12699
12616
|
const dirs = possiblePath.slice(0, possiblePath.length - 1);
|
|
12700
|
-
|
|
12617
|
+
import_fs3.default.mkdirSync((0, import_path3.join)(writePath, ...dirs), { recursive: true });
|
|
12701
12618
|
}
|
|
12702
|
-
|
|
12619
|
+
import_fs3.default.writeFileSync((0, import_path3.join)(writePath, ...possiblePath), data);
|
|
12703
12620
|
}
|
|
12704
12621
|
return writePath;
|
|
12705
12622
|
};
|
|
@@ -12750,21 +12667,21 @@ var deleteFolder = async (bucketName, folder) => {
|
|
|
12750
12667
|
return deleteFolder(bucketName, folder);
|
|
12751
12668
|
}
|
|
12752
12669
|
};
|
|
12753
|
-
var uploadDirectory = async (bucketName, localPath,
|
|
12670
|
+
var uploadDirectory = async (bucketName, localPath, bucketPath2) => {
|
|
12754
12671
|
bucketName = sanitizeBucket(bucketName);
|
|
12755
12672
|
let uploads = [];
|
|
12756
|
-
const
|
|
12757
|
-
for (let file of
|
|
12758
|
-
const path2 = sanitizeKey((0,
|
|
12759
|
-
const local = (0,
|
|
12673
|
+
const files2 = import_fs3.default.readdirSync(localPath, { withFileTypes: true });
|
|
12674
|
+
for (let file of files2) {
|
|
12675
|
+
const path2 = sanitizeKey((0, import_path3.join)(bucketPath2, file.name));
|
|
12676
|
+
const local = (0, import_path3.join)(localPath, file.name);
|
|
12760
12677
|
if (file.isDirectory()) {
|
|
12761
12678
|
uploads.push(uploadDirectory(bucketName, local, path2));
|
|
12762
12679
|
} else {
|
|
12763
|
-
uploads.push(streamUpload(bucketName, path2,
|
|
12680
|
+
uploads.push(streamUpload(bucketName, path2, import_fs3.default.createReadStream(local)));
|
|
12764
12681
|
}
|
|
12765
12682
|
}
|
|
12766
12683
|
await Promise.all(uploads);
|
|
12767
|
-
return
|
|
12684
|
+
return files2;
|
|
12768
12685
|
};
|
|
12769
12686
|
var downloadTarballDirect = async (url, path2, headers = {}) => {
|
|
12770
12687
|
path2 = sanitizeKey(path2);
|
|
@@ -12772,7 +12689,7 @@ var downloadTarballDirect = async (url, path2, headers = {}) => {
|
|
|
12772
12689
|
if (!response.ok) {
|
|
12773
12690
|
throw new Error(`unexpected response ${response.statusText}`);
|
|
12774
12691
|
}
|
|
12775
|
-
await streamPipeline(response.body,
|
|
12692
|
+
await streamPipeline(response.body, import_zlib.default.createUnzip(), import_tar_fs.default.extract(path2));
|
|
12776
12693
|
};
|
|
12777
12694
|
var downloadTarball = async (url, bucketName, path2) => {
|
|
12778
12695
|
bucketName = sanitizeBucket(bucketName);
|
|
@@ -12781,8 +12698,8 @@ var downloadTarball = async (url, bucketName, path2) => {
|
|
|
12781
12698
|
if (!response.ok) {
|
|
12782
12699
|
throw new Error(`unexpected response ${response.statusText}`);
|
|
12783
12700
|
}
|
|
12784
|
-
const tmpPath = (0,
|
|
12785
|
-
await streamPipeline(response.body,
|
|
12701
|
+
const tmpPath = (0, import_path3.join)(budibaseTempDir(), path2);
|
|
12702
|
+
await streamPipeline(response.body, import_zlib.default.createUnzip(), import_tar_fs.default.extract(tmpPath));
|
|
12786
12703
|
if (!environment_default2.isTest() && environment_default2.SELF_HOSTED) {
|
|
12787
12704
|
await uploadDirectory(bucketName, tmpPath, path2);
|
|
12788
12705
|
}
|
|
@@ -12829,12 +12746,12 @@ var getUrl = (s3Key) => {
|
|
|
12829
12746
|
};
|
|
12830
12747
|
|
|
12831
12748
|
// ../backend-core/src/objectStore/buckets/app.ts
|
|
12832
|
-
var clientLibraryUrl = (appId,
|
|
12749
|
+
var clientLibraryUrl = (appId, version2) => {
|
|
12833
12750
|
if (environment_default2.isProd()) {
|
|
12834
12751
|
let file = `${sanitizeKey(appId)}/budibase-client.js`;
|
|
12835
12752
|
if (environment_default2.CLOUDFRONT_CDN) {
|
|
12836
|
-
if (
|
|
12837
|
-
file += `?v=${
|
|
12753
|
+
if (version2) {
|
|
12754
|
+
file += `?v=${version2}`;
|
|
12838
12755
|
}
|
|
12839
12756
|
return getUrl(file);
|
|
12840
12757
|
} else {
|
|
@@ -12855,8 +12772,8 @@ var getAppFileUrl = (s3Key) => {
|
|
|
12855
12772
|
// ../backend-core/src/objectStore/buckets/global.ts
|
|
12856
12773
|
init_environment2();
|
|
12857
12774
|
init_context2();
|
|
12858
|
-
var getGlobalFileUrl = (type,
|
|
12859
|
-
let file = getGlobalFileS3Key(type,
|
|
12775
|
+
var getGlobalFileUrl = (type, name2, etag) => {
|
|
12776
|
+
let file = getGlobalFileS3Key(type, name2);
|
|
12860
12777
|
if (environment_default2.CLOUDFRONT_CDN) {
|
|
12861
12778
|
if (etag) {
|
|
12862
12779
|
file = `${file}?etag=${etag}`;
|
|
@@ -12866,8 +12783,8 @@ var getGlobalFileUrl = (type, name, etag) => {
|
|
|
12866
12783
|
return getPresignedUrl(environment_default2.GLOBAL_BUCKET_NAME, file);
|
|
12867
12784
|
}
|
|
12868
12785
|
};
|
|
12869
|
-
var getGlobalFileS3Key = (type,
|
|
12870
|
-
let file = `${type}/${
|
|
12786
|
+
var getGlobalFileS3Key = (type, name2) => {
|
|
12787
|
+
let file = `${type}/${name2}`;
|
|
12871
12788
|
if (environment_default2.MULTI_TENANCY) {
|
|
12872
12789
|
const tenantId = getTenantId();
|
|
12873
12790
|
file = `${tenantId}/${file}`;
|
|
@@ -12910,11 +12827,11 @@ var getPluginJSKey = (plugin) => {
|
|
|
12910
12827
|
return getPluginS3Key(plugin, "plugin.min.js");
|
|
12911
12828
|
};
|
|
12912
12829
|
var getPluginIconKey = (plugin) => {
|
|
12913
|
-
const
|
|
12914
|
-
if (!
|
|
12830
|
+
const iconFileName2 = plugin.iconUrl ? "icon.svg" : plugin.iconFileName;
|
|
12831
|
+
if (!iconFileName2) {
|
|
12915
12832
|
return;
|
|
12916
12833
|
}
|
|
12917
|
-
return getPluginS3Key(plugin,
|
|
12834
|
+
return getPluginS3Key(plugin, iconFileName2);
|
|
12918
12835
|
};
|
|
12919
12836
|
var getPluginS3Key = (plugin, fileName) => {
|
|
12920
12837
|
const s3Key = getPluginS3Dir(plugin.name);
|
|
@@ -13467,18 +13384,18 @@ function finaliseExternalTables(tables, entities) {
|
|
|
13467
13384
|
let finalTables = {};
|
|
13468
13385
|
const errors = {};
|
|
13469
13386
|
const tableIds = Object.values(tables).map((table) => table._id);
|
|
13470
|
-
for (let [
|
|
13387
|
+
for (let [name2, table] of Object.entries(tables)) {
|
|
13471
13388
|
const schemaFields = Object.keys(table.schema);
|
|
13472
13389
|
if (table.primary == null || table.primary.length === 0) {
|
|
13473
|
-
errors[
|
|
13390
|
+
errors[name2] = "no_key" /* NO_KEY */;
|
|
13474
13391
|
continue;
|
|
13475
13392
|
} else if (schemaFields.find(
|
|
13476
13393
|
(field) => invalidColumns.includes(field)
|
|
13477
13394
|
)) {
|
|
13478
|
-
errors[
|
|
13395
|
+
errors[name2] = "invalid_column" /* INVALID_COLUMN */;
|
|
13479
13396
|
continue;
|
|
13480
13397
|
}
|
|
13481
|
-
finalTables[
|
|
13398
|
+
finalTables[name2] = copyExistingPropsOver(name2, table, entities, tableIds);
|
|
13482
13399
|
}
|
|
13483
13400
|
finalTables = Object.entries(finalTables).sort(([a], [b]) => a.localeCompare(b)).reduce((r, [k, v]) => ({ ...r, [k]: v }), {});
|
|
13484
13401
|
return { tables: finalTables, errors };
|
|
@@ -14438,8 +14355,7 @@ var PostgresIntegration = class extends sql_default {
|
|
|
14438
14355
|
try {
|
|
14439
14356
|
await this.openConnection();
|
|
14440
14357
|
const columnsResponse = await this.client.query(this.COLUMNS_SQL);
|
|
14441
|
-
|
|
14442
|
-
return [...new Set(names)];
|
|
14358
|
+
return columnsResponse.rows.map((row) => row.table_name);
|
|
14443
14359
|
} finally {
|
|
14444
14360
|
await this.closeConnection();
|
|
14445
14361
|
}
|
|
@@ -15052,8 +14968,6 @@ var MongoIntegration = class {
|
|
|
15052
14968
|
response.connected = true;
|
|
15053
14969
|
} catch (e) {
|
|
15054
14970
|
response.error = e.message;
|
|
15055
|
-
} finally {
|
|
15056
|
-
await this.client.close();
|
|
15057
14971
|
}
|
|
15058
14972
|
return response;
|
|
15059
14973
|
}
|
|
@@ -15126,8 +15040,8 @@ var MongoIntegration = class {
|
|
|
15126
15040
|
async create(query) {
|
|
15127
15041
|
try {
|
|
15128
15042
|
await this.connect();
|
|
15129
|
-
const
|
|
15130
|
-
const collection =
|
|
15043
|
+
const db2 = this.client.db(this.config.db);
|
|
15044
|
+
const collection = db2.collection(query.extra.collection);
|
|
15131
15045
|
let json = this.createObjectIds(query.json);
|
|
15132
15046
|
switch (query.extra.actionType) {
|
|
15133
15047
|
case "insertOne": {
|
|
@@ -15152,8 +15066,8 @@ var MongoIntegration = class {
|
|
|
15152
15066
|
async read(query) {
|
|
15153
15067
|
try {
|
|
15154
15068
|
await this.connect();
|
|
15155
|
-
const
|
|
15156
|
-
const collection =
|
|
15069
|
+
const db2 = this.client.db(this.config.db);
|
|
15070
|
+
const collection = db2.collection(query.extra.collection);
|
|
15157
15071
|
let json = this.createObjectIds(query.json);
|
|
15158
15072
|
switch (query.extra.actionType) {
|
|
15159
15073
|
case "find": {
|
|
@@ -15195,8 +15109,8 @@ var MongoIntegration = class {
|
|
|
15195
15109
|
async update(query) {
|
|
15196
15110
|
try {
|
|
15197
15111
|
await this.connect();
|
|
15198
|
-
const
|
|
15199
|
-
const collection =
|
|
15112
|
+
const db2 = this.client.db(this.config.db);
|
|
15113
|
+
const collection = db2.collection(query.extra.collection);
|
|
15200
15114
|
let queryJson = query.json;
|
|
15201
15115
|
if (typeof queryJson === "string") {
|
|
15202
15116
|
queryJson = this.parseQueryParams(queryJson, "update");
|
|
@@ -15233,8 +15147,8 @@ var MongoIntegration = class {
|
|
|
15233
15147
|
async delete(query) {
|
|
15234
15148
|
try {
|
|
15235
15149
|
await this.connect();
|
|
15236
|
-
const
|
|
15237
|
-
const collection =
|
|
15150
|
+
const db2 = this.client.db(this.config.db);
|
|
15151
|
+
const collection = db2.collection(query.extra.collection);
|
|
15238
15152
|
let queryJson = query.json;
|
|
15239
15153
|
if (typeof queryJson === "string") {
|
|
15240
15154
|
queryJson = this.parseQueryParams(queryJson, "delete");
|
|
@@ -15270,25 +15184,25 @@ var MongoIntegration = class {
|
|
|
15270
15184
|
var _a;
|
|
15271
15185
|
try {
|
|
15272
15186
|
await this.connect();
|
|
15273
|
-
const
|
|
15274
|
-
const collection =
|
|
15187
|
+
const db2 = this.client.db(this.config.db);
|
|
15188
|
+
const collection = db2.collection(query.extra.collection);
|
|
15275
15189
|
let response = [];
|
|
15276
15190
|
if (((_a = query.extra) == null ? void 0 : _a.actionType) === "pipeline") {
|
|
15277
|
-
for await (const
|
|
15191
|
+
for await (const doc2 of collection.aggregate(
|
|
15278
15192
|
query.steps.map(({ key, value }) => {
|
|
15279
15193
|
let temp = {};
|
|
15280
15194
|
temp[key] = JSON.parse(value.value);
|
|
15281
15195
|
return this.createObjectIds(temp);
|
|
15282
15196
|
})
|
|
15283
15197
|
)) {
|
|
15284
|
-
response.push(
|
|
15198
|
+
response.push(doc2);
|
|
15285
15199
|
}
|
|
15286
15200
|
} else {
|
|
15287
15201
|
const stages = query.json;
|
|
15288
|
-
for await (const
|
|
15202
|
+
for await (const doc2 of collection.aggregate(
|
|
15289
15203
|
stages ? this.createObjectIds(stages) : []
|
|
15290
15204
|
)) {
|
|
15291
|
-
response.push(
|
|
15205
|
+
response.push(doc2);
|
|
15292
15206
|
}
|
|
15293
15207
|
}
|
|
15294
15208
|
return response;
|
|
@@ -15588,9 +15502,9 @@ var CouchDBIntegration = class {
|
|
|
15588
15502
|
});
|
|
15589
15503
|
}
|
|
15590
15504
|
async delete(query) {
|
|
15591
|
-
const
|
|
15505
|
+
const doc2 = await this.query("get", "Cannot find doc to be deleted", query);
|
|
15592
15506
|
return this.query("remove", "Error deleting couchDB document", {
|
|
15593
|
-
json:
|
|
15507
|
+
json: doc2
|
|
15594
15508
|
});
|
|
15595
15509
|
}
|
|
15596
15510
|
};
|
|
@@ -15769,7 +15683,7 @@ var SqlServerIntegration = class extends sql_default {
|
|
|
15769
15683
|
throw "Unable to get list of tables in database";
|
|
15770
15684
|
}
|
|
15771
15685
|
const schema = this.config.schema || DEFAULT_SCHEMA;
|
|
15772
|
-
const tableNames = tableInfo.filter((record) => record.TABLE_SCHEMA === schema).map((record) => record.TABLE_NAME).filter((
|
|
15686
|
+
const tableNames = tableInfo.filter((record) => record.TABLE_SCHEMA === schema).map((record) => record.TABLE_NAME).filter((name2) => this.MASTER_TABLES.indexOf(name2) === -1);
|
|
15773
15687
|
const tables = {};
|
|
15774
15688
|
for (let tableName of tableNames) {
|
|
15775
15689
|
const definition = await this.runSQL(this.getDefinitionSQL(tableName));
|
|
@@ -15784,16 +15698,16 @@ var SqlServerIntegration = class extends sql_default {
|
|
|
15784
15698
|
const requiredColumns = columns.filter((col) => col.IS_NULLABLE === "NO").map((col) => col.COLUMN_NAME);
|
|
15785
15699
|
let schema2 = {};
|
|
15786
15700
|
for (let def of definition) {
|
|
15787
|
-
const
|
|
15788
|
-
if (typeof
|
|
15701
|
+
const name2 = def.COLUMN_NAME;
|
|
15702
|
+
if (typeof name2 !== "string") {
|
|
15789
15703
|
continue;
|
|
15790
15704
|
}
|
|
15791
15705
|
const hasDefault = def.COLUMN_DEFAULT;
|
|
15792
|
-
const isAuto = !!autoColumns.find((col) => col ===
|
|
15793
|
-
const required = !!requiredColumns.find((col) => col ===
|
|
15794
|
-
schema2[
|
|
15706
|
+
const isAuto = !!autoColumns.find((col) => col === name2);
|
|
15707
|
+
const required = !!requiredColumns.find((col) => col === name2);
|
|
15708
|
+
schema2[name2] = {
|
|
15795
15709
|
autocolumn: isAuto,
|
|
15796
|
-
name,
|
|
15710
|
+
name: name2,
|
|
15797
15711
|
constraints: {
|
|
15798
15712
|
presence: required && !isAuto && !hasDefault
|
|
15799
15713
|
},
|
|
@@ -15815,7 +15729,7 @@ var SqlServerIntegration = class extends sql_default {
|
|
|
15815
15729
|
async queryTableNames() {
|
|
15816
15730
|
let tableInfo = await this.runSQL(this.TABLES_SQL);
|
|
15817
15731
|
const schema = this.config.schema || DEFAULT_SCHEMA;
|
|
15818
|
-
return tableInfo.filter((record) => record.TABLE_SCHEMA === schema).map((record) => record.TABLE_NAME).filter((
|
|
15732
|
+
return tableInfo.filter((record) => record.TABLE_SCHEMA === schema).map((record) => record.TABLE_NAME).filter((name2) => this.MASTER_TABLES.indexOf(name2) === -1);
|
|
15819
15733
|
}
|
|
15820
15734
|
async getTableNames() {
|
|
15821
15735
|
await this.connect();
|
|
@@ -16300,7 +16214,12 @@ function bindingTypeCoerce(bindings) {
|
|
|
16300
16214
|
if (matches2 && matches2[0] !== "" && !isNaN(Number(matches2[0]))) {
|
|
16301
16215
|
bindings[i] = parseFloat(binding);
|
|
16302
16216
|
} else if (/^\d/.test(binding) && (0, import_dayjs.default)(binding).isValid() && !binding.includes(",")) {
|
|
16303
|
-
|
|
16217
|
+
let value;
|
|
16218
|
+
value = new Date(binding);
|
|
16219
|
+
if (isNaN(value)) {
|
|
16220
|
+
value = binding;
|
|
16221
|
+
}
|
|
16222
|
+
bindings[i] = value;
|
|
16304
16223
|
}
|
|
16305
16224
|
}
|
|
16306
16225
|
return bindings;
|
|
@@ -17205,11 +17124,11 @@ var runLuceneQuery = (docs, query) => {
|
|
|
17205
17124
|
return docs;
|
|
17206
17125
|
}
|
|
17207
17126
|
query = cleanupQuery(query);
|
|
17208
|
-
const match = (type, failFn) => (
|
|
17127
|
+
const match = (type, failFn) => (doc2) => {
|
|
17209
17128
|
const filters = Object.entries(query[type] || {});
|
|
17210
17129
|
for (let i = 0; i < filters.length; i++) {
|
|
17211
17130
|
const [key, testValue] = filters[i];
|
|
17212
|
-
const docValue = deepGet(
|
|
17131
|
+
const docValue = deepGet(doc2, removeKeyNumbering2(key));
|
|
17213
17132
|
if (failFn(docValue, testValue)) {
|
|
17214
17133
|
return false;
|
|
17215
17134
|
}
|
|
@@ -17270,8 +17189,8 @@ var runLuceneQuery = (docs, query) => {
|
|
|
17270
17189
|
return testValue == null ? void 0 : testValue.every((item) => docValue == null ? void 0 : docValue.includes(item));
|
|
17271
17190
|
}
|
|
17272
17191
|
);
|
|
17273
|
-
const docMatch = (
|
|
17274
|
-
return stringMatch(
|
|
17192
|
+
const docMatch = (doc2) => {
|
|
17193
|
+
return stringMatch(doc2) && fuzzyMatch(doc2) && rangeMatch(doc2) && equalMatch(doc2) && notEqualMatch(doc2) && emptyMatch(doc2) && notEmptyMatch(doc2) && oneOf(doc2) && contains(doc2) && containsAny(doc2) && notContains(doc2);
|
|
17275
17194
|
};
|
|
17276
17195
|
return docs.filter(docMatch);
|
|
17277
17196
|
};
|
|
@@ -17316,39 +17235,11 @@ var hasFilters = (query) => {
|
|
|
17316
17235
|
// ../shared-core/src/utils.ts
|
|
17317
17236
|
var utils_exports3 = {};
|
|
17318
17237
|
__export(utils_exports3, {
|
|
17319
|
-
parallelForeach: () => parallelForeach,
|
|
17320
17238
|
unreachable: () => unreachable
|
|
17321
17239
|
});
|
|
17322
17240
|
function unreachable(value, message = `No such case in exhaustive switch: ${value}`) {
|
|
17323
17241
|
throw new Error(message);
|
|
17324
17242
|
}
|
|
17325
|
-
async function parallelForeach(items, task, maxConcurrency) {
|
|
17326
|
-
const promises = [];
|
|
17327
|
-
let index2 = 0;
|
|
17328
|
-
const processItem = async (item) => {
|
|
17329
|
-
try {
|
|
17330
|
-
await task(item);
|
|
17331
|
-
} finally {
|
|
17332
|
-
processNext();
|
|
17333
|
-
}
|
|
17334
|
-
};
|
|
17335
|
-
const processNext = () => {
|
|
17336
|
-
if (index2 >= items.length) {
|
|
17337
|
-
return;
|
|
17338
|
-
}
|
|
17339
|
-
const item = items[index2];
|
|
17340
|
-
index2++;
|
|
17341
|
-
const promise = processItem(item);
|
|
17342
|
-
promises.push(promise);
|
|
17343
|
-
if (promises.length >= maxConcurrency) {
|
|
17344
|
-
Promise.race(promises).then(processNext);
|
|
17345
|
-
} else {
|
|
17346
|
-
processNext();
|
|
17347
|
-
}
|
|
17348
|
-
};
|
|
17349
|
-
processNext();
|
|
17350
|
-
await Promise.all(promises);
|
|
17351
|
-
}
|
|
17352
17243
|
|
|
17353
17244
|
// src/integrations/googlesheets.ts
|
|
17354
17245
|
var ALLOWED_TYPES = [
|
|
@@ -17377,7 +17268,7 @@ var SCHEMA12 = {
|
|
|
17377
17268
|
},
|
|
17378
17269
|
datasource: {
|
|
17379
17270
|
spreadsheetId: {
|
|
17380
|
-
display: "
|
|
17271
|
+
display: "Google Sheet URL",
|
|
17381
17272
|
type: "string" /* STRING */,
|
|
17382
17273
|
required: true
|
|
17383
17274
|
}
|
|
@@ -17498,7 +17389,6 @@ var GoogleSheetsIntegration = class {
|
|
|
17498
17389
|
async connect() {
|
|
17499
17390
|
var _a;
|
|
17500
17391
|
try {
|
|
17501
|
-
await setupCreationAuth(this.config);
|
|
17502
17392
|
let googleConfig = await configs_exports.getGoogleDatasourceConfig();
|
|
17503
17393
|
if (!googleConfig) {
|
|
17504
17394
|
throw new HTTPError("Google config not found", 400);
|
|
@@ -17549,22 +17439,21 @@ var GoogleSheetsIntegration = class {
|
|
|
17549
17439
|
return table;
|
|
17550
17440
|
}
|
|
17551
17441
|
async buildSchema(datasourceId, entities) {
|
|
17442
|
+
if (!this.config.auth) {
|
|
17443
|
+
return;
|
|
17444
|
+
}
|
|
17552
17445
|
await this.connect();
|
|
17553
17446
|
const sheets = this.client.sheetsByIndex;
|
|
17554
17447
|
const tables = {};
|
|
17555
|
-
|
|
17556
|
-
|
|
17557
|
-
|
|
17558
|
-
|
|
17559
|
-
|
|
17560
|
-
|
|
17561
|
-
|
|
17562
|
-
|
|
17563
|
-
|
|
17564
|
-
);
|
|
17565
|
-
},
|
|
17566
|
-
10
|
|
17567
|
-
);
|
|
17448
|
+
for (let sheet of sheets) {
|
|
17449
|
+
await sheet.getRows();
|
|
17450
|
+
const id = buildExternalTableId(datasourceId, sheet.title);
|
|
17451
|
+
tables[sheet.title] = this.getTableSchema(
|
|
17452
|
+
sheet.title,
|
|
17453
|
+
sheet.headerValues,
|
|
17454
|
+
id
|
|
17455
|
+
);
|
|
17456
|
+
}
|
|
17568
17457
|
const final = finaliseExternalTables(tables, entities);
|
|
17569
17458
|
this.tables = final.tables;
|
|
17570
17459
|
this.schemaErrors = final.errors;
|
|
@@ -17612,13 +17501,13 @@ var GoogleSheetsIntegration = class {
|
|
|
17612
17501
|
}
|
|
17613
17502
|
return rowObject;
|
|
17614
17503
|
}
|
|
17615
|
-
async createTable(
|
|
17616
|
-
if (!
|
|
17504
|
+
async createTable(name2) {
|
|
17505
|
+
if (!name2) {
|
|
17617
17506
|
throw new Error("Must provide name for new sheet.");
|
|
17618
17507
|
}
|
|
17619
17508
|
try {
|
|
17620
17509
|
await this.connect();
|
|
17621
|
-
return await this.client.addSheet({ title:
|
|
17510
|
+
return await this.client.addSheet({ title: name2, headerValues: [name2] });
|
|
17622
17511
|
} catch (err) {
|
|
17623
17512
|
console.error("Error creating new table in google sheets", err);
|
|
17624
17513
|
throw err;
|
|
@@ -17810,16 +17699,6 @@ var GoogleSheetsIntegration = class {
|
|
|
17810
17699
|
}
|
|
17811
17700
|
}
|
|
17812
17701
|
};
|
|
17813
|
-
async function setupCreationAuth(datasouce) {
|
|
17814
|
-
if (datasouce.continueSetupId) {
|
|
17815
|
-
const appId = context_exports.getAppId();
|
|
17816
|
-
const tokens = await cache_exports.get(
|
|
17817
|
-
`datasource:creation:${appId}:google:${datasouce.continueSetupId}`
|
|
17818
|
-
);
|
|
17819
|
-
datasouce.auth = tokens.tokens;
|
|
17820
|
-
delete datasouce.continueSetupId;
|
|
17821
|
-
}
|
|
17822
|
-
}
|
|
17823
17702
|
var googlesheets_default = {
|
|
17824
17703
|
schema: SCHEMA12,
|
|
17825
17704
|
integration: GoogleSheetsIntegration
|
|
@@ -17949,7 +17828,7 @@ var FirebaseIntegration = class {
|
|
|
17949
17828
|
snapshot = await collectionRef.get();
|
|
17950
17829
|
}
|
|
17951
17830
|
const result = [];
|
|
17952
|
-
snapshot.forEach((
|
|
17831
|
+
snapshot.forEach((doc2) => result.push(doc2.data()));
|
|
17953
17832
|
return result;
|
|
17954
17833
|
} catch (err) {
|
|
17955
17834
|
console.error("Error querying Firestore", err);
|
|
@@ -18598,24 +18477,24 @@ init_src();
|
|
|
18598
18477
|
var budibaseTempDir2 = objectStore_exports2.budibaseTempDir;
|
|
18599
18478
|
|
|
18600
18479
|
// src/utilities/fileSystem/app.ts
|
|
18601
|
-
var
|
|
18480
|
+
var import_path5 = require("path");
|
|
18602
18481
|
|
|
18603
18482
|
// src/utilities/fileSystem/filesystem.ts
|
|
18604
|
-
var
|
|
18605
|
-
var
|
|
18483
|
+
var import_fs4 = __toESM(require("fs"));
|
|
18484
|
+
var import_path4 = require("path");
|
|
18606
18485
|
var import_tar = __toESM(require("tar"));
|
|
18607
18486
|
var uuid2 = require("uuid/v4");
|
|
18608
|
-
var TOP_LEVEL_PATH = environment_default.TOP_LEVEL_PATH || (0,
|
|
18487
|
+
var TOP_LEVEL_PATH = environment_default.TOP_LEVEL_PATH || (0, import_path4.resolve)((0, import_path4.join)(__dirname, "..", "..", ".."));
|
|
18609
18488
|
var streamFile = (path2) => {
|
|
18610
|
-
return
|
|
18489
|
+
return import_fs4.default.createReadStream(path2);
|
|
18611
18490
|
};
|
|
18612
18491
|
var createTempFolder = (item) => {
|
|
18613
|
-
const path2 = (0,
|
|
18492
|
+
const path2 = (0, import_path4.join)(budibaseTempDir2(), item);
|
|
18614
18493
|
try {
|
|
18615
|
-
if (
|
|
18616
|
-
|
|
18494
|
+
if (import_fs4.default.existsSync(path2)) {
|
|
18495
|
+
import_fs4.default.rmSync(path2, { recursive: true, force: true });
|
|
18617
18496
|
}
|
|
18618
|
-
|
|
18497
|
+
import_fs4.default.mkdirSync(path2);
|
|
18619
18498
|
} catch (err) {
|
|
18620
18499
|
throw new Error(`Path cannot be created: ${err.message}`);
|
|
18621
18500
|
}
|
|
@@ -18629,21 +18508,21 @@ var extractTarball = async (fromFilePath, toPath) => {
|
|
|
18629
18508
|
};
|
|
18630
18509
|
|
|
18631
18510
|
// src/utilities/fileSystem/app.ts
|
|
18632
|
-
var NODE_MODULES_PATH = (0,
|
|
18511
|
+
var NODE_MODULES_PATH = (0, import_path5.join)(TOP_LEVEL_PATH, "node_modules");
|
|
18633
18512
|
|
|
18634
18513
|
// src/utilities/fileSystem/plugin.ts
|
|
18635
|
-
var
|
|
18636
|
-
var
|
|
18637
|
-
var DATASOURCE_PATH = (0,
|
|
18638
|
-
var AUTOMATION_PATH = (0,
|
|
18514
|
+
var import_fs5 = __toESM(require("fs"));
|
|
18515
|
+
var import_path6 = require("path");
|
|
18516
|
+
var DATASOURCE_PATH = (0, import_path6.join)(budibaseTempDir2(), "datasource");
|
|
18517
|
+
var AUTOMATION_PATH = (0, import_path6.join)(budibaseTempDir2(), "automation");
|
|
18639
18518
|
var getPluginMetadata = async (path2) => {
|
|
18640
|
-
let
|
|
18519
|
+
let metadata2 = {};
|
|
18641
18520
|
try {
|
|
18642
|
-
const pkg2 =
|
|
18643
|
-
const schema =
|
|
18644
|
-
|
|
18645
|
-
|
|
18646
|
-
if (!
|
|
18521
|
+
const pkg2 = import_fs5.default.readFileSync((0, import_path6.join)(path2, "package.json"), "utf8");
|
|
18522
|
+
const schema = import_fs5.default.readFileSync((0, import_path6.join)(path2, "schema.json"), "utf8");
|
|
18523
|
+
metadata2.schema = JSON.parse(schema);
|
|
18524
|
+
metadata2.package = JSON.parse(pkg2);
|
|
18525
|
+
if (!metadata2.package.name || !metadata2.package.version || !metadata2.package.description) {
|
|
18647
18526
|
throw new Error(
|
|
18648
18527
|
"package.json is missing one of 'name', 'version' or 'description'."
|
|
18649
18528
|
);
|
|
@@ -18653,24 +18532,24 @@ var getPluginMetadata = async (path2) => {
|
|
|
18653
18532
|
`Unable to process schema.json/package.json in plugin. ${err.message}`
|
|
18654
18533
|
);
|
|
18655
18534
|
}
|
|
18656
|
-
return { metadata, directory: path2 };
|
|
18535
|
+
return { metadata: metadata2, directory: path2 };
|
|
18657
18536
|
};
|
|
18658
18537
|
async function getPluginImpl(path2, plugin) {
|
|
18659
18538
|
var _a;
|
|
18660
|
-
const
|
|
18661
|
-
if (!
|
|
18662
|
-
|
|
18539
|
+
const hash3 = (_a = plugin.schema) == null ? void 0 : _a.hash;
|
|
18540
|
+
if (!import_fs5.default.existsSync(path2)) {
|
|
18541
|
+
import_fs5.default.mkdirSync(path2);
|
|
18663
18542
|
}
|
|
18664
|
-
const filename = (0,
|
|
18543
|
+
const filename = (0, import_path6.join)(path2, plugin.name);
|
|
18665
18544
|
const metadataName = `${filename}.bbmetadata`;
|
|
18666
|
-
if (
|
|
18667
|
-
const currentHash =
|
|
18668
|
-
if (currentHash ===
|
|
18545
|
+
if (import_fs5.default.existsSync(filename)) {
|
|
18546
|
+
const currentHash = import_fs5.default.readFileSync(metadataName, "utf8");
|
|
18547
|
+
if (currentHash === hash3) {
|
|
18669
18548
|
return require(filename);
|
|
18670
18549
|
} else {
|
|
18671
18550
|
console.log(`Updating plugin: ${plugin.name}`);
|
|
18672
18551
|
delete require.cache[require.resolve(filename)];
|
|
18673
|
-
|
|
18552
|
+
import_fs5.default.unlinkSync(filename);
|
|
18674
18553
|
}
|
|
18675
18554
|
}
|
|
18676
18555
|
const pluginKey = objectStore_exports2.getPluginJSKey(plugin);
|
|
@@ -18678,8 +18557,8 @@ async function getPluginImpl(path2, plugin) {
|
|
|
18678
18557
|
objectStore_exports2.ObjectStoreBuckets.PLUGINS,
|
|
18679
18558
|
pluginKey
|
|
18680
18559
|
);
|
|
18681
|
-
|
|
18682
|
-
|
|
18560
|
+
import_fs5.default.writeFileSync(filename, pluginJs);
|
|
18561
|
+
import_fs5.default.writeFileSync(metadataName, hash3);
|
|
18683
18562
|
return require(filename);
|
|
18684
18563
|
}
|
|
18685
18564
|
var getDatasourcePlugin = async (plugin) => {
|
|
@@ -18687,9 +18566,9 @@ var getDatasourcePlugin = async (plugin) => {
|
|
|
18687
18566
|
};
|
|
18688
18567
|
|
|
18689
18568
|
// src/utilities/fileSystem/template.ts
|
|
18690
|
-
var downloadTemplate = async (type,
|
|
18569
|
+
var downloadTemplate = async (type, name2) => {
|
|
18691
18570
|
const DEFAULT_TEMPLATES_BUCKET = "prod-budi-templates.s3-eu-west-1.amazonaws.com";
|
|
18692
|
-
const templateUrl = `https://${DEFAULT_TEMPLATES_BUCKET}/templates/${type}/${
|
|
18571
|
+
const templateUrl = `https://${DEFAULT_TEMPLATES_BUCKET}/templates/${type}/${name2}.tar.gz`;
|
|
18693
18572
|
return objectStore_exports2.downloadTarball(
|
|
18694
18573
|
templateUrl,
|
|
18695
18574
|
ObjectStoreBuckets2.TEMPLATES,
|
|
@@ -18714,23 +18593,22 @@ var GLOBAL_DB_EXPORT_FILE = "global.txt";
|
|
|
18714
18593
|
var STATIC_APP_FILES = ["manifest.json", "budibase-client.js"];
|
|
18715
18594
|
|
|
18716
18595
|
// src/sdk/app/backups/exports.ts
|
|
18717
|
-
var
|
|
18718
|
-
var
|
|
18719
|
-
var import_tar2 = __toESM(require("tar"));
|
|
18596
|
+
var import_fs6 = __toESM(require("fs"));
|
|
18597
|
+
var import_path7 = require("path");
|
|
18720
18598
|
var uuid3 = require("uuid/v4");
|
|
18599
|
+
var tar3 = require("tar");
|
|
18721
18600
|
var MemoryStream = require("memorystream");
|
|
18722
|
-
function tarFilesToTmp(tmpDir,
|
|
18723
|
-
const
|
|
18724
|
-
|
|
18725
|
-
import_tar2.default.create(
|
|
18601
|
+
function tarFilesToTmp(tmpDir, files2) {
|
|
18602
|
+
const exportFile = (0, import_path7.join)(budibaseTempDir2(), `${uuid3()}.tar.gz`);
|
|
18603
|
+
tar3.create(
|
|
18726
18604
|
{
|
|
18727
18605
|
sync: true,
|
|
18728
18606
|
gzip: true,
|
|
18729
18607
|
file: exportFile,
|
|
18730
|
-
|
|
18608
|
+
recursive: true,
|
|
18731
18609
|
cwd: tmpDir
|
|
18732
18610
|
},
|
|
18733
|
-
|
|
18611
|
+
files2
|
|
18734
18612
|
);
|
|
18735
18613
|
return exportFile;
|
|
18736
18614
|
}
|
|
@@ -18741,11 +18619,11 @@ async function exportDB(dbName, opts = {}) {
|
|
|
18741
18619
|
batch_limit: 5,
|
|
18742
18620
|
style: "main_only"
|
|
18743
18621
|
};
|
|
18744
|
-
return db_exports.doWithDB(dbName, async (
|
|
18622
|
+
return db_exports.doWithDB(dbName, async (db2) => {
|
|
18745
18623
|
if (opts == null ? void 0 : opts.exportPath) {
|
|
18746
18624
|
const path2 = opts == null ? void 0 : opts.exportPath;
|
|
18747
|
-
const writeStream =
|
|
18748
|
-
await
|
|
18625
|
+
const writeStream = import_fs6.default.createWriteStream(path2);
|
|
18626
|
+
await db2.dump(writeStream, exportOpts);
|
|
18749
18627
|
return path2;
|
|
18750
18628
|
} else {
|
|
18751
18629
|
const memStream = new MemoryStream();
|
|
@@ -18753,7 +18631,7 @@ async function exportDB(dbName, opts = {}) {
|
|
|
18753
18631
|
memStream.on("data", (chunk) => {
|
|
18754
18632
|
appString += chunk.toString();
|
|
18755
18633
|
});
|
|
18756
|
-
await
|
|
18634
|
+
await db2.dump(memStream, exportOpts);
|
|
18757
18635
|
return appString;
|
|
18758
18636
|
}
|
|
18759
18637
|
});
|
|
@@ -18766,7 +18644,7 @@ function defineFilter(excludeRows, excludeLogs) {
|
|
|
18766
18644
|
if (excludeLogs) {
|
|
18767
18645
|
ids.push(AUTOMATION_LOG_PREFIX);
|
|
18768
18646
|
}
|
|
18769
|
-
return (
|
|
18647
|
+
return (doc2) => !ids.map((key) => doc2._id.includes(key)).reduce((prev, curr) => prev || curr);
|
|
18770
18648
|
}
|
|
18771
18649
|
async function exportApp(appId, config) {
|
|
18772
18650
|
const prodAppId = db_exports.getProdAppID(appId);
|
|
@@ -18777,9 +18655,9 @@ async function exportApp(appId, config) {
|
|
|
18777
18655
|
for (let path2 of STATIC_APP_FILES) {
|
|
18778
18656
|
const contents = await objectStore_exports2.retrieve(
|
|
18779
18657
|
ObjectStoreBuckets2.APPS,
|
|
18780
|
-
(0,
|
|
18658
|
+
(0, import_path7.join)(appPath, path2)
|
|
18781
18659
|
);
|
|
18782
|
-
|
|
18660
|
+
import_fs6.default.writeFileSync((0, import_path7.join)(tmpPath, path2), contents);
|
|
18783
18661
|
}
|
|
18784
18662
|
} else {
|
|
18785
18663
|
tmpPath = await objectStore_exports2.retrieveDirectory(
|
|
@@ -18788,48 +18666,33 @@ async function exportApp(appId, config) {
|
|
|
18788
18666
|
);
|
|
18789
18667
|
}
|
|
18790
18668
|
}
|
|
18791
|
-
const downloadedPath = (0,
|
|
18792
|
-
if (
|
|
18793
|
-
const allFiles =
|
|
18669
|
+
const downloadedPath = (0, import_path7.join)(tmpPath, appPath);
|
|
18670
|
+
if (import_fs6.default.existsSync(downloadedPath)) {
|
|
18671
|
+
const allFiles = import_fs6.default.readdirSync(downloadedPath);
|
|
18794
18672
|
for (let file of allFiles) {
|
|
18795
|
-
const path2 = (0,
|
|
18796
|
-
|
|
18673
|
+
const path2 = (0, import_path7.join)(downloadedPath, file);
|
|
18674
|
+
import_fs6.default.renameSync(path2, (0, import_path7.join)(downloadedPath, "..", file));
|
|
18797
18675
|
}
|
|
18798
|
-
|
|
18676
|
+
import_fs6.default.rmdirSync(downloadedPath);
|
|
18799
18677
|
}
|
|
18800
|
-
const dbPath = (0,
|
|
18678
|
+
const dbPath = (0, import_path7.join)(tmpPath, DB_EXPORT_FILE);
|
|
18801
18679
|
await exportDB(appId, {
|
|
18802
18680
|
filter: defineFilter(config == null ? void 0 : config.excludeRows, config == null ? void 0 : config.excludeLogs),
|
|
18803
18681
|
exportPath: dbPath
|
|
18804
18682
|
});
|
|
18805
|
-
if (config == null ? void 0 : config.encryptPassword) {
|
|
18806
|
-
for (let file of import_fs7.default.readdirSync(tmpPath)) {
|
|
18807
|
-
const path2 = (0, import_path8.join)(tmpPath, file);
|
|
18808
|
-
await encryption_exports.encryptFile(
|
|
18809
|
-
{ dir: tmpPath, filename: file },
|
|
18810
|
-
config.encryptPassword
|
|
18811
|
-
);
|
|
18812
|
-
import_fs7.default.rmSync(path2);
|
|
18813
|
-
}
|
|
18814
|
-
}
|
|
18815
18683
|
if (config == null ? void 0 : config.tar) {
|
|
18816
|
-
const tarPath = tarFilesToTmp(tmpPath,
|
|
18817
|
-
|
|
18684
|
+
const tarPath = tarFilesToTmp(tmpPath, import_fs6.default.readdirSync(tmpPath));
|
|
18685
|
+
import_fs6.default.rmSync(tmpPath, { recursive: true, force: true });
|
|
18818
18686
|
return tarPath;
|
|
18819
18687
|
} else {
|
|
18820
18688
|
return tmpPath;
|
|
18821
18689
|
}
|
|
18822
18690
|
}
|
|
18823
|
-
async function streamExportApp({
|
|
18824
|
-
appId,
|
|
18825
|
-
excludeRows,
|
|
18826
|
-
encryptPassword
|
|
18827
|
-
}) {
|
|
18691
|
+
async function streamExportApp(appId, excludeRows) {
|
|
18828
18692
|
const tmpPath = await exportApp(appId, {
|
|
18829
18693
|
excludeRows,
|
|
18830
18694
|
excludeLogs: true,
|
|
18831
|
-
tar: true
|
|
18832
|
-
encryptPassword
|
|
18695
|
+
tar: true
|
|
18833
18696
|
});
|
|
18834
18697
|
return streamFile(tmpPath);
|
|
18835
18698
|
}
|
|
@@ -18843,8 +18706,8 @@ __export(imports_exports, {
|
|
|
18843
18706
|
untarFile: () => untarFile,
|
|
18844
18707
|
updateAttachmentColumns: () => updateAttachmentColumns
|
|
18845
18708
|
});
|
|
18846
|
-
var
|
|
18847
|
-
var
|
|
18709
|
+
var import_path8 = require("path");
|
|
18710
|
+
var import_fs7 = __toESM(require("fs"));
|
|
18848
18711
|
init_src();
|
|
18849
18712
|
var uuid4 = require("uuid/v4");
|
|
18850
18713
|
var tar4 = require("tar");
|
|
@@ -18860,12 +18723,12 @@ function rewriteAttachmentUrl(appId, attachment) {
|
|
|
18860
18723
|
// calculated on retrieval using key
|
|
18861
18724
|
};
|
|
18862
18725
|
}
|
|
18863
|
-
async function updateAttachmentColumns(prodAppId,
|
|
18864
|
-
const tables = await sdk_default.tables.getAllInternalTables(
|
|
18726
|
+
async function updateAttachmentColumns(prodAppId, db2) {
|
|
18727
|
+
const tables = await sdk_default.tables.getAllInternalTables(db2);
|
|
18865
18728
|
let updatedRows = [];
|
|
18866
18729
|
for (let table of tables) {
|
|
18867
18730
|
const { rows: rows2, columns } = await sdk_default.rows.getRowsWithAttachments(
|
|
18868
|
-
|
|
18731
|
+
db2.name,
|
|
18869
18732
|
table
|
|
18870
18733
|
);
|
|
18871
18734
|
updatedRows = updatedRows.concat(
|
|
@@ -18881,11 +18744,11 @@ async function updateAttachmentColumns(prodAppId, db) {
|
|
|
18881
18744
|
})
|
|
18882
18745
|
);
|
|
18883
18746
|
}
|
|
18884
|
-
await
|
|
18747
|
+
await db2.bulkDocs(updatedRows);
|
|
18885
18748
|
}
|
|
18886
|
-
async function updateAutomations(prodAppId,
|
|
18749
|
+
async function updateAutomations(prodAppId, db2) {
|
|
18887
18750
|
var _a;
|
|
18888
|
-
const automations2 = (await
|
|
18751
|
+
const automations2 = (await db2.allDocs(
|
|
18889
18752
|
getAutomationParams(null, {
|
|
18890
18753
|
include_docs: true
|
|
18891
18754
|
})
|
|
@@ -18904,23 +18767,23 @@ async function updateAutomations(prodAppId, db) {
|
|
|
18904
18767
|
automation.appId = devAppId;
|
|
18905
18768
|
toSave.push(automation);
|
|
18906
18769
|
}
|
|
18907
|
-
await
|
|
18770
|
+
await db2.bulkDocs(toSave);
|
|
18908
18771
|
}
|
|
18909
18772
|
async function getTemplateStream(template) {
|
|
18910
18773
|
if (template.file && template.file.type !== "text/plain") {
|
|
18911
18774
|
throw new Error("Cannot import a non-text based file.");
|
|
18912
18775
|
}
|
|
18913
18776
|
if (template.file) {
|
|
18914
|
-
return
|
|
18777
|
+
return import_fs7.default.createReadStream(template.file.path);
|
|
18915
18778
|
} else if (template.key) {
|
|
18916
|
-
const [type,
|
|
18917
|
-
const tmpPath = await downloadTemplate(type,
|
|
18918
|
-
return
|
|
18779
|
+
const [type, name2] = template.key.split("/");
|
|
18780
|
+
const tmpPath = await downloadTemplate(type, name2);
|
|
18781
|
+
return import_fs7.default.createReadStream((0, import_path8.join)(tmpPath, name2, "db", "dump.txt"));
|
|
18919
18782
|
}
|
|
18920
18783
|
}
|
|
18921
18784
|
function untarFile(file) {
|
|
18922
|
-
const tmpPath = (0,
|
|
18923
|
-
|
|
18785
|
+
const tmpPath = (0, import_path8.join)(budibaseTempDir2(), uuid4());
|
|
18786
|
+
import_fs7.default.mkdirSync(tmpPath);
|
|
18924
18787
|
tar4.extract({
|
|
18925
18788
|
sync: true,
|
|
18926
18789
|
cwd: tmpPath,
|
|
@@ -18928,49 +18791,31 @@ function untarFile(file) {
|
|
|
18928
18791
|
});
|
|
18929
18792
|
return tmpPath;
|
|
18930
18793
|
}
|
|
18931
|
-
async function decryptFiles(path2, password) {
|
|
18932
|
-
try {
|
|
18933
|
-
for (let file of import_fs8.default.readdirSync(path2)) {
|
|
18934
|
-
const inputPath = (0, import_path9.join)(path2, file);
|
|
18935
|
-
const outputPath = inputPath.replace(/\.enc$/, "");
|
|
18936
|
-
await encryption_exports.decryptFile(inputPath, outputPath, password);
|
|
18937
|
-
import_fs8.default.rmSync(inputPath);
|
|
18938
|
-
}
|
|
18939
|
-
} catch (err) {
|
|
18940
|
-
if (err.message === "incorrect header check") {
|
|
18941
|
-
throw new Error("File cannot be imported");
|
|
18942
|
-
}
|
|
18943
|
-
throw err;
|
|
18944
|
-
}
|
|
18945
|
-
}
|
|
18946
18794
|
function getGlobalDBFile(tmpPath) {
|
|
18947
|
-
return
|
|
18795
|
+
return import_fs7.default.readFileSync((0, import_path8.join)(tmpPath, GLOBAL_DB_EXPORT_FILE), "utf8");
|
|
18948
18796
|
}
|
|
18949
18797
|
function getListOfAppsInMulti(tmpPath) {
|
|
18950
|
-
return
|
|
18798
|
+
return import_fs7.default.readdirSync(tmpPath).filter((dir) => dir !== GLOBAL_DB_EXPORT_FILE);
|
|
18951
18799
|
}
|
|
18952
|
-
async function importApp(appId,
|
|
18800
|
+
async function importApp(appId, db2, template) {
|
|
18953
18801
|
var _a, _b;
|
|
18954
18802
|
let prodAppId = db_exports.getProdAppID(appId);
|
|
18955
18803
|
let dbStream;
|
|
18956
18804
|
const isTar = template.file && ((_b = (_a = template == null ? void 0 : template.file) == null ? void 0 : _a.type) == null ? void 0 : _b.endsWith("gzip"));
|
|
18957
|
-
const isDirectory = template.file &&
|
|
18805
|
+
const isDirectory = template.file && import_fs7.default.lstatSync(template.file.path).isDirectory();
|
|
18958
18806
|
if (template.file && (isTar || isDirectory)) {
|
|
18959
18807
|
const tmpPath = isTar ? untarFile(template.file) : template.file.path;
|
|
18960
|
-
|
|
18961
|
-
await decryptFiles(tmpPath, template.file.password);
|
|
18962
|
-
}
|
|
18963
|
-
const contents = import_fs8.default.readdirSync(tmpPath);
|
|
18808
|
+
const contents = import_fs7.default.readdirSync(tmpPath);
|
|
18964
18809
|
if (contents.length) {
|
|
18965
18810
|
let promises = [];
|
|
18966
18811
|
let excludedFiles = [GLOBAL_DB_EXPORT_FILE, DB_EXPORT_FILE];
|
|
18967
18812
|
for (let filename of contents) {
|
|
18968
|
-
const path2 = (0,
|
|
18813
|
+
const path2 = (0, import_path8.join)(tmpPath, filename);
|
|
18969
18814
|
if (excludedFiles.includes(filename)) {
|
|
18970
18815
|
continue;
|
|
18971
18816
|
}
|
|
18972
|
-
filename = (0,
|
|
18973
|
-
if (
|
|
18817
|
+
filename = (0, import_path8.join)(prodAppId, filename);
|
|
18818
|
+
if (import_fs7.default.lstatSync(path2).isDirectory()) {
|
|
18974
18819
|
promises.push(
|
|
18975
18820
|
objectStore_exports2.uploadDirectory(ObjectStoreBuckets2.APPS, path2, filename)
|
|
18976
18821
|
);
|
|
@@ -18986,16 +18831,16 @@ async function importApp(appId, db, template) {
|
|
|
18986
18831
|
}
|
|
18987
18832
|
await Promise.all(promises);
|
|
18988
18833
|
}
|
|
18989
|
-
dbStream =
|
|
18834
|
+
dbStream = import_fs7.default.createReadStream((0, import_path8.join)(tmpPath, DB_EXPORT_FILE));
|
|
18990
18835
|
} else {
|
|
18991
18836
|
dbStream = await getTemplateStream(template);
|
|
18992
18837
|
}
|
|
18993
|
-
const { ok } = await
|
|
18838
|
+
const { ok } = await db2.load(dbStream);
|
|
18994
18839
|
if (!ok) {
|
|
18995
18840
|
throw "Error loading database dump from template.";
|
|
18996
18841
|
}
|
|
18997
|
-
await updateAttachmentColumns(prodAppId,
|
|
18998
|
-
await updateAutomations(prodAppId,
|
|
18842
|
+
await updateAttachmentColumns(prodAppId, db2);
|
|
18843
|
+
await updateAutomations(prodAppId, db2);
|
|
18999
18844
|
return ok;
|
|
19000
18845
|
}
|
|
19001
18846
|
|
|
@@ -19007,54 +18852,54 @@ __export(statistics_exports, {
|
|
|
19007
18852
|
calculateDatasourceCount: () => calculateDatasourceCount,
|
|
19008
18853
|
calculateScreenCount: () => calculateScreenCount
|
|
19009
18854
|
});
|
|
19010
|
-
async function runInContext(appId, cb,
|
|
19011
|
-
if (
|
|
19012
|
-
return cb(
|
|
18855
|
+
async function runInContext(appId, cb, db2) {
|
|
18856
|
+
if (db2) {
|
|
18857
|
+
return cb(db2);
|
|
19013
18858
|
} else {
|
|
19014
18859
|
const devAppId = db_exports.getDevAppID(appId);
|
|
19015
18860
|
return context_exports.doInAppContext(devAppId, () => {
|
|
19016
|
-
const
|
|
19017
|
-
return cb(
|
|
18861
|
+
const db3 = context_exports.getAppDB();
|
|
18862
|
+
return cb(db3);
|
|
19018
18863
|
});
|
|
19019
18864
|
}
|
|
19020
18865
|
}
|
|
19021
|
-
async function calculateDatasourceCount(appId,
|
|
18866
|
+
async function calculateDatasourceCount(appId, db2) {
|
|
19022
18867
|
return runInContext(
|
|
19023
18868
|
appId,
|
|
19024
|
-
async (
|
|
19025
|
-
const datasourceList = await
|
|
19026
|
-
const tableList = await
|
|
18869
|
+
async (db3) => {
|
|
18870
|
+
const datasourceList = await db3.allDocs(getDatasourceParams());
|
|
18871
|
+
const tableList = await db3.allDocs(getTableParams());
|
|
19027
18872
|
return datasourceList.rows.length + tableList.rows.length;
|
|
19028
18873
|
},
|
|
19029
|
-
|
|
18874
|
+
db2
|
|
19030
18875
|
);
|
|
19031
18876
|
}
|
|
19032
|
-
async function calculateAutomationCount(appId,
|
|
18877
|
+
async function calculateAutomationCount(appId, db2) {
|
|
19033
18878
|
return runInContext(
|
|
19034
18879
|
appId,
|
|
19035
|
-
async (
|
|
19036
|
-
const automationList = await
|
|
18880
|
+
async (db3) => {
|
|
18881
|
+
const automationList = await db3.allDocs(getAutomationParams());
|
|
19037
18882
|
return automationList.rows.length;
|
|
19038
18883
|
},
|
|
19039
|
-
|
|
18884
|
+
db2
|
|
19040
18885
|
);
|
|
19041
18886
|
}
|
|
19042
|
-
async function calculateScreenCount(appId,
|
|
18887
|
+
async function calculateScreenCount(appId, db2) {
|
|
19043
18888
|
return runInContext(
|
|
19044
18889
|
appId,
|
|
19045
|
-
async (
|
|
19046
|
-
const screenList = await
|
|
18890
|
+
async (db3) => {
|
|
18891
|
+
const screenList = await db3.allDocs(getScreenParams());
|
|
19047
18892
|
return screenList.rows.length;
|
|
19048
18893
|
},
|
|
19049
|
-
|
|
18894
|
+
db2
|
|
19050
18895
|
);
|
|
19051
18896
|
}
|
|
19052
18897
|
async function calculateBackupStats(appId) {
|
|
19053
|
-
return runInContext(appId, async (
|
|
18898
|
+
return runInContext(appId, async (db2) => {
|
|
19054
18899
|
const promises = [];
|
|
19055
|
-
promises.push(calculateDatasourceCount(appId,
|
|
19056
|
-
promises.push(calculateAutomationCount(appId,
|
|
19057
|
-
promises.push(calculateScreenCount(appId,
|
|
18900
|
+
promises.push(calculateDatasourceCount(appId, db2));
|
|
18901
|
+
promises.push(calculateAutomationCount(appId, db2));
|
|
18902
|
+
promises.push(calculateScreenCount(appId, db2));
|
|
19058
18903
|
const responses = await Promise.all(promises);
|
|
19059
18904
|
return {
|
|
19060
18905
|
datasources: responses[0],
|
|
@@ -19300,11 +19145,11 @@ var setCurrentMonth = (usage) => {
|
|
|
19300
19145
|
}
|
|
19301
19146
|
usage.monthly.current = usage.monthly[currentMonth];
|
|
19302
19147
|
};
|
|
19303
|
-
var getBreakdownName = (
|
|
19304
|
-
if (!id || !
|
|
19148
|
+
var getBreakdownName = (name2, id) => {
|
|
19149
|
+
if (!id || !name2) {
|
|
19305
19150
|
return;
|
|
19306
19151
|
}
|
|
19307
|
-
switch (
|
|
19152
|
+
switch (name2) {
|
|
19308
19153
|
case "automations" /* AUTOMATIONS */:
|
|
19309
19154
|
return "automations" /* AUTOMATIONS */;
|
|
19310
19155
|
case "queries" /* QUERIES */:
|
|
@@ -19318,11 +19163,11 @@ var getDB2 = () => {
|
|
|
19318
19163
|
return new Writethrough2(tenancy.getGlobalDB());
|
|
19319
19164
|
};
|
|
19320
19165
|
var bustCache2 = async () => {
|
|
19321
|
-
const
|
|
19166
|
+
const db2 = getDB2();
|
|
19322
19167
|
try {
|
|
19323
|
-
const usage = await
|
|
19168
|
+
const usage = await db2.get(db_exports.StaticDatabases.GLOBAL.docs.usageQuota);
|
|
19324
19169
|
if (usage == null ? void 0 : usage._rev) {
|
|
19325
|
-
await
|
|
19170
|
+
await db2.remove(
|
|
19326
19171
|
db_exports.StaticDatabases.GLOBAL.docs.usageQuota,
|
|
19327
19172
|
usage == null ? void 0 : usage._rev
|
|
19328
19173
|
);
|
|
@@ -19334,16 +19179,16 @@ var bustCache2 = async () => {
|
|
|
19334
19179
|
}
|
|
19335
19180
|
};
|
|
19336
19181
|
var getQuotaUsage = async () => {
|
|
19337
|
-
const
|
|
19182
|
+
const db2 = getDB2();
|
|
19338
19183
|
let usage;
|
|
19339
19184
|
try {
|
|
19340
|
-
usage = await
|
|
19185
|
+
usage = await db2.get(db_exports.StaticDatabases.GLOBAL.docs.usageQuota);
|
|
19341
19186
|
setCurrentMonth(usage);
|
|
19342
19187
|
setQuotaReset(usage);
|
|
19343
19188
|
} catch (err) {
|
|
19344
19189
|
if (err.status === 404) {
|
|
19345
19190
|
usage = generateNewQuotaUsage();
|
|
19346
|
-
const response = await
|
|
19191
|
+
const response = await db2.put(usage);
|
|
19347
19192
|
usage._rev = response.rev;
|
|
19348
19193
|
} else {
|
|
19349
19194
|
throw err;
|
|
@@ -19358,17 +19203,17 @@ var getQuotaUsage = async () => {
|
|
|
19358
19203
|
delete usage.usageQuota.developers;
|
|
19359
19204
|
return usage;
|
|
19360
19205
|
};
|
|
19361
|
-
var setUsage = async (value,
|
|
19362
|
-
return setAllUsage(
|
|
19206
|
+
var setUsage = async (value, name2, type) => {
|
|
19207
|
+
return setAllUsage(name2, type, { total: value });
|
|
19363
19208
|
};
|
|
19364
|
-
var setUsagePerApp = async (appValues,
|
|
19365
|
-
const
|
|
19209
|
+
var setUsagePerApp = async (appValues, name2, type) => {
|
|
19210
|
+
const db2 = getDB2();
|
|
19366
19211
|
let quotaUsage = await getQuotaUsage();
|
|
19367
19212
|
const total = Object.values(appValues).reduce((sum, num) => sum + num, 0);
|
|
19368
19213
|
for (let [appId, value] of Object.entries(appValues)) {
|
|
19369
19214
|
quotaUsage = coreUsageUpdate(
|
|
19370
19215
|
quotaUsage,
|
|
19371
|
-
|
|
19216
|
+
name2,
|
|
19372
19217
|
type,
|
|
19373
19218
|
{
|
|
19374
19219
|
total,
|
|
@@ -19379,12 +19224,12 @@ var setUsagePerApp = async (appValues, name, type) => {
|
|
|
19379
19224
|
}
|
|
19380
19225
|
);
|
|
19381
19226
|
}
|
|
19382
|
-
const response = await
|
|
19227
|
+
const response = await db2.put(quotaUsage);
|
|
19383
19228
|
quotaUsage._rev = response.rev;
|
|
19384
19229
|
return quotaUsage;
|
|
19385
19230
|
};
|
|
19386
|
-
var setBreakdown = (monthUsage,
|
|
19387
|
-
const breakdownName = getBreakdownName(
|
|
19231
|
+
var setBreakdown = (monthUsage, name2, id, values) => {
|
|
19232
|
+
const breakdownName = getBreakdownName(name2, id);
|
|
19388
19233
|
if (!breakdownName || !(values == null ? void 0 : values.breakdown)) {
|
|
19389
19234
|
return monthUsage;
|
|
19390
19235
|
}
|
|
@@ -19393,7 +19238,7 @@ var setBreakdown = (monthUsage, name, id, values) => {
|
|
|
19393
19238
|
}
|
|
19394
19239
|
if (!monthUsage.breakdown[breakdownName]) {
|
|
19395
19240
|
monthUsage.breakdown[breakdownName] = {
|
|
19396
|
-
parent:
|
|
19241
|
+
parent: name2,
|
|
19397
19242
|
values: {}
|
|
19398
19243
|
};
|
|
19399
19244
|
}
|
|
@@ -19401,14 +19246,14 @@ var setBreakdown = (monthUsage, name, id, values) => {
|
|
|
19401
19246
|
breakdown.values[id] = values.breakdown;
|
|
19402
19247
|
return monthUsage;
|
|
19403
19248
|
};
|
|
19404
|
-
var setAppUsageValue = (quotaUsage,
|
|
19249
|
+
var setAppUsageValue = (quotaUsage, name2, type, opts = {}, values) => {
|
|
19405
19250
|
var _a;
|
|
19406
19251
|
let appId;
|
|
19407
19252
|
try {
|
|
19408
19253
|
appId = db_exports.getProdAppID((opts == null ? void 0 : opts.appId) || context_exports.getAppId());
|
|
19409
19254
|
} catch (err) {
|
|
19410
19255
|
}
|
|
19411
|
-
if (!appId || !values.app || !APP_QUOTA_NAMES.includes(
|
|
19256
|
+
if (!appId || !values.app || !APP_QUOTA_NAMES.includes(name2)) {
|
|
19412
19257
|
return quotaUsage;
|
|
19413
19258
|
}
|
|
19414
19259
|
if (!((_a = quotaUsage.apps) == null ? void 0 : _a[appId])) {
|
|
@@ -19420,11 +19265,11 @@ var setAppUsageValue = (quotaUsage, name, type, opts = {}, values) => {
|
|
|
19420
19265
|
const appUsage = quotaUsage.apps[appId];
|
|
19421
19266
|
switch (type) {
|
|
19422
19267
|
case "static" /* STATIC */:
|
|
19423
|
-
appUsage.usageQuota[
|
|
19268
|
+
appUsage.usageQuota[name2] = values.app;
|
|
19424
19269
|
break;
|
|
19425
19270
|
case "monthly" /* MONTHLY */:
|
|
19426
19271
|
const currentMonth = getCurrentMonthString();
|
|
19427
|
-
const monthlyName =
|
|
19272
|
+
const monthlyName = name2;
|
|
19428
19273
|
let monthUsage = appUsage.monthly[currentMonth];
|
|
19429
19274
|
if (!monthUsage) {
|
|
19430
19275
|
appUsage.monthly[currentMonth] = generateNewMonthlyQuotas();
|
|
@@ -19438,9 +19283,9 @@ var setAppUsageValue = (quotaUsage, name, type, opts = {}, values) => {
|
|
|
19438
19283
|
}
|
|
19439
19284
|
return quotaUsage;
|
|
19440
19285
|
};
|
|
19441
|
-
var getAppUsageValue = (quotaUsage, type,
|
|
19286
|
+
var getAppUsageValue = (quotaUsage, type, name2, id) => {
|
|
19442
19287
|
var _a, _b, _c, _d, _e;
|
|
19443
|
-
if (!APP_QUOTA_NAMES.includes(
|
|
19288
|
+
if (!APP_QUOTA_NAMES.includes(name2)) {
|
|
19444
19289
|
return {};
|
|
19445
19290
|
}
|
|
19446
19291
|
let appId;
|
|
@@ -19454,13 +19299,13 @@ var getAppUsageValue = (quotaUsage, type, name, id) => {
|
|
|
19454
19299
|
const appUsage = quotaUsage.apps[appId];
|
|
19455
19300
|
switch (type) {
|
|
19456
19301
|
case "static" /* STATIC */:
|
|
19457
|
-
if ((_a = appUsage.usageQuota) == null ? void 0 : _a[
|
|
19458
|
-
return { app: appUsage.usageQuota[
|
|
19302
|
+
if ((_a = appUsage.usageQuota) == null ? void 0 : _a[name2]) {
|
|
19303
|
+
return { app: appUsage.usageQuota[name2] };
|
|
19459
19304
|
}
|
|
19460
19305
|
break;
|
|
19461
19306
|
case "monthly" /* MONTHLY */:
|
|
19462
19307
|
const currentMonth = getCurrentMonthString();
|
|
19463
|
-
const monthlyName =
|
|
19308
|
+
const monthlyName = name2;
|
|
19464
19309
|
if (!((_c = (_b = appUsage.monthly) == null ? void 0 : _b[currentMonth]) == null ? void 0 : _c[monthlyName])) {
|
|
19465
19310
|
break;
|
|
19466
19311
|
}
|
|
@@ -19475,68 +19320,68 @@ var getAppUsageValue = (quotaUsage, type, name, id) => {
|
|
|
19475
19320
|
}
|
|
19476
19321
|
return { app: 0 };
|
|
19477
19322
|
};
|
|
19478
|
-
var setStaticTriggers = (
|
|
19323
|
+
var setStaticTriggers = (name2, quotaUsage, triggers) => {
|
|
19479
19324
|
if (!quotaUsage.usageQuota.triggers) {
|
|
19480
19325
|
quotaUsage.usageQuota.triggers = {};
|
|
19481
19326
|
}
|
|
19482
19327
|
if (triggers) {
|
|
19483
|
-
quotaUsage.usageQuota.triggers[
|
|
19328
|
+
quotaUsage.usageQuota.triggers[name2] = triggers;
|
|
19484
19329
|
}
|
|
19485
19330
|
};
|
|
19486
|
-
var setMonthlyTriggers = (
|
|
19331
|
+
var setMonthlyTriggers = (name2, currentMonth, quotaUsage, triggers) => {
|
|
19487
19332
|
if (!quotaUsage.monthly[currentMonth].triggers) {
|
|
19488
19333
|
quotaUsage.monthly[currentMonth].triggers = {};
|
|
19489
19334
|
}
|
|
19490
19335
|
if (triggers) {
|
|
19491
|
-
quotaUsage.monthly[currentMonth].triggers[
|
|
19336
|
+
quotaUsage.monthly[currentMonth].triggers[name2] = triggers;
|
|
19492
19337
|
}
|
|
19493
19338
|
};
|
|
19494
|
-
var coreUsageUpdate = (quotaUsage,
|
|
19339
|
+
var coreUsageUpdate = (quotaUsage, name2, type, values, opts = {}) => {
|
|
19495
19340
|
if (type === "static" /* STATIC */) {
|
|
19496
|
-
|
|
19497
|
-
quotaUsage.usageQuota[
|
|
19498
|
-
setStaticTriggers(
|
|
19341
|
+
name2 = name2;
|
|
19342
|
+
quotaUsage.usageQuota[name2] = values.total;
|
|
19343
|
+
setStaticTriggers(name2, quotaUsage, values.triggers);
|
|
19499
19344
|
} else if (type === "monthly" /* MONTHLY */) {
|
|
19500
|
-
|
|
19345
|
+
name2 = name2;
|
|
19501
19346
|
const currentMonth = getCurrentMonthString();
|
|
19502
|
-
quotaUsage.monthly[currentMonth][
|
|
19503
|
-
setMonthlyTriggers(
|
|
19347
|
+
quotaUsage.monthly[currentMonth][name2] = values.total;
|
|
19348
|
+
setMonthlyTriggers(name2, currentMonth, quotaUsage, values.triggers);
|
|
19504
19349
|
} else {
|
|
19505
19350
|
throw new Error(`Invalid usage type: ${type}`);
|
|
19506
19351
|
}
|
|
19507
|
-
return setAppUsageValue(quotaUsage,
|
|
19352
|
+
return setAppUsageValue(quotaUsage, name2, type, opts, values);
|
|
19508
19353
|
};
|
|
19509
|
-
var setAllUsage = async (
|
|
19510
|
-
const
|
|
19354
|
+
var setAllUsage = async (name2, type, values, opts = {}) => {
|
|
19355
|
+
const db2 = getDB2();
|
|
19511
19356
|
let quotaUsage = await getQuotaUsage();
|
|
19512
|
-
quotaUsage = coreUsageUpdate(quotaUsage,
|
|
19513
|
-
const response = await
|
|
19357
|
+
quotaUsage = coreUsageUpdate(quotaUsage, name2, type, values, opts);
|
|
19358
|
+
const response = await db2.put(quotaUsage);
|
|
19514
19359
|
quotaUsage._rev = response.rev;
|
|
19515
19360
|
return quotaUsage;
|
|
19516
19361
|
};
|
|
19517
|
-
var getCurrentUsageValues = async (type,
|
|
19362
|
+
var getCurrentUsageValues = async (type, name2, id) => {
|
|
19518
19363
|
const quotaUsage = await getQuotaUsage();
|
|
19519
19364
|
let total = 0, appValues = {};
|
|
19520
19365
|
switch (type) {
|
|
19521
19366
|
case "static" /* STATIC */:
|
|
19522
|
-
if (quotaUsage.usageQuota[
|
|
19523
|
-
const staticName =
|
|
19367
|
+
if (quotaUsage.usageQuota[name2]) {
|
|
19368
|
+
const staticName = name2;
|
|
19524
19369
|
total = quotaUsage.usageQuota[staticName];
|
|
19525
|
-
appValues = getAppUsageValue(quotaUsage, type,
|
|
19370
|
+
appValues = getAppUsageValue(quotaUsage, type, name2, id);
|
|
19526
19371
|
}
|
|
19527
19372
|
break;
|
|
19528
19373
|
case "monthly" /* MONTHLY */:
|
|
19529
19374
|
const currentMonth = getCurrentMonthString();
|
|
19530
|
-
const monthlyName =
|
|
19375
|
+
const monthlyName = name2;
|
|
19531
19376
|
if (quotaUsage.monthly[currentMonth][monthlyName]) {
|
|
19532
19377
|
total = quotaUsage.monthly[currentMonth][monthlyName];
|
|
19533
|
-
appValues = getAppUsageValue(quotaUsage, type,
|
|
19378
|
+
appValues = getAppUsageValue(quotaUsage, type, name2, id);
|
|
19534
19379
|
}
|
|
19535
19380
|
break;
|
|
19536
19381
|
default:
|
|
19537
19382
|
throw new Error(`Invalid usage type: ${type}`);
|
|
19538
19383
|
}
|
|
19539
|
-
if (APP_QUOTA_NAMES.includes(
|
|
19384
|
+
if (APP_QUOTA_NAMES.includes(name2) && !(appValues.app || appValues.breakdown)) {
|
|
19540
19385
|
appValues.app = appValues.app || 0;
|
|
19541
19386
|
appValues.breakdown = appValues.breakdown || 0;
|
|
19542
19387
|
}
|
|
@@ -19557,8 +19402,8 @@ var newLicenseInfo = (licenseKey) => {
|
|
|
19557
19402
|
};
|
|
19558
19403
|
};
|
|
19559
19404
|
var save2 = async (licenseInfo) => {
|
|
19560
|
-
const
|
|
19561
|
-
const response = await
|
|
19405
|
+
const db2 = tenancy.getGlobalDB();
|
|
19406
|
+
const response = await db2.put(licenseInfo);
|
|
19562
19407
|
licenseInfo._rev = response.rev;
|
|
19563
19408
|
return licenseInfo;
|
|
19564
19409
|
};
|
|
@@ -19567,9 +19412,9 @@ var create = async (licenseKey) => {
|
|
|
19567
19412
|
return save2(licenseInfo);
|
|
19568
19413
|
};
|
|
19569
19414
|
var get4 = async () => {
|
|
19570
|
-
const
|
|
19415
|
+
const db2 = tenancy.getGlobalDB();
|
|
19571
19416
|
try {
|
|
19572
|
-
return await
|
|
19417
|
+
return await db2.get(StaticDatabases.GLOBAL.docs.licenseInfo);
|
|
19573
19418
|
} catch (err) {
|
|
19574
19419
|
if (err.status === 404) {
|
|
19575
19420
|
return void 0;
|
|
@@ -19582,8 +19427,8 @@ var destroy2 = async () => {
|
|
|
19582
19427
|
if (!info) {
|
|
19583
19428
|
return;
|
|
19584
19429
|
}
|
|
19585
|
-
const
|
|
19586
|
-
return
|
|
19430
|
+
const db2 = tenancy.getGlobalDB();
|
|
19431
|
+
return db2.remove(StaticDatabases.GLOBAL.docs.licenseInfo, info._rev);
|
|
19587
19432
|
};
|
|
19588
19433
|
|
|
19589
19434
|
// ../pro/packages/pro/src/db/groups.ts
|
|
@@ -19605,10 +19450,10 @@ __export(groups_exports, {
|
|
|
19605
19450
|
// ../pro/packages/pro/src/db/views/staticViews.ts
|
|
19606
19451
|
init_src();
|
|
19607
19452
|
async function createAuditLogSearchIndex() {
|
|
19608
|
-
const
|
|
19453
|
+
const db2 = context_exports.getAuditLogsDB();
|
|
19609
19454
|
let designDoc;
|
|
19610
19455
|
try {
|
|
19611
|
-
designDoc = await
|
|
19456
|
+
designDoc = await db2.get("_design/database");
|
|
19612
19457
|
} catch (err) {
|
|
19613
19458
|
if (err.status === 404) {
|
|
19614
19459
|
designDoc = { _id: "_design/database" };
|
|
@@ -19651,14 +19496,14 @@ async function createAuditLogSearchIndex() {
|
|
|
19651
19496
|
}
|
|
19652
19497
|
}
|
|
19653
19498
|
};
|
|
19654
|
-
await
|
|
19499
|
+
await db2.put(designDoc);
|
|
19655
19500
|
}
|
|
19656
19501
|
|
|
19657
19502
|
// ../pro/packages/pro/src/db/views/groups.ts
|
|
19658
19503
|
var { ViewName: ViewName4, SEPARATOR: SEPARATOR5, DocumentType: DocumentType3, createView: createView2 } = db_exports;
|
|
19659
19504
|
var USER_PREFIX = DocumentType3.USER + SEPARATOR5;
|
|
19660
19505
|
async function createGroupUserLookupView() {
|
|
19661
|
-
const
|
|
19506
|
+
const db2 = tenancy.getGlobalDB();
|
|
19662
19507
|
const viewJs = `function(doc) {
|
|
19663
19508
|
if (doc._id.startsWith("${USER_PREFIX}") && Array.isArray(doc.userGroups)) {
|
|
19664
19509
|
for (let groupId of doc.userGroups) {
|
|
@@ -19667,7 +19512,7 @@ async function createGroupUserLookupView() {
|
|
|
19667
19512
|
}
|
|
19668
19513
|
}
|
|
19669
19514
|
}`;
|
|
19670
|
-
await createView2(
|
|
19515
|
+
await createView2(db2, viewJs, ViewName4.USER_BY_GROUP);
|
|
19671
19516
|
}
|
|
19672
19517
|
|
|
19673
19518
|
// ../pro/packages/pro/src/db/groups.ts
|
|
@@ -19707,17 +19552,17 @@ function generateUserGroupID() {
|
|
|
19707
19552
|
return `${GROUP_PREFIX}${utils_exports2.newid()}`;
|
|
19708
19553
|
}
|
|
19709
19554
|
async function getGroupUsers(groupId, params2) {
|
|
19710
|
-
const
|
|
19555
|
+
const db2 = tenancy.getGlobalDB();
|
|
19711
19556
|
const userDocs = await db_exports.queryView(
|
|
19712
19557
|
db_exports.ViewName.USER_BY_GROUP,
|
|
19713
19558
|
getGroupUsersParams(groupId, params2),
|
|
19714
|
-
|
|
19559
|
+
db2,
|
|
19715
19560
|
createGroupUserLookupView,
|
|
19716
19561
|
{ arrayResponse: true }
|
|
19717
19562
|
);
|
|
19718
|
-
const users2 = userDocs.map((
|
|
19719
|
-
_id:
|
|
19720
|
-
email:
|
|
19563
|
+
const users2 = userDocs.map((doc2) => ({
|
|
19564
|
+
_id: doc2.userId,
|
|
19565
|
+
email: doc2.email
|
|
19721
19566
|
})) || [];
|
|
19722
19567
|
return users2;
|
|
19723
19568
|
}
|
|
@@ -19746,9 +19591,9 @@ async function cleanupUsers(group) {
|
|
|
19746
19591
|
}
|
|
19747
19592
|
}
|
|
19748
19593
|
async function fetch11() {
|
|
19749
|
-
const
|
|
19594
|
+
const db2 = tenancy.getGlobalDB();
|
|
19750
19595
|
try {
|
|
19751
|
-
const groups = (await
|
|
19596
|
+
const groups = (await db2.allDocs(
|
|
19752
19597
|
getUserGroupsParams(null, {
|
|
19753
19598
|
include_docs: true
|
|
19754
19599
|
})
|
|
@@ -19763,18 +19608,18 @@ async function fetch11() {
|
|
|
19763
19608
|
}
|
|
19764
19609
|
}
|
|
19765
19610
|
async function get5(groupId) {
|
|
19766
|
-
const
|
|
19611
|
+
const db2 = tenancy.getGlobalDB();
|
|
19767
19612
|
try {
|
|
19768
|
-
const group = await
|
|
19613
|
+
const group = await db2.get(groupId);
|
|
19769
19614
|
return await enrichGroup(group);
|
|
19770
19615
|
} catch (err) {
|
|
19771
19616
|
throw err;
|
|
19772
19617
|
}
|
|
19773
19618
|
}
|
|
19774
19619
|
async function getBulk(groupIds, opts = { enriched: true }) {
|
|
19775
|
-
const
|
|
19620
|
+
const db2 = tenancy.getGlobalDB();
|
|
19776
19621
|
try {
|
|
19777
|
-
const groups = (await
|
|
19622
|
+
const groups = (await db2.allDocs({
|
|
19778
19623
|
keys: groupIds,
|
|
19779
19624
|
include_docs: true
|
|
19780
19625
|
})).rows.map((row) => row.doc);
|
|
@@ -19792,26 +19637,26 @@ async function getBulk(groupIds, opts = { enriched: true }) {
|
|
|
19792
19637
|
}
|
|
19793
19638
|
}
|
|
19794
19639
|
async function save3(group) {
|
|
19795
|
-
const
|
|
19796
|
-
return await
|
|
19640
|
+
const db2 = tenancy.getGlobalDB();
|
|
19641
|
+
return await db2.put(group);
|
|
19797
19642
|
}
|
|
19798
19643
|
async function bulkSave(groups) {
|
|
19799
|
-
const
|
|
19800
|
-
return await
|
|
19644
|
+
const db2 = tenancy.getGlobalDB();
|
|
19645
|
+
return await db2.bulkDocs(groups);
|
|
19801
19646
|
}
|
|
19802
19647
|
async function destroy3(groupId, revision) {
|
|
19803
|
-
const
|
|
19804
|
-
const group = await
|
|
19805
|
-
let resp = await
|
|
19648
|
+
const db2 = tenancy.getGlobalDB();
|
|
19649
|
+
const group = await db2.get(groupId);
|
|
19650
|
+
let resp = await db2.remove(groupId, revision);
|
|
19806
19651
|
await cleanupUsers(group);
|
|
19807
19652
|
return resp;
|
|
19808
19653
|
}
|
|
19809
|
-
async function getByName(
|
|
19654
|
+
async function getByName(name2) {
|
|
19810
19655
|
try {
|
|
19811
19656
|
const groups = await db_exports.directCouchFind(tenancy.getGlobalDBName(), {
|
|
19812
19657
|
selector: {
|
|
19813
19658
|
name: {
|
|
19814
|
-
$regex: `^(?i)${
|
|
19659
|
+
$regex: `^(?i)${name2}$`
|
|
19815
19660
|
}
|
|
19816
19661
|
},
|
|
19817
19662
|
limit: 1
|
|
@@ -19861,7 +19706,7 @@ var { ViewName: ViewName5, AutomationViewMode: AutomationViewMode2, SEPARATOR: S
|
|
|
19861
19706
|
var LOG_PREFIX = DocumentType4.AUTOMATION_LOG + SEPARATOR6;
|
|
19862
19707
|
var APP_BACKUP_PREFIX = DocumentType4.APP_BACKUP + SEPARATOR6;
|
|
19863
19708
|
async function createLogByAutomationView() {
|
|
19864
|
-
const
|
|
19709
|
+
const db2 = context_exports.getProdAppDB();
|
|
19865
19710
|
const viewJs = `function(doc) {
|
|
19866
19711
|
if (doc._id.startsWith("${LOG_PREFIX}")) {
|
|
19867
19712
|
let autoId = doc.automationId + "${SEPARATOR6}"
|
|
@@ -19874,10 +19719,10 @@ async function createLogByAutomationView() {
|
|
|
19874
19719
|
emit(allKey)
|
|
19875
19720
|
}
|
|
19876
19721
|
}`;
|
|
19877
|
-
await createView3(
|
|
19722
|
+
await createView3(db2, viewJs, ViewName5.AUTOMATION_LOGS);
|
|
19878
19723
|
}
|
|
19879
19724
|
async function createAppBackupTriggerView() {
|
|
19880
|
-
const
|
|
19725
|
+
const db2 = tenancy.getGlobalDB();
|
|
19881
19726
|
const viewJs = `function(doc) {
|
|
19882
19727
|
if (doc._id.startsWith("${APP_BACKUP_PREFIX}") && doc.type && doc.trigger) {
|
|
19883
19728
|
let full = doc.appId + "${SEPARATOR6}"
|
|
@@ -19886,7 +19731,7 @@ async function createAppBackupTriggerView() {
|
|
|
19886
19731
|
emit("${APP_BACKUP_PREFIX}" + full + doc.timestamp)
|
|
19887
19732
|
}
|
|
19888
19733
|
}`;
|
|
19889
|
-
await createView3(
|
|
19734
|
+
await createView3(db2, viewJs, ViewName5.APP_BACKUP_BY_TRIGGER);
|
|
19890
19735
|
}
|
|
19891
19736
|
|
|
19892
19737
|
// ../pro/packages/pro/src/db/utils/retention.ts
|
|
@@ -20105,17 +19950,17 @@ __export(version_exports, {
|
|
|
20105
19950
|
getLicenseVersion: () => getLicenseVersion,
|
|
20106
19951
|
getProVersion: () => getProVersion
|
|
20107
19952
|
});
|
|
20108
|
-
var
|
|
20109
|
-
var
|
|
19953
|
+
var import_fs8 = __toESM(require("fs"));
|
|
19954
|
+
var import_path9 = __toESM(require("path"));
|
|
20110
19955
|
var getLicenseVersion = () => {
|
|
20111
19956
|
if (environment_default2.isDev()) {
|
|
20112
19957
|
const DEV_VER_FILENAME = "dev-version.txt";
|
|
20113
|
-
const verFile =
|
|
20114
|
-
if (
|
|
20115
|
-
return
|
|
19958
|
+
const verFile = import_path9.default.join(objectStore_exports2.budibaseTempDir(), DEV_VER_FILENAME);
|
|
19959
|
+
if (import_fs8.default.existsSync(verFile)) {
|
|
19960
|
+
return import_fs8.default.readFileSync(verFile, "utf8");
|
|
20116
19961
|
} else {
|
|
20117
19962
|
const devVer = utils_exports2.newid();
|
|
20118
|
-
|
|
19963
|
+
import_fs8.default.writeFileSync(verFile, devVer);
|
|
20119
19964
|
return devVer;
|
|
20120
19965
|
}
|
|
20121
19966
|
} else {
|
|
@@ -20123,11 +19968,11 @@ var getLicenseVersion = () => {
|
|
|
20123
19968
|
}
|
|
20124
19969
|
};
|
|
20125
19970
|
var getProVersion = () => {
|
|
20126
|
-
const
|
|
20127
|
-
if (!
|
|
19971
|
+
const version2 = environment_default2.VERSION;
|
|
19972
|
+
if (!version2) {
|
|
20128
19973
|
throw new Error("No budibase pro version was specified");
|
|
20129
19974
|
}
|
|
20130
|
-
return
|
|
19975
|
+
return version2;
|
|
20131
19976
|
};
|
|
20132
19977
|
|
|
20133
19978
|
// ../pro/packages/pro/src/constants/misc.ts
|
|
@@ -20180,17 +20025,17 @@ async function getAppBackupParams(appId, filters, otherProps = {}) {
|
|
|
20180
20025
|
endkey: `${APP_BACKUP_PREFIX2}${endKey}`
|
|
20181
20026
|
};
|
|
20182
20027
|
}
|
|
20183
|
-
async function getAppBackupsByTrigger(
|
|
20028
|
+
async function getAppBackupsByTrigger(db2, params2) {
|
|
20184
20029
|
let backups = [];
|
|
20185
20030
|
try {
|
|
20186
20031
|
const queryIndex = db_exports.getQueryIndex(
|
|
20187
20032
|
db_exports.ViewName.APP_BACKUP_BY_TRIGGER
|
|
20188
20033
|
);
|
|
20189
|
-
backups = await
|
|
20034
|
+
backups = await db2.query(queryIndex, params2);
|
|
20190
20035
|
} catch (err) {
|
|
20191
20036
|
if (err != null && err.error === "not_found") {
|
|
20192
20037
|
await createAppBackupTriggerView();
|
|
20193
|
-
return getAppBackupsByTrigger(
|
|
20038
|
+
return getAppBackupsByTrigger(db2, params2);
|
|
20194
20039
|
} else {
|
|
20195
20040
|
throw err;
|
|
20196
20041
|
}
|
|
@@ -20201,7 +20046,7 @@ function generateAppBackupID(appId, timestamp) {
|
|
|
20201
20046
|
return `${APP_BACKUP_PREFIX2}${appId}${db_exports.SEPARATOR}${timestamp}`;
|
|
20202
20047
|
}
|
|
20203
20048
|
async function fetchAppBackups(appId, opts = {}) {
|
|
20204
|
-
const
|
|
20049
|
+
const db2 = tenancy.getGlobalDB();
|
|
20205
20050
|
let backups;
|
|
20206
20051
|
const pageSize = opts.limit || GENERIC_PAGE_SIZE;
|
|
20207
20052
|
const params2 = await getAppBackupParams(appId, opts, {
|
|
@@ -20212,9 +20057,9 @@ async function fetchAppBackups(appId, opts = {}) {
|
|
|
20212
20057
|
params2.startkey = opts.page;
|
|
20213
20058
|
}
|
|
20214
20059
|
if (!opts.trigger || !opts.type) {
|
|
20215
|
-
backups = await
|
|
20060
|
+
backups = await db2.allDocs(params2);
|
|
20216
20061
|
} else {
|
|
20217
|
-
backups = await getAppBackupsByTrigger(
|
|
20062
|
+
backups = await getAppBackupsByTrigger(db2, params2);
|
|
20218
20063
|
}
|
|
20219
20064
|
const pageData = pagination2(backups, {
|
|
20220
20065
|
paginate: opts.paginate,
|
|
@@ -20237,15 +20082,15 @@ async function fetchAppBackups(appId, opts = {}) {
|
|
|
20237
20082
|
}
|
|
20238
20083
|
return pageData;
|
|
20239
20084
|
}
|
|
20240
|
-
async function storeAppBackupMetadata(
|
|
20241
|
-
const
|
|
20242
|
-
const prodAppId = db_exports.getProdAppID(
|
|
20243
|
-
let _id = generateAppBackupID(prodAppId,
|
|
20085
|
+
async function storeAppBackupMetadata(metadata2, opts = {}) {
|
|
20086
|
+
const db2 = tenancy.getGlobalDB();
|
|
20087
|
+
const prodAppId = db_exports.getProdAppID(metadata2.appId);
|
|
20088
|
+
let _id = generateAppBackupID(prodAppId, metadata2.timestamp);
|
|
20244
20089
|
const appBackupDoc = {
|
|
20245
|
-
...
|
|
20090
|
+
...metadata2,
|
|
20246
20091
|
_id,
|
|
20247
20092
|
appId: prodAppId,
|
|
20248
|
-
name:
|
|
20093
|
+
name: metadata2.name
|
|
20249
20094
|
};
|
|
20250
20095
|
if (opts.filename) {
|
|
20251
20096
|
appBackupDoc.filename = opts.filename;
|
|
@@ -20254,27 +20099,27 @@ async function storeAppBackupMetadata(metadata, opts = {}) {
|
|
|
20254
20099
|
appBackupDoc._id = opts.docId;
|
|
20255
20100
|
appBackupDoc._rev = opts.docRev;
|
|
20256
20101
|
}
|
|
20257
|
-
if (
|
|
20102
|
+
if (metadata2.createdBy) {
|
|
20258
20103
|
appBackupDoc.createdBy = db_exports.getGlobalIDFromUserMetadataID(
|
|
20259
|
-
|
|
20104
|
+
metadata2.createdBy
|
|
20260
20105
|
);
|
|
20261
20106
|
}
|
|
20262
|
-
return await
|
|
20107
|
+
return await db2.put(appBackupDoc);
|
|
20263
20108
|
}
|
|
20264
|
-
async function updateAppBackupMetadata(backupId,
|
|
20265
|
-
const
|
|
20266
|
-
const
|
|
20267
|
-
|
|
20268
|
-
return await
|
|
20109
|
+
async function updateAppBackupMetadata(backupId, name2) {
|
|
20110
|
+
const db2 = tenancy.getGlobalDB();
|
|
20111
|
+
const metadata2 = await db2.get(backupId);
|
|
20112
|
+
metadata2.name = name2;
|
|
20113
|
+
return await db2.put(metadata2);
|
|
20269
20114
|
}
|
|
20270
20115
|
async function deleteAppBackupMetadata(backupId) {
|
|
20271
|
-
const
|
|
20272
|
-
const backupDoc = await
|
|
20273
|
-
await
|
|
20116
|
+
const db2 = tenancy.getGlobalDB();
|
|
20117
|
+
const backupDoc = await db2.get(backupId);
|
|
20118
|
+
await db2.remove(backupDoc._id, backupDoc._rev);
|
|
20274
20119
|
}
|
|
20275
20120
|
async function getAppBackupMetadata(backupId) {
|
|
20276
|
-
const
|
|
20277
|
-
return await
|
|
20121
|
+
const db2 = tenancy.getGlobalDB();
|
|
20122
|
+
return await db2.get(backupId);
|
|
20278
20123
|
}
|
|
20279
20124
|
|
|
20280
20125
|
// ../pro/packages/pro/src/db/environmentVariables.ts
|
|
@@ -20293,16 +20138,16 @@ var cache = new import_lru_cache.default({
|
|
|
20293
20138
|
function getEnvVarID() {
|
|
20294
20139
|
return StaticDatabases.GLOBAL.docs.environmentVariables;
|
|
20295
20140
|
}
|
|
20296
|
-
function getCacheEnvVarID(
|
|
20141
|
+
function getCacheEnvVarID(rev2) {
|
|
20297
20142
|
const tenantId = tenancy.getTenantId();
|
|
20298
|
-
return `${tenantId}/${getEnvVarID()}/${
|
|
20143
|
+
return `${tenantId}/${getEnvVarID()}/${rev2 || ""}`;
|
|
20299
20144
|
}
|
|
20300
20145
|
async function get6() {
|
|
20301
20146
|
const id = getEnvVarID();
|
|
20302
|
-
const
|
|
20147
|
+
const db2 = tenancy.getGlobalDB();
|
|
20303
20148
|
let encrypted, notFound = false;
|
|
20304
20149
|
try {
|
|
20305
|
-
encrypted = await
|
|
20150
|
+
encrypted = await db2.get(id);
|
|
20306
20151
|
} catch (err) {
|
|
20307
20152
|
if (err.status == 404) {
|
|
20308
20153
|
notFound = true;
|
|
@@ -20335,14 +20180,14 @@ async function get6() {
|
|
|
20335
20180
|
cache.set(cacheKey, finalDoc);
|
|
20336
20181
|
return finalDoc;
|
|
20337
20182
|
}
|
|
20338
|
-
async function update(
|
|
20183
|
+
async function update(doc2) {
|
|
20339
20184
|
const id = getEnvVarID();
|
|
20340
|
-
const
|
|
20341
|
-
return await
|
|
20342
|
-
_id:
|
|
20343
|
-
_rev:
|
|
20185
|
+
const db2 = tenancy.getGlobalDB();
|
|
20186
|
+
return await db2.put({
|
|
20187
|
+
_id: doc2._id || id,
|
|
20188
|
+
_rev: doc2._rev || void 0,
|
|
20344
20189
|
variables: encryption_exports.encrypt(
|
|
20345
|
-
JSON.stringify(
|
|
20190
|
+
JSON.stringify(doc2.variables),
|
|
20346
20191
|
encryption_exports.SecretOption.ENCRYPTION
|
|
20347
20192
|
)
|
|
20348
20193
|
});
|
|
@@ -20474,16 +20319,16 @@ __export(offline_exports, {
|
|
|
20474
20319
|
getOfflineLicense: () => getOfflineLicense,
|
|
20475
20320
|
writeOfflineLicenseToDisk: () => writeOfflineLicenseToDisk
|
|
20476
20321
|
});
|
|
20477
|
-
var
|
|
20478
|
-
var
|
|
20322
|
+
var import_fs9 = __toESM(require("fs"));
|
|
20323
|
+
var import_path10 = require("path");
|
|
20479
20324
|
var import_os2 = require("os");
|
|
20480
20325
|
var import_jsonwebtoken = __toESM(require("jsonwebtoken"));
|
|
20481
20326
|
var SUB_DIRECTORY = environment_default2.isTest() ? ".budibase-test" : ".budibase";
|
|
20482
|
-
var DIRECTORY = (0,
|
|
20327
|
+
var DIRECTORY = (0, import_path10.join)((0, import_os2.tmpdir)(), SUB_DIRECTORY);
|
|
20483
20328
|
var OFFLINE_LICENSE_FILE = "offline_license.txt";
|
|
20484
|
-
var LICENSE_FILE_PATH = (0,
|
|
20485
|
-
if (!
|
|
20486
|
-
|
|
20329
|
+
var LICENSE_FILE_PATH = (0, import_path10.join)(DIRECTORY, OFFLINE_LICENSE_FILE);
|
|
20330
|
+
if (!import_fs9.default.existsSync(DIRECTORY)) {
|
|
20331
|
+
import_fs9.default.mkdirSync(DIRECTORY);
|
|
20487
20332
|
}
|
|
20488
20333
|
var PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvz3jePLCFBXZ19c8Dpkv\nXtSgOhKFOcvQdo/LV0KJRUzQWDPWuO4ILtBtnqhjtIzZH4CH0qCYBet5L6Qr4CM1\nl2HXiAD1Q2rlHNW9wDaYyKb1F5f+v4RyqCAyzlkwRdksmkLeECTboojNnmRCrE3C\n8suunQP5bEScqEY2kclqzSf8e6xqMzPUg3mL/pNa1iEv7TuLbU9nJfgR36l0WmZY\n94fWnSaT8OSXSqcxsaByf06gfS3HAoTJNc7eqz1Hf9fUORQGPUAnFK8cT3SfdA36\nd/o3ZWE1TTj1zYwlCLN5qRKr3hU8nC3xEYNEbkB9SfTRaOq9Q7P8WmfLkoCPm3pR\nmwIDAQAB\n-----END PUBLIC KEY-----\n";
|
|
20489
20334
|
function getOfflineLicense() {
|
|
@@ -20494,16 +20339,16 @@ function getOfflineLicense() {
|
|
|
20494
20339
|
}
|
|
20495
20340
|
}
|
|
20496
20341
|
function getOfflineLicenseFromDisk() {
|
|
20497
|
-
if (
|
|
20498
|
-
const token =
|
|
20342
|
+
if (import_fs9.default.existsSync(LICENSE_FILE_PATH)) {
|
|
20343
|
+
const token = import_fs9.default.readFileSync(LICENSE_FILE_PATH, { encoding: "utf-8" });
|
|
20499
20344
|
return import_jsonwebtoken.default.verify(token, PUBLIC_KEY, { algorithms: ["RS256"] });
|
|
20500
20345
|
}
|
|
20501
20346
|
}
|
|
20502
20347
|
function writeOfflineLicenseToDisk(signedLicense) {
|
|
20503
|
-
|
|
20348
|
+
import_fs9.default.writeFileSync(LICENSE_FILE_PATH, signedLicense, { encoding: "utf-8" });
|
|
20504
20349
|
}
|
|
20505
20350
|
function deleteOfflineLicense() {
|
|
20506
|
-
|
|
20351
|
+
import_fs9.default.rmSync(LICENSE_FILE_PATH, { force: true });
|
|
20507
20352
|
}
|
|
20508
20353
|
|
|
20509
20354
|
// ../pro/packages/pro/src/sdk/licensing/licenses/licenses.ts
|
|
@@ -20706,14 +20551,14 @@ __export(quotas_exports4, {
|
|
|
20706
20551
|
|
|
20707
20552
|
// ../pro/packages/pro/src/sdk/quotas/quotas.ts
|
|
20708
20553
|
init_src();
|
|
20709
|
-
var increment = (
|
|
20710
|
-
return tryIncrement(1,
|
|
20554
|
+
var increment = (name2, type, opts) => {
|
|
20555
|
+
return tryIncrement(1, name2, type, opts);
|
|
20711
20556
|
};
|
|
20712
|
-
var incrementMany = (change,
|
|
20713
|
-
return tryIncrement(change,
|
|
20557
|
+
var incrementMany = (change, name2, type, opts) => {
|
|
20558
|
+
return tryIncrement(change, name2, type, opts);
|
|
20714
20559
|
};
|
|
20715
|
-
var tryIncrement = async (change,
|
|
20716
|
-
await updateUsage(change,
|
|
20560
|
+
var tryIncrement = async (change, name2, type, opts = {}) => {
|
|
20561
|
+
await updateUsage(change, name2, type, {
|
|
20717
20562
|
dryRun: true,
|
|
20718
20563
|
suppressErrorLog: opts.suppressErrorLog,
|
|
20719
20564
|
id: opts.id
|
|
@@ -20722,7 +20567,7 @@ var tryIncrement = async (change, name, type, opts = {}) => {
|
|
|
20722
20567
|
if (opts.fn) {
|
|
20723
20568
|
result = await opts.fn();
|
|
20724
20569
|
}
|
|
20725
|
-
await updateUsage(change,
|
|
20570
|
+
await updateUsage(change, name2, type, {
|
|
20726
20571
|
dryRun: false,
|
|
20727
20572
|
valueFn: opts.valueFn,
|
|
20728
20573
|
suppressErrorLog: opts.suppressErrorLog,
|
|
@@ -20730,32 +20575,32 @@ var tryIncrement = async (change, name, type, opts = {}) => {
|
|
|
20730
20575
|
});
|
|
20731
20576
|
return result;
|
|
20732
20577
|
};
|
|
20733
|
-
var decrement = (
|
|
20734
|
-
return updateUsage(-1,
|
|
20578
|
+
var decrement = (name2, type, opts = {}) => {
|
|
20579
|
+
return updateUsage(-1, name2, type, opts);
|
|
20735
20580
|
};
|
|
20736
|
-
var decrementMany = (change,
|
|
20737
|
-
return updateUsage(-change,
|
|
20581
|
+
var decrementMany = (change, name2, type, opts = {}) => {
|
|
20582
|
+
return updateUsage(-change, name2, type, opts);
|
|
20738
20583
|
};
|
|
20739
|
-
var set2 = async (
|
|
20740
|
-
return quotas_exports.setUsage(value,
|
|
20584
|
+
var set2 = async (name2, type, value) => {
|
|
20585
|
+
return quotas_exports.setUsage(value, name2, type);
|
|
20741
20586
|
};
|
|
20742
|
-
var getExistingTriggers = (type,
|
|
20587
|
+
var getExistingTriggers = (type, name2, quotaUsage) => {
|
|
20743
20588
|
if (type == "static" /* STATIC */) {
|
|
20744
20589
|
const triggers = quotaUsage.usageQuota.triggers;
|
|
20745
|
-
return triggers ? triggers[
|
|
20590
|
+
return triggers ? triggers[name2] || {} : {};
|
|
20746
20591
|
} else {
|
|
20747
20592
|
const currentMonthString = quotas_exports.utils.getCurrentMonthString();
|
|
20748
20593
|
const triggers = quotaUsage.monthly[currentMonthString].triggers;
|
|
20749
|
-
return triggers ? triggers[
|
|
20594
|
+
return triggers ? triggers[name2] || {} : {};
|
|
20750
20595
|
}
|
|
20751
20596
|
};
|
|
20752
|
-
var triggerQuota2 = async (
|
|
20597
|
+
var triggerQuota2 = async (name2, quota, percentage, resetDate) => {
|
|
20753
20598
|
try {
|
|
20754
20599
|
await redlockImpl_exports.doWithLock(
|
|
20755
20600
|
{
|
|
20756
20601
|
type: "try_once" /* TRY_ONCE */,
|
|
20757
20602
|
name: "trigger_quota" /* TRIGGER_QUOTA */,
|
|
20758
|
-
resource:
|
|
20603
|
+
resource: name2,
|
|
20759
20604
|
// use the quota name for extra uniqueness on the lock
|
|
20760
20605
|
ttl: 1e4
|
|
20761
20606
|
// auto expire after 10 seconds
|
|
@@ -20775,10 +20620,10 @@ var triggerQuota2 = async (name, quota, percentage, resetDate) => {
|
|
|
20775
20620
|
logging_exports.logAlert("Error triggering quota", e);
|
|
20776
20621
|
}
|
|
20777
20622
|
};
|
|
20778
|
-
var checkTriggers = async (type,
|
|
20623
|
+
var checkTriggers = async (type, name2, totalValue, quota) => {
|
|
20779
20624
|
const usage = await getQuotaUsage();
|
|
20780
20625
|
const resetDate = type === "monthly" /* MONTHLY */ ? usage.quotaReset : void 0;
|
|
20781
|
-
const triggers = await getExistingTriggers(type,
|
|
20626
|
+
const triggers = await getExistingTriggers(type, name2, usage);
|
|
20782
20627
|
const quotaTriggers = quota.triggers;
|
|
20783
20628
|
let percentage = totalValue / quota.value * 100;
|
|
20784
20629
|
if (percentage > 100) {
|
|
@@ -20794,7 +20639,7 @@ var checkTriggers = async (type, name, totalValue, quota) => {
|
|
|
20794
20639
|
const isAtTrigger = percentage === triggerPercentage;
|
|
20795
20640
|
const sendNotification = !nextIsTriggered || isAtTrigger;
|
|
20796
20641
|
if (sendNotification) {
|
|
20797
|
-
await triggerQuota2(
|
|
20642
|
+
await triggerQuota2(name2, quota, percentage, resetDate);
|
|
20798
20643
|
}
|
|
20799
20644
|
}
|
|
20800
20645
|
} else {
|
|
@@ -20803,23 +20648,23 @@ var checkTriggers = async (type, name, totalValue, quota) => {
|
|
|
20803
20648
|
}
|
|
20804
20649
|
return triggers;
|
|
20805
20650
|
};
|
|
20806
|
-
var updateUsage = async (usageChange,
|
|
20651
|
+
var updateUsage = async (usageChange, name2, type, opts = {}) => {
|
|
20807
20652
|
let appId = null;
|
|
20808
20653
|
try {
|
|
20809
20654
|
appId = context_exports.getAppId();
|
|
20810
20655
|
} catch (err) {
|
|
20811
20656
|
}
|
|
20812
|
-
const isAppQuota = APP_QUOTA_NAMES.includes(
|
|
20657
|
+
const isAppQuota = APP_QUOTA_NAMES.includes(name2);
|
|
20813
20658
|
if (isAppQuota && !appId) {
|
|
20814
20659
|
throw new Error("App context required for quota update");
|
|
20815
20660
|
}
|
|
20816
20661
|
try {
|
|
20817
|
-
const licensedQuota = await getLicensedQuota("usage" /* USAGE */,
|
|
20662
|
+
const licensedQuota = await getLicensedQuota("usage" /* USAGE */, name2, type);
|
|
20818
20663
|
let {
|
|
20819
20664
|
total: totalValue,
|
|
20820
20665
|
app: appValue,
|
|
20821
20666
|
breakdown: breakdownValue
|
|
20822
|
-
} = await quotas_exports.getCurrentUsageValues(type,
|
|
20667
|
+
} = await quotas_exports.getCurrentUsageValues(type, name2, opts.id);
|
|
20823
20668
|
totalValue += usageChange;
|
|
20824
20669
|
if (appValue != null) {
|
|
20825
20670
|
appValue += usageChange;
|
|
@@ -20829,7 +20674,7 @@ var updateUsage = async (usageChange, name, type, opts = {}) => {
|
|
|
20829
20674
|
}
|
|
20830
20675
|
let triggers = {};
|
|
20831
20676
|
if (!opts.dryRun) {
|
|
20832
|
-
triggers = await checkTriggers(type,
|
|
20677
|
+
triggers = await checkTriggers(type, name2, totalValue, licensedQuota);
|
|
20833
20678
|
}
|
|
20834
20679
|
if (licensedQuota.value !== quotas_exports2.UNLIMITED && totalValue > licensedQuota.value && usageChange > 0) {
|
|
20835
20680
|
throw new UsageLimitError(
|
|
@@ -20852,7 +20697,7 @@ var updateUsage = async (usageChange, name, type, opts = {}) => {
|
|
|
20852
20697
|
appValue = totalValue;
|
|
20853
20698
|
}
|
|
20854
20699
|
await quotas_exports.setAllUsage(
|
|
20855
|
-
|
|
20700
|
+
name2,
|
|
20856
20701
|
type,
|
|
20857
20702
|
{
|
|
20858
20703
|
total: totalValue,
|
|
@@ -20864,30 +20709,30 @@ var updateUsage = async (usageChange, name, type, opts = {}) => {
|
|
|
20864
20709
|
);
|
|
20865
20710
|
} catch (err) {
|
|
20866
20711
|
if (!opts.suppressErrorLog) {
|
|
20867
|
-
console.error(`Error updating usage quotas for ${
|
|
20712
|
+
console.error(`Error updating usage quotas for ${name2}`, err);
|
|
20868
20713
|
}
|
|
20869
20714
|
throw err;
|
|
20870
20715
|
}
|
|
20871
20716
|
};
|
|
20872
|
-
var getLicensedQuota = async (quotaType,
|
|
20717
|
+
var getLicensedQuota = async (quotaType, name2, usageType) => {
|
|
20873
20718
|
const license = await cache_exports2.getCachedLicense();
|
|
20874
20719
|
if (!license) {
|
|
20875
20720
|
const tenantId = tenancy.getTenantId();
|
|
20876
20721
|
throw new Error("License not found for tenant id " + tenantId);
|
|
20877
20722
|
}
|
|
20878
|
-
if (usageType && isStaticQuota(quotaType, usageType,
|
|
20879
|
-
return license.quotas[quotaType][usageType][
|
|
20880
|
-
} else if (usageType && isMonthlyQuota(quotaType, usageType,
|
|
20881
|
-
return license.quotas[quotaType][usageType][
|
|
20882
|
-
} else if (isConstantQuota(quotaType,
|
|
20883
|
-
return license.quotas[quotaType][
|
|
20723
|
+
if (usageType && isStaticQuota(quotaType, usageType, name2)) {
|
|
20724
|
+
return license.quotas[quotaType][usageType][name2];
|
|
20725
|
+
} else if (usageType && isMonthlyQuota(quotaType, usageType, name2)) {
|
|
20726
|
+
return license.quotas[quotaType][usageType][name2];
|
|
20727
|
+
} else if (isConstantQuota(quotaType, name2)) {
|
|
20728
|
+
return license.quotas[quotaType][name2];
|
|
20884
20729
|
} else {
|
|
20885
20730
|
throw new Error("Invalid quota type");
|
|
20886
20731
|
}
|
|
20887
20732
|
};
|
|
20888
|
-
var usageLimitIsExceeded = async (
|
|
20733
|
+
var usageLimitIsExceeded = async (name2, type) => {
|
|
20889
20734
|
try {
|
|
20890
|
-
await updateUsage(1,
|
|
20735
|
+
await updateUsage(1, name2, type, { dryRun: true });
|
|
20891
20736
|
return false;
|
|
20892
20737
|
} catch (e) {
|
|
20893
20738
|
if (e.code === "usage_limit_exceeded" /* USAGE_LIMIT_EXCEEDED */) {
|
|
@@ -21001,19 +20846,19 @@ async function recordDayPassOnQuotas() {
|
|
|
21001
20846
|
});
|
|
21002
20847
|
}
|
|
21003
20848
|
async function recordDayPassTimeOnUser(user) {
|
|
21004
|
-
const
|
|
21005
|
-
let dbUser = await
|
|
20849
|
+
const db2 = tenancy.getGlobalDB();
|
|
20850
|
+
let dbUser = await db2.get(user._id);
|
|
21006
20851
|
const now = /* @__PURE__ */ new Date();
|
|
21007
20852
|
const nowString = (/* @__PURE__ */ new Date()).toISOString();
|
|
21008
20853
|
user.dayPassRecordedAt = nowString;
|
|
21009
20854
|
dbUser.dayPassRecordedAt = nowString;
|
|
21010
20855
|
try {
|
|
21011
20856
|
console.log(`Recording day pass for user=${user._id}`);
|
|
21012
|
-
await
|
|
20857
|
+
await db2.put(dbUser);
|
|
21013
20858
|
} catch (e) {
|
|
21014
20859
|
if (e.status === 409) {
|
|
21015
20860
|
console.warn(`Conflict recording day pass for user=${user._id}`);
|
|
21016
|
-
dbUser = await
|
|
20861
|
+
dbUser = await db2.get(user._id);
|
|
21017
20862
|
if (!dbUser.dayPassRecordedAt || new Date(dbUser.dayPassRecordedAt).getDay() !== now.getDay()) {
|
|
21018
20863
|
console.error(`Day pass not recorded for user=${user._id}`);
|
|
21019
20864
|
throw e;
|
|
@@ -21262,9 +21107,9 @@ function generateAutomationLogID(isoDate, status2, automationId) {
|
|
|
21262
21107
|
return `${DocumentType5.AUTOMATION_LOG}${SEPARATOR7}${isoDate}${SEPARATOR7}${automationId}${SEPARATOR7}${status2}`;
|
|
21263
21108
|
}
|
|
21264
21109
|
async function getAllLogs(startDate, endDate, opts = { docs: true }) {
|
|
21265
|
-
let
|
|
21266
|
-
if (!await
|
|
21267
|
-
|
|
21110
|
+
let db2 = context_exports.getProdAppDB();
|
|
21111
|
+
if (!await db2.exists()) {
|
|
21112
|
+
db2 = context_exports.getDevAppDB();
|
|
21268
21113
|
}
|
|
21269
21114
|
let optional = { status: opts.status };
|
|
21270
21115
|
let limit = (opts == null ? void 0 : opts.limit) ? opts.limit : (opts == null ? void 0 : opts.paginate) ? GENERIC_PAGE_SIZE + 1 : void 0;
|
|
@@ -21275,16 +21120,16 @@ async function getAllLogs(startDate, endDate, opts = { docs: true }) {
|
|
|
21275
21120
|
if (opts == null ? void 0 : opts.page) {
|
|
21276
21121
|
params2.startkey = opts.page;
|
|
21277
21122
|
}
|
|
21278
|
-
let response = await
|
|
21123
|
+
let response = await db2.allDocs(params2);
|
|
21279
21124
|
return pagination2(response, {
|
|
21280
21125
|
paginate: opts == null ? void 0 : opts.paginate,
|
|
21281
21126
|
pageSize: GENERIC_PAGE_SIZE
|
|
21282
21127
|
});
|
|
21283
21128
|
}
|
|
21284
21129
|
async function getLogsByView(startDate, endDate, viewParams = {}) {
|
|
21285
|
-
let
|
|
21286
|
-
if (!await
|
|
21287
|
-
|
|
21130
|
+
let db2 = context_exports.getProdAppDB();
|
|
21131
|
+
if (!await db2.exists()) {
|
|
21132
|
+
db2 = context_exports.getDevAppDB();
|
|
21288
21133
|
}
|
|
21289
21134
|
let response;
|
|
21290
21135
|
try {
|
|
@@ -21299,7 +21144,7 @@ async function getLogsByView(startDate, endDate, viewParams = {}) {
|
|
|
21299
21144
|
if (viewParams == null ? void 0 : viewParams.page) {
|
|
21300
21145
|
params2.startkey = viewParams.page;
|
|
21301
21146
|
}
|
|
21302
|
-
response = await
|
|
21147
|
+
response = await db2.query(getQueryIndex3(ViewName6.AUTOMATION_LOGS), params2);
|
|
21303
21148
|
} catch (err) {
|
|
21304
21149
|
if (err != null && (err.name === "not_found" || err.error === "not_found")) {
|
|
21305
21150
|
await createLogByAutomationView();
|
|
@@ -21311,9 +21156,9 @@ async function getLogsByView(startDate, endDate, viewParams = {}) {
|
|
|
21311
21156
|
return pagination2(response);
|
|
21312
21157
|
}
|
|
21313
21158
|
async function writeLog(automation, results) {
|
|
21314
|
-
const
|
|
21159
|
+
const db2 = context_exports.getProdAppDB();
|
|
21315
21160
|
const automationId = automation._id;
|
|
21316
|
-
const
|
|
21161
|
+
const name2 = automation.name;
|
|
21317
21162
|
const status2 = getStatus(results);
|
|
21318
21163
|
const isoDate = (/* @__PURE__ */ new Date()).toISOString();
|
|
21319
21164
|
const id = generateAutomationLogID(isoDate, status2, automationId);
|
|
@@ -21322,23 +21167,23 @@ async function writeLog(automation, results) {
|
|
|
21322
21167
|
...results,
|
|
21323
21168
|
automationId,
|
|
21324
21169
|
status: status2,
|
|
21325
|
-
automationName:
|
|
21170
|
+
automationName: name2,
|
|
21326
21171
|
createdAt: isoDate,
|
|
21327
21172
|
_id: id
|
|
21328
21173
|
};
|
|
21329
|
-
await
|
|
21174
|
+
await db2.put(log);
|
|
21330
21175
|
return id;
|
|
21331
21176
|
}
|
|
21332
21177
|
async function updateAppMetadataWithErrors(logIds, { clearing } = { clearing: false }) {
|
|
21333
|
-
const
|
|
21178
|
+
const db2 = context_exports.getProdAppDB();
|
|
21334
21179
|
await backOff(async () => {
|
|
21335
|
-
const
|
|
21180
|
+
const metadata2 = await db2.get(db_exports.DocumentType.APP_METADATA);
|
|
21336
21181
|
for (let logId of logIds) {
|
|
21337
21182
|
const parts = logId.split(db_exports.SEPARATOR);
|
|
21338
21183
|
const autoId = `${parts[parts.length - 3]}${db_exports.SEPARATOR}${parts[parts.length - 2]}`;
|
|
21339
21184
|
let errors = {};
|
|
21340
|
-
if (
|
|
21341
|
-
errors =
|
|
21185
|
+
if (metadata2.automationErrors) {
|
|
21186
|
+
errors = metadata2.automationErrors;
|
|
21342
21187
|
}
|
|
21343
21188
|
if (!Array.isArray(errors[autoId])) {
|
|
21344
21189
|
errors[autoId] = [];
|
|
@@ -21352,10 +21197,10 @@ async function updateAppMetadataWithErrors(logIds, { clearing } = { clearing: fa
|
|
|
21352
21197
|
if (errors[autoId].length === 0) {
|
|
21353
21198
|
delete errors[autoId];
|
|
21354
21199
|
}
|
|
21355
|
-
|
|
21200
|
+
metadata2.automationErrors = errors;
|
|
21356
21201
|
}
|
|
21357
|
-
await
|
|
21358
|
-
await cache_exports.app.invalidateAppMetadata(
|
|
21202
|
+
await db2.put(metadata2);
|
|
21203
|
+
await cache_exports.app.invalidateAppMetadata(metadata2.appId, metadata2);
|
|
21359
21204
|
}, "Failed to update app metadata with automation log error");
|
|
21360
21205
|
}
|
|
21361
21206
|
async function getExpiredLogs() {
|
|
@@ -21371,29 +21216,29 @@ async function getExpiredLogs() {
|
|
|
21371
21216
|
}
|
|
21372
21217
|
}
|
|
21373
21218
|
async function clearOldHistory() {
|
|
21374
|
-
const
|
|
21219
|
+
const db2 = context_exports.getProdAppDB();
|
|
21375
21220
|
try {
|
|
21376
21221
|
const expired = await getExpiredLogs();
|
|
21377
21222
|
if (!expired.data || expired.data.length === 0) {
|
|
21378
21223
|
return;
|
|
21379
21224
|
}
|
|
21380
|
-
const toDelete = expired.data.map((
|
|
21381
|
-
_id:
|
|
21382
|
-
_rev:
|
|
21225
|
+
const toDelete = expired.data.map((doc2) => ({
|
|
21226
|
+
_id: doc2.id,
|
|
21227
|
+
_rev: doc2.value.rev,
|
|
21383
21228
|
_deleted: true
|
|
21384
21229
|
}));
|
|
21385
|
-
const errorLogIds = expired.data.filter((
|
|
21386
|
-
const parts =
|
|
21230
|
+
const errorLogIds = expired.data.filter((doc2) => {
|
|
21231
|
+
const parts = doc2.id.split(db_exports.SEPARATOR);
|
|
21387
21232
|
const status2 = parts[parts.length - 1];
|
|
21388
21233
|
return status2 === "error" /* ERROR */;
|
|
21389
|
-
}).map((
|
|
21390
|
-
await
|
|
21234
|
+
}).map((doc2) => doc2.id);
|
|
21235
|
+
await db2.bulkDocs(toDelete);
|
|
21391
21236
|
if (errorLogIds.length) {
|
|
21392
21237
|
await updateAppMetadataWithErrors(errorLogIds, { clearing: true });
|
|
21393
21238
|
}
|
|
21394
21239
|
} catch (err) {
|
|
21395
21240
|
logging_exports.logAlert(
|
|
21396
|
-
`Failed to cleanup automation log history - Database "${
|
|
21241
|
+
`Failed to cleanup automation log history - Database "${db2.name}"`,
|
|
21397
21242
|
err
|
|
21398
21243
|
);
|
|
21399
21244
|
}
|
|
@@ -21566,10 +21411,10 @@ async function get7(id) {
|
|
|
21566
21411
|
async function getBulk2(ids, opts = { enriched: true }) {
|
|
21567
21412
|
return await groups_exports.getBulk(ids, opts);
|
|
21568
21413
|
}
|
|
21569
|
-
async function guardNameAvailility(
|
|
21570
|
-
const existingGroup = await groups_exports.getByName(
|
|
21414
|
+
async function guardNameAvailility(name2) {
|
|
21415
|
+
const existingGroup = await groups_exports.getByName(name2);
|
|
21571
21416
|
if (existingGroup) {
|
|
21572
|
-
throw new GroupNameUnavailableError(
|
|
21417
|
+
throw new GroupNameUnavailableError(name2);
|
|
21573
21418
|
}
|
|
21574
21419
|
}
|
|
21575
21420
|
async function save4(group) {
|
|
@@ -21708,16 +21553,16 @@ __export(plugins_exports, {
|
|
|
21708
21553
|
init_src();
|
|
21709
21554
|
|
|
21710
21555
|
// ../pro/packages/pro/src/utilities/fileSystem.ts
|
|
21711
|
-
var
|
|
21712
|
-
var
|
|
21713
|
-
function loadJSFile(
|
|
21714
|
-
return
|
|
21556
|
+
var import_fs10 = __toESM(require("fs"));
|
|
21557
|
+
var import_path11 = require("path");
|
|
21558
|
+
function loadJSFile(directory2, name2) {
|
|
21559
|
+
return import_fs10.default.readFileSync((0, import_path11.join)(directory2, name2), "utf8");
|
|
21715
21560
|
}
|
|
21716
21561
|
|
|
21717
21562
|
// ../pro/packages/pro/src/sdk/plugins/index.ts
|
|
21718
21563
|
async function storePlugin(metadata, directory, source) {
|
|
21719
21564
|
const db = tenancy.getGlobalDB();
|
|
21720
|
-
const version = metadata.package.version, name = metadata.package.name, description = metadata.package.description,
|
|
21565
|
+
const version = metadata.package.version, name = metadata.package.name, description = metadata.package.description, hash = metadata.schema.hash;
|
|
21721
21566
|
const bucketPath = objectStore_exports2.getPluginS3Dir(name);
|
|
21722
21567
|
const files = await objectStore_exports2.uploadDirectory(
|
|
21723
21568
|
objectStore_exports2.ObjectStoreBuckets.PLUGINS,
|
|
@@ -21732,8 +21577,7 @@ async function storePlugin(metadata, directory, source) {
|
|
|
21732
21577
|
if (metadata.schema.type === "datasource" /* DATASOURCE */) {
|
|
21733
21578
|
const js = loadJSFile(directory, jsFile.name);
|
|
21734
21579
|
try {
|
|
21735
|
-
;
|
|
21736
|
-
(0, eval)(js);
|
|
21580
|
+
eval(js);
|
|
21737
21581
|
} catch (err) {
|
|
21738
21582
|
const message = (err == null ? void 0 : err.message) ? err.message : JSON.stringify(err);
|
|
21739
21583
|
throw new Error(`JS invalid: ${message}`);
|
|
@@ -21754,7 +21598,7 @@ async function storePlugin(metadata, directory, source) {
|
|
|
21754
21598
|
...metadata,
|
|
21755
21599
|
name,
|
|
21756
21600
|
version,
|
|
21757
|
-
hash
|
|
21601
|
+
hash,
|
|
21758
21602
|
description
|
|
21759
21603
|
};
|
|
21760
21604
|
if (iconFileName) {
|
|
@@ -21766,7 +21610,7 @@ async function storePlugin(metadata, directory, source) {
|
|
|
21766
21610
|
source
|
|
21767
21611
|
};
|
|
21768
21612
|
}
|
|
21769
|
-
const
|
|
21613
|
+
const write = async () => {
|
|
21770
21614
|
const response = await db.put(doc);
|
|
21771
21615
|
await events_exports.plugin.imported(doc);
|
|
21772
21616
|
return {
|
|
@@ -21775,21 +21619,21 @@ async function storePlugin(metadata, directory, source) {
|
|
|
21775
21619
|
};
|
|
21776
21620
|
};
|
|
21777
21621
|
if (!rev) {
|
|
21778
|
-
return await addPlugin(
|
|
21622
|
+
return await addPlugin(write);
|
|
21779
21623
|
} else {
|
|
21780
|
-
return await
|
|
21624
|
+
return await write();
|
|
21781
21625
|
}
|
|
21782
21626
|
}
|
|
21783
|
-
async function deletePlugin(
|
|
21784
|
-
const
|
|
21627
|
+
async function deletePlugin(pluginId2) {
|
|
21628
|
+
const db2 = tenancy.getGlobalDB();
|
|
21785
21629
|
try {
|
|
21786
|
-
const plugin = await
|
|
21787
|
-
const
|
|
21630
|
+
const plugin = await db2.get(pluginId2);
|
|
21631
|
+
const bucketPath2 = objectStore_exports2.getPluginS3Dir(plugin.name);
|
|
21788
21632
|
await objectStore_exports2.deleteFolder(
|
|
21789
21633
|
objectStore_exports2.ObjectStoreBuckets.PLUGINS,
|
|
21790
|
-
|
|
21634
|
+
bucketPath2
|
|
21791
21635
|
);
|
|
21792
|
-
await
|
|
21636
|
+
await db2.remove(pluginId2, plugin._rev);
|
|
21793
21637
|
await events_exports.plugin.deleted(plugin);
|
|
21794
21638
|
await removePlugin();
|
|
21795
21639
|
} catch (err) {
|
|
@@ -21798,9 +21642,9 @@ async function deletePlugin(pluginId) {
|
|
|
21798
21642
|
}
|
|
21799
21643
|
}
|
|
21800
21644
|
async function checkPluginQuotas() {
|
|
21801
|
-
const
|
|
21645
|
+
const db2 = tenancy.getGlobalDB();
|
|
21802
21646
|
try {
|
|
21803
|
-
const allPlugins = await
|
|
21647
|
+
const allPlugins = await db2.allDocs(db_exports.getPluginParams());
|
|
21804
21648
|
const pluginCount = allPlugins.rows.length;
|
|
21805
21649
|
console.log(`Syncing plugin count: ${pluginCount}`);
|
|
21806
21650
|
await updatePluginCount(pluginCount);
|
|
@@ -21826,12 +21670,12 @@ function isEncryptionKeyAvailable() {
|
|
|
21826
21670
|
return !!environment_default2.ENCRYPTION_KEY;
|
|
21827
21671
|
}
|
|
21828
21672
|
async function fetch13() {
|
|
21829
|
-
const
|
|
21830
|
-
return Object.keys(
|
|
21673
|
+
const doc2 = await environmentVariables_exports.get();
|
|
21674
|
+
return Object.keys(doc2.variables);
|
|
21831
21675
|
}
|
|
21832
21676
|
async function fetchValues(environment3) {
|
|
21833
|
-
const
|
|
21834
|
-
const decrypted =
|
|
21677
|
+
const doc2 = await environmentVariables_exports.get();
|
|
21678
|
+
const decrypted = doc2.variables;
|
|
21835
21679
|
const output = {};
|
|
21836
21680
|
for (let [key, value] of Object.entries(decrypted)) {
|
|
21837
21681
|
switch (environment3) {
|
|
@@ -21853,9 +21697,9 @@ async function changeValues(cb) {
|
|
|
21853
21697
|
"User does not have access to environment variables feature."
|
|
21854
21698
|
);
|
|
21855
21699
|
}
|
|
21856
|
-
const
|
|
21857
|
-
|
|
21858
|
-
await environmentVariables_exports.update(
|
|
21700
|
+
const doc2 = await environmentVariables_exports.get();
|
|
21701
|
+
doc2.variables = cb(doc2.variables);
|
|
21702
|
+
await environmentVariables_exports.update(doc2);
|
|
21859
21703
|
}
|
|
21860
21704
|
async function update2(varName, value) {
|
|
21861
21705
|
const checkName = isValid(varName);
|
|
@@ -21884,7 +21728,7 @@ __export(auditLogs_exports2, {
|
|
|
21884
21728
|
definitions: () => definitions,
|
|
21885
21729
|
download: () => download,
|
|
21886
21730
|
fetch: () => fetch14,
|
|
21887
|
-
write: () =>
|
|
21731
|
+
write: () => write2
|
|
21888
21732
|
});
|
|
21889
21733
|
|
|
21890
21734
|
// ../pro/packages/pro/src/sdk/auditLogs/auditLogs.ts
|
|
@@ -21896,15 +21740,15 @@ var MemoryStream2 = require("memorystream");
|
|
|
21896
21740
|
function generateAuditLogID(timestamp) {
|
|
21897
21741
|
return `${"al" /* AUDIT_LOG */}${SEPARATOR}${timestamp}${SEPARATOR}${utils_exports2.newid()}`;
|
|
21898
21742
|
}
|
|
21899
|
-
async function save5(
|
|
21900
|
-
if (!
|
|
21901
|
-
|
|
21743
|
+
async function save5(doc2) {
|
|
21744
|
+
if (!doc2._id) {
|
|
21745
|
+
doc2._id = generateAuditLogID(doc2.timestamp);
|
|
21902
21746
|
}
|
|
21903
21747
|
try {
|
|
21904
|
-
const
|
|
21905
|
-
const response = await
|
|
21748
|
+
const db2 = context_exports.getAuditLogsDB();
|
|
21749
|
+
const response = await db2.put(doc2);
|
|
21906
21750
|
return {
|
|
21907
|
-
...
|
|
21751
|
+
...doc2,
|
|
21908
21752
|
_rev: response.rev
|
|
21909
21753
|
};
|
|
21910
21754
|
} catch (err) {
|
|
@@ -21929,12 +21773,12 @@ async function search(search3, bookmark) {
|
|
|
21929
21773
|
);
|
|
21930
21774
|
}
|
|
21931
21775
|
function dump(params2) {
|
|
21932
|
-
const
|
|
21776
|
+
const db2 = context_exports.getAuditLogsDB();
|
|
21933
21777
|
const stream3 = new MemoryStream2();
|
|
21934
|
-
const promise =
|
|
21935
|
-
filter: (
|
|
21778
|
+
const promise = db2.dump(stream3, {
|
|
21779
|
+
filter: (doc2) => {
|
|
21936
21780
|
var _a;
|
|
21937
|
-
const auditLog =
|
|
21781
|
+
const auditLog = doc2;
|
|
21938
21782
|
if (!((_a = auditLog._id) == null ? void 0 : _a.startsWith("al" /* AUDIT_LOG */))) {
|
|
21939
21783
|
return false;
|
|
21940
21784
|
}
|
|
@@ -21952,7 +21796,7 @@ function dump(params2) {
|
|
|
21952
21796
|
allMatched = allMatched && auditLog.timestamp >= params2.startDate && auditLog.timestamp <= params2.endDate;
|
|
21953
21797
|
}
|
|
21954
21798
|
if (params2.fullSearch) {
|
|
21955
|
-
const json = JSON.stringify(
|
|
21799
|
+
const json = JSON.stringify(doc2);
|
|
21956
21800
|
allMatched = allMatched && json.includes(params2.fullSearch);
|
|
21957
21801
|
}
|
|
21958
21802
|
return allMatched;
|
|
@@ -21963,8 +21807,8 @@ function dump(params2) {
|
|
|
21963
21807
|
const json = JSON.parse(Buffer.from(data).toString());
|
|
21964
21808
|
if (Array.isArray(json.docs)) {
|
|
21965
21809
|
let str = "";
|
|
21966
|
-
for (let
|
|
21967
|
-
str += JSON.stringify(
|
|
21810
|
+
for (let doc2 of json.docs) {
|
|
21811
|
+
str += JSON.stringify(doc2) + "\n";
|
|
21968
21812
|
}
|
|
21969
21813
|
returnStream.write(str);
|
|
21970
21814
|
}
|
|
@@ -22070,12 +21914,12 @@ async function auditLogsEnabled() {
|
|
|
22070
21914
|
const license = await licensing_exports.cache.getCachedLicense();
|
|
22071
21915
|
return license.features.includes("auditLogs" /* AUDIT_LOGS */);
|
|
22072
21916
|
}
|
|
22073
|
-
function getEventFriendlyName(event,
|
|
21917
|
+
function getEventFriendlyName(event, metadata2) {
|
|
22074
21918
|
const friendly = AuditedEventFriendlyName[event];
|
|
22075
21919
|
if (!friendly) {
|
|
22076
21920
|
throw new Error("No friendly name found.");
|
|
22077
21921
|
}
|
|
22078
|
-
let processed = processStringSync(friendly,
|
|
21922
|
+
let processed = processStringSync(friendly, metadata2);
|
|
22079
21923
|
if (processed.includes(`""`)) {
|
|
22080
21924
|
processed = removeTemplateStrings(friendly);
|
|
22081
21925
|
}
|
|
@@ -22083,29 +21927,29 @@ function getEventFriendlyName(event, metadata) {
|
|
|
22083
21927
|
}
|
|
22084
21928
|
|
|
22085
21929
|
// ../pro/packages/pro/src/sdk/auditLogs/auditLogs.ts
|
|
22086
|
-
async function
|
|
21930
|
+
async function write2(event, metadata2, opts) {
|
|
22087
21931
|
if (!await auditLogsEnabled() || !utils_exports2.isAudited(event)) {
|
|
22088
21932
|
return;
|
|
22089
21933
|
}
|
|
22090
|
-
const friendly = getEventFriendlyName(event,
|
|
21934
|
+
const friendly = getEventFriendlyName(event, metadata2);
|
|
22091
21935
|
let date = /* @__PURE__ */ new Date();
|
|
22092
21936
|
if (opts == null ? void 0 : opts.timestamp) {
|
|
22093
21937
|
date = new Date(opts.timestamp);
|
|
22094
21938
|
}
|
|
22095
|
-
const
|
|
21939
|
+
const doc2 = {
|
|
22096
21940
|
timestamp: date.toISOString(),
|
|
22097
21941
|
event,
|
|
22098
21942
|
name: friendly,
|
|
22099
21943
|
userId: (opts == null ? void 0 : opts.userId) || AuditLogSystemUser,
|
|
22100
21944
|
metadata: {
|
|
22101
|
-
...
|
|
21945
|
+
...metadata2,
|
|
22102
21946
|
...opts == null ? void 0 : opts.hostInfo
|
|
22103
21947
|
}
|
|
22104
21948
|
};
|
|
22105
21949
|
const fallback = {};
|
|
22106
21950
|
try {
|
|
22107
21951
|
if (opts == null ? void 0 : opts.appId) {
|
|
22108
|
-
|
|
21952
|
+
doc2.appId = db_exports.getProdAppID(opts.appId);
|
|
22109
21953
|
const appMetadata = await cache_exports.app.getAppMetadata(opts.appId);
|
|
22110
21954
|
fallback.appName = appMetadata.name;
|
|
22111
21955
|
}
|
|
@@ -22119,8 +21963,8 @@ async function write(event, metadata, opts) {
|
|
|
22119
21963
|
err
|
|
22120
21964
|
);
|
|
22121
21965
|
}
|
|
22122
|
-
|
|
22123
|
-
return await save5(
|
|
21966
|
+
doc2.fallback = fallback;
|
|
21967
|
+
return await save5(doc2);
|
|
22124
21968
|
}
|
|
22125
21969
|
async function enrich(logs) {
|
|
22126
21970
|
const allUserIds = logs.map((log) => log.userId);
|
|
@@ -22191,8 +22035,8 @@ function getBackupQueue() {
|
|
|
22191
22035
|
}
|
|
22192
22036
|
|
|
22193
22037
|
// ../pro/packages/pro/src/sdk/backups/backup.ts
|
|
22194
|
-
async function storeAppBackupMetadata2(
|
|
22195
|
-
return backups_exports.storeAppBackupMetadata(
|
|
22038
|
+
async function storeAppBackupMetadata2(metadata2, opts = {}) {
|
|
22039
|
+
return backups_exports.storeAppBackupMetadata(metadata2, opts);
|
|
22196
22040
|
}
|
|
22197
22041
|
function getTimestamps(status2) {
|
|
22198
22042
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -22206,7 +22050,7 @@ function getTimestamps(status2) {
|
|
|
22206
22050
|
return { timestamp, createdAt: timestamp };
|
|
22207
22051
|
}
|
|
22208
22052
|
}
|
|
22209
|
-
async function updateBackupStatus(id,
|
|
22053
|
+
async function updateBackupStatus(id, rev2, status2, contents, filename) {
|
|
22210
22054
|
const backup = await getAppBackup(id);
|
|
22211
22055
|
return await backups_exports.storeAppBackupMetadata(
|
|
22212
22056
|
{
|
|
@@ -22216,10 +22060,10 @@ async function updateBackupStatus(id, rev, status2, contents, filename) {
|
|
|
22216
22060
|
status: status2,
|
|
22217
22061
|
type: "backup" /* BACKUP */
|
|
22218
22062
|
},
|
|
22219
|
-
{ filename, docId: id, docRev:
|
|
22063
|
+
{ filename, docId: id, docRev: rev2 }
|
|
22220
22064
|
);
|
|
22221
22065
|
}
|
|
22222
|
-
async function updateRestoreStatus(id,
|
|
22066
|
+
async function updateRestoreStatus(id, rev2, status2) {
|
|
22223
22067
|
const restore = await getAppBackup(id);
|
|
22224
22068
|
return await backups_exports.storeAppBackupMetadata(
|
|
22225
22069
|
{
|
|
@@ -22229,7 +22073,7 @@ async function updateRestoreStatus(id, rev, status2) {
|
|
|
22229
22073
|
type: "restore" /* RESTORE */,
|
|
22230
22074
|
trigger: "manual" /* MANUAL */
|
|
22231
22075
|
},
|
|
22232
|
-
{ docId: id, docRev:
|
|
22076
|
+
{ docId: id, docRev: rev2 }
|
|
22233
22077
|
);
|
|
22234
22078
|
}
|
|
22235
22079
|
async function getAppBackup(backupId) {
|
|
@@ -22239,11 +22083,11 @@ async function updateAppBackup(backupId, backupName) {
|
|
|
22239
22083
|
return backups_exports.updateAppBackupMetadata(backupId, backupName);
|
|
22240
22084
|
}
|
|
22241
22085
|
async function deleteAppBackup(backupId) {
|
|
22242
|
-
const
|
|
22243
|
-
if (
|
|
22086
|
+
const metadata2 = await backups_exports.getAppBackupMetadata(backupId);
|
|
22087
|
+
if (metadata2.filename) {
|
|
22244
22088
|
await objectStore_exports2.deleteFile(
|
|
22245
22089
|
objectStore_exports2.ObjectStoreBuckets.BACKUPS,
|
|
22246
|
-
|
|
22090
|
+
metadata2.filename
|
|
22247
22091
|
);
|
|
22248
22092
|
}
|
|
22249
22093
|
return backups_exports.deleteAppBackupMetadata(backupId);
|
|
@@ -22252,15 +22096,15 @@ async function fetchAppBackups2(appId, opts) {
|
|
|
22252
22096
|
return backups_exports.fetchAppBackups(appId, opts);
|
|
22253
22097
|
}
|
|
22254
22098
|
async function downloadAppBackup(backupId) {
|
|
22255
|
-
const
|
|
22256
|
-
if (!
|
|
22099
|
+
const metadata2 = await backups_exports.getAppBackupMetadata(backupId);
|
|
22100
|
+
if (!metadata2.filename) {
|
|
22257
22101
|
throw new Error("Backup incomplete - cannot download.");
|
|
22258
22102
|
}
|
|
22259
22103
|
const path2 = await objectStore_exports2.retrieveToTmp(
|
|
22260
22104
|
objectStore_exports2.ObjectStoreBuckets.BACKUPS,
|
|
22261
|
-
|
|
22105
|
+
metadata2.filename
|
|
22262
22106
|
);
|
|
22263
|
-
return { metadata, path: path2 };
|
|
22107
|
+
return { metadata: metadata2, path: path2 };
|
|
22264
22108
|
}
|
|
22265
22109
|
async function triggerAppBackup(appId, trigger, opts = {}) {
|
|
22266
22110
|
let backup;
|
|
@@ -22299,7 +22143,7 @@ async function triggerAppBackup(appId, trigger, opts = {}) {
|
|
|
22299
22143
|
return backup.id;
|
|
22300
22144
|
}
|
|
22301
22145
|
async function triggerAppRestore(appId, backupId, nameForBackup, createdBy) {
|
|
22302
|
-
const
|
|
22146
|
+
const metadata2 = await getAppBackup(backupId);
|
|
22303
22147
|
let restore;
|
|
22304
22148
|
try {
|
|
22305
22149
|
restore = await storeAppBackupMetadata2({
|
|
@@ -22326,7 +22170,7 @@ async function triggerAppRestore(appId, backupId, nameForBackup, createdBy) {
|
|
|
22326
22170
|
createdBy
|
|
22327
22171
|
}
|
|
22328
22172
|
});
|
|
22329
|
-
return { restoreId: restore.id, metadata };
|
|
22173
|
+
return { restoreId: restore.id, metadata: metadata2 };
|
|
22330
22174
|
}
|
|
22331
22175
|
var pkg = {
|
|
22332
22176
|
isEnabled: isBackupsEnabled,
|
|
@@ -22349,7 +22193,7 @@ __export(processing_exports, {
|
|
|
22349
22193
|
init: () => init12
|
|
22350
22194
|
});
|
|
22351
22195
|
init_src();
|
|
22352
|
-
var
|
|
22196
|
+
var import_fs11 = __toESM(require("fs"));
|
|
22353
22197
|
async function init12(opts) {
|
|
22354
22198
|
await getBackupQueue().process(async (job) => {
|
|
22355
22199
|
const data = job.data;
|
|
@@ -22417,8 +22261,8 @@ async function runBackup(trigger, tenantId, appId, opts) {
|
|
|
22417
22261
|
}
|
|
22418
22262
|
});
|
|
22419
22263
|
await updateMetadata("complete" /* COMPLETE */, { filename, contents });
|
|
22420
|
-
if (
|
|
22421
|
-
|
|
22264
|
+
if (import_fs11.default.existsSync(tarPath)) {
|
|
22265
|
+
import_fs11.default.rmSync(tarPath);
|
|
22422
22266
|
}
|
|
22423
22267
|
} catch (err) {
|
|
22424
22268
|
logging_exports.logAlert("App backup error", err);
|
|
@@ -22431,7 +22275,7 @@ async function importProcessor(job, opts) {
|
|
|
22431
22275
|
const tenantId = tenancy.getTenantIDFromAppID(appId);
|
|
22432
22276
|
return tenancy.doInTenant(tenantId, async () => {
|
|
22433
22277
|
const devAppId = db_exports.getDevAppID(appId);
|
|
22434
|
-
const { rev } = await backup_default2.updateRestoreStatus(
|
|
22278
|
+
const { rev: rev2 } = await backup_default2.updateRestoreStatus(
|
|
22435
22279
|
data.docId,
|
|
22436
22280
|
data.docRev,
|
|
22437
22281
|
"started" /* STARTED */
|
|
@@ -22456,23 +22300,23 @@ async function importProcessor(job, opts) {
|
|
|
22456
22300
|
logging_exports.logAlert("App restore error", err);
|
|
22457
22301
|
status2 = "failed" /* FAILED */;
|
|
22458
22302
|
}
|
|
22459
|
-
await backup_default2.updateRestoreStatus(data.docId,
|
|
22303
|
+
await backup_default2.updateRestoreStatus(data.docId, rev2, status2);
|
|
22460
22304
|
});
|
|
22461
22305
|
}
|
|
22462
22306
|
async function exportProcessor(job, opts) {
|
|
22463
22307
|
const data = job.data;
|
|
22464
|
-
const appId = data.appId, trigger = data.export.trigger,
|
|
22308
|
+
const appId = data.appId, trigger = data.export.trigger, name2 = data.export.name;
|
|
22465
22309
|
const tenantId = tenancy.getTenantIDFromAppID(appId);
|
|
22466
22310
|
await tenancy.doInTenant(tenantId, async () => {
|
|
22467
|
-
const { rev } = await backup_default2.updateBackupStatus(
|
|
22311
|
+
const { rev: rev2 } = await backup_default2.updateBackupStatus(
|
|
22468
22312
|
data.docId,
|
|
22469
22313
|
data.docRev,
|
|
22470
22314
|
"started" /* STARTED */
|
|
22471
22315
|
);
|
|
22472
22316
|
return runBackup(trigger, tenantId, appId, {
|
|
22473
22317
|
processing: opts,
|
|
22474
|
-
doc: { id: data.docId, rev },
|
|
22475
|
-
name
|
|
22318
|
+
doc: { id: data.docId, rev: rev2 },
|
|
22319
|
+
name: name2
|
|
22476
22320
|
});
|
|
22477
22321
|
});
|
|
22478
22322
|
}
|
|
@@ -22519,8 +22363,8 @@ var ScimUserService = class {
|
|
|
22519
22363
|
constructor(config) {
|
|
22520
22364
|
this.get = async (params2) => {
|
|
22521
22365
|
var _a;
|
|
22522
|
-
const
|
|
22523
|
-
const builder2 = new db_exports.QueryBuilder(
|
|
22366
|
+
const db2 = tenancy.getGlobalDB();
|
|
22367
|
+
const builder2 = new db_exports.QueryBuilder(db2.name, "user" /* USER */);
|
|
22524
22368
|
builder2.setIndexBuilder(db_exports.searchIndexes.createUserIndex);
|
|
22525
22369
|
builder2.setLimit(params2.pageSize);
|
|
22526
22370
|
builder2.addEqual("scimInfo.isSync", true);
|
|
@@ -22656,9 +22500,9 @@ var fetch15 = async (ctx) => {
|
|
|
22656
22500
|
ctx.body = { data: await fetch12() };
|
|
22657
22501
|
};
|
|
22658
22502
|
var destroy4 = async (ctx) => {
|
|
22659
|
-
const { id, rev } = ctx.params;
|
|
22503
|
+
const { id, rev: rev2 } = ctx.params;
|
|
22660
22504
|
try {
|
|
22661
|
-
await remove2(id,
|
|
22505
|
+
await remove2(id, rev2);
|
|
22662
22506
|
ctx.body = { message: "Group deleted successfully" };
|
|
22663
22507
|
} catch (err) {
|
|
22664
22508
|
ctx.throw(err.status, err);
|
|
@@ -22703,13 +22547,13 @@ async function fetch16(ctx) {
|
|
|
22703
22547
|
};
|
|
22704
22548
|
}
|
|
22705
22549
|
async function create3(ctx) {
|
|
22706
|
-
const { name, production, development } = ctx.request.body;
|
|
22707
|
-
await environmentVariables_exports2.update(
|
|
22550
|
+
const { name: name2, production, development } = ctx.request.body;
|
|
22551
|
+
await environmentVariables_exports2.update(name2, { production, development });
|
|
22708
22552
|
const environments = ["production" /* PRODUCTION */];
|
|
22709
22553
|
if (production !== development) {
|
|
22710
22554
|
environments.push("development" /* DEVELOPMENT */);
|
|
22711
22555
|
}
|
|
22712
|
-
await events_exports.environmentVariable.created(
|
|
22556
|
+
await events_exports.environmentVariable.created(name2, environments);
|
|
22713
22557
|
ctx.status = 200;
|
|
22714
22558
|
}
|
|
22715
22559
|
async function update4(ctx) {
|
|
@@ -22871,7 +22715,7 @@ router3.post(
|
|
|
22871
22715
|
|
|
22872
22716
|
// ../pro/packages/pro/src/api/controllers/apps/backups.ts
|
|
22873
22717
|
init_src();
|
|
22874
|
-
var
|
|
22718
|
+
var import_fs12 = __toESM(require("fs"));
|
|
22875
22719
|
async function checkAppID(ctx, appId) {
|
|
22876
22720
|
if (!await utils_exports5.appExists(appId)) {
|
|
22877
22721
|
ctx.throw(400, `Provided app ID: ${appId} - is invalid.`);
|
|
@@ -22955,9 +22799,9 @@ async function downloadBackup(ctx) {
|
|
|
22955
22799
|
const appId = ctx.params.appId;
|
|
22956
22800
|
await checkAppID(ctx, appId);
|
|
22957
22801
|
const backupId = ctx.params.backupId;
|
|
22958
|
-
const { metadata, path: path2 } = await backups_default2.downloadAppBackup(backupId);
|
|
22959
|
-
ctx.attachment(`backup-${
|
|
22960
|
-
ctx.body =
|
|
22802
|
+
const { metadata: metadata2, path: path2 } = await backups_default2.downloadAppBackup(backupId);
|
|
22803
|
+
ctx.attachment(`backup-${metadata2.timestamp}.tar.gz`);
|
|
22804
|
+
ctx.body = import_fs12.default.createReadStream(path2);
|
|
22961
22805
|
}
|
|
22962
22806
|
|
|
22963
22807
|
// ../pro/packages/pro/src/api/routes/apps/backups.ts
|
|
@@ -23072,8 +22916,8 @@ var import_router6 = __toESM(require("@koa/router"));
|
|
|
23072
22916
|
|
|
23073
22917
|
// ../pro/packages/pro/src/api/controllers/global/scim/users.ts
|
|
23074
22918
|
var import_scim_patch = require("scim-patch");
|
|
23075
|
-
function tryGetQueryAsNumber(ctx,
|
|
23076
|
-
const value = ctx.request.query[
|
|
22919
|
+
function tryGetQueryAsNumber(ctx, name2) {
|
|
22920
|
+
const value = ctx.request.query[name2];
|
|
23077
22921
|
if (value === void 0) {
|
|
23078
22922
|
return void 0;
|
|
23079
22923
|
}
|
|
@@ -23619,11 +23463,11 @@ var datasources_default = {
|
|
|
23619
23463
|
};
|
|
23620
23464
|
|
|
23621
23465
|
// src/sdk/app/tables/index.ts
|
|
23622
|
-
async function getAllInternalTables(
|
|
23623
|
-
if (!
|
|
23624
|
-
|
|
23466
|
+
async function getAllInternalTables(db2) {
|
|
23467
|
+
if (!db2) {
|
|
23468
|
+
db2 = context_exports.getAppDB();
|
|
23625
23469
|
}
|
|
23626
|
-
const internalTables = await
|
|
23470
|
+
const internalTables = await db2.allDocs(
|
|
23627
23471
|
getTableParams(null, {
|
|
23628
23472
|
include_docs: true
|
|
23629
23473
|
})
|
|
@@ -23635,7 +23479,7 @@ async function getAllInternalTables(db) {
|
|
|
23635
23479
|
}));
|
|
23636
23480
|
}
|
|
23637
23481
|
async function getAllExternalTables(datasourceId) {
|
|
23638
|
-
const
|
|
23482
|
+
const db2 = context_exports.getAppDB();
|
|
23639
23483
|
const datasource2 = await datasources_default.get(datasourceId, { enriched: true });
|
|
23640
23484
|
if (!datasource2 || !datasource2.entities) {
|
|
23641
23485
|
throw "Datasource is not configured fully.";
|
|
@@ -23647,14 +23491,14 @@ async function getExternalTable(datasourceId, tableName) {
|
|
|
23647
23491
|
return entities[tableName];
|
|
23648
23492
|
}
|
|
23649
23493
|
async function getTable(tableId) {
|
|
23650
|
-
const
|
|
23494
|
+
const db2 = context_exports.getAppDB();
|
|
23651
23495
|
if (isExternalTable(tableId)) {
|
|
23652
23496
|
let { datasourceId, tableName } = breakExternalTableId(tableId);
|
|
23653
23497
|
const datasource2 = await datasources_default.get(datasourceId);
|
|
23654
23498
|
const table = await getExternalTable(datasourceId, tableName);
|
|
23655
23499
|
return { ...table, sql: isSQL(datasource2) };
|
|
23656
23500
|
} else {
|
|
23657
|
-
return
|
|
23501
|
+
return db2.get(tableId);
|
|
23658
23502
|
}
|
|
23659
23503
|
}
|
|
23660
23504
|
var tables_default = {
|
|
@@ -23674,10 +23518,10 @@ __export(webhook_exports, {
|
|
|
23674
23518
|
function isWebhookID(id) {
|
|
23675
23519
|
return id.startsWith(db_exports.DocumentType.WEBHOOK);
|
|
23676
23520
|
}
|
|
23677
|
-
function newDoc(
|
|
23521
|
+
function newDoc(name2, type, target) {
|
|
23678
23522
|
return {
|
|
23679
23523
|
live: true,
|
|
23680
|
-
name,
|
|
23524
|
+
name: name2,
|
|
23681
23525
|
action: {
|
|
23682
23526
|
type,
|
|
23683
23527
|
target
|
|
@@ -23685,22 +23529,22 @@ function newDoc(name, type, target) {
|
|
|
23685
23529
|
};
|
|
23686
23530
|
}
|
|
23687
23531
|
async function save7(webhook) {
|
|
23688
|
-
const
|
|
23532
|
+
const db2 = context_exports.getAppDB();
|
|
23689
23533
|
if (webhook._id && isWebhookID(webhook._id)) {
|
|
23690
|
-
await
|
|
23534
|
+
await db2.get(webhook._id);
|
|
23691
23535
|
} else {
|
|
23692
23536
|
webhook._id = generateWebhookID();
|
|
23693
23537
|
}
|
|
23694
|
-
const response = await
|
|
23538
|
+
const response = await db2.put(webhook);
|
|
23695
23539
|
webhook._rev = response.rev;
|
|
23696
23540
|
return webhook;
|
|
23697
23541
|
}
|
|
23698
|
-
async function destroy6(id,
|
|
23699
|
-
const
|
|
23542
|
+
async function destroy6(id, rev2) {
|
|
23543
|
+
const db2 = context_exports.getAppDB();
|
|
23700
23544
|
if (!id || !isWebhookID(id)) {
|
|
23701
23545
|
throw new Error("Provided webhook ID is not valid.");
|
|
23702
23546
|
}
|
|
23703
|
-
return await
|
|
23547
|
+
return await db2.remove(id, rev2);
|
|
23704
23548
|
}
|
|
23705
23549
|
|
|
23706
23550
|
// src/sdk/app/automations/utils.ts
|
|
@@ -23780,14 +23624,14 @@ async function processUser(user, opts = {}) {
|
|
|
23780
23624
|
}
|
|
23781
23625
|
async function getGlobalUsers(userIds, opts) {
|
|
23782
23626
|
const appId = context_exports.getAppId();
|
|
23783
|
-
const
|
|
23627
|
+
const db2 = tenancy.getGlobalDB();
|
|
23784
23628
|
let globalUsers;
|
|
23785
23629
|
if (userIds) {
|
|
23786
|
-
globalUsers = (await
|
|
23630
|
+
globalUsers = (await db2.allDocs(getMultiIDParams(userIds))).rows.map(
|
|
23787
23631
|
(row) => row.doc
|
|
23788
23632
|
);
|
|
23789
23633
|
} else {
|
|
23790
|
-
globalUsers = (await
|
|
23634
|
+
globalUsers = (await db2.allDocs(
|
|
23791
23635
|
db_exports.getGlobalUserParams(null, {
|
|
23792
23636
|
include_docs: true
|
|
23793
23637
|
})
|
|
@@ -23814,7 +23658,7 @@ async function syncUsersToApp(appId, users2, groups) {
|
|
|
23814
23658
|
return;
|
|
23815
23659
|
}
|
|
23816
23660
|
await context_exports.doInAppContext(appId, async () => {
|
|
23817
|
-
const
|
|
23661
|
+
const db2 = context_exports.getAppDB();
|
|
23818
23662
|
for (let user of users2) {
|
|
23819
23663
|
let ctxUser = user;
|
|
23820
23664
|
let deletedUser = false;
|
|
@@ -23829,9 +23673,9 @@ async function syncUsersToApp(appId, users2, groups) {
|
|
|
23829
23673
|
if (roleId === roles_exports.BUILTIN_ROLE_IDS.PUBLIC) {
|
|
23830
23674
|
roleId = void 0;
|
|
23831
23675
|
}
|
|
23832
|
-
let
|
|
23676
|
+
let metadata2;
|
|
23833
23677
|
try {
|
|
23834
|
-
|
|
23678
|
+
metadata2 = await db2.get(metadataId);
|
|
23835
23679
|
} catch (err) {
|
|
23836
23680
|
if (err.status !== 404) {
|
|
23837
23681
|
throw err;
|
|
@@ -23839,21 +23683,21 @@ async function syncUsersToApp(appId, users2, groups) {
|
|
|
23839
23683
|
if (!roleId) {
|
|
23840
23684
|
continue;
|
|
23841
23685
|
} else if (!deletedUser) {
|
|
23842
|
-
|
|
23686
|
+
metadata2 = {
|
|
23843
23687
|
tableId: InternalTables.USER_METADATA
|
|
23844
23688
|
};
|
|
23845
23689
|
}
|
|
23846
23690
|
}
|
|
23847
23691
|
if (deletedUser || !roleId) {
|
|
23848
|
-
await
|
|
23692
|
+
await db2.remove(metadata2);
|
|
23849
23693
|
continue;
|
|
23850
23694
|
}
|
|
23851
23695
|
if (roleId) {
|
|
23852
|
-
|
|
23696
|
+
metadata2.roleId = roleId;
|
|
23853
23697
|
}
|
|
23854
|
-
let combined = sdk_default.users.combineMetadataAndUser(ctxUser,
|
|
23698
|
+
let combined = sdk_default.users.combineMetadataAndUser(ctxUser, metadata2);
|
|
23855
23699
|
if (combined) {
|
|
23856
|
-
await
|
|
23700
|
+
await db2.put(combined);
|
|
23857
23701
|
}
|
|
23858
23702
|
}
|
|
23859
23703
|
});
|
|
@@ -23908,7 +23752,7 @@ async function syncApp(appId, opts) {
|
|
|
23908
23752
|
try {
|
|
23909
23753
|
const replOpts = replication.appReplicateOpts();
|
|
23910
23754
|
if (opts == null ? void 0 : opts.automationOnly) {
|
|
23911
|
-
replOpts.filter = (
|
|
23755
|
+
replOpts.filter = (doc2) => doc2._id.startsWith(db_exports.DocumentType.AUTOMATION);
|
|
23912
23756
|
}
|
|
23913
23757
|
await replication.replicate(replOpts);
|
|
23914
23758
|
} catch (err) {
|
|
@@ -24021,7 +23865,7 @@ function generateAttachmentFindParams(tableId, attachmentCols, bookmark) {
|
|
|
24021
23865
|
return params2;
|
|
24022
23866
|
}
|
|
24023
23867
|
async function getRowsWithAttachments(appId, table) {
|
|
24024
|
-
const
|
|
23868
|
+
const db2 = db_exports.getDB(appId);
|
|
24025
23869
|
const attachmentCols = [];
|
|
24026
23870
|
for (let [key, column] of Object.entries(table.schema)) {
|
|
24027
23871
|
if (column.type === "attachment" /* ATTACHMENT */) {
|
|
@@ -24038,7 +23882,7 @@ async function getRowsWithAttachments(appId, table) {
|
|
|
24038
23882
|
attachmentCols,
|
|
24039
23883
|
bookmark
|
|
24040
23884
|
);
|
|
24041
|
-
const resp = await db_exports.directCouchFind(
|
|
23885
|
+
const resp = await db_exports.directCouchFind(db2.name, params2);
|
|
24042
23886
|
bookmark = resp.bookmark;
|
|
24043
23887
|
rowsLength = resp.rows.length;
|
|
24044
23888
|
const rows2 = resp.rows;
|
|
@@ -24053,13 +23897,13 @@ __export(rows_exports, {
|
|
|
24053
23897
|
getAllInternalRows: () => getAllInternalRows
|
|
24054
23898
|
});
|
|
24055
23899
|
async function getAllInternalRows(appId) {
|
|
24056
|
-
let
|
|
23900
|
+
let db2;
|
|
24057
23901
|
if (appId) {
|
|
24058
|
-
|
|
23902
|
+
db2 = db_exports.getDB(appId);
|
|
24059
23903
|
} else {
|
|
24060
|
-
|
|
23904
|
+
db2 = context_exports.getAppDB();
|
|
24061
23905
|
}
|
|
24062
|
-
const response = await
|
|
23906
|
+
const response = await db2.allDocs(
|
|
24063
23907
|
getRowParams2(null, null, {
|
|
24064
23908
|
include_docs: true
|
|
24065
23909
|
})
|
|
@@ -24081,9 +23925,9 @@ __export(utils_exports8, {
|
|
|
24081
23925
|
syncGlobalUsers: () => syncGlobalUsers
|
|
24082
23926
|
});
|
|
24083
23927
|
var import_lodash5 = require("lodash");
|
|
24084
|
-
function combineMetadataAndUser(user,
|
|
23928
|
+
function combineMetadataAndUser(user, metadata2) {
|
|
24085
23929
|
const metadataId = generateUserMetadataID2(user._id);
|
|
24086
|
-
const found = Array.isArray(
|
|
23930
|
+
const found = Array.isArray(metadata2) ? metadata2.find((doc2) => doc2._id === metadataId) : metadata2;
|
|
24087
23931
|
if (user.roleId == null || user.roleId === roles_exports.BUILTIN_ROLE_IDS.PUBLIC) {
|
|
24088
23932
|
if (found == null ? void 0 : found._id) {
|
|
24089
23933
|
return { ...found, _deleted: true };
|
|
@@ -24110,11 +23954,11 @@ function combineMetadataAndUser(user, metadata) {
|
|
|
24110
23954
|
}
|
|
24111
23955
|
return null;
|
|
24112
23956
|
}
|
|
24113
|
-
async function rawUserMetadata(
|
|
24114
|
-
if (!
|
|
24115
|
-
|
|
23957
|
+
async function rawUserMetadata(db2) {
|
|
23958
|
+
if (!db2) {
|
|
23959
|
+
db2 = context_exports.getAppDB();
|
|
24116
23960
|
}
|
|
24117
|
-
return (await
|
|
23961
|
+
return (await db2.allDocs(
|
|
24118
23962
|
getUserMetadataParams2(null, {
|
|
24119
23963
|
include_docs: true
|
|
24120
23964
|
})
|
|
@@ -24122,22 +23966,22 @@ async function rawUserMetadata(db) {
|
|
|
24122
23966
|
}
|
|
24123
23967
|
async function syncGlobalUsers() {
|
|
24124
23968
|
const dbs = [context_exports.getDevAppDB(), context_exports.getProdAppDB()];
|
|
24125
|
-
for (let
|
|
24126
|
-
if (!await
|
|
23969
|
+
for (let db2 of dbs) {
|
|
23970
|
+
if (!await db2.exists()) {
|
|
24127
23971
|
continue;
|
|
24128
23972
|
}
|
|
24129
|
-
const resp = await Promise.all([getGlobalUsers(), rawUserMetadata(
|
|
23973
|
+
const resp = await Promise.all([getGlobalUsers(), rawUserMetadata(db2)]);
|
|
24130
23974
|
const users2 = resp[0];
|
|
24131
|
-
const
|
|
23975
|
+
const metadata2 = resp[1];
|
|
24132
23976
|
const toWrite = [];
|
|
24133
23977
|
for (let user of users2) {
|
|
24134
|
-
const combined = combineMetadataAndUser(user,
|
|
23978
|
+
const combined = combineMetadataAndUser(user, metadata2);
|
|
24135
23979
|
if (combined) {
|
|
24136
23980
|
toWrite.push(combined);
|
|
24137
23981
|
}
|
|
24138
23982
|
}
|
|
24139
23983
|
let foundEmails = [];
|
|
24140
|
-
for (let data of
|
|
23984
|
+
for (let data of metadata2) {
|
|
24141
23985
|
if (!data._id) {
|
|
24142
23986
|
continue;
|
|
24143
23987
|
}
|
|
@@ -24150,7 +23994,7 @@ async function syncGlobalUsers() {
|
|
|
24150
23994
|
foundEmails.push(data.email);
|
|
24151
23995
|
}
|
|
24152
23996
|
}
|
|
24153
|
-
await
|
|
23997
|
+
await db2.bulkDocs(toWrite);
|
|
24154
23998
|
}
|
|
24155
23999
|
}
|
|
24156
24000
|
|
|
@@ -24211,8 +24055,8 @@ var clientAppSocket;
|
|
|
24211
24055
|
|
|
24212
24056
|
// src/sdk/plugins/plugins.ts
|
|
24213
24057
|
async function fetch17(type) {
|
|
24214
|
-
const
|
|
24215
|
-
const response = await
|
|
24058
|
+
const db2 = tenancy.getGlobalDB();
|
|
24059
|
+
const response = await db2.allDocs(
|
|
24216
24060
|
db_exports.getPluginParams(null, {
|
|
24217
24061
|
include_docs: true
|
|
24218
24062
|
})
|
|
@@ -24228,16 +24072,16 @@ async function fetch17(type) {
|
|
|
24228
24072
|
return plugins2;
|
|
24229
24073
|
}
|
|
24230
24074
|
}
|
|
24231
|
-
async function processUploaded(plugin,
|
|
24075
|
+
async function processUploaded(plugin, source2) {
|
|
24232
24076
|
var _a, _b;
|
|
24233
|
-
const { metadata, directory } = await fileUpload(plugin);
|
|
24234
|
-
plugin_exports.validate(
|
|
24235
|
-
if (!environment_default.SELF_HOSTED && ((_a =
|
|
24077
|
+
const { metadata: metadata2, directory: directory2 } = await fileUpload(plugin);
|
|
24078
|
+
plugin_exports.validate(metadata2 == null ? void 0 : metadata2.schema);
|
|
24079
|
+
if (!environment_default.SELF_HOSTED && ((_a = metadata2 == null ? void 0 : metadata2.schema) == null ? void 0 : _a.type) !== "component" /* COMPONENT */) {
|
|
24236
24080
|
throw new Error("Only component plugins are supported outside of self-host");
|
|
24237
24081
|
}
|
|
24238
|
-
const
|
|
24239
|
-
(_b = clientAppSocket) == null ? void 0 : _b.emit("plugin-update", { name:
|
|
24240
|
-
return
|
|
24082
|
+
const doc2 = await sdk_exports.plugins.storePlugin(metadata2, directory2, source2);
|
|
24083
|
+
(_b = clientAppSocket) == null ? void 0 : _b.emit("plugin-update", { name: doc2.name, hash: doc2.hash });
|
|
24084
|
+
return doc2;
|
|
24241
24085
|
}
|
|
24242
24086
|
|
|
24243
24087
|
// src/sdk/plugins/index.ts
|
|
@@ -24301,13 +24145,13 @@ if (process.arch && !process.arch.startsWith("arm") && oracle_default.integratio
|
|
|
24301
24145
|
DEFINITIONS2["ORACLE" /* ORACLE */] = oracle_default.schema;
|
|
24302
24146
|
INTEGRATIONS["ORACLE" /* ORACLE */] = oracle_default.integration;
|
|
24303
24147
|
}
|
|
24304
|
-
async function getDefinition(
|
|
24305
|
-
const definition = DEFINITIONS2[
|
|
24148
|
+
async function getDefinition(source2) {
|
|
24149
|
+
const definition = DEFINITIONS2[source2];
|
|
24306
24150
|
if (definition) {
|
|
24307
24151
|
return definition;
|
|
24308
24152
|
}
|
|
24309
24153
|
const allDefinitions = await getDefinitions();
|
|
24310
|
-
return allDefinitions[
|
|
24154
|
+
return allDefinitions[source2];
|
|
24311
24155
|
}
|
|
24312
24156
|
async function getDefinitions() {
|
|
24313
24157
|
const pluginSchemas = {};
|
|
@@ -24510,8 +24354,8 @@ var QueryRunner = class {
|
|
|
24510
24354
|
return { rows: rows2, keys: keys2, info, extra, pagination: pagination3 };
|
|
24511
24355
|
}
|
|
24512
24356
|
async runAnotherQuery(queryId, parameters) {
|
|
24513
|
-
const
|
|
24514
|
-
const query = await
|
|
24357
|
+
const db2 = context_exports.getAppDB();
|
|
24358
|
+
const query = await db2.get(queryId);
|
|
24515
24359
|
const datasource2 = await sdk_default.datasources.get(query.datasourceId, {
|
|
24516
24360
|
enriched: true
|
|
24517
24361
|
});
|
|
@@ -24553,14 +24397,14 @@ var QueryRunner = class {
|
|
|
24553
24397
|
}
|
|
24554
24398
|
async getDynamicVariable(variable) {
|
|
24555
24399
|
let { parameters } = this;
|
|
24556
|
-
const queryId = variable.queryId,
|
|
24557
|
-
let value = await utils_default.checkCacheForDynamicVariable(queryId,
|
|
24400
|
+
const queryId = variable.queryId, name2 = variable.name;
|
|
24401
|
+
let value = await utils_default.checkCacheForDynamicVariable(queryId, name2);
|
|
24558
24402
|
if (!value) {
|
|
24559
24403
|
value = this.queryResponse[queryId] ? this.queryResponse[queryId] : await this.runAnotherQuery(queryId, parameters);
|
|
24560
24404
|
this.queryResponse[queryId] = value;
|
|
24561
|
-
await utils_default.storeDynamicVariable(queryId,
|
|
24405
|
+
await utils_default.storeDynamicVariable(queryId, name2, value);
|
|
24562
24406
|
} else {
|
|
24563
|
-
this.cachedVariables.push({ queryId, name });
|
|
24407
|
+
this.cachedVariables.push({ queryId, name: name2 });
|
|
24564
24408
|
}
|
|
24565
24409
|
return value;
|
|
24566
24410
|
}
|