@niledatabase/server 3.0.0-alpha.9 → 3.0.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/express.d.mts +24 -0
- package/dist/express.d.ts +24 -0
- package/dist/express.js +147 -0
- package/dist/express.js.map +1 -0
- package/dist/express.mjs +144 -0
- package/dist/express.mjs.map +1 -0
- package/dist/index.d.mts +323 -0
- package/dist/index.d.ts +323 -5
- package/dist/index.js +2382 -5
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2377 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +17 -4
- package/dist/Api.d.ts +0 -22
- package/dist/Server.d.ts +0 -29
- package/dist/api/handlers/DELETE.d.ts +0 -3
- package/dist/api/handlers/GET.d.ts +0 -3
- package/dist/api/handlers/POST.d.ts +0 -3
- package/dist/api/handlers/PUT.d.ts +0 -3
- package/dist/api/handlers/index.d.ts +0 -8
- package/dist/api/routes/auth/callback.d.ts +0 -3
- package/dist/api/routes/auth/csrf.d.ts +0 -3
- package/dist/api/routes/auth/error.d.ts +0 -3
- package/dist/api/routes/auth/index.d.ts +0 -7
- package/dist/api/routes/auth/providers.d.ts +0 -3
- package/dist/api/routes/auth/session.d.ts +0 -4
- package/dist/api/routes/auth/signin.d.ts +0 -33
- package/dist/api/routes/auth/signout.d.ts +0 -3
- package/dist/api/routes/me/index.d.ts +0 -4
- package/dist/api/routes/tenants/GET.d.ts +0 -32
- package/dist/api/routes/tenants/POST.d.ts +0 -45
- package/dist/api/routes/tenants/[tenantId]/DELETE.d.ts +0 -34
- package/dist/api/routes/tenants/[tenantId]/users/GET.d.ts +0 -35
- package/dist/api/routes/tenants/[tenantId]/users/POST.d.ts +0 -44
- package/dist/api/routes/tenants/[tenantId]/users/PUT.d.ts +0 -29
- package/dist/api/routes/tenants/[tenantId]/users/[userId]/DELETE.d.ts +0 -30
- package/dist/api/routes/tenants/[tenantId]/users/index.d.ts +0 -4
- package/dist/api/routes/tenants/index.d.ts +0 -4
- package/dist/api/routes/users/GET.d.ts +0 -34
- package/dist/api/routes/users/POST.d.ts +0 -66
- package/dist/api/routes/users/[userId]/PUT.d.ts +0 -40
- package/dist/api/routes/users/index.d.ts +0 -4
- package/dist/api/swagger.d.ts +0 -152
- package/dist/api/types.d.ts +0 -18
- package/dist/api/utils/auth.d.ts +0 -14
- package/dist/api/utils/request.d.ts +0 -4
- package/dist/api/utils/routes/apiRoutes.d.ts +0 -14
- package/dist/api/utils/routes/defaultRoutes.d.ts +0 -2
- package/dist/api/utils/routes/makeRestUrl.d.ts +0 -1
- package/dist/api/utils/routes/proxyRoutes.d.ts +0 -12
- package/dist/api/utils/routes/urlMatches.d.ts +0 -1
- package/dist/auth/index.d.ts +0 -13
- package/dist/db/DBManager.d.ts +0 -12
- package/dist/db/NileInstance.d.ts +0 -14
- package/dist/db/PoolProxy.d.ts +0 -3
- package/dist/db/index.d.ts +0 -1
- package/dist/db/isUUID.d.ts +0 -1
- package/dist/server.cjs.development.js +0 -3976
- package/dist/server.cjs.development.js.map +0 -1
- package/dist/server.cjs.production.min.js +0 -2
- package/dist/server.cjs.production.min.js.map +0 -1
- package/dist/server.esm.js +0 -3974
- package/dist/server.esm.js.map +0 -1
- package/dist/tenants/index.d.ts +0 -21
- package/dist/types.d.ts +0 -37
- package/dist/users/index.d.ts +0 -52
- package/dist/utils/Config/envVars.d.ts +0 -22
- package/dist/utils/Config/index.d.ts +0 -47
- package/dist/utils/Event/index.d.ts +0 -12
- package/dist/utils/Logger.d.ts +0 -7
- package/dist/utils/Requester/index.d.ts +0 -23
- package/dist/utils/Requester/types.d.ts +0 -88
- package/dist/utils/ResponseError.d.ts +0 -4
- package/dist/utils/Server/index.d.ts +0 -4
- package/dist/utils/fetch.d.ts +0 -9
package/dist/types.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { PoolClient, PoolConfig } from 'pg';
|
|
2
|
-
export type Opts = {
|
|
3
|
-
basePath?: string;
|
|
4
|
-
fetch?: typeof fetch;
|
|
5
|
-
};
|
|
6
|
-
export type NilePoolConfig = PoolConfig & {
|
|
7
|
-
afterCreate?: AfterCreate;
|
|
8
|
-
};
|
|
9
|
-
export type ServerConfig = {
|
|
10
|
-
databaseId?: string;
|
|
11
|
-
user?: string;
|
|
12
|
-
password?: string;
|
|
13
|
-
databaseName?: string;
|
|
14
|
-
tenantId?: string | null | undefined;
|
|
15
|
-
userId?: string | null | undefined;
|
|
16
|
-
debug?: boolean;
|
|
17
|
-
configureUrl?: string;
|
|
18
|
-
db?: NilePoolConfig;
|
|
19
|
-
api?: {
|
|
20
|
-
version?: number;
|
|
21
|
-
basePath?: string;
|
|
22
|
-
cookieKey?: string;
|
|
23
|
-
token?: string;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export type NileDb = NilePoolConfig & {
|
|
27
|
-
tenantId?: string;
|
|
28
|
-
};
|
|
29
|
-
export type AfterCreate = (conn: PoolClient, done: (err: null | Error, conn: PoolClient) => void) => void;
|
|
30
|
-
export type Database = {
|
|
31
|
-
name: string;
|
|
32
|
-
apiHost: string;
|
|
33
|
-
dbHost: string;
|
|
34
|
-
id: string;
|
|
35
|
-
message?: string;
|
|
36
|
-
status: 'READY' | string;
|
|
37
|
-
};
|
package/dist/users/index.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { Config } from '../utils/Config';
|
|
2
|
-
import { NileRequest } from '../utils/Requester';
|
|
3
|
-
export interface CreateBasicUserRequest {
|
|
4
|
-
email: string;
|
|
5
|
-
password: string;
|
|
6
|
-
preferredName?: string;
|
|
7
|
-
newTenant?: string;
|
|
8
|
-
}
|
|
9
|
-
export declare const LoginUserResponseTokenTypeEnum: {
|
|
10
|
-
readonly AccessToken: "ACCESS_TOKEN";
|
|
11
|
-
readonly RefreshToken: "REFRESH_TOKEN";
|
|
12
|
-
readonly IdToken: "ID_TOKEN";
|
|
13
|
-
};
|
|
14
|
-
export type LoginUserResponseTokenTypeEnum = (typeof LoginUserResponseTokenTypeEnum)[keyof typeof LoginUserResponseTokenTypeEnum];
|
|
15
|
-
export interface LoginUserResponseToken {
|
|
16
|
-
jwt: string;
|
|
17
|
-
maxAge: number;
|
|
18
|
-
type: LoginUserResponseTokenTypeEnum;
|
|
19
|
-
}
|
|
20
|
-
export interface LoginUserResponse {
|
|
21
|
-
[key: string]: any;
|
|
22
|
-
id: string;
|
|
23
|
-
token: LoginUserResponseToken;
|
|
24
|
-
}
|
|
25
|
-
export interface User {
|
|
26
|
-
id?: string;
|
|
27
|
-
tenants?: Set<string>;
|
|
28
|
-
email?: string;
|
|
29
|
-
preferredName?: string;
|
|
30
|
-
}
|
|
31
|
-
export default class Users extends Config {
|
|
32
|
-
headers?: Headers;
|
|
33
|
-
constructor(config: Config, headers?: Headers);
|
|
34
|
-
get usersUrl(): string;
|
|
35
|
-
get tenantUsersUrl(): string;
|
|
36
|
-
handleHeaders(init?: RequestInit): RequestInit | undefined;
|
|
37
|
-
createUser: (req: NileRequest<CreateBasicUserRequest>, init?: RequestInit) => Promise<User | Response>;
|
|
38
|
-
updateUser: (userId: string, req: NileRequest<User>, init?: RequestInit) => Promise<User | Response>;
|
|
39
|
-
listUsers: (req: NileRequest<void> | Headers, init?: RequestInit) => Promise<User[] | Response>;
|
|
40
|
-
linkUser: (req: NileRequest<{
|
|
41
|
-
id: string;
|
|
42
|
-
}> | Headers, init?: RequestInit) => Promise<User | Response>;
|
|
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) => Promise<User[] | Response>;
|
|
50
|
-
get meUrl(): string;
|
|
51
|
-
me: (req: NileRequest<void> | Headers, init?: RequestInit) => Promise<User | Response>;
|
|
52
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import 'dotenv/config';
|
|
2
|
-
import { ServerConfig } from '../../types';
|
|
3
|
-
export type EnvConfig = {
|
|
4
|
-
logger?: string;
|
|
5
|
-
config?: ServerConfig;
|
|
6
|
-
};
|
|
7
|
-
export declare const getDatabaseId: (cfg: EnvConfig) => string | undefined;
|
|
8
|
-
export declare const getUsername: (cfg: EnvConfig) => string | undefined;
|
|
9
|
-
export declare const getPassword: (cfg: EnvConfig) => string | undefined;
|
|
10
|
-
export declare const getInfoBearer: (cfg: EnvConfig) => string;
|
|
11
|
-
export declare const getToken: (cfg: EnvConfig) => string | undefined;
|
|
12
|
-
export declare const getDatabaseName: (cfg: EnvConfig) => string | null;
|
|
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
|
-
*/
|
|
19
|
-
export declare const getBasePath: (cfg: EnvConfig) => string;
|
|
20
|
-
export declare const getControlPlane: (cfg: EnvConfig) => string;
|
|
21
|
-
export declare function getDbHost(cfg: EnvConfig): string;
|
|
22
|
-
export declare function getDbPort(cfg: EnvConfig): number;
|
|
@@ -1,47 +0,0 @@
|
|
|
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
|
-
};
|
|
12
|
-
declare class ApiConfig {
|
|
13
|
-
cookieKey?: string;
|
|
14
|
-
basePath?: string;
|
|
15
|
-
version?: number;
|
|
16
|
-
localPath?: string;
|
|
17
|
-
private _token?;
|
|
18
|
-
constructor({ basePath, cookieKey, token, version, localPath, }: {
|
|
19
|
-
basePath: string;
|
|
20
|
-
cookieKey: string;
|
|
21
|
-
token: string | undefined;
|
|
22
|
-
version: number;
|
|
23
|
-
localPath: string;
|
|
24
|
-
});
|
|
25
|
-
get token(): string | undefined;
|
|
26
|
-
set token(value: string | undefined);
|
|
27
|
-
}
|
|
28
|
-
export declare class Config {
|
|
29
|
-
user: string;
|
|
30
|
-
password: string;
|
|
31
|
-
databaseId: string;
|
|
32
|
-
databaseName: string;
|
|
33
|
-
routePrefix?: string;
|
|
34
|
-
routes?: ConfigRoutes;
|
|
35
|
-
debug: boolean;
|
|
36
|
-
db: NilePoolConfig;
|
|
37
|
-
api: ApiConfig;
|
|
38
|
-
private _tenantId?;
|
|
39
|
-
private _userId?;
|
|
40
|
-
get tenantId(): string | undefined | null;
|
|
41
|
-
set tenantId(value: string | undefined | null);
|
|
42
|
-
get userId(): string | undefined | null;
|
|
43
|
-
set userId(value: string | undefined | null);
|
|
44
|
-
constructor(config?: ServerConfig, logger?: string);
|
|
45
|
-
configure: (config: ServerConfig) => Promise<Config>;
|
|
46
|
-
}
|
|
47
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
type BusValues = undefined | null | string;
|
|
2
|
-
type EventFn = (params: BusValues) => void;
|
|
3
|
-
export declare const updateTenantId: (tenantId: BusValues) => void;
|
|
4
|
-
export declare const watchTenantId: (cb: EventFn) => void;
|
|
5
|
-
export declare const updateUserId: (userId: BusValues) => void;
|
|
6
|
-
export declare const watchUserId: (cb: EventFn) => void;
|
|
7
|
-
export declare const updateToken: (val: BusValues) => void;
|
|
8
|
-
export declare const watchToken: (cb: EventFn) => void;
|
|
9
|
-
export declare const watchEvictPool: (cb: EventFn) => void;
|
|
10
|
-
export declare const closeEvictPool: (cb: EventFn) => void;
|
|
11
|
-
export declare const evictPool: (val: BusValues) => void;
|
|
12
|
-
export {};
|
package/dist/utils/Logger.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ServerConfig } from '../types';
|
|
2
|
-
import { Config } from './Config';
|
|
3
|
-
export default function Logger(config: void | Config | ServerConfig, ...params: unknown[]): {
|
|
4
|
-
info(...args: unknown[]): void;
|
|
5
|
-
warn(...args: unknown[]): void;
|
|
6
|
-
error(...args: unknown[]): void;
|
|
7
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Config } from '../Config';
|
|
2
|
-
export { NileResponse, NileRequest } from './types';
|
|
3
|
-
type Methods = 'DELETE' | 'POST' | 'GET' | 'PUT';
|
|
4
|
-
export default class Requester<T> extends Config {
|
|
5
|
-
constructor(config: Config);
|
|
6
|
-
rawRequest(method: Methods, url: string, init: RequestInit, body?: string): Promise<Response>;
|
|
7
|
-
/**
|
|
8
|
-
* three options here
|
|
9
|
-
* 1) pass in headers for a server side request
|
|
10
|
-
* 2) pass in the payload that matches the api
|
|
11
|
-
* 3) pass in the request object sent by a browser
|
|
12
|
-
* @param method
|
|
13
|
-
* @param url
|
|
14
|
-
* @param req
|
|
15
|
-
* @param init
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
protected request(method: Methods, url: string, req: T | Headers, init?: RequestInit): Promise<Response>;
|
|
19
|
-
post<R = JSON>(req: T | Headers, url: string, init?: RequestInit): Promise<Response | R>;
|
|
20
|
-
get<R = JSON>(req: T | Headers, url: string, init?: RequestInit): Promise<Response | R>;
|
|
21
|
-
put<R = JSON>(req: T | Headers, url: string, init?: RequestInit): Promise<Response | R>;
|
|
22
|
-
delete<R = JSON>(req: T | Headers, url: string, init?: RequestInit): Promise<Response | R>;
|
|
23
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
interface NileBody<R, B> {
|
|
2
|
-
readonly body: ReadableStream<Uint8Array> | null | B;
|
|
3
|
-
readonly bodyUsed: boolean;
|
|
4
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
|
5
|
-
blob(): Promise<Blob>;
|
|
6
|
-
formData(): Promise<FormData>;
|
|
7
|
-
json(): Promise<R>;
|
|
8
|
-
text(): Promise<string>;
|
|
9
|
-
}
|
|
10
|
-
interface NResponse<T> extends NileBody<T, any> {
|
|
11
|
-
readonly headers: Headers;
|
|
12
|
-
readonly ok: boolean;
|
|
13
|
-
readonly redirected: boolean;
|
|
14
|
-
readonly status: number;
|
|
15
|
-
readonly statusText: string;
|
|
16
|
-
readonly type: ResponseType;
|
|
17
|
-
readonly url: string;
|
|
18
|
-
clone(): Response;
|
|
19
|
-
}
|
|
20
|
-
interface NRequest<T> extends NileBody<any, T> {
|
|
21
|
-
/** Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching. */
|
|
22
|
-
readonly cache: RequestCache;
|
|
23
|
-
/** Returns the credentials mode associated with request, which is a string indicating whether credentials will be sent with the request always, never, or only when sent to a same-origin URL. */
|
|
24
|
-
readonly credentials: RequestCredentials;
|
|
25
|
-
/** Returns the kind of resource requested by request, e.g., "document" or "script". */
|
|
26
|
-
readonly destination: RequestDestination;
|
|
27
|
-
/** Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header. */
|
|
28
|
-
readonly headers: Headers;
|
|
29
|
-
/** Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI] */
|
|
30
|
-
readonly integrity: string;
|
|
31
|
-
/** Returns a boolean indicating whether or not request can outlive the global in which it was created. */
|
|
32
|
-
readonly keepalive: boolean;
|
|
33
|
-
/** Returns request's HTTP method, which is "GET" by default. */
|
|
34
|
-
readonly method: string;
|
|
35
|
-
/** Returns the mode associated with request, which is a string indicating whether the request will use CORS, or will be restricted to same-origin URLs. */
|
|
36
|
-
readonly mode: RequestMode;
|
|
37
|
-
/** Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default. */
|
|
38
|
-
readonly redirect: RequestRedirect;
|
|
39
|
-
/** Returns the referrer of request. Its value can be a same-origin URL if explicitly set in init, the empty string to indicate no referrer, and "about:client" when defaulting to the global's default. This is used during fetching to determine the value of the `Referer` header of the request being made. */
|
|
40
|
-
readonly referrer: string;
|
|
41
|
-
/** Returns the referrer policy associated with request. This is used during fetching to compute the value of the request's referrer. */
|
|
42
|
-
readonly referrerPolicy: ReferrerPolicy;
|
|
43
|
-
/** Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler. */
|
|
44
|
-
readonly signal: AbortSignal;
|
|
45
|
-
/** Returns the URL of request as a string. */
|
|
46
|
-
readonly url: string;
|
|
47
|
-
clone(): Request;
|
|
48
|
-
}
|
|
49
|
-
export type NileRequest<T> = NRequest<T> | T;
|
|
50
|
-
export declare const APIErrorErrorCodeEnum: {
|
|
51
|
-
readonly InternalError: "internal_error";
|
|
52
|
-
readonly BadRequest: "bad_request";
|
|
53
|
-
readonly EntityNotFound: "entity_not_found";
|
|
54
|
-
readonly DuplicateEntity: "duplicate_entity";
|
|
55
|
-
readonly InvalidCredentials: "invalid_credentials";
|
|
56
|
-
readonly UnknownOidcProvider: "unknown_oidc_provider";
|
|
57
|
-
readonly ProviderAlreadyExists: "provider_already_exists";
|
|
58
|
-
readonly ProviderConfigError: "provider_config_error";
|
|
59
|
-
readonly ProviderMismatch: "provider_mismatch";
|
|
60
|
-
readonly ProviderUpdateError: "provider_update_error";
|
|
61
|
-
readonly SessionStateMissing: "session_state_missing";
|
|
62
|
-
readonly SessionStateMismatch: "session_state_mismatch";
|
|
63
|
-
readonly OidcCodeMissing: "oidc_code_missing";
|
|
64
|
-
};
|
|
65
|
-
export type APIErrorErrorCodeEnum = (typeof APIErrorErrorCodeEnum)[keyof typeof APIErrorErrorCodeEnum];
|
|
66
|
-
export interface APIError {
|
|
67
|
-
[key: string]: any | any;
|
|
68
|
-
/**
|
|
69
|
-
*
|
|
70
|
-
* @type {string}
|
|
71
|
-
* @memberof APIError
|
|
72
|
-
*/
|
|
73
|
-
errorCode: APIErrorErrorCodeEnum;
|
|
74
|
-
/**
|
|
75
|
-
*
|
|
76
|
-
* @type {string}
|
|
77
|
-
* @memberof APIError
|
|
78
|
-
*/
|
|
79
|
-
message: string;
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
* @type {number}
|
|
83
|
-
* @memberof APIError
|
|
84
|
-
*/
|
|
85
|
-
statusCode: number;
|
|
86
|
-
}
|
|
87
|
-
export type NileResponse<T> = Promise<T | NResponse<T & APIError>>;
|
|
88
|
-
export {};
|
package/dist/utils/fetch.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ResponseError } from './ResponseError';
|
|
2
|
-
import { Config } from './Config';
|
|
3
|
-
import { NileRequest } from './Requester';
|
|
4
|
-
export declare const X_NILE_TENANT = "niledb-tenant-id";
|
|
5
|
-
export declare const X_NILE_USER_ID = "niledb-user-id";
|
|
6
|
-
export declare function handleTenantId(req: NileRequest<any>, config: Config): ResponseError | void;
|
|
7
|
-
export declare function getTenantFromHttp(headers: Headers, config?: Config): string | null | undefined;
|
|
8
|
-
export declare function getUserFromHttp(headers: Headers, config: Config): string | null | undefined;
|
|
9
|
-
export declare function _fetch(config: Config, path: string, opts?: RequestInit): Promise<Response | ResponseError>;
|