@niledatabase/server 3.0.0-alpha.2 → 3.0.0-alpha.21

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.
Files changed (43) hide show
  1. package/dist/Api.d.ts +22 -0
  2. package/dist/Server.d.ts +2 -25
  3. package/dist/api/routes/auth/callback.d.ts +2 -1
  4. package/dist/api/routes/auth/csrf.d.ts +2 -1
  5. package/dist/api/routes/auth/error.d.ts +2 -1
  6. package/dist/api/routes/auth/providers.d.ts +2 -1
  7. package/dist/api/routes/auth/signin.d.ts +2 -1
  8. package/dist/api/routes/auth/signout.d.ts +2 -1
  9. package/dist/api/routes/tenants/GET.d.ts +3 -2
  10. package/dist/api/routes/tenants/POST.d.ts +3 -3
  11. package/dist/api/routes/tenants/[tenantId]/DELETE.d.ts +3 -3
  12. package/dist/api/routes/tenants/[tenantId]/GET.d.ts +37 -0
  13. package/dist/api/routes/tenants/[tenantId]/PUT.d.ts +38 -0
  14. package/dist/api/routes/tenants/[tenantId]/users/GET.d.ts +3 -3
  15. package/dist/api/routes/tenants/[tenantId]/users/POST.d.ts +3 -2
  16. package/dist/api/routes/tenants/[tenantId]/users/PUT.d.ts +4 -5
  17. package/dist/api/routes/tenants/[tenantId]/users/[userId]/DELETE.d.ts +5 -5
  18. package/dist/api/routes/users/GET.d.ts +3 -2
  19. package/dist/api/routes/users/POST.d.ts +3 -3
  20. package/dist/api/routes/users/[userId]/PUT.d.ts +3 -2
  21. package/dist/api/utils/request.d.ts +1 -1
  22. package/dist/api/utils/routes/apiRoutes.d.ts +2 -1
  23. package/dist/api/utils/routes/makeRestUrl.d.ts +2 -1
  24. package/dist/api/utils/routes/proxyRoutes.d.ts +2 -1
  25. package/dist/db/DBManager.d.ts +1 -0
  26. package/dist/db/NileInstance.d.ts +1 -1
  27. package/dist/server.cjs.development.js +2790 -2485
  28. package/dist/server.cjs.development.js.map +1 -1
  29. package/dist/server.cjs.production.min.js +1 -1
  30. package/dist/server.cjs.production.min.js.map +1 -1
  31. package/dist/server.esm.js +2791 -2486
  32. package/dist/server.esm.js.map +1 -1
  33. package/dist/tenants/index.d.ts +7 -3
  34. package/dist/types.d.ts +8 -0
  35. package/dist/users/index.d.ts +7 -7
  36. package/dist/utils/Config/envVars.d.ts +1 -2
  37. package/dist/utils/Config/index.d.ts +8 -8
  38. package/dist/utils/Event/index.d.ts +0 -1
  39. package/dist/utils/Logger.d.ts +5 -4
  40. package/dist/utils/Requester/index.d.ts +5 -5
  41. package/dist/utils/Requester/types.d.ts +1 -1
  42. package/package.json +2 -2
  43. package/dist/utils/Server/index.d.ts +0 -4
@@ -1,5 +1,5 @@
1
1
  import { Config } from '../utils/Config';
2
- import { NileRequest, NileResponse } from '../utils/Requester';
2
+ import { NileRequest } from '../utils/Requester';
3
3
  export interface Tenant {
4
4
  id: string;
5
5
  name?: string;
@@ -12,6 +12,10 @@ export default class Tenants extends Config {
12
12
  get tenantUrl(): string;
13
13
  createTenant: (req: NileRequest<{
14
14
  name: string;
15
- }>, init?: RequestInit) => NileResponse<Tenant>;
16
- getTenant: (req: NileRequest<void>, init?: RequestInit) => NileResponse<Tenant>;
15
+ }> | Headers | string, init?: RequestInit) => Promise<Tenant | Response>;
16
+ getTenant: (req: NileRequest<{
17
+ id: string;
18
+ }> | Headers | string | void, init?: RequestInit) => Promise<Tenant | Response>;
19
+ get tenantListUrl(): string;
20
+ listTenants: (req: NileRequest<void> | Headers, init?: RequestInit) => Promise<Tenant[] | Response>;
17
21
  }
