my-typescript-library-rahul52us 1.3.4 → 1.3.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 (214) hide show
  1. package/dist/config/auth/passportConfig.js +1 -0
  2. package/dist/config/auth/passportConfig.js.map +1 -1
  3. package/dist/controllers/auth.controller.js.map +1 -1
  4. package/dist/controllers/license/license.controller.js +1 -1
  5. package/dist/controllers/license/license.controller.js.map +1 -1
  6. package/dist/controllers/rbac/rbac.controller.js +1 -5
  7. package/dist/controllers/rbac/rbac.controller.js.map +1 -1
  8. package/dist/repository/document.repository.js +174 -22
  9. package/dist/repository/document.repository.js.map +1 -1
  10. package/dist/repository/filesystem.repository.js +3 -3
  11. package/dist/repository/filesystem.repository.js.map +1 -1
  12. package/dist/repository/log.repository.js.map +1 -1
  13. package/dist/repository/notifications.repository.js.map +1 -1
  14. package/dist/repository/organisation.repository.js.map +1 -1
  15. package/dist/repository/schemas/accountdetails.schema.js.map +1 -1
  16. package/dist/repository/schemas/accounts.schema.js +10 -33
  17. package/dist/repository/schemas/accounts.schema.js.map +1 -1
  18. package/dist/repository/schemas/document.schema.js +12 -19
  19. package/dist/repository/schemas/document.schema.js.map +1 -1
  20. package/dist/repository/schemas/extracted.schema.js +3 -5
  21. package/dist/repository/schemas/extracted.schema.js.map +1 -1
  22. package/dist/repository/schemas/fileSystem.schema.js +2 -5
  23. package/dist/repository/schemas/fileSystem.schema.js.map +1 -1
  24. package/dist/repository/schemas/form.schema.js +1 -1
  25. package/dist/repository/schemas/form.schema.js.map +1 -1
  26. package/dist/repository/schemas/log.schema.js +4 -4
  27. package/dist/repository/schemas/log.schema.js.map +1 -1
  28. package/dist/repository/schemas/notifications.schema.js +2 -3
  29. package/dist/repository/schemas/notifications.schema.js.map +1 -1
  30. package/dist/repository/schemas/organisation.schema.js +25 -29
  31. package/dist/repository/schemas/organisation.schema.js.map +1 -1
  32. package/dist/repository/schemas/profile.schema.js +1 -1
  33. package/dist/repository/schemas/profile.schema.js.map +1 -1
  34. package/dist/repository/schemas/role.schema.js +1 -1
  35. package/dist/repository/schemas/role.schema.js.map +1 -1
  36. package/dist/repository/schemas/tokens.schema.js +5 -5
  37. package/dist/repository/schemas/tokens.schema.js.map +1 -1
  38. package/dist/repository/schemas/userrole.schema.js +1 -1
  39. package/dist/repository/schemas/userrole.schema.js.map +1 -1
  40. package/dist/repository/schemas/workflow.schema.js +14 -40
  41. package/dist/repository/schemas/workflow.schema.js.map +1 -1
  42. package/dist/repository/user.repository.js +32 -20
  43. package/dist/repository/user.repository.js.map +1 -1
  44. package/dist/repository/user_tokens.repository.js.map +1 -1
  45. package/dist/repository/userrole.repository.js +1 -1
  46. package/dist/repository/userrole.repository.js.map +1 -1
  47. package/dist/repository/workflow.repository.js +0 -1
  48. package/dist/repository/workflow.repository.js.map +1 -1
  49. package/dist/routes/auth.route.js +6 -5
  50. package/dist/routes/auth.route.js.map +1 -1
  51. package/dist/routes/document.route.js +2 -0
  52. package/dist/routes/document.route.js.map +1 -1
  53. package/dist/routes/fileSystem.route.js +1 -0
  54. package/dist/routes/fileSystem.route.js.map +1 -1
  55. package/dist/routes/form.route.js +1 -1
  56. package/dist/routes/form.route.js.map +1 -1
  57. package/dist/routes/index.js +1 -1
  58. package/dist/routes/index.js.map +1 -1
  59. package/dist/routes/log.route.js +1 -1
  60. package/dist/routes/log.route.js.map +1 -1
  61. package/dist/routes/notifications.route.js +1 -1
  62. package/dist/routes/notifications.route.js.map +1 -1
  63. package/dist/routes/profile.route.js +4 -3
  64. package/dist/routes/profile.route.js.map +1 -1
  65. package/dist/routes/role.route.js +7 -4
  66. package/dist/routes/role.route.js.map +1 -1
  67. package/dist/routes/user.route.js +10 -8
  68. package/dist/routes/user.route.js.map +1 -1
  69. package/dist/routes/userrole.route.js +6 -4
  70. package/dist/routes/userrole.route.js.map +1 -1
  71. package/dist/routes/workflow.route.js.map +1 -1
  72. package/dist/server.js +1 -3
  73. package/dist/server.js.map +1 -1
  74. package/dist/services/apikey/apikey.service.js +102 -0
  75. package/dist/services/apikey/apikey.service.js.map +1 -0
  76. package/dist/services/authentication/change-password.service.js +1 -1
  77. package/dist/services/authentication/change-password.service.js.map +1 -1
  78. package/dist/services/authentication/forgot-password.service.js.map +1 -1
  79. package/dist/services/authentication/login.service.js.map +1 -1
  80. package/dist/services/authentication/register.service.js.map +1 -1
  81. package/dist/services/authentication/resend-email.service.js.map +1 -1
  82. package/dist/services/authentication/reset-password.service.js +25 -7
  83. package/dist/services/authentication/reset-password.service.js.map +1 -1
  84. package/dist/services/authentication/verify-email.service.js.map +1 -1
  85. package/dist/services/document/document.services.js +172 -89
  86. package/dist/services/document/document.services.js.map +1 -1
  87. package/dist/services/document/dummy.js +85 -0
  88. package/dist/services/document/dummy.js.map +1 -0
  89. package/dist/services/fileSystem/fileSystem.service.js.map +1 -1
  90. package/dist/services/logs/vendorLog.service.js +1 -1
  91. package/dist/services/logs/vendorLog.service.js.map +1 -1
  92. package/dist/services/notifications/notifications.service.js.map +1 -1
  93. package/dist/services/organisation/organisation.service.js.map +1 -1
  94. package/dist/services/profile/profile.services.js.map +1 -1
  95. package/dist/services/userroles/userrole.service.js.map +1 -1
  96. package/dist/services/workflow/workflow.service.js +2 -0
  97. package/dist/services/workflow/workflow.service.js.map +1 -1
  98. package/dist/types/controllers/auth.controller.d.ts +3 -3
  99. package/dist/types/repository/document.repository.d.ts +56 -16
  100. package/dist/types/repository/form.repository.d.ts +7 -3
  101. package/dist/types/repository/organisation.repository.d.ts +1 -6
  102. package/dist/types/repository/profile.repository.d.ts +4 -3
  103. package/dist/types/repository/role.repository.d.ts +5 -2
  104. package/dist/types/repository/schemas/accounts.schema.d.ts +14 -11
  105. package/dist/types/repository/schemas/document.schema.d.ts +4 -4
  106. package/dist/types/repository/schemas/extracted.schema.d.ts +3 -3
  107. package/dist/types/repository/schemas/fileSystem.schema.d.ts +2 -6
  108. package/dist/types/repository/schemas/form.schema.d.ts +1 -1
  109. package/dist/types/repository/schemas/organisation.schema.d.ts +11 -11
  110. package/dist/types/repository/schemas/profile.schema.d.ts +1 -1
  111. package/dist/types/repository/schemas/role.schema.d.ts +1 -1
  112. package/dist/types/repository/schemas/userrole.schema.d.ts +1 -1
  113. package/dist/types/repository/schemas/workflow.schema.d.ts +2 -14
  114. package/dist/types/repository/user.repository.d.ts +45 -16
  115. package/dist/types/repository/userrole.repository.d.ts +5 -2
  116. package/dist/types/repository/workflow.repository.d.ts +4 -38
  117. package/dist/types/server.d.ts +0 -1
  118. package/dist/types/services/apikey/apikey.service.d.ts +12 -0
  119. package/dist/types/services/authentication/change-password.service.d.ts +1 -1
  120. package/dist/types/services/authentication/forgot-password.service.d.ts +2 -2
  121. package/dist/types/services/authentication/getuser.service.d.ts +29 -3
  122. package/dist/types/services/authentication/login.service.d.ts +1 -1
  123. package/dist/types/services/authentication/register.admin.service.d.ts +1 -1
  124. package/dist/types/services/authentication/register.service.d.ts +1 -1
  125. package/dist/types/services/authentication/resend-email.service.d.ts +2 -2
  126. package/dist/types/services/authentication/reset-password.service.d.ts +2 -2
  127. package/dist/types/services/authentication/verify-email.service.d.ts +1 -1
  128. package/dist/types/services/document/document.services.d.ts +42 -12
  129. package/dist/types/services/document/dummy.d.ts +45 -0
  130. package/dist/types/services/logs/log.service.d.ts +1 -1
  131. package/dist/types/services/profile/profile.services.d.ts +3 -3
  132. package/dist/types/services/roles/role.services.d.ts +33 -5
  133. package/dist/types/services/userroles/userrole.service.d.ts +5 -13
  134. package/dist/types/services/workflow/workflow.service.d.ts +2 -2
  135. package/dist/types/utils/common.d.ts +5 -0
  136. package/dist/utils/common.js +23 -1
  137. package/dist/utils/common.js.map +1 -1
  138. package/dist/utils/log.service.js +1 -1
  139. package/dist/utils/log.service.js.map +1 -1
  140. package/package.json +1 -1
  141. package/src/config/auth/passportConfig.ts +3 -0
  142. package/src/controllers/auth.controller.ts +2 -2
  143. package/src/controllers/license/license.controller.ts +1 -1
  144. package/src/controllers/rbac/rbac.controller.ts +1 -2
  145. package/src/repository/document.repository.ts +221 -37
  146. package/src/repository/filesystem.repository.ts +4 -4
  147. package/src/repository/form.repository.ts +4 -4
  148. package/src/repository/log.repository.ts +1 -1
  149. package/src/repository/notifications.repository.ts +1 -3
  150. package/src/repository/organisation.repository.ts +1 -2
  151. package/src/repository/profile.repository.ts +1 -1
  152. package/src/repository/role.repository.ts +1 -1
  153. package/src/repository/schemas/WorkflowSettingsScheme.ts +0 -2
  154. package/src/repository/schemas/accountdetails.schema.ts +2 -5
  155. package/src/repository/schemas/accounts.schema.ts +30 -31
  156. package/src/repository/schemas/document.schema.ts +15 -18
  157. package/src/repository/schemas/extracted.schema.ts +28 -31
  158. package/src/repository/schemas/fileSystem.schema.ts +4 -7
  159. package/src/repository/schemas/form.schema.ts +1 -2
  160. package/src/repository/schemas/log.schema.ts +6 -7
  161. package/src/repository/schemas/notifications.schema.ts +2 -4
  162. package/src/repository/schemas/organisation.schema.ts +44 -51
  163. package/src/repository/schemas/profile.schema.ts +1 -2
  164. package/src/repository/schemas/role.schema.ts +1 -2
  165. package/src/repository/schemas/tokens.schema.ts +18 -20
  166. package/src/repository/schemas/userrole.schema.ts +1 -2
  167. package/src/repository/schemas/workflow.schema.ts +41 -61
  168. package/src/repository/user.repository.ts +74 -56
  169. package/src/repository/user_tokens.repository.ts +1 -1
  170. package/src/repository/userrole.repository.ts +3 -3
  171. package/src/repository/workflow.repository.ts +4 -5
  172. package/src/routes/auth.route.ts +6 -5
  173. package/src/routes/document.route.ts +5 -1
  174. package/src/routes/fileSystem.route.ts +2 -0
  175. package/src/routes/form.route.ts +6 -1
  176. package/src/routes/index.ts +2 -1
  177. package/src/routes/log.route.ts +2 -4
  178. package/src/routes/notifications.route.ts +2 -2
  179. package/src/routes/org.route.ts +1 -1
  180. package/src/routes/profile.route.ts +4 -3
  181. package/src/routes/role.route.ts +7 -4
  182. package/src/routes/user.route.ts +29 -7
  183. package/src/routes/userrole.route.ts +6 -4
  184. package/src/routes/workflow.route.ts +10 -2
  185. package/src/server.ts +0 -1
  186. package/src/services/authentication/change-password.service.ts +3 -7
  187. package/src/services/authentication/forgot-password.service.ts +2 -2
  188. package/src/services/authentication/login.service.ts +1 -1
  189. package/src/services/authentication/register.admin.service.ts +1 -1
  190. package/src/services/authentication/register.service.ts +0 -2
  191. package/src/services/authentication/resend-email.service.ts +2 -3
  192. package/src/services/authentication/reset-password.service.ts +33 -12
  193. package/src/services/authentication/verify-email.service.ts +1 -1
  194. package/src/services/document/document.services.ts +216 -119
  195. package/src/services/document/dummy.ts +81 -0
  196. package/src/services/fileSystem/fileSystem.service.ts +3 -3
  197. package/src/services/logs/log.service.ts +1 -1
  198. package/src/services/logs/vendorLog.service.ts +1 -1
  199. package/src/services/notifications/notifications.service.ts +8 -9
  200. package/src/services/organisation/organisation.service.ts +5 -7
  201. package/src/services/profile/profile.services.ts +4 -7
  202. package/src/services/roles/role.services.ts +4 -4
  203. package/src/services/statement/accountdetails.service.ts +1 -1
  204. package/src/services/userroles/userrole.service.ts +5 -6
  205. package/src/services/workflow/workSettings.service.ts +1 -1
  206. package/src/services/workflow/workflow.service.ts +11 -5
  207. package/src/utils/common.ts +36 -13
  208. package/src/utils/log.service.ts +1 -1
  209. package/.vscode/extensions.json +0 -5
  210. package/dist/controllers/rbac/grantaccess.json +0 -72
  211. package/dist/setupModal.js +0 -58
  212. package/dist/setupModal.js.map +0 -1
  213. package/dist/types/setupModal.d.ts +0 -7
  214. package/src/setupModal.ts +0 -60
