@spytecgps/nova-orm 0.0.11 → 0.0.13
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/index.js +1 -1
- package/dist/repositories/security/createUserRole.d.ts +5 -0
- package/dist/repositories/security/index.d.ts +28 -1
- package/dist/repositories/security/removeUserRoles.d.ts +4 -0
- package/dist/repositories/security/updateUserRole.d.ts +4 -0
- package/dist/repositories/security/userIsAdminOrOwner.d.ts +4 -0
- package/dist/types/logger.d.ts +8 -0
- package/dist/types/security.d.ts +23 -0
- package/dist/utils/writeToLog.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { UserSecurityRole } from '../../entities';
|
|
2
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
3
|
+
import { Logger } from '../../types/logger';
|
|
4
|
+
import { CreateUserRoleParams } from '../../types/security';
|
|
5
|
+
export declare const createUserRole: (novaDataSource: NovaDataSource, params: CreateUserRoleParams, logger: Logger) => Promise<UserSecurityRole>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SecurityRole, UserSecurityRole } from '../../entities';
|
|
2
|
-
import { GetUserRolesByClientIdParams, GetUserRolesParams, UserIsInRoleParams } from '../../types/security';
|
|
2
|
+
import { CreateUserRoleParams, GetUserRolesByClientIdParams, GetUserRolesParams, RemoveUserRolesParams, UpdateUserRoleParams, UserIsAdminOrOwnerParams, UserIsInRoleParams } from '../../types/security';
|
|
3
3
|
import { BaseRepository } from '../baseRepository';
|
|
4
4
|
export declare class SecurityRepository extends BaseRepository {
|
|
5
5
|
/**
|
|
@@ -26,4 +26,31 @@ export declare class SecurityRepository extends BaseRepository {
|
|
|
26
26
|
* - filters.role: The role to check if the user is in that role
|
|
27
27
|
*/
|
|
28
28
|
userIsInRole(params: UserIsInRoleParams): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the user is admin or owner
|
|
31
|
+
* @param {UserIsAdminOrOwnerParams} params containing information to know if the user is admin or owner
|
|
32
|
+
* - filters.userId: The user id
|
|
33
|
+
*/
|
|
34
|
+
userIsAdminOrOwner(params: UserIsAdminOrOwnerParams): Promise<boolean>;
|
|
35
|
+
/**
|
|
36
|
+
* Create user role
|
|
37
|
+
* @param {CreateUserRoleParams} params containing information to create user role
|
|
38
|
+
* - userId: The user id
|
|
39
|
+
* - clientId: The client id
|
|
40
|
+
* - roleId: The role to assign to the user
|
|
41
|
+
*/
|
|
42
|
+
createUserRole(params: CreateUserRoleParams): Promise<UserSecurityRole>;
|
|
43
|
+
/**
|
|
44
|
+
* Update user role
|
|
45
|
+
* @param {UpdateUserRoleParams} params containing information to update user role
|
|
46
|
+
* - filters.userId: The user id to update role
|
|
47
|
+
* - values.roleId: The role to assign to the user
|
|
48
|
+
*/
|
|
49
|
+
updateUserRole(params: UpdateUserRoleParams): Promise<boolean>;
|
|
50
|
+
/**
|
|
51
|
+
* Remove user roles
|
|
52
|
+
* @param {RemoveUserRolesParams} params containing information to remove user roles
|
|
53
|
+
* - filters.userId: The user id to remove roles from
|
|
54
|
+
*/
|
|
55
|
+
removeUserRoles(params: RemoveUserRolesParams): Promise<boolean>;
|
|
29
56
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { Logger } from '../../types/logger';
|
|
3
|
+
import { RemoveUserRolesParams } from '../../types/security';
|
|
4
|
+
export declare const removeUserRoles: (novaDataSource: NovaDataSource, params: RemoveUserRolesParams, logger: Logger) => Promise<boolean>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { Logger } from '../../types/logger';
|
|
3
|
+
import { UpdateUserRoleParams } from '../../types/security';
|
|
4
|
+
export declare const updateUserRole: (novaDataSource: NovaDataSource, params: UpdateUserRoleParams, logger: Logger) => Promise<boolean>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { Logger } from '../../types/logger';
|
|
3
|
+
import { UserIsAdminOrOwnerParams } from '../../types/security';
|
|
4
|
+
export declare const userIsAdminOrOwner: (novaDataSource: NovaDataSource, params: UserIsAdminOrOwnerParams, logger: Logger) => Promise<boolean>;
|
package/dist/types/logger.d.ts
CHANGED
|
@@ -2,6 +2,14 @@ export interface LogFn {
|
|
|
2
2
|
(msg: string, ...args: any[]): void;
|
|
3
3
|
(obj: object, msg?: string, ...args: any[]): void;
|
|
4
4
|
}
|
|
5
|
+
export declare enum LogLevel {
|
|
6
|
+
FATAL = "fatal",
|
|
7
|
+
ERROR = "error",
|
|
8
|
+
WARN = "warn",
|
|
9
|
+
INFO = "info",
|
|
10
|
+
DEBUG = "debug",
|
|
11
|
+
TRACE = "trace"
|
|
12
|
+
}
|
|
5
13
|
export interface Logger {
|
|
6
14
|
/**
|
|
7
15
|
* Log at `'fatal'` level the given msg. If the first argument is an object, all its properties will be included in the JSON line.
|
package/dist/types/security.d.ts
CHANGED
|
@@ -16,3 +16,26 @@ export interface UserIsInRoleParams {
|
|
|
16
16
|
role: HapnSecurityRole;
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
+
export interface UserIsAdminOrOwnerParams {
|
|
20
|
+
filters: {
|
|
21
|
+
userId: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export interface UpdateUserRoleParams {
|
|
25
|
+
filters: {
|
|
26
|
+
userId: string;
|
|
27
|
+
};
|
|
28
|
+
values: {
|
|
29
|
+
roleId: number;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface CreateUserRoleParams {
|
|
33
|
+
userId: string;
|
|
34
|
+
clientId: number;
|
|
35
|
+
roleId: number;
|
|
36
|
+
}
|
|
37
|
+
export interface RemoveUserRolesParams {
|
|
38
|
+
filters: {
|
|
39
|
+
userId: string;
|
|
40
|
+
};
|
|
41
|
+
}
|