package/dist/types.d.ts CHANGED
@@ -6,6 +6,12 @@ export type Opts = {
6
6
  export type NilePoolConfig = PoolConfig & {
7
7
  afterCreate?: AfterCreate;
8
8
  };
9
+ export type LoggerType = {
10
+ info?: (args: unknown[]) => void;
11
+ warn?: (args: unknown[]) => void;
12
+ error?: (args: unknown[]) => void;
13
+ debug?: (args: unknown[]) => void;
14
+ };
9
15
  export type ServerConfig = {
10
16
  databaseId?: string;
11
17
  user?: string;
@@ -14,6 +20,7 @@ export type ServerConfig = {
14
20
  tenantId?: string | null | undefined;
15
21
  userId?: string | null | undefined;
16
22
  debug?: boolean;
23
+ configureUrl?: string;
17
24
  db?: NilePoolConfig;
18
25
  api?: {
19
26
  version?: number;
@@ -21,6 +28,7 @@ export type ServerConfig = {
21
28
  cookieKey?: string;
22
29
  token?: string;
23
30
  };
31
+ logger?: LoggerType;
24
32
  };
25
33
  export type NileDb = NilePoolConfig & {
26
34
  tenantId?: string;
@@ -1,5 +1,5 @@
1
1
  import { Config } from '../utils/Config';
2
- import { NileRequest, NileResponse } from '../utils/Requester';
2
+ import { NileRequest } from '../utils/Requester';
3
3
  export interface CreateBasicUserRequest {
4
4
  email: string;
5
5
  password: string;
@@ -34,19 +34,19 @@ export default class Users extends Config {
34
34
  get usersUrl(): string;
35
35
  get tenantUsersUrl(): string;
36
36
  handleHeaders(init?: RequestInit): RequestInit | undefined;
37
- createUser: (req: NileRequest<CreateBasicUserRequest>, init?: RequestInit) => NileResponse<LoginUserResponse>;
38
- updateUser: (userId: string, req: NileRequest<User>, init?: RequestInit) => NileResponse<User>;
39
- listUsers: (req: NileRequest<void> | Headers, init?: RequestInit) => NileResponse<User[]>;
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
40
  linkUser: (req: NileRequest<{
41
41
  id: string;
42
- }> | Headers, init?: RequestInit) => NileResponse<User[]>;
42
+ }> | Headers, init?: RequestInit) => Promise<User | Response>;
43
43
  tenantUsersDeleteUrl: (userId?: string) => string;
44
44
  getUserId: (req: Headers | NileRequest<{
45
45
  id: string;
46
46
  }>) => Promise<any>;
47
47
  unlinkUser: (req: NileRequest<{
48
48
  id: string;
49
- }> | Headers, init?: RequestInit) => NileResponse<User[]>;
49
+ }> | Headers, init?: RequestInit) => Promise<User[] | Response>;
50
50
  get meUrl(): string;
51
- me: (req: NileRequest<void>, init?: RequestInit) => NileResponse<User>;
51
+ me: (req: NileRequest<void> | Headers, init?: RequestInit) => Promise<User | Response>;
52
52
  }
@@ -11,12 +11,11 @@ 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
14
  /**
16
15
  * @param cfg various overrides
17
16
  * @returns the url for REST to use
18
17
  */
19
- export declare const getBasePath: (cfg: EnvConfig) => string;
18
+ export declare const getBasePath: (cfg: EnvConfig) => undefined | string;
20
19
  export declare const getControlPlane: (cfg: EnvConfig) => string;
21
20
  export declare function getDbHost(cfg: EnvConfig): string;
22
21
  export declare function getDbPort(cfg: EnvConfig): number;
@@ -1,4 +1,4 @@
1
- import { NilePoolConfig, ServerConfig } from '../../types';
1
+ import { LoggerType, NilePoolConfig, ServerConfig } from '../../types';
2
2
  export type ConfigRoutes = {
3
3
  SIGNIN?: string;
4
4
  SESSION?: string;
@@ -8,19 +8,18 @@ export type ConfigRoutes = {
8
8
  SIGNOUT?: string;
9
9
  ME?: string;
10
10
  ERROR?: string;
11
+ TENANTS?: string;
12
+ TENANT_USERS?: string;
13
+ USERS?: string;
11
14
  };
12
15
  declare class ApiConfig {
13
16
  cookieKey?: string;
14
- basePath?: string;
15
- version?: number;
16
- localPath?: string;
17
+ basePath?: string | undefined;
17
18
  private _token?;
18
- constructor({ basePath, cookieKey, token, version, localPath, }: {
19
- basePath: string;
19
+ constructor({ basePath, cookieKey, token, }: {
20
+ basePath?: string | undefined;
20
21
  cookieKey: string;
21
22
  token: string | undefined;
22
- version: number;
23
- localPath: string;
24
23
  });
25
24
  get token(): string | undefined;
26
25
  set token(value: string | undefined);
@@ -32,6 +31,7 @@ export declare class Config {
32
31
  databaseName: string;
33
32
  routePrefix?: string;
34
33
  routes?: ConfigRoutes;
34
+ logger?: LoggerType;
35
35
  debug: boolean;
36
36
  db: NilePoolConfig;
37
37
  api: ApiConfig;
@@ -7,6 +7,5 @@ export declare const watchUserId: (cb: EventFn) => void;
7
7
  export declare const updateToken: (val: BusValues) => void;
8
8
  export declare const watchToken: (cb: EventFn) => void;
9
9
  export declare const watchEvictPool: (cb: EventFn) => void;
10
- export declare const closeEvictPool: (cb: EventFn) => void;
11
10
  export declare const evictPool: (val: BusValues) => void;
12
11
  export {};
@@ -1,7 +1,8 @@
1
1
  import { ServerConfig } from '../types';
2
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;
3
+ export default function Logger(config?: Config | ServerConfig, ...params: unknown[]): {
4
+ info: (message: string | unknown, meta?: Record<string, unknown>) => void;
5
+ warn: (message: string | unknown, meta?: Record<string, unknown>) => void;
6
+ error: (message: string | unknown, meta?: Record<string, unknown>) => void;
7
+ debug: (message: string | unknown, meta?: Record<string, unknown>) => void;
7
8
  };
@@ -5,7 +5,7 @@ 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>;
7
7
  /**
8
- * three optios here
8
+ * three options here
9
9
  * 1) pass in headers for a server side request
10
10
  * 2) pass in the payload that matches the api
11
11
  * 3) pass in the request object sent by a browser
@@ -16,8 +16,8 @@ export default class Requester<T> extends Config {
16
16
  * @returns
17
17
  */
18
18
  protected request(method: Methods, url: string, req: T | Headers, init?: RequestInit): Promise<Response>;
19
- post: (req: T | Headers, url: string, init?: RequestInit) => Promise<Response>;
20
- get: (req: T | Headers, url: string, init?: RequestInit) => Promise<Response>;
21
- put: (req: T | Headers, url: string, init?: RequestInit) => Promise<Response>;
22
- delete: (req: T | Headers, url: string, 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
23
  }
@@ -84,5 +84,5 @@ export interface APIError {
84
84
  */
85
85
  statusCode: number;
86
86
  }
87
- export type NileResponse<T> = Promise<NResponse<T & APIError>>;
87
+ export type NileResponse<T> = Promise<T | NResponse<T & APIError>>;
88
88
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@niledatabase/server",
3
- "version": "3.0.0-alpha.2",
3
+ "version": "3.0.0-alpha.21",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/server.esm.js",
@@ -74,5 +74,5 @@
74
74
  "jose": "^4.15.4",
75
75
  "pg": "^8.11.3"
76
76
  },
77
- "gitHead": "7efb0236cc07c8021673e24f0fdb3e794b5f1775"
77
+ "gitHead": "e7fed252032085c4f2e81769374c0688284ad5fe"
78
78
  }
@@ -1,4 +0,0 @@
1
- import { ServerConfig } from '../../types';
2
- import { Config } from '../Config';
3
- export declare const getServerId: (config: ServerConfig) => string;
4
- export declare const makeServerId: (config: Config) => string;