@niledatabase/server 3.0.0-alpha.27 → 3.0.0-alpha.28
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/dist/api/utils/routes/apiRoutes.d.ts +4 -1
- package/dist/api/utils/routes/makeRestUrl.d.ts +1 -1
- package/dist/server.cjs.development.js +23 -11
- package/dist/server.cjs.development.js.map +1 -1
- package/dist/server.cjs.production.min.js +1 -1
- package/dist/server.cjs.production.min.js.map +1 -1
- package/dist/server.esm.js +23 -11
- package/dist/server.esm.js.map +1 -1
- package/package.json +2 -2
|
@@ -3,7 +3,10 @@ type ApiRouteKeys = keyof typeof apiRoutes;
|
|
|
3
3
|
export type ApiRoutePaths = (typeof apiRoutes)[ApiRouteKeys];
|
|
4
4
|
export declare const apiRoutes: (config: Config) => {
|
|
5
5
|
ME: string;
|
|
6
|
-
USERS: (
|
|
6
|
+
USERS: (qp: {
|
|
7
|
+
tenantId?: null | string;
|
|
8
|
+
newTenantName?: null | string;
|
|
9
|
+
}) => string;
|
|
7
10
|
USER: (userId: string) => string;
|
|
8
11
|
TENANTS: string;
|
|
9
12
|
TENANT: (tenantId: string) => string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Config } from '../../../utils/Config';
|
|
2
|
-
export declare function makeRestUrl(config: Config, path: string, qp?: Record<string, string>): string;
|
|
2
|
+
export declare function makeRestUrl(config: Config, path: string, qp?: Record<string, string | null>): string;
|
|
@@ -1217,22 +1217,30 @@ var DBManager = /*#__PURE__*/function () {
|
|
|
1217
1217
|
}();
|
|
1218
1218
|
|
|
1219
1219
|
var NILEDB_API_URL = process.env.NILEDB_API_URL;
|
|
1220
|
+
function filterNullUndefined(obj) {
|
|
1221
|
+
if (!obj) {
|
|
1222
|
+
return undefined;
|
|
1223
|
+
}
|
|
1224
|
+
return Object.fromEntries(Object.entries(obj).filter(function (_ref) {
|
|
1225
|
+
var value = _ref[1];
|
|
1226
|
+
return value !== null && value !== undefined;
|
|
1227
|
+
}));
|
|
1228
|
+
}
|
|
1220
1229
|
function makeRestUrl(config, path, qp) {
|
|
1221
1230
|
var url = config.api.basePath || NILEDB_API_URL;
|
|
1222
1231
|
if (!url) {
|
|
1223
1232
|
throw new Error('An API url is required. Set it via NILEDB_API_URL. Was auto configuration run?');
|
|
1224
1233
|
}
|
|
1225
|
-
var params = new URLSearchParams(qp);
|
|
1226
|
-
|
|
1234
|
+
var params = new URLSearchParams(filterNullUndefined(qp));
|
|
1235
|
+
var strParams = params.toString();
|
|
1236
|
+
return "" + [url, path.substring(1, path.length)].join('/') + (strParams ? "?" + strParams : '');
|
|
1227
1237
|
}
|
|
1228
1238
|
|
|
1229
1239
|
var apiRoutes = function apiRoutes(config) {
|
|
1230
1240
|
return {
|
|
1231
1241
|
ME: makeRestUrl(config, '/me'),
|
|
1232
|
-
USERS: function USERS(
|
|
1233
|
-
return makeRestUrl(config, '/users',
|
|
1234
|
-
tenantId: tenantId
|
|
1235
|
-
} : undefined);
|
|
1242
|
+
USERS: function USERS(qp) {
|
|
1243
|
+
return makeRestUrl(config, '/users', qp);
|
|
1236
1244
|
},
|
|
1237
1245
|
USER: function USER(userId) {
|
|
1238
1246
|
return makeRestUrl(config, "/users/" + userId);
|
|
@@ -1781,7 +1789,7 @@ function POST$2(_x, _x2) {
|
|
|
1781
1789
|
}
|
|
1782
1790
|
function _POST$2() {
|
|
1783
1791
|
_POST$2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(config, init) {
|
|
1784
|
-
var yurl, tenantId, tenant, url;
|
|
1792
|
+
var yurl, tenantId, newTenantName, tenant, url;
|
|
1785
1793
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1786
1794
|
while (1) switch (_context.prev = _context.next) {
|
|
1787
1795
|
case 0:
|
|
@@ -1789,13 +1797,17 @@ function _POST$2() {
|
|
|
1789
1797
|
init.method = 'POST';
|
|
1790
1798
|
yurl = new URL(init.request.url);
|
|
1791
1799
|
tenantId = yurl.searchParams.get('tenantId');
|
|
1800
|
+
newTenantName = yurl.searchParams.get('newTenantName');
|
|
1792
1801
|
tenant = tenantId != null ? tenantId : getTenantFromHttp(init.request.headers);
|
|
1793
|
-
url = apiRoutes(config).USERS(
|
|
1794
|
-
|
|
1802
|
+
url = apiRoutes(config).USERS({
|
|
1803
|
+
tenantId: tenant,
|
|
1804
|
+
newTenantName: newTenantName
|
|
1805
|
+
});
|
|
1806
|
+
_context.next = 9;
|
|
1795
1807
|
return request(url, init, config);
|
|
1796
|
-
case 8:
|
|
1797
|
-
return _context.abrupt("return", _context.sent);
|
|
1798
1808
|
case 9:
|
|
1809
|
+
return _context.abrupt("return", _context.sent);
|
|
1810
|
+
case 10:
|
|
1799
1811
|
case "end":
|
|
1800
1812
|
return _context.stop();
|
|
1801
1813
|
}
|