my-typescript-library-rahul52us 1.3.4 → 1.3.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.
- package/dist/config/auth/passportConfig.js +3 -2
- package/dist/config/auth/passportConfig.js.map +1 -1
- package/dist/controllers/auth.controller.js +1 -1
- package/dist/controllers/auth.controller.js.map +1 -1
- package/dist/controllers/rbac/rbac.controller.js +1 -5
- package/dist/controllers/rbac/rbac.controller.js.map +1 -1
- package/dist/helpers/jwt.helper.js +1 -1
- package/dist/helpers/jwt.helper.js.map +1 -1
- package/dist/libs/mail.js +1 -1
- package/dist/libs/mail.js.map +1 -1
- package/dist/repository/accountdetails.repository.js +1 -1
- package/dist/repository/accountdetails.repository.js.map +1 -1
- package/dist/repository/document.repository.js +175 -23
- package/dist/repository/document.repository.js.map +1 -1
- package/dist/repository/filesystem.repository.js +3 -3
- package/dist/repository/filesystem.repository.js.map +1 -1
- package/dist/repository/log.repository.js +3 -3
- package/dist/repository/log.repository.js.map +1 -1
- package/dist/repository/notifications.repository.js.map +1 -1
- package/dist/repository/schemas/accountdetails.schema.js.map +1 -1
- package/dist/repository/schemas/accounts.schema.js +10 -33
- package/dist/repository/schemas/accounts.schema.js.map +1 -1
- package/dist/repository/schemas/document.schema.js +12 -19
- package/dist/repository/schemas/document.schema.js.map +1 -1
- package/dist/repository/schemas/extracted.schema.js +3 -5
- package/dist/repository/schemas/extracted.schema.js.map +1 -1
- package/dist/repository/schemas/fileSystem.schema.js +2 -5
- package/dist/repository/schemas/fileSystem.schema.js.map +1 -1
- package/dist/repository/schemas/form.schema.js +1 -1
- package/dist/repository/schemas/form.schema.js.map +1 -1
- package/dist/repository/schemas/log.schema.js +4 -4
- package/dist/repository/schemas/log.schema.js.map +1 -1
- package/dist/repository/schemas/notifications.schema.js +2 -3
- package/dist/repository/schemas/notifications.schema.js.map +1 -1
- package/dist/repository/schemas/organisation.schema.js +25 -29
- package/dist/repository/schemas/organisation.schema.js.map +1 -1
- package/dist/repository/schemas/profile.schema.js +1 -1
- package/dist/repository/schemas/profile.schema.js.map +1 -1
- package/dist/repository/schemas/role.schema.js +1 -1
- package/dist/repository/schemas/role.schema.js.map +1 -1
- package/dist/repository/schemas/tokens.schema.js +5 -5
- package/dist/repository/schemas/tokens.schema.js.map +1 -1
- package/dist/repository/schemas/userrole.schema.js +1 -1
- package/dist/repository/schemas/userrole.schema.js.map +1 -1
- package/dist/repository/schemas/workflow.schema.js +14 -40
- package/dist/repository/schemas/workflow.schema.js.map +1 -1
- package/dist/repository/user.repository.js +32 -20
- package/dist/repository/user.repository.js.map +1 -1
- package/dist/repository/user_tokens.repository.js +1 -1
- package/dist/repository/user_tokens.repository.js.map +1 -1
- package/dist/repository/userrole.repository.js.map +1 -1
- package/dist/repository/workflow.repository.js +0 -1
- package/dist/repository/workflow.repository.js.map +1 -1
- package/dist/routes/accountdetails.route.js +2 -2
- package/dist/routes/accountdetails.route.js.map +1 -1
- package/dist/routes/auth.route.js +6 -5
- package/dist/routes/auth.route.js.map +1 -1
- package/dist/routes/document.route.js +4 -2
- package/dist/routes/document.route.js.map +1 -1
- package/dist/routes/fileSystem.route.js +2 -1
- package/dist/routes/fileSystem.route.js.map +1 -1
- package/dist/routes/form.route.js +2 -2
- package/dist/routes/form.route.js.map +1 -1
- package/dist/routes/index.js +1 -1
- package/dist/routes/index.js.map +1 -1
- package/dist/routes/log.route.js +3 -3
- package/dist/routes/log.route.js.map +1 -1
- package/dist/routes/notifications.route.js +1 -1
- package/dist/routes/notifications.route.js.map +1 -1
- package/dist/routes/org.route.js +2 -2
- package/dist/routes/org.route.js.map +1 -1
- package/dist/routes/profile.route.js +4 -3
- package/dist/routes/profile.route.js.map +1 -1
- package/dist/routes/role.route.js +7 -4
- package/dist/routes/role.route.js.map +1 -1
- package/dist/routes/user.route.js +12 -10
- package/dist/routes/user.route.js.map +1 -1
- package/dist/routes/userrole.route.js +6 -4
- package/dist/routes/userrole.route.js.map +1 -1
- package/dist/routes/workflow.route.js +3 -3
- package/dist/routes/workflow.route.js.map +1 -1
- package/dist/server.js +1 -3
- package/dist/server.js.map +1 -1
- package/dist/services/apikey/apikey.service.js +102 -0
- package/dist/services/apikey/apikey.service.js.map +1 -0
- package/dist/services/authentication/change-password.service.js +4 -4
- package/dist/services/authentication/change-password.service.js.map +1 -1
- package/dist/services/authentication/forgot-password.service.js +6 -6
- package/dist/services/authentication/forgot-password.service.js.map +1 -1
- package/dist/services/authentication/getuser.service.js +2 -2
- package/dist/services/authentication/getuser.service.js.map +1 -1
- package/dist/services/authentication/login.service.js +4 -4
- package/dist/services/authentication/login.service.js.map +1 -1
- package/dist/services/authentication/register.admin.service.js +1 -1
- package/dist/services/authentication/register.admin.service.js.map +1 -1
- package/dist/services/authentication/register.service.js +8 -8
- package/dist/services/authentication/register.service.js.map +1 -1
- package/dist/services/authentication/resend-email.service.js +6 -6
- package/dist/services/authentication/resend-email.service.js.map +1 -1
- package/dist/services/authentication/reset-password.service.js +29 -11
- package/dist/services/authentication/reset-password.service.js.map +1 -1
- package/dist/services/authentication/verify-email.service.js +4 -4
- package/dist/services/authentication/verify-email.service.js.map +1 -1
- package/dist/services/document/document.services.js +177 -94
- package/dist/services/document/document.services.js.map +1 -1
- package/dist/services/document/dummy.js +85 -0
- package/dist/services/document/dummy.js.map +1 -0
- package/dist/services/fileSystem/fileSystem.service.js +1 -1
- package/dist/services/fileSystem/fileSystem.service.js.map +1 -1
- package/dist/services/form/form.service.js +1 -1
- package/dist/services/form/form.service.js.map +1 -1
- package/dist/services/logs/log.service.js +1 -1
- package/dist/services/logs/log.service.js.map +1 -1
- package/dist/services/notifications/notifications.service.js +1 -1
- package/dist/services/notifications/notifications.service.js.map +1 -1
- package/dist/services/organisation/organisation.service.js +2 -2
- package/dist/services/organisation/organisation.service.js.map +1 -1
- package/dist/services/profile/profile.services.js +1 -1
- package/dist/services/profile/profile.services.js.map +1 -1
- package/dist/services/roles/role.services.js +1 -1
- package/dist/services/roles/role.services.js.map +1 -1
- package/dist/services/statement/accountdetails.service.js +1 -1
- package/dist/services/statement/accountdetails.service.js.map +1 -1
- package/dist/services/userroles/userrole.service.js +1 -1
- package/dist/services/userroles/userrole.service.js.map +1 -1
- package/dist/services/workflow/workSettings.service.js +1 -1
- package/dist/services/workflow/workSettings.service.js.map +1 -1
- package/dist/services/workflow/workflow.service.js +9 -7
- package/dist/services/workflow/workflow.service.js.map +1 -1
- package/dist/types/controllers/auth.controller.d.ts +4 -4
- package/dist/types/repository/document.repository.d.ts +56 -16
- package/dist/types/repository/form.repository.d.ts +7 -3
- package/dist/types/repository/organisation.repository.d.ts +1 -6
- package/dist/types/repository/profile.repository.d.ts +4 -3
- package/dist/types/repository/role.repository.d.ts +5 -2
- package/dist/types/repository/schemas/accounts.schema.d.ts +14 -11
- package/dist/types/repository/schemas/document.schema.d.ts +4 -4
- package/dist/types/repository/schemas/extracted.schema.d.ts +3 -3
- package/dist/types/repository/schemas/fileSystem.schema.d.ts +2 -6
- package/dist/types/repository/schemas/form.schema.d.ts +1 -1
- package/dist/types/repository/schemas/organisation.schema.d.ts +11 -11
- package/dist/types/repository/schemas/profile.schema.d.ts +1 -1
- package/dist/types/repository/schemas/role.schema.d.ts +1 -1
- package/dist/types/repository/schemas/userrole.schema.d.ts +1 -1
- package/dist/types/repository/schemas/workflow.schema.d.ts +2 -14
- package/dist/types/repository/user.repository.d.ts +45 -16
- package/dist/types/repository/userrole.repository.d.ts +5 -2
- package/dist/types/repository/workflow.repository.d.ts +4 -38
- package/dist/types/server.d.ts +0 -1
- package/dist/types/services/apikey/apikey.service.d.ts +12 -0
- package/dist/types/services/authentication/change-password.service.d.ts +1 -1
- package/dist/types/services/authentication/forgot-password.service.d.ts +2 -2
- package/dist/types/services/authentication/getuser.service.d.ts +29 -3
- package/dist/types/services/authentication/login.service.d.ts +1 -1
- package/dist/types/services/authentication/register.admin.service.d.ts +1 -1
- package/dist/types/services/authentication/register.service.d.ts +1 -1
- package/dist/types/services/authentication/resend-email.service.d.ts +2 -2
- package/dist/types/services/authentication/reset-password.service.d.ts +2 -2
- package/dist/types/services/authentication/verify-email.service.d.ts +1 -1
- package/dist/types/services/document/document.services.d.ts +42 -12
- package/dist/types/services/document/dummy.d.ts +45 -0
- package/dist/types/services/logs/log.service.d.ts +1 -1
- package/dist/types/services/profile/profile.services.d.ts +3 -3
- package/dist/types/services/roles/role.services.d.ts +33 -5
- package/dist/types/services/userroles/userrole.service.d.ts +5 -13
- package/dist/types/services/workflow/workflow.service.d.ts +2 -2
- package/dist/types/utils/common.d.ts +5 -0
- package/dist/utils/common.js +23 -1
- package/dist/utils/common.js.map +1 -1
- package/package.json +1 -1
- package/src/config/auth/passportConfig.ts +5 -2
- package/src/controllers/auth.controller.ts +3 -3
- package/src/controllers/rbac/rbac.controller.ts +1 -2
- package/src/helpers/jwt.helper.ts +1 -1
- package/src/libs/mail.ts +2 -2
- package/src/repository/accountdetails.repository.ts +1 -1
- package/src/repository/document.repository.ts +222 -38
- package/src/repository/filesystem.repository.ts +5 -5
- package/src/repository/form.repository.ts +4 -4
- package/src/repository/log.repository.ts +3 -3
- package/src/repository/notifications.repository.ts +2 -1
- package/src/repository/organisation.repository.ts +1 -1
- package/src/repository/profile.repository.ts +1 -1
- package/src/repository/role.repository.ts +1 -1
- package/src/repository/schemas/WorkflowSettingsScheme.ts +0 -2
- package/src/repository/schemas/accountdetails.schema.ts +2 -5
- package/src/repository/schemas/accounts.schema.ts +30 -31
- package/src/repository/schemas/document.schema.ts +15 -18
- package/src/repository/schemas/extracted.schema.ts +28 -31
- package/src/repository/schemas/fileSystem.schema.ts +4 -7
- package/src/repository/schemas/form.schema.ts +1 -2
- package/src/repository/schemas/log.schema.ts +6 -7
- package/src/repository/schemas/notifications.schema.ts +2 -4
- package/src/repository/schemas/organisation.schema.ts +44 -51
- package/src/repository/schemas/profile.schema.ts +1 -2
- package/src/repository/schemas/role.schema.ts +1 -2
- package/src/repository/schemas/tokens.schema.ts +18 -20
- package/src/repository/schemas/userrole.schema.ts +1 -2
- package/src/repository/schemas/workflow.schema.ts +41 -61
- package/src/repository/user.repository.ts +75 -54
- package/src/repository/user_tokens.repository.ts +3 -3
- package/src/repository/userrole.repository.ts +2 -2
- package/src/repository/workflow.repository.ts +4 -5
- package/src/routes/accountdetails.route.ts +3 -2
- package/src/routes/auth.route.ts +6 -5
- package/src/routes/document.route.ts +6 -2
- package/src/routes/fileSystem.route.ts +3 -1
- package/src/routes/form.route.ts +7 -2
- package/src/routes/index.ts +2 -1
- package/src/routes/log.route.ts +4 -4
- package/src/routes/notifications.route.ts +1 -1
- package/src/routes/org.route.ts +2 -2
- package/src/routes/profile.route.ts +4 -3
- package/src/routes/role.route.ts +7 -4
- package/src/routes/user.route.ts +30 -8
- package/src/routes/userrole.route.ts +6 -4
- package/src/routes/workflow.route.ts +12 -4
- package/src/server.ts +0 -1
- package/src/services/authentication/change-password.service.ts +8 -8
- package/src/services/authentication/forgot-password.service.ts +8 -8
- package/src/services/authentication/getuser.service.ts +3 -3
- package/src/services/authentication/login.service.ts +5 -5
- package/src/services/authentication/register.admin.service.ts +2 -2
- package/src/services/authentication/register.service.ts +9 -9
- package/src/services/authentication/resend-email.service.ts +10 -10
- package/src/services/authentication/reset-password.service.ts +37 -16
- package/src/services/authentication/verify-email.service.ts +5 -5
- package/src/services/document/document.services.ts +222 -124
- package/src/services/document/dummy.ts +81 -0
- package/src/services/fileSystem/fileSystem.service.ts +8 -4
- package/src/services/form/form.service.ts +1 -1
- package/src/services/logs/log.service.ts +2 -2
- package/src/services/notifications/notifications.service.ts +9 -9
- package/src/services/organisation/organisation.service.ts +8 -8
- package/src/services/profile/profile.services.ts +6 -6
- package/src/services/roles/role.services.ts +5 -5
- package/src/services/statement/accountdetails.service.ts +2 -2
- package/src/services/userroles/userrole.service.ts +6 -6
- package/src/services/workflow/workSettings.service.ts +2 -2
- package/src/services/workflow/workflow.service.ts +18 -12
- package/src/utils/common.ts +36 -13
- package/.vscode/extensions.json +0 -5
- package/dist/controllers/rbac/grantaccess.json +0 -72
- package/dist/setupModal.js +0 -58
- package/dist/setupModal.js.map +0 -1
- package/dist/types/setupModal.d.ts +0 -7
- package/src/setupModal.ts +0 -60
|
@@ -1,71 +1,51 @@
|
|
|
1
|
-
import mongoose
|
|
1
|
+
import mongoose from 'mongoose'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
defaultActive: {
|
|
41
|
-
type: Boolean,
|
|
42
|
-
default: false,
|
|
43
|
-
},
|
|
44
|
-
created_At: {
|
|
45
|
-
type: Date,
|
|
46
|
-
default: Date.now,
|
|
47
|
-
},
|
|
48
|
-
updated_At: {
|
|
49
|
-
type: Date,
|
|
50
|
-
},
|
|
51
|
-
deletedAt: {
|
|
52
|
-
type: Date,
|
|
53
|
-
},
|
|
54
|
-
schema: {
|
|
55
|
-
type: mongoose.Schema.Types.Mixed,
|
|
56
|
-
default: {},
|
|
57
|
-
},
|
|
58
|
-
});
|
|
3
|
+
const workFlowSchema = new mongoose.Schema({
|
|
4
|
+
user : {
|
|
5
|
+
type : mongoose.Schema.Types.ObjectId,
|
|
6
|
+
ref : 'Accounts'
|
|
7
|
+
},
|
|
8
|
+
company : {
|
|
9
|
+
type : mongoose.Schema.Types.ObjectId,
|
|
10
|
+
ref : 'Organisation'
|
|
11
|
+
},
|
|
12
|
+
identifier : {
|
|
13
|
+
type : String
|
|
14
|
+
},
|
|
15
|
+
workFlowName : {
|
|
16
|
+
type : String
|
|
17
|
+
},
|
|
18
|
+
values : {
|
|
19
|
+
type : mongoose.Schema.Types.Mixed
|
|
20
|
+
},
|
|
21
|
+
defaultActive : {
|
|
22
|
+
type : Boolean,
|
|
23
|
+
default : false
|
|
24
|
+
},
|
|
25
|
+
created_At: {
|
|
26
|
+
type: Date,
|
|
27
|
+
default: Date.now,
|
|
28
|
+
},
|
|
29
|
+
updated_At : {
|
|
30
|
+
type : Date
|
|
31
|
+
},
|
|
32
|
+
deletedAt: {
|
|
33
|
+
type: Date
|
|
34
|
+
},
|
|
35
|
+
schema : {
|
|
36
|
+
type : mongoose.Schema.Types.Mixed,
|
|
37
|
+
default : {}
|
|
38
|
+
}
|
|
39
|
+
})
|
|
59
40
|
|
|
60
|
-
|
|
61
|
-
let WorkFlowModel: mongoose.Model<IWorkFlow> | null = null;
|
|
41
|
+
let WorkFlowModel: mongoose.Model<any> | null = null;
|
|
62
42
|
|
|
63
43
|
if (mongoose.models.WorkFlow) {
|
|
64
44
|
console.log("WorkFlow model already exists.");
|
|
65
45
|
WorkFlowModel = mongoose.models.WorkFlow;
|
|
66
46
|
} else {
|
|
67
47
|
console.log("Creating WorkFlow model fallback.");
|
|
68
|
-
WorkFlowModel = mongoose.model<
|
|
48
|
+
WorkFlowModel = mongoose.model<any>("WorkFlow", workFlowSchema);
|
|
69
49
|
}
|
|
70
50
|
|
|
71
|
-
export default WorkFlowModel;
|
|
51
|
+
export default WorkFlowModel;
|
|
@@ -2,8 +2,8 @@ import Account from "./schemas/accounts.schema";
|
|
|
2
2
|
import organisation from "./schemas/organisation.schema";
|
|
3
3
|
import Tokens from "./schemas/tokens.schema";
|
|
4
4
|
import mongoose, { Schema, Document, Types } from "mongoose";
|
|
5
|
-
import User from "
|
|
6
|
-
import { VERIFY_EMAIL } from "
|
|
5
|
+
import User from "~/routes/user.route";
|
|
6
|
+
import { VERIFY_EMAIL } from "~/utils/env";
|
|
7
7
|
|
|
8
8
|
export const usersColumns = {
|
|
9
9
|
id: "users.id",
|
|
@@ -37,7 +37,7 @@ type FindUserProps = {
|
|
|
37
37
|
export type UserProfile = {
|
|
38
38
|
_id?: string;
|
|
39
39
|
name?: string;
|
|
40
|
-
email?:
|
|
40
|
+
email?: any;
|
|
41
41
|
password?: string;
|
|
42
42
|
avatarUrl?: string;
|
|
43
43
|
is_active?: boolean;
|
|
@@ -69,7 +69,7 @@ export type UserProfile = {
|
|
|
69
69
|
* @param {string} mobileNumber
|
|
70
70
|
* @param {FindUserProps} deleted_at=null}
|
|
71
71
|
*/
|
|
72
|
-
export async function findUser({ id, email, moNumber }: FindUserProps) {
|
|
72
|
+
export async function findUser({ id, email, moNumber }: FindUserProps) : Promise<any> {
|
|
73
73
|
let search = {};
|
|
74
74
|
// let search: any = { deletedAt: { $exists: false } };
|
|
75
75
|
if (id) search = { _id: new mongoose.Types.ObjectId(id) };
|
|
@@ -86,21 +86,28 @@ export async function findUser({ id, email, moNumber }: FindUserProps) {
|
|
|
86
86
|
*/
|
|
87
87
|
|
|
88
88
|
export async function createUser(
|
|
89
|
-
userData:
|
|
90
|
-
|
|
89
|
+
userData: { name: string;
|
|
90
|
+
email: string;
|
|
91
|
+
role: string;
|
|
92
|
+
company: any;
|
|
93
|
+
permission: string[];
|
|
94
|
+
userType: string;
|
|
95
|
+
password: string;}
|
|
96
|
+
): Promise<Schema.Types.ObjectId | Error> {
|
|
91
97
|
try {
|
|
92
|
-
const user = await Account.register(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
);
|
|
98
|
+
const user = await Account.register(userData.email, userData.password);
|
|
99
|
+
|
|
100
|
+
// Manually set additional fields post-registration
|
|
101
|
+
user.name = userData.name;
|
|
102
|
+
user.role = userData.role;
|
|
103
|
+
user.company = userData.company.toString(); // Convert ObjectId to string
|
|
104
|
+
user.permission = userData.permission;
|
|
105
|
+
user.userType = userData.userType;
|
|
106
|
+
user.is_active = true; // Set based on logic
|
|
107
|
+
|
|
108
|
+
// Save changes to DB
|
|
109
|
+
await user.save();
|
|
110
|
+
|
|
104
111
|
const userId = user._id.toString();
|
|
105
112
|
return userId;
|
|
106
113
|
} catch (error) {
|
|
@@ -114,7 +121,7 @@ export async function createUser(
|
|
|
114
121
|
* @param {string} id
|
|
115
122
|
* @param {UserProfile} data
|
|
116
123
|
*/
|
|
117
|
-
export async function updateUser(id: string, data: UserProfile)
|
|
124
|
+
export async function updateUser(id: string, data: UserProfile): Promise<any> {
|
|
118
125
|
try {
|
|
119
126
|
const user = await Account.updateOne({ _id: id }, { $set: data });
|
|
120
127
|
return user;
|
|
@@ -123,35 +130,47 @@ export async function updateUser(id: string, data: UserProfile) : Promise<any> {
|
|
|
123
130
|
}
|
|
124
131
|
}
|
|
125
132
|
|
|
126
|
-
export async function createWorkFlowUser(userData: any)
|
|
133
|
+
export async function createWorkFlowUser(userData: any) {
|
|
127
134
|
try {
|
|
128
|
-
|
|
135
|
+
console.log(userData);
|
|
136
|
+
|
|
137
|
+
// Check if the user already exists
|
|
138
|
+
const checkUser: any = await Account.findOne({ username: userData.email });
|
|
129
139
|
if (checkUser) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
140
|
+
// Update the password if needed
|
|
141
|
+
if (userData.isText === 1 && userData?.password?.trim()) {
|
|
142
|
+
await new Promise((resolve, reject) => {
|
|
143
|
+
checkUser.setPassword(userData.password, (err: any) => {
|
|
144
|
+
if (err) return reject(err);
|
|
145
|
+
resolve(null);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
await checkUser.save();
|
|
135
149
|
}
|
|
136
150
|
return {
|
|
137
151
|
status: "success",
|
|
138
152
|
data: checkUser?._id,
|
|
139
153
|
};
|
|
140
154
|
} else {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
+
// Create a new instance of the Account model
|
|
156
|
+
const user = new Account({
|
|
157
|
+
username: userData.email,
|
|
158
|
+
role: userData.role,
|
|
159
|
+
moNumber: userData.moNumber,
|
|
160
|
+
designation: userData.designation,
|
|
161
|
+
level: userData.level,
|
|
162
|
+
company: userData.company,
|
|
163
|
+
permission: userData.permission,
|
|
164
|
+
is_active: userData.isActive,
|
|
165
|
+
defaultWorkflow: userData.defaultWorkflow,
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// Register the user and set the password
|
|
169
|
+
await Account.register(user as any, userData.password);
|
|
170
|
+
|
|
171
|
+
// Save the user
|
|
172
|
+
await user.save();
|
|
173
|
+
|
|
155
174
|
if (user) {
|
|
156
175
|
return {
|
|
157
176
|
status: "success",
|
|
@@ -164,14 +183,16 @@ export async function createWorkFlowUser(userData: any) : Promise<any>{
|
|
|
164
183
|
};
|
|
165
184
|
}
|
|
166
185
|
}
|
|
167
|
-
} catch (error) {
|
|
168
|
-
console.
|
|
186
|
+
} catch (error: any) {
|
|
187
|
+
console.error(error);
|
|
169
188
|
return {
|
|
170
189
|
status: "error",
|
|
171
190
|
data: error.message,
|
|
172
191
|
};
|
|
173
192
|
}
|
|
174
193
|
}
|
|
194
|
+
|
|
195
|
+
|
|
175
196
|
//update usertoken in mongodb in Tokens collection
|
|
176
197
|
/**
|
|
177
198
|
* @param {string} id
|
|
@@ -180,7 +201,7 @@ export async function createWorkFlowUser(userData: any) : Promise<any>{
|
|
|
180
201
|
export async function getUserByIdAndJoinUserToken(
|
|
181
202
|
id: string,
|
|
182
203
|
type: "verify_email" | "forgot_password" | "team_invitation_email"
|
|
183
|
-
)
|
|
204
|
+
) {
|
|
184
205
|
try {
|
|
185
206
|
const session = await Tokens.findOneAndUpdate(
|
|
186
207
|
{ user_id: new mongoose.Types.ObjectId(id) },
|
|
@@ -196,7 +217,7 @@ export async function getUserByIdAndJoinUserToken(
|
|
|
196
217
|
/**
|
|
197
218
|
* @param {string} id
|
|
198
219
|
*/
|
|
199
|
-
export async function activeUser(id: string)
|
|
220
|
+
export async function activeUser(id: string): Promise<any> {
|
|
200
221
|
try {
|
|
201
222
|
const user = await Account.findByIdAndUpdate(id, { is_active: true });
|
|
202
223
|
return user;
|
|
@@ -205,7 +226,7 @@ export async function activeUser(id: string) : Promise<any>{
|
|
|
205
226
|
}
|
|
206
227
|
}
|
|
207
228
|
|
|
208
|
-
export async function getPermissions(id: string)
|
|
229
|
+
export async function getPermissions(id: string) {
|
|
209
230
|
try {
|
|
210
231
|
const pipeline = [
|
|
211
232
|
{
|
|
@@ -253,7 +274,7 @@ export async function getallusers(
|
|
|
253
274
|
sort: string | null,
|
|
254
275
|
skip: string | null,
|
|
255
276
|
limit: string | null
|
|
256
|
-
)
|
|
277
|
+
) {
|
|
257
278
|
try {
|
|
258
279
|
let infiniteScroll: any = [];
|
|
259
280
|
if (sort && skip && limit) {
|
|
@@ -319,7 +340,7 @@ export async function getalluser(
|
|
|
319
340
|
company: string,
|
|
320
341
|
user: string,
|
|
321
342
|
role: string
|
|
322
|
-
){
|
|
343
|
+
) {
|
|
323
344
|
try {
|
|
324
345
|
let idSearch: object = { user: user };
|
|
325
346
|
if (role === "admin") {
|
|
@@ -359,7 +380,7 @@ export async function getalluser(
|
|
|
359
380
|
}
|
|
360
381
|
}
|
|
361
382
|
|
|
362
|
-
export async function deleteUserById(id: string)
|
|
383
|
+
export async function deleteUserById(id: string): Promise<any> {
|
|
363
384
|
try {
|
|
364
385
|
const result = await Account.updateOne(
|
|
365
386
|
{ _id: id },
|
|
@@ -373,7 +394,7 @@ export async function deleteUserById(id: string) : Promise<any> {
|
|
|
373
394
|
}
|
|
374
395
|
}
|
|
375
396
|
|
|
376
|
-
export async function getUser(id: string)
|
|
397
|
+
export async function getUser(id: string) {
|
|
377
398
|
const pipeline = [
|
|
378
399
|
{
|
|
379
400
|
$match: {
|
|
@@ -403,7 +424,7 @@ export async function getUser(id: string) : Promise<any> {
|
|
|
403
424
|
});
|
|
404
425
|
}
|
|
405
426
|
|
|
406
|
-
export async function getUserAccountDetails(id: string)
|
|
427
|
+
export async function getUserAccountDetails(id: string) {
|
|
407
428
|
try {
|
|
408
429
|
const accountData = await Account.findById(id).populate("company");
|
|
409
430
|
if (accountData) {
|
|
@@ -417,7 +438,7 @@ export async function getUserAccountDetails(id: string) : Promise<any>{
|
|
|
417
438
|
}
|
|
418
439
|
}
|
|
419
440
|
|
|
420
|
-
export async function updateUserAccountDetails(id: string, data: any)
|
|
441
|
+
export async function updateUserAccountDetails(id: string, data: any) {
|
|
421
442
|
try {
|
|
422
443
|
const accountData = await Account.findByIdAndUpdate(
|
|
423
444
|
id,
|
|
@@ -435,7 +456,7 @@ export async function updateUserAccountDetails(id: string, data: any) : Promise
|
|
|
435
456
|
}
|
|
436
457
|
}
|
|
437
458
|
|
|
438
|
-
export async function getCompanyByUserId(id: string)
|
|
459
|
+
export async function getCompanyByUserId(id: string) {
|
|
439
460
|
try {
|
|
440
461
|
const account = await Account.findById(id);
|
|
441
462
|
if (!account) {
|
|
@@ -447,7 +468,7 @@ export async function getCompanyByUserId(id: string) : Promise<any>{
|
|
|
447
468
|
}
|
|
448
469
|
}
|
|
449
470
|
|
|
450
|
-
export async function getUserByLevel(level: string)
|
|
471
|
+
export async function getUserByLevel(level: string) {
|
|
451
472
|
try {
|
|
452
473
|
const account = await Account.findOne({ level: level });
|
|
453
474
|
if (account) {
|
|
@@ -470,7 +491,7 @@ export async function getUserByLevel(level: string) : Promise<any>{
|
|
|
470
491
|
}
|
|
471
492
|
}
|
|
472
493
|
|
|
473
|
-
export async function updateUserWorkFlowStatus(data: any)
|
|
494
|
+
export async function updateUserWorkFlowStatus(data: any) {
|
|
474
495
|
try {
|
|
475
496
|
const modifiedData = await Account.findByIdAndUpdate(data.id, data, {
|
|
476
497
|
new: true,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Tokens from '
|
|
1
|
+
import Tokens from '~/repository/schemas/tokens.schema'
|
|
2
2
|
import mongoose, { Schema, Document } from 'mongoose';
|
|
3
3
|
|
|
4
4
|
//this defines the data strucutre of the Condition object
|
|
@@ -20,7 +20,7 @@ type GetToken = {
|
|
|
20
20
|
*/
|
|
21
21
|
export async function createToken(userId: string, token: string, type: 'verify_email' | 'forgot_password' | 'signup_vendor') {
|
|
22
22
|
try {
|
|
23
|
-
const tokens
|
|
23
|
+
const tokens = await Tokens.collection.insertOne({ token, type, user_id: new mongoose.Types.ObjectId(userId), isActive: true })
|
|
24
24
|
return tokens
|
|
25
25
|
} catch (err) {
|
|
26
26
|
return err
|
|
@@ -52,7 +52,7 @@ export async function findToken(token: string){
|
|
|
52
52
|
}catch(err){
|
|
53
53
|
return err
|
|
54
54
|
}
|
|
55
|
-
}
|
|
55
|
+
}
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* change token status in mongodb in Tokens collection
|
|
@@ -112,7 +112,7 @@ import mongoose from 'mongoose';
|
|
|
112
112
|
import UserRole from '~/repository/schemas/userrole.schema'
|
|
113
113
|
|
|
114
114
|
export { IUserRole }
|
|
115
|
-
export async function createRolePermission(data: IUserRole) {
|
|
115
|
+
export async function createRolePermission(data: IUserRole): Promise<mongoose.Types.ObjectId | Error> {
|
|
116
116
|
try {
|
|
117
117
|
// const result = await UserRole.deleteMany({});
|
|
118
118
|
const rolePermission = new UserRole({
|
|
@@ -123,7 +123,7 @@ export async function createRolePermission(data: IUserRole) {
|
|
|
123
123
|
createdAt: new Date()
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
-
const savedData
|
|
126
|
+
const savedData = await rolePermission.save()
|
|
127
127
|
savedData.template = savedData._id
|
|
128
128
|
await savedData.save()
|
|
129
129
|
console.log(rolePermission)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Schema } from "mongoose";
|
|
2
1
|
import WorkFlow from "./schemas/workflow.schema";
|
|
2
|
+
import { Schema } from "mongoose";
|
|
3
3
|
|
|
4
4
|
export type WorkFlowData = {
|
|
5
5
|
_id?: string;
|
|
@@ -13,7 +13,7 @@ export type WorkFlowData = {
|
|
|
13
13
|
|
|
14
14
|
export async function createWorkFlow(
|
|
15
15
|
workFlowData: WorkFlowData
|
|
16
|
-
){
|
|
16
|
+
): Promise<Schema.Types.ObjectId | Error> {
|
|
17
17
|
try {
|
|
18
18
|
const workflow = WorkFlow.create(new WorkFlow(workFlowData));
|
|
19
19
|
if (!workflow) {
|
|
@@ -263,7 +263,6 @@ export async function getDefaultWorkFlow(data: any) {
|
|
|
263
263
|
|
|
264
264
|
export async function getSingleWorkFlow(data: any) {
|
|
265
265
|
try {
|
|
266
|
-
console.log(WorkFlow)
|
|
267
266
|
let workflow = await WorkFlow.findOne(data);
|
|
268
267
|
if (workflow) {
|
|
269
268
|
workflow.values = Array.isArray(workflow.values)
|
|
@@ -309,7 +308,7 @@ export async function getDefaultWorkFlows(data: any) {
|
|
|
309
308
|
}
|
|
310
309
|
}
|
|
311
310
|
|
|
312
|
-
export async function getWorkFlow(data: any) {
|
|
311
|
+
export async function getWorkFlow(data: any): Promise<WorkFlowData> {
|
|
313
312
|
try {
|
|
314
313
|
const workflow = await WorkFlow.findOne(data);
|
|
315
314
|
return workflow;
|
|
@@ -318,7 +317,7 @@ export async function getWorkFlow(data: any) {
|
|
|
318
317
|
}
|
|
319
318
|
}
|
|
320
319
|
|
|
321
|
-
export async function getWorkFlowLevel(Id: any) {
|
|
320
|
+
export async function getWorkFlowLevel(Id: any): Promise<WorkFlowData> {
|
|
322
321
|
try {
|
|
323
322
|
const workflow = await WorkFlow.findById(Id);
|
|
324
323
|
return workflow;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import express, { Request, Response, NextFunction, Router } from 'express';
|
|
2
|
-
import { authenticateJWT } from '
|
|
3
|
-
import {
|
|
2
|
+
import { authenticateJWT } from '~/controllers/auth.controller';
|
|
3
|
+
import { grantAccess } from '~/controllers/rbac/rbac.controller';
|
|
4
|
+
import { createAccountService, getAccountService } from '~/services/statement/accountdetails.service';
|
|
4
5
|
|
|
5
6
|
const AccountDetails = express.Router();
|
|
6
7
|
|
package/src/routes/auth.route.ts
CHANGED
|
@@ -2,6 +2,7 @@ import express from 'express';
|
|
|
2
2
|
|
|
3
3
|
import auth from 'express-basic-auth'
|
|
4
4
|
|
|
5
|
+
import { registerAdmin, loginUser, forgotPasswordUser, verifyEmail, resetPasswordUser } from '~/services/authentication';
|
|
5
6
|
|
|
6
7
|
const basic = auth({
|
|
7
8
|
users: { 'admin': 'abc12345' },
|
|
@@ -11,14 +12,14 @@ const basic = auth({
|
|
|
11
12
|
|
|
12
13
|
const Auth = express.Router();
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
Auth.post('/signup', registerAdmin)
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
Auth.post('/login', loginUser);
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
Auth.post('/forgotPassword', forgotPasswordUser)
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
Auth.get('/verifyEmail', verifyEmail);
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
Auth.post('/resetPassword', resetPasswordUser)
|
|
23
24
|
|
|
24
25
|
export default Auth
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
|
-
import { authenticateJWT } from '
|
|
3
|
-
import { createPendingApprovalService, deleteAllDocumentsService, deleteSingleDocumentService, findOneAndDeleteDocument, getAllDocumentService, getcountDocumentsByLevelAndStatusService, sendMailService, updateDocumentService, updateStatusService } from '
|
|
2
|
+
import { authenticateJWT } from '~/controllers/auth.controller';
|
|
3
|
+
import { createPendingApprovalService, deleteAllDocumentsService, deleteSingleDocumentService, findOneAndDeleteDocument, getAllDocumentService, getcountDocumentsByLevelAndStatusService, saveAsDraftService, sendMailService, updateDocumentService, updateStatusService, uploadAddtionalDocumentsService } from '~/services/document/document.services';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
const Document = express.Router();
|
|
@@ -13,8 +13,12 @@ Document.post('/getcount', authenticateJWT, getcountDocumentsByLevelAndStatusSer
|
|
|
13
13
|
|
|
14
14
|
Document.put('/updatedoc/:id', authenticateJWT,updateDocumentService)
|
|
15
15
|
|
|
16
|
+
Document.put('/save/:id', authenticateJWT, saveAsDraftService)
|
|
17
|
+
|
|
16
18
|
Document.post('/create',authenticateJWT,createPendingApprovalService)
|
|
17
19
|
|
|
20
|
+
Document.post('/upload/addtionalDocument',authenticateJWT,uploadAddtionalDocumentsService)
|
|
21
|
+
|
|
18
22
|
Document.delete('/single/:id',authenticateJWT,deleteSingleDocumentService)
|
|
19
23
|
|
|
20
24
|
Document.delete('/deleteMany',authenticateJWT,deleteAllDocumentsService)
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import express from 'express'
|
|
2
|
-
import { uploadFileService, getFileService, downloadFile } from '
|
|
2
|
+
import { uploadFileService, getFileService, downloadFile } from '~/services/fileSystem/fileSystem.service'
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
const FileUpload = express()
|
|
6
6
|
|
|
7
|
+
// route.post('/upload-file',uploadFileWithMulter)
|
|
8
|
+
|
|
7
9
|
|
|
8
10
|
FileUpload.post('/upload', uploadFileService)
|
|
9
11
|
|
package/src/routes/form.route.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import express from "express";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { authenticateJWT } from "~/controllers/auth.controller";
|
|
3
|
+
import {
|
|
4
|
+
createFormService,
|
|
5
|
+
deleteFormService,
|
|
6
|
+
getallFormService,
|
|
7
|
+
updateFormService,
|
|
8
|
+
} from "~/services/form/form.service";
|
|
4
9
|
|
|
5
10
|
const Form = express.Router();
|
|
6
11
|
|
package/src/routes/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import express, { Request, Response, NextFunction } from 'express';
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
//import Account from '../repository/schemas/accounts.schema'
|
|
4
|
+
import { authenticateJWT } from '~/controllers/auth.controller';
|
|
4
5
|
|
|
5
6
|
const routes = express.Router();
|
|
6
7
|
|
package/src/routes/log.route.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import express, { Request, Response, NextFunction, Router } from 'express';
|
|
2
2
|
|
|
3
|
-
import { authenticateJWT } from
|
|
3
|
+
import { authenticateJWT } from '~/controllers/auth.controller';
|
|
4
4
|
|
|
5
|
-
import { grantAccess } from '
|
|
6
|
-
import { createLogService, getLogService } from '
|
|
5
|
+
import { grantAccess } from '~/controllers/rbac/rbac.controller'
|
|
6
|
+
import { createLogService, getLogService } from '~/services/logs/log.service';
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
const Logs = express.Router();
|
|
10
10
|
|
|
11
11
|
Logs.post('/create', authenticateJWT, createLogService)
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Logs.get('/get', authenticateJWT, getLogService)
|
|
14
14
|
|
|
15
15
|
export default Logs;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { authenticateJWT } from '~/controllers/auth.controller';
|
|
3
|
-
import { createNotificationsService,
|
|
3
|
+
import { createNotificationsService, getUnreadNotificationsCountService,getUnreadNotificationsService,getReadNotificationsService, updateNotificationsService, deleteNotificationsService, markAllNotificationsAsReadService, getAllNotificationsService } from '~/services/notifications/notifications.service';
|
|
4
4
|
|
|
5
5
|
const Notifications = express.Router();
|
|
6
6
|
|
package/src/routes/org.route.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import express, { Request, Response, NextFunction, Router } from 'express';
|
|
2
|
-
import { authenticateJWT } from
|
|
3
|
-
import { createOrganizationService, getComplainceCountService, getOrgDetailsService, getOrganisationService, updateOrganisationHandler } from '
|
|
2
|
+
import { authenticateJWT } from '~/controllers/auth.controller';
|
|
3
|
+
import { createOrganizationService, getComplainceCountService, getOrgDetailsService, getOrganisationService, updateOrganisationHandler } from '~/services/organisation/organisation.service';
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
const Organisation = express.Router();
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import express, { Request, Response, NextFunction, Router } from 'express';
|
|
2
|
+
import { createProfileService, getAllProfileService, updateProfileService } from '~/services/profile/profile.services'
|
|
2
3
|
|
|
3
4
|
const Profile = express.Router();
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
Profile.get('/get', getAllProfileService)
|
|
7
|
+
Profile.post('/create', createProfileService)
|
|
8
|
+
Profile.put('/update/:id', updateProfileService)
|
|
8
9
|
|
|
9
10
|
export default Profile;
|
package/src/routes/role.route.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import express, { Request, Response, NextFunction, Router } from 'express';
|
|
2
2
|
|
|
3
|
+
import { authenticateJWT } from '~/controllers/auth.controller';
|
|
4
|
+
import { grantAccess } from '~/controllers/rbac/rbac.controller'
|
|
3
5
|
|
|
4
6
|
|
|
7
|
+
import { createRoleService, getAllRolesService, getRoleById, deleteRoleService, updateRoleService } from '~/services/roles/role.services';
|
|
5
8
|
|
|
6
9
|
const Roles = express.Router();
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
Roles.post('/create', authenticateJWT, grantAccess('create', 'roles'), createRoleService) // grantAccess('create', 'roles'),
|
|
12
|
+
Roles.get('/get', authenticateJWT, grantAccess('get', 'roles'), getAllRolesService) // grantAccess('get', 'roles')
|
|
10
13
|
// Roles.get('/get/:id', authenticateJWT, grantAccess('get', 'roles'), getRoleById)
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
Roles.delete('/delete/:id', grantAccess('delete', 'roles'), authenticateJWT, deleteRoleService)
|
|
15
|
+
Roles.put('/update/:id', authenticateJWT, grantAccess('update', 'roles'), updateRoleService)
|
|
13
16
|
|
|
14
17
|
export default Roles;
|