@niledatabase/server 3.0.0-alpha.4 → 3.0.0-alpha.5

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.
@@ -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,8 +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>;
17
19
  get tenantListUrl(): string;
18
- listTenants: (req: NileRequest<void>, init?: RequestInit) => Promise<Response>;
20
+ listTenants: (req: NileRequest<void> | Headers, init?: RequestInit) => Promise<Tenant[] | Response>;
19
21
  }
@@ -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
  }
@@ -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.4",
3
+ "version": "3.0.0-alpha.5",
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": "52ad5379abd61930e2d984495cba8b4b8b5803c4"
77
+ "gitHead": "bd0c6918a744feaf883b7dab6d5b076a4a0585a1"
78
78
  }