@@ -1,39 +1,40 @@
1
1
  import mongoose, { Schema, Document, Model } from "mongoose";
2
2
  import passportLocalMongoose from "passport-local-mongoose";
3
3
 
4
- // Define the Account Interface
5
- export interface IAccount extends Document {
4
+ // Interface definition for the Account Document
5
+ interface IAccount extends Document {
6
6
  name: string;
7
7
  username: string;
8
8
  moNumber: string;
9
- role?: string; // Changed to `string` since it appears to represent roles like "admin"
9
+ role?: string;
10
10
  userType?: string;
11
11
  approvalType?: string;
12
12
  avatarUrl?: string;
13
13
  is_active?: boolean;
14
- createdAt?: string;
15
- updatedAt?: string;
16
- deletedAt?: string;
17
- company?: string;
14
+ createdAt?: Date;
15
+ updatedAt?: Date;
16
+ deletedAt?: Date;
17
+ company?: mongoose.Types.ObjectId;
18
18
  permission?: string[];
19
- setPassword(password: string, cb: (err: any, user: this) => void): void;
20
- clientOrg?: string; // Fixed the incorrect type definition
19
+ clientOrg?: string;
20
+
21
+ // Added missing fields
22
+ designation?: string;
23
+ level?: string;
24
+ defaultWorkflow?: mongoose.Types.ObjectId;
25
+ userPermission?: string[];
21
26
  }
22
27
 
23
- // Define the Account Model Interface with Static Methods from passport-local-mongoose
28
+ // Extend the Mongoose Model interface to include `register`
24
29
  interface IAccountModel extends Model<IAccount> {
25
- register(user: Partial<IAccount>, password: string): Promise<IAccount>;
26
- authenticate(): (
27
- username: string,
28
- password: string,
29
- cb: (err: any, user?: IAccount | false) => void
30
- ) => void;
31
- serializeUser(): (user: IAccount, done: (err: any, id?: any) => void) => void;
32
- deserializeUser(): (id: any, done: (err: any, user?: IAccount | null) => void) => void;
33
- }
30
+ register(email: string, password: string): Promise<IAccount>;
31
+ authenticate: any;
32
+ serializeUser: any;
33
+ deserializeUser: any;
34
34
 
35
- // Define the Mongoose Schema
36
- const AccountSchema: Schema = new Schema({
35
+ }
36
+ // Define your schema
37
+ const AccountSchema: Schema = new mongoose.Schema<IAccount>({
37
38
  name: {
38
39
  type: String,
39
40
  trim: true,
@@ -44,14 +45,14 @@ const AccountSchema: Schema = new Schema({
44
45
  trim: true,
45
46
  lowercase: true,
46
47
  unique: true,
47
- required: [true, "Email address is required"],
48
+ required: [true, 'Email address is required'],
48
49
  },
49
50
  designation: {
50
51
  type: String,
51
52
  },
52
53
  userType: {
53
54
  type: String,
54
- default: "user",
55
+ default: 'user',
55
56
  },
56
57
  role: {
57
58
  type: String,
@@ -59,7 +60,7 @@ const AccountSchema: Schema = new Schema({
59
60
  },
60
61
  level: {
61
62
  type: String,
62
- default: "admin",
63
+ default: 'admin',
63
64
  },
64
65
  avatarUrl: {
65
66
  type: String,
@@ -79,12 +80,12 @@ const AccountSchema: Schema = new Schema({
79
80
  type: Date,
80
81
  },
81
82
  company: {
82
- type: mongoose.Types.ObjectId,
83
- ref: "Organisation",
83
+ type: mongoose.Schema.Types.ObjectId, // Fixed type issue here
84
+ ref: 'Organisation',
84
85
  },
85
86
  defaultWorkflow: {
86
87
  type: mongoose.Schema.Types.ObjectId,
87
- ref: "WorkFlow",
88
+ ref: 'WorkFlow',
88
89
  },
89
90
  permission: {
90
91
  type: [String],
@@ -94,7 +95,7 @@ const AccountSchema: Schema = new Schema({
94
95
  },
95
96
  });
96
97
 
97
- // Add passport-local-mongoose Plugin
98
+ // Apply the passportLocalMongoose plugin
98
99
  AccountSchema.plugin(passportLocalMongoose);
99
100
 
100
101
  let AccountModel: IAccountModel;
@@ -105,6 +106,4 @@ if (mongoose.models.Account) {
105
106
  AccountModel = mongoose.model<IAccount, IAccountModel>("Account", AccountSchema);
106
107
  }
107
108
 
108
- export default AccountModel;
109
-
110
-
109
+ export default AccountModel;
@@ -1,4 +1,4 @@
1
- import mongoose, { Schema } from "mongoose";
1
+ import mongoose, { Schema, Document } from "mongoose";
2
2
 
3
3
  export interface IDocument extends Document {
4
4
  documentId?: string;
@@ -13,7 +13,9 @@ export interface IDocument extends Document {
13
13
  user?: string;
14
14
  tags?: any;
15
15
  additionalFiles?: any;
16
+ isguaranteed?:boolean
16
17
  }
18
+
17
19
  export interface IApproval extends Document {
18
20
  comment?: string;
19
21
  status: string;
@@ -22,7 +24,7 @@ export interface IApproval extends Document {
22
24
  userId?: mongoose.Types.ObjectId;
23
25
  createdAt: any;
24
26
  }
25
- export const ApprovalSchema: Schema = new mongoose.Schema({
27
+ const ApprovalSchema: Schema = new mongoose.Schema({
26
28
  comment: {
27
29
  type: String,
28
30
  default: "",
@@ -55,7 +57,7 @@ export const ApprovalSchema: Schema = new mongoose.Schema({
55
57
  },
56
58
  createdAt: {
57
59
  type: Date,
58
- default: new Date(),
60
+ default : new Date()
59
61
  },
60
62
  updatedAt: {
61
63
  type: Date,
@@ -71,17 +73,9 @@ export const DocumentSchema: Schema = new mongoose.Schema({
71
73
  type: mongoose.Schema.Types.ObjectId,
72
74
  default: "WorkFlow",
73
75
  },
74
- partnerName : {
75
- type : String,
76
- default : ""
77
- },
78
- partnerId : {
79
- type : String,
80
- default : ""
81
- },
82
- order_taken_by:{
83
- type : String,
84
- default : ""
76
+ isguaranteed:{
77
+ type : Boolean,
78
+ default : false
85
79
  },
86
80
  company: {
87
81
  type: mongoose.Schema.Types.ObjectId,
@@ -135,6 +129,7 @@ export const DocumentSchema: Schema = new mongoose.Schema({
135
129
  },
136
130
  status: {
137
131
  type: String,
132
+ default : 'pending'
138
133
  },
139
134
  helpInfo: {
140
135
  type: mongoose.Schema.Types.Mixed,
@@ -142,14 +137,16 @@ export const DocumentSchema: Schema = new mongoose.Schema({
142
137
  }
143
138
  });
144
139
 
145
- let DocumentModel: mongoose.Model<IDocument> | null = null;
140
+
141
+ let DocumentModal: mongoose.Model<any> | null = null;
146
142
 
147
143
  if (mongoose.models.Document) {
148
144
  console.log("Document model already exists.");
149
- DocumentModel = mongoose.models.Document;
145
+ DocumentModal = mongoose.models.Document;
150
146
  } else {
151
147
  console.log("Creating Document model fallback.");
152
- DocumentModel = mongoose.model<IDocument>("Document", DocumentSchema);
148
+ DocumentModal = mongoose.model<any>("Document", DocumentSchema);
153
149
  }
154
150
 
155
- export default DocumentModel
151
+ export default DocumentModal;
152
+
@@ -1,38 +1,35 @@
1
- import mongoose, { Schema, Document } from "mongoose";
1
+ import mongoose, { Schema, Document, Date } from "mongoose";
2
2
 
3
- // Define the interface for Extracted
4
3
  export interface IExtracted extends Document {
5
- created_At?: Date;
6
- updated_At?: Date;
7
- deleted_At?: Date;
8
- fileId?: mongoose.Types.ObjectId;
9
- data: Record<string, any>;
4
+ created_At?: Date;
5
+ updated_At?: Date;
6
+ deleted_At?: Date;
7
+ fileId?: string;
8
+ data: object;
10
9
  }
11
10
 
12
- // Define the extracted schema
13
- const extractedSchema: Schema = new Schema({
14
- created_At: {
15
- type: Date,
16
- default: Date.now,
17
- },
18
- updated_At: {
19
- type: Date,
20
- default: Date.now,
21
- },
22
- deleted_At: {
23
- type: Date,
24
- },
25
- fileId: {
26
- type: mongoose.Types.ObjectId,
27
- ref: "fs.files",
28
- },
29
- data: {
30
- type: Object,
31
- required: true,
32
- },
33
- });
11
+ const extractedSchema = new Schema({
12
+ created_At: {
13
+ type: Date,
14
+ default: Date.now,
15
+ },
16
+ updated_At: {
17
+ type: Date,
18
+ default: Date.now,
19
+ },
20
+ deleted_At: {
21
+ type: Date,
22
+ },
23
+ fileId: {
24
+ type: mongoose.Types.ObjectId,
25
+ ref: "fs.files"
26
+ },
27
+ data: {
28
+ type: Object,
29
+ required: true
30
+ }
31
+ })
34
32
 
35
- // Handle model initialization
36
33
  let ExtractedModel: mongoose.Model<IExtracted> | null = null;
37
34
 
38
35
  if (mongoose.models.Extracted) {
@@ -43,4 +40,4 @@ if (mongoose.models.Extracted) {
43
40
  ExtractedModel = mongoose.model<IExtracted>("Extracted", extractedSchema);
44
41
  }
45
42
 
46
- export default ExtractedModel;
43
+ export default ExtractedModel;
@@ -1,30 +1,27 @@
1
1
  import mongoose, { Document, Model, Schema } from "mongoose";
2
2
 
3
- // Define the TypeScript Interface for the Schema
4
- export interface IFileSystemSchema extends Document {
3
+ interface IfileSystemSchema extends Document {
5
4
  fileId: mongoose.Types.ObjectId;
6
5
  }
7
6
 
8
- // Define the Mongoose Schema
9
- export const fileSystemSchema: Schema = new Schema(
7
+ const fileSystemSchema: Schema = new Schema(
10
8
  {
11
9
  fileId: {
12
10
  type: mongoose.Types.ObjectId,
13
11
  index: true,
14
- required: true, // Ensure it's a required field to align with interface expectations
15
12
  },
16
13
  },
17
14
  { timestamps: true }
18
15
  );
19
16
 
20
17
  // Handle Model Initialization
21
- let FileSystemModel: Model<IFileSystemSchema> | null = null;
18
+ let FileSystemModel: Model<any> | null = null;
22
19
 
23
20
  // Check if the model already exists to avoid overwriting during hot reloads
24
21
  if (mongoose.models.FileSystem) {
25
22
  FileSystemModel = mongoose.models.FileSystem;
26
23
  } else {
27
- FileSystemModel = mongoose.model<IFileSystemSchema>("FileSystem", fileSystemSchema);
24
+ FileSystemModel = mongoose.model<any>("FileSystem", fileSystemSchema);
28
25
  }
29
26
 
30
27
  export default FileSystemModel;
@@ -31,5 +31,4 @@ const formSchema = new mongoose.Schema({
31
31
  },
32
32
  })
33
33
 
34
- export default mongoose.models.Form || mongoose.model('Form', formSchema);
35
-
34
+ export default mongoose.model('Form',formSchema)
@@ -1,28 +1,26 @@
1
1
  import mongoose, { Schema, Document } from "mongoose";
2
2
 
3
- // Define interface
4
3
  export interface ILog extends Document {
5
4
  message: string;
6
5
  type: string;
7
6
  logtype: string;
8
7
  created_At: Date;
9
- company?: string; // Made optional
10
- user?: string; // Made optional
8
+ company?: string;
9
+ user?: string;
11
10
  statuscode?: number;
12
11
  }
13
12
 
14
- // Define schema
15
13
  export const LogSchema: Schema = new mongoose.Schema({
16
14
  statuscode: {
17
15
  type: Number,
18
16
  },
19
17
  message: {
20
18
  type: String,
21
- required: [true, "Message is required"], // Ensure message is required
22
19
  },
23
20
  type: {
24
21
  type: String,
25
- required: [true, "Type is required"],
22
+ value: String,
23
+ required: [true, "type is required"],
26
24
  enum: ["log", "error", "warning", "info", "success"],
27
25
  },
28
26
  logtype: {
@@ -31,10 +29,12 @@ export const LogSchema: Schema = new mongoose.Schema({
31
29
  },
32
30
  company: {
33
31
  type: mongoose.Types.ObjectId,
32
+ required: [true, "User is not logged in"],
34
33
  ref: "Organisation",
35
34
  },
36
35
  user: {
37
36
  type: mongoose.Types.ObjectId,
37
+ required: [true, "User is not logged in"],
38
38
  ref: "Account",
39
39
  },
40
40
  created_At: {
@@ -43,7 +43,6 @@ export const LogSchema: Schema = new mongoose.Schema({
43
43
  },
44
44
  });
45
45
 
46
- // Model initialization safely
47
46
  let LogModal: mongoose.Model<ILog>;
48
47
 
49
48
  if (mongoose.models.Log) {
@@ -1,6 +1,5 @@
1
1
  import mongoose, { Schema, Document } from "mongoose";
2
2
 
3
- // Interface for type safety
4
3
  export interface INotifications extends Document {
5
4
  role?: string;
6
5
  user?: string;
@@ -12,7 +11,6 @@ export interface INotifications extends Document {
12
11
  deletedAt?: any;
13
12
  }
14
13
 
15
- // Define Notifications Schema
16
14
  const NotificationsSchema: Schema = new mongoose.Schema(
17
15
  {
18
16
  workflow: {
@@ -37,9 +35,9 @@ const NotificationsSchema: Schema = new mongoose.Schema(
37
35
  ref: "Account",
38
36
  },
39
37
  ],
40
- notificationType: {
38
+ type: {
41
39
  type: String,
42
- required: true,
40
+ default: null,
43
41
  },
44
42
  documentId: {
45
43
  type: String,
@@ -1,12 +1,11 @@
1
1
  import mongoose, { Schema, Document } from "mongoose";
2
2
 
3
- // Interfaces
4
- export interface IGSTInformation {
3
+ interface IGSTInformation {
5
4
  gsttreatment: string;
6
5
  businessgst: string;
7
6
  }
8
7
 
9
- export type Address = {
8
+ type address = {
10
9
  billing?: {
11
10
  street: string;
12
11
  city: string;
@@ -24,22 +23,20 @@ export type Address = {
24
23
  phone: string;
25
24
  };
26
25
  };
27
-
28
- export interface IComplianceItem {
29
- date: string;
30
- status: string;
31
- moreinfo: string;
32
- }
33
-
34
- export interface ICompliance {
26
+ interface ICompliance {
35
27
  type: string;
36
28
  file: string;
37
29
  info: object;
38
30
  compliant: IComplianceItem[];
39
31
  }
40
32
 
41
- // Organisation interface extending Document
42
- export interface IOrganisation extends Document {
33
+ interface IComplianceItem {
34
+ date: string;
35
+ status: string;
36
+ moreinfo: string;
37
+ }
38
+
39
+ interface IOrganisation extends Document {
43
40
  name: string;
44
41
  compliances: ICompliance[];
45
42
  domain?: string;
@@ -47,14 +44,13 @@ export interface IOrganisation extends Document {
47
44
  gstin: string;
48
45
  pan?: string;
49
46
  license: string;
50
- address: Address;
47
+ address: address;
51
48
  gstinformation?: IGSTInformation[];
52
49
  customerOrg?: string;
53
- deposits?: Record<string, any>;
50
+ deposits?: object;
54
51
  }
55
52
 
56
- // Define Organisation schema
57
- const OrganisationSchema: Schema = new Schema({
53
+ const OrganisationSchema: Schema = new mongoose.Schema({
58
54
  name: {
59
55
  type: String,
60
56
  trim: true,
@@ -65,19 +61,27 @@ const OrganisationSchema: Schema = new Schema({
65
61
  compliances: {
66
62
  type: [
67
63
  {
68
- type: String,
69
- file: String,
70
- info: Schema.Types.Mixed,
64
+ file: {
65
+ type: String,
66
+ },
67
+ info: {
68
+ type: Object,
69
+ },
71
70
  compliant: [
72
71
  {
73
- date: String,
74
- status: String,
75
- moreinfo: String,
72
+ date: {
73
+ type: String,
74
+ },
75
+ status: {
76
+ type: String,
77
+ },
78
+ moreinfo: {
79
+ type: String,
80
+ },
76
81
  },
77
82
  ],
78
83
  },
79
84
  ],
80
- default: [],
81
85
  },
82
86
  gstin: {
83
87
  type: String,
@@ -107,34 +111,24 @@ const OrganisationSchema: Schema = new Schema({
107
111
  },
108
112
  address: {
109
113
  billing: {
110
- street: { type: String },
111
- city: { type: String },
112
- state: { type: String },
113
- pin: { type: String },
114
- country: { type: String },
115
- phone: { type: String },
114
+ type: Object,
116
115
  },
117
116
  shipping: {
118
- street: { type: String },
119
- city: { type: String },
120
- state: { type: String },
121
- pin: { type: String },
122
- country: { type: String },
123
- phone: { type: String },
117
+ type: Object,
124
118
  },
125
119
  },
126
120
  bankDetails: {
127
- type: Schema.Types.Mixed,
121
+ type: Object,
128
122
  },
129
123
  deposits: {
130
- type: Schema.Types.Mixed,
124
+ type: Object,
131
125
  },
132
126
  certificates: {
133
127
  msme: [
134
128
  {
135
129
  files: [
136
130
  {
137
- type: mongoose.Schema.Types.ObjectId,
131
+ type: Schema.Types.ObjectId,
138
132
  ref: "fs.files",
139
133
  },
140
134
  ],
@@ -144,7 +138,7 @@ const OrganisationSchema: Schema = new Schema({
144
138
  {
145
139
  files: [
146
140
  {
147
- type: mongoose.Schema.Types.ObjectId,
141
+ type: Schema.Types.ObjectId,
148
142
  ref: "fs.files",
149
143
  },
150
144
  ],
@@ -154,30 +148,29 @@ const OrganisationSchema: Schema = new Schema({
154
148
  {
155
149
  files: [
156
150
  {
157
- type: mongoose.Schema.Types.ObjectId,
151
+ type: Schema.Types.ObjectId,
158
152
  ref: "fs.files",
159
153
  },
160
154
  ],
161
155
  },
162
156
  ],
163
157
  cancelledCheque: [
164
- {
165
- files: [
166
- {
167
- type: mongoose.Schema.Types.ObjectId,
168
- ref: "fs.files",
169
- },
170
- ],
171
- },
158
+ {
159
+ files: [
160
+ {
161
+ type: Schema.Types.ObjectId,
162
+ ref: "fs.files",
163
+ },
164
+ ],
165
+ },
172
166
  ],
173
167
  },
174
168
  customerOrg: {
175
169
  type: mongoose.Schema.Types.ObjectId,
176
- ref: "Organisation",
170
+ ref: "organisation",
177
171
  },
178
172
  });
179
173
 
180
- // Export the mongoose model with generic typing and fallback logic
181
174
  let OrganisationModel: mongoose.Model<IOrganisation>;
182
175
 
183
176
  if (mongoose.models.Organisation) {
@@ -62,5 +62,4 @@ const profileSchema: Schema = new mongoose.Schema({
62
62
  }
63
63
  })
64
64
 
65
- export default mongoose.models.Profile || mongoose.model('Profile', profileSchema);
66
-
65
+ export default mongoose.model<profile>('Profile', profileSchema)
@@ -42,5 +42,4 @@ const RoleSchema: Schema = new mongoose.Schema({
42
42
  }
43
43
  });
44
44
 
45
- export default mongoose.models.Role || mongoose.model('Role', RoleSchema);
46
-
45
+ export default mongoose.model<IRole>('Role', RoleSchema);
@@ -1,25 +1,25 @@
1
1
  import mongoose, { Schema, Document } from "mongoose";
2
2
 
3
3
  interface ISession extends Document {
4
- userId: Schema.Types.ObjectId;
5
- type: string;
6
- created_at: Date;
7
- }
4
+ userId: Schema.Types.ObjectId;
5
+ type: string;
6
+ created_at: Date;
7
+ };
8
8
 
9
9
  const TokensSchema: Schema = new mongoose.Schema({
10
- userId: {
11
- type: Schema.Types.ObjectId,
12
- required: true,
13
- },
14
- type: {
15
- type: String,
16
- required: true,
17
- },
18
- created_at: {
19
- type: Date,
20
- default: Date.now,
21
- },
22
- });
10
+ userId: {
11
+ type: Schema.Types.ObjectId,
12
+ required: true
13
+ },
14
+ type: {
15
+ type: String
16
+ },
17
+ created_at:{
18
+ type: Date,
19
+ default: Date.now
20
+ }
21
+
22
+ })
23
23
 
24
24
  // Safe way to dynamically fetch or initialize the model
25
25
  let TokenModel : any = null;
@@ -32,6 +32,4 @@ if (mongoose.models.Token) {
32
32
  TokenModel = mongoose.model<ISession>('Token', TokensSchema);
33
33
  }
34
34
 
35
- export default TokenModel;
36
-
37
-
35
+ export default TokenModel;
@@ -89,5 +89,4 @@ const UserRoleSchema: Schema = new mongoose.Schema({
89
89
  }
90
90
  });
91
91
 
92
- export default mongoose.models.UserRole || mongoose.model('UserRole', UserRoleSchema);
93
-
92
+ export default mongoose.model<IUserRole>('UserRole', UserRoleSchema);