my-typescript-library-rahul52us 1.2.4 → 1.2.6

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 (42) hide show
  1. package/dist/repository/document.repository.js.map +1 -1
  2. package/dist/repository/filesystem.repository.js +5 -2
  3. package/dist/repository/filesystem.repository.js.map +1 -1
  4. package/dist/repository/schemas/fileSystem.schema.js +36 -4
  5. package/dist/repository/schemas/fileSystem.schema.js.map +1 -1
  6. package/dist/repository/schemas/workflow.schema.js +50 -16
  7. package/dist/repository/schemas/workflow.schema.js.map +1 -1
  8. package/dist/repository/workflow.repository.js +16 -14
  9. package/dist/repository/workflow.repository.js.map +1 -1
  10. package/dist/routes/workflow.route.js +9 -8
  11. package/dist/routes/workflow.route.js.map +1 -1
  12. package/dist/services/document/document.services.js +3 -7
  13. package/dist/services/document/document.services.js.map +1 -1
  14. package/dist/setupModal.js +6 -8
  15. package/dist/setupModal.js.map +1 -1
  16. package/dist/types/repository/document.repository.d.ts +18 -47
  17. package/dist/types/repository/form.repository.d.ts +2 -32
  18. package/dist/types/repository/notifications.repository.d.ts +1 -2
  19. package/dist/types/repository/schemas/fileSystem.schema.d.ts +6 -1
  20. package/dist/types/repository/schemas/workflow.schema.d.ts +14 -38
  21. package/dist/types/repository/user.repository.d.ts +13 -110
  22. package/dist/types/repository/workflow.repository.d.ts +38 -3
  23. package/dist/types/services/authentication/getuser.service.d.ts +3 -3
  24. package/dist/types/services/authentication/register.service.d.ts +2 -2
  25. package/dist/types/services/document/document.services.d.ts +15 -41
  26. package/dist/types/services/workflow/workSettings.service.d.ts +1 -1
  27. package/dist/types/services/workflow/workflow.service.d.ts +8 -8
  28. package/dist/types/setupModal.d.ts +0 -1
  29. package/package.json +1 -1
  30. package/src/repository/document.repository.ts +20 -20
  31. package/src/repository/filesystem.repository.ts +2 -2
  32. package/src/repository/form.repository.ts +4 -4
  33. package/src/repository/notifications.repository.ts +1 -1
  34. package/src/repository/schemas/fileSystem.schema.ts +17 -2
  35. package/src/repository/schemas/workflow.schema.ts +69 -39
  36. package/src/repository/user.repository.ts +15 -15
  37. package/src/repository/workflow.repository.ts +1 -2
  38. package/src/routes/workflow.route.ts +10 -8
  39. package/src/services/document/document.services.ts +22 -22
  40. package/src/services/workflow/workSettings.service.ts +1 -1
  41. package/src/services/workflow/workflow.service.ts +7 -7
  42. package/src/setupModal.ts +6 -6
