@niledatabase/server 2.4.2-alpha.4 → 3.0.0-alpha.0
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/Server.d.ts +17 -4
- package/dist/api/handlers/DELETE.d.ts +3 -0
- package/dist/api/handlers/GET.d.ts +3 -0
- package/dist/api/handlers/POST.d.ts +3 -0
- package/dist/api/handlers/PUT.d.ts +3 -0
- package/dist/api/handlers/index.d.ts +8 -0
- package/dist/api/routes/auth/callback.d.ts +3 -0
- package/dist/api/routes/auth/csrf.d.ts +3 -0
- package/dist/api/routes/auth/error.d.ts +3 -0
- package/dist/api/routes/auth/index.d.ts +7 -0
- package/dist/api/routes/auth/providers.d.ts +3 -0
- package/dist/api/routes/auth/session.d.ts +3 -0
- package/dist/api/routes/auth/signin.d.ts +33 -0
- package/dist/api/routes/auth/signout.d.ts +3 -0
- package/dist/api/routes/me/index.d.ts +4 -0
- package/dist/api/routes/tenants/GET.d.ts +32 -0
- package/dist/api/routes/tenants/POST.d.ts +45 -0
- package/dist/api/routes/tenants/[tenantId]/DELETE.d.ts +34 -0
- package/dist/api/routes/tenants/[tenantId]/users/GET.d.ts +35 -0
- package/dist/api/routes/tenants/[tenantId]/users/POST.d.ts +44 -0
- package/dist/api/routes/tenants/[tenantId]/users/PUT.d.ts +30 -0
- package/dist/api/routes/tenants/[tenantId]/users/[userId]/DELETE.d.ts +30 -0
- package/dist/api/routes/tenants/[tenantId]/users/index.d.ts +4 -0
- package/dist/api/routes/tenants/index.d.ts +4 -0
- package/dist/api/routes/users/GET.d.ts +34 -0
- package/dist/api/routes/users/POST.d.ts +66 -0
- package/dist/api/routes/users/[userId]/PUT.d.ts +40 -0
- package/dist/api/routes/users/index.d.ts +4 -0
- package/dist/api/swagger.d.ts +152 -0
- package/dist/api/types.d.ts +18 -0
- package/dist/api/utils/auth.d.ts +6 -0
- package/dist/api/utils/request.d.ts +3 -0
- package/dist/api/utils/routes/apiRoutes.d.ts +14 -0
- package/dist/api/utils/routes/defaultRoutes.d.ts +2 -0
- package/dist/api/utils/routes/makeRestUrl.d.ts +1 -0
- package/dist/api/utils/routes/proxyRoutes.d.ts +12 -0
- package/dist/api/utils/routes/urlMatches.d.ts +1 -0
- package/dist/auth/index.d.ts +12 -38
- package/dist/server.cjs.development.js +2240 -643
- 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 +2240 -643
- package/dist/server.esm.js.map +1 -1
- package/dist/tenants/index.d.ts +3 -1
- package/dist/types.d.ts +9 -0
- package/dist/users/index.d.ts +15 -5
- package/dist/utils/Config/envVars.d.ts +6 -1
- package/dist/utils/Config/index.d.ts +17 -1
- package/dist/utils/Requester/index.d.ts +2 -1
- package/dist/utils/fetch.d.ts +3 -3
- package/package.json +5 -3
package/dist/tenants/index.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ export interface Tenant {
|
|
|
5
5
|
name?: string;
|
|
6
6
|
}
|
|
7
7
|
export default class Tenants extends Config {
|
|
8
|
-
|
|
8
|
+
headers?: Headers;
|
|
9
|
+
constructor(config: Config, headers?: Headers);
|
|
10
|
+
handleHeaders(init?: RequestInit): RequestInit | undefined;
|
|
9
11
|
get tenantsUrl(): string;
|
|
10
12
|
get tenantUrl(): string;
|
|
11
13
|
createTenant: (req: NileRequest<{
|
package/dist/types.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type ServerConfig = {
|
|
|
16
16
|
debug?: boolean;
|
|
17
17
|
db?: NilePoolConfig;
|
|
18
18
|
api?: {
|
|
19
|
+
version?: number;
|
|
19
20
|
basePath?: string;
|
|
20
21
|
cookieKey?: string;
|
|
21
22
|
token?: string;
|
|
@@ -25,3 +26,11 @@ export type NileDb = NilePoolConfig & {
|
|
|
25
26
|
tenantId?: string;
|
|
26
27
|
};
|
|
27
28
|
export type AfterCreate = (conn: PoolClient, done: (err: null | Error, conn: PoolClient) => void) => void;
|
|
29
|
+
export type Database = {
|
|
30
|
+
name: string;
|
|
31
|
+
apiHost: string;
|
|
32
|
+
dbHost: string;
|
|
33
|
+
id: string;
|
|
34
|
+
message?: string;
|
|
35
|
+
status: 'READY' | string;
|
|
36
|
+
};
|
package/dist/users/index.d.ts
CHANGED
|
@@ -29,14 +29,24 @@ export interface User {
|
|
|
29
29
|
preferredName?: string;
|
|
30
30
|
}
|
|
31
31
|
export default class Users extends Config {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
headers?: Headers;
|
|
33
|
+
constructor(config: Config, headers?: Headers);
|
|
34
34
|
get usersUrl(): string;
|
|
35
35
|
get tenantUsersUrl(): string;
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
handleHeaders(init?: RequestInit): RequestInit | undefined;
|
|
37
|
+
createUser: (req: NileRequest<CreateBasicUserRequest>, init?: RequestInit) => NileResponse<LoginUserResponse>;
|
|
38
38
|
updateUser: (userId: string, req: NileRequest<User>, init?: RequestInit) => NileResponse<User>;
|
|
39
|
-
|
|
39
|
+
listUsers: (req: NileRequest<void> | Headers, init?: RequestInit) => NileResponse<User[]>;
|
|
40
|
+
linkUser: (req: NileRequest<{
|
|
41
|
+
id: string;
|
|
42
|
+
}> | Headers, init?: RequestInit) => NileResponse<User[]>;
|
|
43
|
+
tenantUsersDeleteUrl: (userId?: string) => string;
|
|
44
|
+
getUserId: (req: Headers | NileRequest<{
|
|
45
|
+
id: string;
|
|
46
|
+
}>) => Promise<any>;
|
|
47
|
+
unlinkUser: (req: NileRequest<{
|
|
48
|
+
id: string;
|
|
49
|
+
}> | Headers, init?: RequestInit) => NileResponse<User[]>;
|
|
40
50
|
get meUrl(): string;
|
|
41
51
|
me: (req: NileRequest<void>, init?: RequestInit) => NileResponse<User>;
|
|
42
52
|
}
|
|
@@ -4,13 +4,18 @@ export type EnvConfig = {
|
|
|
4
4
|
logger?: string;
|
|
5
5
|
config?: ServerConfig;
|
|
6
6
|
};
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const getDatabaseId: (cfg: EnvConfig) => string | undefined;
|
|
8
8
|
export declare const getUsername: (cfg: EnvConfig) => string | undefined;
|
|
9
9
|
export declare const getPassword: (cfg: EnvConfig) => string | undefined;
|
|
10
10
|
export declare const getInfoBearer: (cfg: EnvConfig) => string;
|
|
11
11
|
export declare const getToken: (cfg: EnvConfig) => string | undefined;
|
|
12
12
|
export declare const getDatabaseName: (cfg: EnvConfig) => string | null;
|
|
13
13
|
export declare const getTenantId: (cfg: EnvConfig) => string | null;
|
|
14
|
+
export declare const getLocal: (cfg: EnvConfig) => string;
|
|
15
|
+
/**
|
|
16
|
+
* @param cfg various overrides
|
|
17
|
+
* @returns the url for REST to use
|
|
18
|
+
*/
|
|
14
19
|
export declare const getBasePath: (cfg: EnvConfig) => string;
|
|
15
20
|
export declare const getControlPlane: (cfg: EnvConfig) => string;
|
|
16
21
|
export declare function getDbHost(cfg: EnvConfig): string;
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import { NilePoolConfig, ServerConfig } from '../../types';
|
|
2
|
+
export type ConfigRoutes = {
|
|
3
|
+
SIGNIN?: string;
|
|
4
|
+
SESSION?: string;
|
|
5
|
+
PROVIDERS?: string;
|
|
6
|
+
CSRF?: string;
|
|
7
|
+
CALLBACK?: string;
|
|
8
|
+
SIGNOUT?: string;
|
|
9
|
+
ME?: string;
|
|
10
|
+
ERROR?: string;
|
|
11
|
+
};
|
|
2
12
|
declare class ApiConfig {
|
|
3
13
|
cookieKey?: string;
|
|
4
14
|
basePath?: string;
|
|
15
|
+
version?: number;
|
|
16
|
+
localPath?: string;
|
|
5
17
|
private _token?;
|
|
6
|
-
constructor({ basePath, cookieKey, token, }: {
|
|
18
|
+
constructor({ basePath, cookieKey, token, version, localPath, }: {
|
|
7
19
|
basePath: string;
|
|
8
20
|
cookieKey: string;
|
|
9
21
|
token: string | undefined;
|
|
22
|
+
version: number;
|
|
23
|
+
localPath: string;
|
|
10
24
|
});
|
|
11
25
|
get token(): string | undefined;
|
|
12
26
|
set token(value: string | undefined);
|
|
@@ -16,6 +30,8 @@ export declare class Config {
|
|
|
16
30
|
password: string;
|
|
17
31
|
databaseId: string;
|
|
18
32
|
databaseName: string;
|
|
33
|
+
routePrefix?: string;
|
|
34
|
+
routes?: ConfigRoutes;
|
|
19
35
|
debug: boolean;
|
|
20
36
|
db: NilePoolConfig;
|
|
21
37
|
api: ApiConfig;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Config } from '../Config';
|
|
2
2
|
export { NileResponse, NileRequest } from './types';
|
|
3
|
-
type Methods = 'POST' | 'GET' | 'PUT';
|
|
3
|
+
type Methods = 'DELETE' | 'POST' | 'GET' | 'PUT';
|
|
4
4
|
export default class Requester<T> extends Config {
|
|
5
5
|
constructor(config: Config);
|
|
6
6
|
rawRequest(method: Methods, url: string, init: RequestInit, body?: string): Promise<Response>;
|
|
@@ -19,4 +19,5 @@ export default class Requester<T> extends Config {
|
|
|
19
19
|
post: (req: T | Headers, url: string, init?: RequestInit) => Promise<Response>;
|
|
20
20
|
get: (req: T | Headers, url: string, init?: RequestInit) => Promise<Response>;
|
|
21
21
|
put: (req: T | Headers, url: string, init?: RequestInit) => Promise<Response>;
|
|
22
|
+
delete: (req: T | Headers, url: string, init?: RequestInit) => Promise<Response>;
|
|
22
23
|
}
|
package/dist/utils/fetch.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ResponseError } from './ResponseError';
|
|
2
2
|
import { Config } from './Config';
|
|
3
3
|
import { NileRequest } from './Requester';
|
|
4
|
-
export declare const X_NILE_TENANT = "
|
|
5
|
-
export declare const X_NILE_USER_ID = "
|
|
4
|
+
export declare const X_NILE_TENANT = "niledb-tenant-id";
|
|
5
|
+
export declare const X_NILE_USER_ID = "niledb-user-id";
|
|
6
6
|
export declare function handleTenantId(req: NileRequest<any>, config: Config): ResponseError | void;
|
|
7
|
-
export declare function getTenantFromHttp(headers: Headers, config
|
|
7
|
+
export declare function getTenantFromHttp(headers: Headers, config?: Config): string | null | undefined;
|
|
8
8
|
export declare function getUserFromHttp(headers: Headers, config: Config): string | null | undefined;
|
|
9
9
|
export declare function _fetch(config: Config, path: string, opts?: RequestInit): Promise<Response | ResponseError>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@niledatabase/server",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/server.esm.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
14
|
"start": "dts watch",
|
|
15
|
-
"build:spec": "yarn swagger-cli
|
|
15
|
+
"build:spec": "mkdir -p public && yarn next-swagger-doc-cli src/api/openapi/swagger-doc.json",
|
|
16
16
|
"build": "yarn build:spec && dts build --tsconfig ./tsconfig.build.json",
|
|
17
17
|
"test": "dts test",
|
|
18
18
|
"integration": "NODE_ENV=DEV dts test integration",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@apidevtools/swagger-cli": "^4.0.4",
|
|
50
50
|
"@babel/core": "^7.23.3",
|
|
51
|
+
"@openapitools/openapi-generator-cli": "^2.13.4",
|
|
51
52
|
"@types/jest": "^29.5.9",
|
|
52
53
|
"@types/lodash": "^4",
|
|
53
54
|
"@types/lodash-es": "^4",
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
"husky": "^8.0.3",
|
|
63
64
|
"jest": "^29.7.0",
|
|
64
65
|
"jest-environment-jsdom": "^29.7.0",
|
|
66
|
+
"next-swagger-doc": "^0.4.0",
|
|
65
67
|
"size-limit": "^8.2.6",
|
|
66
68
|
"ts-jest": "^29.1.1",
|
|
67
69
|
"tslib": "^2.6.2",
|
|
@@ -72,5 +74,5 @@
|
|
|
72
74
|
"jose": "^4.15.4",
|
|
73
75
|
"pg": "^8.11.3"
|
|
74
76
|
},
|
|
75
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "b08cacad84c9cf4446259cdf9a5747cd4592151c"
|
|
76
78
|
}
|