@@ -87,7 +87,7 @@ export async function findUser({ id, email, moNumber }: FindUserProps) {
87
87
 
88
88
  export async function createUser(
89
89
  userData: UserProfile
90
- ) {
90
+ ) : Promise<any>{
91
91
  try {
92
92
  const user = await Account.register(
93
93
  new Account({
@@ -114,7 +114,7 @@ export async function createUser(
114
114
  * @param {string} id
115
115
  * @param {UserProfile} data
116
116
  */
117
- export async function updateUser(id: string, data: UserProfile) {
117
+ export async function updateUser(id: string, data: UserProfile) : Promise<any> {
118
118
  try {
119
119
  const user = await Account.updateOne({ _id: id }, { $set: data });
120
120
  return user;
@@ -123,7 +123,7 @@ export async function updateUser(id: string, data: UserProfile) {
123
123
  }
124
124
  }
125
125
 
126
- export async function createWorkFlowUser(userData: any) {
126
+ export async function createWorkFlowUser(userData: any) : Promise<any>{
127
127
  try {
128
128
  const checkUser = await Account.findOne({ username: userData.email });
129
129
  if (checkUser) {
@@ -180,7 +180,7 @@ export async function createWorkFlowUser(userData: any) {
180
180
  export async function getUserByIdAndJoinUserToken(
181
181
  id: string,
182
182
  type: "verify_email" | "forgot_password" | "team_invitation_email"
183
- ) {
183
+ ) : Promise<any>{
184
184
  try {
185
185
  const session = await Tokens.findOneAndUpdate(
186
186
  { user_id: new mongoose.Types.ObjectId(id) },
@@ -196,7 +196,7 @@ export async function getUserByIdAndJoinUserToken(
196
196
  /**
197
197
  * @param {string} id
198
198
  */
199
- export async function activeUser(id: string) {
199
+ export async function activeUser(id: string) : Promise<any>{
200
200
  try {
201
201
  const user = await Account.findByIdAndUpdate(id, { is_active: true });
202
202
  return user;
@@ -205,7 +205,7 @@ export async function activeUser(id: string) {
205
205
  }
206
206
  }
207
207
 
208
- export async function getPermissions(id: string) {
208
+ export async function getPermissions(id: string) : Promise<any> {
209
209
  try {
210
210
  const pipeline = [
211
211
  {
@@ -253,7 +253,7 @@ export async function getallusers(
253
253
  sort: string | null,
254
254
  skip: string | null,
255
255
  limit: string | null
256
- ) {
256
+ ) : Promise<any> {
257
257
  try {
258
258
  let infiniteScroll: any = [];
259
259
  if (sort && skip && limit) {
@@ -319,7 +319,7 @@ export async function getalluser(
319
319
  company: string,
320
320
  user: string,
321
321
  role: string
322
- ) {
322
+ ) : Promise<any>{
323
323
  try {
324
324
  let idSearch: object = { user: user };
325
325
  if (role === "admin") {
@@ -359,7 +359,7 @@ export async function getalluser(
359
359
  }
360
360
  }
361
361
 
362
- export async function deleteUserById(id: string) {
362
+ export async function deleteUserById(id: string) : Promise<any> {
363
363
  try {
364
364
  const result = await Account.updateOne(
365
365
  { _id: id },
@@ -373,7 +373,7 @@ export async function deleteUserById(id: string) {
373
373
  }
374
374
  }
375
375
 
376
- export async function getUser(id: string) {
376
+ export async function getUser(id: string) : Promise<any> {
377
377
  const pipeline = [
378
378
  {
379
379
  $match: {
@@ -403,7 +403,7 @@ export async function getUser(id: string) {
403
403
  });
404
404
  }
405
405
 
406
- export async function getUserAccountDetails(id: string) {
406
+ export async function getUserAccountDetails(id: string) : Promise<any>{
407
407
  try {
408
408
  const accountData = await Account.findById(id).populate("company");
409
409
  if (accountData) {
@@ -417,7 +417,7 @@ export async function getUserAccountDetails(id: string) {
417
417
  }
418
418
  }
419
419
 
420
- export async function updateUserAccountDetails(id: string, data: any) {
420
+ export async function updateUserAccountDetails(id: string, data: any) : Promise<any>{
421
421
  try {
422
422
  const accountData = await Account.findByIdAndUpdate(
423
423
  id,
@@ -435,7 +435,7 @@ export async function updateUserAccountDetails(id: string, data: any) {
435
435
  }
436
436
  }
437
437
 
438
- export async function getCompanyByUserId(id: string) {
438
+ export async function getCompanyByUserId(id: string) : Promise<any>{
439
439
  try {
440
440
  const account = await Account.findById(id);
441
441
  if (!account) {
@@ -447,7 +447,7 @@ export async function getCompanyByUserId(id: string) {
447
447
  }
448
448
  }
449
449
 
450
- export async function getUserByLevel(level: string) {
450
+ export async function getUserByLevel(level: string) : Promise<any>{
451
451
  try {
452
452
  const account = await Account.findOne({ level: level });
453
453
  if (account) {
@@ -470,7 +470,7 @@ export async function getUserByLevel(level: string) {
470
470
  }
471
471
  }
472
472
 
473
- export async function updateUserWorkFlowStatus(data: any) {
473
+ export async function updateUserWorkFlowStatus(data: any) : Promise<any> {
474
474
  try {
475
475
  const modifiedData = await Account.findByIdAndUpdate(data.id, data, {
476
476
  new: true,
@@ -1,7 +1,6 @@
1
1
  import { Schema } from "mongoose";
2
- import { getWorkflowModel } from "../setupModal";
2
+ import WorkFlow from "./schemas/workflow.schema";
3
3
 
4
- const WorkFlow = getWorkflowModel()
5
4
  export type WorkFlowData = {
6
5
  _id?: string;
7
6
  username: string;
@@ -1,27 +1,29 @@
1
1
  import express from "express";
2
2
  import { authenticateJWT } from "../controllers/auth.controller";
3
3
  import {
4
+ createWorkflowSettingService,
4
5
  getWorkflowSettingsService,
5
6
  } from "../services/workflow/workSettings.service";
7
+ import { createWorkFlowService, deleteWorkflow, getallUsersWorkFlowService, getallWorkFlowService, getDefaultWorkFlowService, updateWorkFlowService, updateWorkFlowUserStatus } from "../services/workflow/workflow.service";
6
8
 
7
9
 
8
10
  const WorkFlow = express.Router();
9
11
 
10
- // WorkFlow.get("/get", authenticateJWT, getallWorkFlowService);
12
+ WorkFlow.get("/get", authenticateJWT, getallWorkFlowService);
11
13
 
12
- // WorkFlow.post("/create", authenticateJWT, createWorkFlowService);
14
+ WorkFlow.post("/create", authenticateJWT, createWorkFlowService);
13
15
 
14
- // WorkFlow.put("/update/:id", authenticateJWT, updateWorkFlowService);
16
+ WorkFlow.put("/update/:id", authenticateJWT, updateWorkFlowService);
15
17
 
16
- // WorkFlow.delete("/delete/:id", authenticateJWT, deleteWorkflow);
18
+ WorkFlow.delete("/delete/:id", authenticateJWT, deleteWorkflow);
17
19
 
18
- // WorkFlow.get("/get/default", authenticateJWT, getDefaultWorkFlowService);
20
+ WorkFlow.get("/get/default", authenticateJWT, getDefaultWorkFlowService);
19
21
 
20
- // WorkFlow.put("/status/:id", authenticateJWT, updateWorkFlowUserStatus);
22
+ WorkFlow.put("/status/:id", authenticateJWT, updateWorkFlowUserStatus);
21
23
 
22
- // WorkFlow.get("/get/users", authenticateJWT, getallUsersWorkFlowService);
24
+ WorkFlow.get("/get/users", authenticateJWT, getallUsersWorkFlowService);
23
25
 
24
- // WorkFlow.post("/setting/create", authenticateJWT, createWorkflowSettingService);
26
+ WorkFlow.post("/setting/create", authenticateJWT, createWorkflowSettingService);
25
27
 
26
28
  WorkFlow.get("/setting/get", authenticateJWT, getWorkflowSettingsService);
27
29
 
@@ -45,7 +45,7 @@ interface UserRequest extends Request {
45
45
  };
46
46
  }
47
47
 
48
- export async function getCountService(req: UserRequest, res: Response) {
48
+ export async function getCountService(req: UserRequest, res: Response): Promise<any> {
49
49
  try {
50
50
  let { level, _id } = req.user;
51
51
  let exchangeType = (req.query.exchangeType as string) || null;
@@ -57,7 +57,7 @@ export async function getCountService(req: UserRequest, res: Response) {
57
57
  }
58
58
  }
59
59
 
60
- export async function findOneAndDeleteDocument(req : any, res : any) {
60
+ export async function findOneAndDeleteDocument(req : any, res : any): Promise<any> {
61
61
  try
62
62
  {
63
63
  await findOneByDocumentIdAndDelete({
@@ -76,7 +76,7 @@ export async function findOneAndDeleteDocument(req : any, res : any) {
76
76
  }
77
77
  }
78
78
 
79
- export async function createPendingApprovalFunction(req: any) {
79
+ export async function createPendingApprovalFunction(req: any) : Promise<any> {
80
80
  try {
81
81
  if (req.body.documentId) {
82
82
  await findOneByDocumentIdAndDelete({
@@ -93,7 +93,7 @@ export async function createPendingApprovalFunction(req: any) {
93
93
  req.body.activeWorkflow || req.user.defaultWorkflow
94
94
  );
95
95
 
96
- if (true) {
96
+ if (status === "success") {
97
97
  if (type === "word") {
98
98
  values = {
99
99
  user: userID,
@@ -145,12 +145,12 @@ export async function createPendingApprovalFunction(req: any) {
145
145
  helpInfo: req.body.helpInfo || {},
146
146
  };
147
147
  if (file) {
148
- // const uploadedFile: any = await uploadFile(
149
- // file.file,
150
- // file.name,
151
- // file.type
152
- // );
153
- values = { ...values, file: '67319823bbf5d3230ca58bdd' };
148
+ const uploadedFile: any = await uploadFile(
149
+ file.file,
150
+ file.name,
151
+ file.type
152
+ );
153
+ values = { ...values, file: uploadedFile.fileId };
154
154
  }
155
155
  } else {
156
156
  const uploadedFile: any = await uploadFile(
@@ -476,7 +476,7 @@ export async function createPendingApprovalFunction(req: any) {
476
476
  export async function createPendingApprovalService(
477
477
  req: UserRequest,
478
478
  res: Response
479
- ) {
479
+ ) : Promise<any> {
480
480
  try {
481
481
  const { status, data, statusCode, message } =
482
482
  await createPendingApprovalFunction({ user: req?.user, body: req?.body });
@@ -498,7 +498,7 @@ export async function createPendingApprovalService(
498
498
  export async function getAllPendingApprovalService(
499
499
  req: UserRequest,
500
500
  res: Response
501
- ) {
501
+ ) : Promise<any>{
502
502
  try {
503
503
  let { company, _id } = req.user;
504
504
  let value = (req.query.value as string) || "";
@@ -523,7 +523,7 @@ export async function getAllPendingApprovalService(
523
523
  }
524
524
  }
525
525
 
526
- export async function getAllDocumentFunction(req: any) {
526
+ export async function getAllDocumentFunction(req: any) : Promise<any> {
527
527
  try {
528
528
  // let { company, _id, level, defaultWorkflow } = req.user;
529
529
  let { defaultWorkflow } = req.user;
@@ -598,7 +598,7 @@ export async function getAllDocumentFunction(req: any) {
598
598
  }
599
599
  }
600
600
 
601
- export async function getAllDocumentService(req: UserRequest, res: Response) {
601
+ export async function getAllDocumentService(req: UserRequest, res: Response) : Promise<any> {
602
602
  try {
603
603
  const { status, statusCode, documents } = await getAllDocumentFunction({
604
604
  body: req?.body,
@@ -645,7 +645,7 @@ export async function getCountByLevelAndStatusFunction(req: any) {
645
645
  export async function getcountDocumentsByLevelAndStatusService(
646
646
  req: UserRequest,
647
647
  res: Response
648
- ) {
648
+ ) : Promise<any> {
649
649
  try {
650
650
  const { status, statusCode, data } = await getCountByLevelAndStatusFunction(
651
651
  { body: req?.body, user: req?.user }
@@ -658,7 +658,7 @@ export async function getcountDocumentsByLevelAndStatusService(
658
658
  export async function getPendingApprovalService(
659
659
  req: UserRequest,
660
660
  res: Response
661
- ) {
661
+ ) : Promise<any>{
662
662
  try {
663
663
  let { company, _id } = req.user;
664
664
  let value = (req.query.value as string) || "";
@@ -997,7 +997,7 @@ export async function updateDocumentFunction(req: any, docId: any) {
997
997
  }
998
998
  }
999
999
 
1000
- export async function updateDocumentService(req: UserRequest, res: Response) {
1000
+ export async function updateDocumentService(req: UserRequest, res: Response) : Promise<any> {
1001
1001
  try {
1002
1002
  const id = req?.params?.id;
1003
1003
  const { status, statusCode, message } = await updateDocumentFunction(
@@ -1017,7 +1017,7 @@ export async function updateDocumentService(req: UserRequest, res: Response) {
1017
1017
  export async function updateDocumentLevel2Service(
1018
1018
  req: UserRequest,
1019
1019
  res: Response
1020
- ) {
1020
+ ) : Promise<any>{
1021
1021
  try {
1022
1022
  const id = req.params.id;
1023
1023
  const updates = req.body;
@@ -1074,7 +1074,7 @@ export async function updateDocumentLevel2Service(
1074
1074
  export async function updateDocumentLevelService(
1075
1075
  req: UserRequest,
1076
1076
  res: Response
1077
- ) {
1077
+ ) : Promise<any>{
1078
1078
  try {
1079
1079
  const id = req.params.id;
1080
1080
  const updates = req.body;
@@ -1134,7 +1134,7 @@ export async function updateDocumentLevelService(
1134
1134
  }
1135
1135
  }
1136
1136
 
1137
- export const getDashChartService = async (req: UserRequest, res: Response) => {
1137
+ export const getDashChartService = async (req: UserRequest, res: Response) : Promise<any> => {
1138
1138
  try {
1139
1139
  req.body.user = req.user;
1140
1140
  const result = await getDashChartdata(req.body);
@@ -1147,7 +1147,7 @@ export const getDashChartService = async (req: UserRequest, res: Response) => {
1147
1147
  }
1148
1148
  };
1149
1149
 
1150
- export const deleteAllDocumentsService = async (req: any, res: Response) => {
1150
+ export const deleteAllDocumentsService = async (req: any, res: Response) : Promise<any> => {
1151
1151
  try {
1152
1152
  const { status, data } = await deleteAllDocuments();
1153
1153
  if (status === "success") {
@@ -1169,7 +1169,7 @@ export const deleteAllDocumentsService = async (req: any, res: Response) => {
1169
1169
  }
1170
1170
  };
1171
1171
 
1172
- export const deleteSingleDocumentService = async (req: any, res: Response) => {
1172
+ export const deleteSingleDocumentService = async (req: any, res: Response) : Promise<any> => {
1173
1173
  try {
1174
1174
  const { status, data } = await deleteSingleDocument({
1175
1175
  id: new mongoose.Types.ObjectId(req.params.id),
@@ -41,7 +41,7 @@ export async function createWorkflowSettingFunction(req: any) {
41
41
  }
42
42
  }
43
43
 
44
- export async function createWorkflowSettingService(req: any, res: Response) {
44
+ export async function createWorkflowSettingService(req: any, res: Response):Promise<any> {
45
45
  try {
46
46
  const { status, statusCode, data } = await createWorkflowSettingFunction({
47
47
  body: req?.body,
@@ -182,7 +182,7 @@ export async function generateWorkflow(req: any) {
182
182
  export async function createWorkFlowService(
183
183
  req: UserRequest,
184
184
  res: Response
185
- ): Promise<Response> {
185
+ ): Promise<any> {
186
186
  try {
187
187
  const { status, statusCode, message } = await generateWorkflow({
188
188
  body: req.body,
@@ -272,7 +272,7 @@ export async function getDefaultWorkflowFunction(req: any) {
272
272
  export async function getDefaultWorkFlowService(
273
273
  req: UserRequest,
274
274
  res: Response
275
- ) {
275
+ ) : Promise<any>{
276
276
  try {
277
277
  const { status, statusCode, data } = await getDefaultWorkflowFunction({
278
278
  query: req?.query,
@@ -503,7 +503,7 @@ export async function updateWorkflowFunction(req: any, workflowId: any) {
503
503
  export async function updateWorkFlowService(
504
504
  req: UserRequest,
505
505
  res: Response
506
- ): Promise<Response> {
506
+ ): Promise<any> {
507
507
  try {
508
508
  const { id } = req.params;
509
509
  const { status, statusCode, message } = await updateWorkflowFunction(
@@ -549,7 +549,7 @@ export async function getWorkflowFunctionService(req: any) {
549
549
  export async function getallWorkFlowService(
550
550
  req: UserRequest,
551
551
  res: Response
552
- ): Promise<Response> {
552
+ ): Promise<any> {
553
553
  try {
554
554
  const { status, statusCode, data } = await getWorkflowFunctionService({
555
555
  query: req?.query,
@@ -586,7 +586,7 @@ export async function getUserWorkflowFunction(req: any) {
586
586
  export async function getallUsersWorkFlowService(
587
587
  req: UserRequest,
588
588
  res: Response
589
- ): Promise<Response> {
589
+ ): Promise<any> {
590
590
  try {
591
591
  const { status, statusCode, workflow } = await getUserWorkflowFunction({
592
592
  user: req?.user,
@@ -632,7 +632,7 @@ export async function deleteWorkflowFunction(id: any) {
632
632
  export async function deleteWorkflow(
633
633
  req: Request,
634
634
  res: Response
635
- ): Promise<Response> {
635
+ ): Promise<any> {
636
636
  const { id } = req.params;
637
637
  try {
638
638
  const { status, statusCode, message } = await deleteWorkflowFunction(id);
@@ -715,7 +715,7 @@ export async function updateWorkflowStatusFunction(id: any, req: any) {
715
715
  export async function updateWorkFlowUserStatus(
716
716
  req: UserRequest,
717
717
  res: Response
718
- ) {
718
+ ) : Promise<any>{
719
719
  try {
720
720
  const id = req?.params?.id;
721
721
  const { status, statusCode, message } = await updateWorkflowStatusFunction(
package/src/setupModal.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // library/mongooseSetup.ts
2
2
  import mongoose from "mongoose";
3
3
  import { DocumentSchema } from "./repository/schemas/document.schema";
4
- import { workFlowSchema } from "./repository/schemas/workflow.schema";
4
+ import workFlowSchema from "./repository/schemas/workflow.schema";
5
5
  import { fileSystemSchema } from './repository/schemas/fileSystem.schema';
6
6
 
7
7
  /**
@@ -36,7 +36,7 @@ export const setupLibrary = (connection: typeof mongoose) => {
36
36
 
37
37
  // Dynamically resolve models and store them
38
38
  DocumentModel = getOrCreateModel("Document", DocumentSchema);
39
- WorkflowModel = getOrCreateModel("Workflow", workFlowSchema);
39
+ // WorkflowModel = getOrCreateModel("Workflow", workFlowSchema);
40
40
  FileSystemModel = getOrCreateModel("FileSystem", fileSystemSchema);
41
41
 
42
42
  modelsInitialized = true;
@@ -58,10 +58,10 @@ export const getDocumentModel = () => {
58
58
  return DocumentModel;
59
59
  };
60
60
 
61
- export const getWorkflowModel = () => {
62
- checkInitialization();
63
- return WorkflowModel;
64
- };
61
+ // export const getWorkflowModel = () => {
62
+ // checkInitialization();
63
+ // return WorkflowModel;
64
+ // };
65
65
 
66
66
  export const getFileSystemModel = () => {
67
67
  checkInitialization();