my-typescript-library-rahul52us 1.2.2 → 1.2.4
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/repository/document.repository.js +27 -28
- package/dist/repository/document.repository.js.map +1 -1
- package/dist/repository/schemas/document.schema.js +10 -0
- package/dist/repository/schemas/document.schema.js.map +1 -1
- package/dist/repository/schemas/extracted.schema.js +15 -4
- package/dist/repository/schemas/extracted.schema.js.map +1 -1
- package/dist/repository/schemas/log.schema.js +19 -10
- package/dist/repository/schemas/log.schema.js.map +1 -1
- package/dist/repository/schemas/notifications.schema.js +14 -3
- package/dist/repository/schemas/notifications.schema.js.map +1 -1
- package/dist/repository/schemas/organisation.schema.js +38 -27
- package/dist/repository/schemas/organisation.schema.js.map +1 -1
- package/dist/types/repository/organisation.repository.d.ts +6 -1
- package/dist/types/repository/schemas/document.schema.d.ts +2 -0
- package/dist/types/repository/schemas/extracted.schema.d.ts +5 -5
- package/dist/types/repository/schemas/log.schema.d.ts +3 -3
- package/dist/types/repository/schemas/notifications.schema.d.ts +2 -2
- package/dist/types/repository/schemas/organisation.schema.d.ts +4 -5
- package/dist/types/services/organisation/organisation.service.d.ts +32 -1
- package/package.json +1 -1
- package/src/repository/document.repository.ts +1 -4
- package/src/repository/schemas/document.schema.ts +12 -0
- package/src/repository/schemas/extracted.schema.ts +40 -28
- package/src/repository/schemas/log.schema.ts +52 -44
- package/src/repository/schemas/notifications.schema.ts +16 -3
- package/src/repository/schemas/organisation.schema.ts +42 -30
|
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
const mongoose_1 = __importStar(require("mongoose"));
|
|
27
|
-
// Define
|
|
27
|
+
// Define Organisation schema
|
|
28
28
|
const OrganisationSchema = new mongoose_1.Schema({
|
|
29
29
|
name: {
|
|
30
30
|
type: String,
|
|
@@ -36,27 +36,19 @@ const OrganisationSchema = new mongoose_1.Schema({
|
|
|
36
36
|
compliances: {
|
|
37
37
|
type: [
|
|
38
38
|
{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
info: {
|
|
43
|
-
type: Object,
|
|
44
|
-
},
|
|
39
|
+
type: String,
|
|
40
|
+
file: String,
|
|
41
|
+
info: mongoose_1.Schema.Types.Mixed,
|
|
45
42
|
compliant: [
|
|
46
43
|
{
|
|
47
|
-
date:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
status: {
|
|
51
|
-
type: String,
|
|
52
|
-
},
|
|
53
|
-
moreinfo: {
|
|
54
|
-
type: String,
|
|
55
|
-
},
|
|
44
|
+
date: String,
|
|
45
|
+
status: String,
|
|
46
|
+
moreinfo: String,
|
|
56
47
|
},
|
|
57
48
|
],
|
|
58
49
|
},
|
|
59
50
|
],
|
|
51
|
+
default: [],
|
|
60
52
|
},
|
|
61
53
|
gstin: {
|
|
62
54
|
type: String,
|
|
@@ -86,24 +78,34 @@ const OrganisationSchema = new mongoose_1.Schema({
|
|
|
86
78
|
},
|
|
87
79
|
address: {
|
|
88
80
|
billing: {
|
|
89
|
-
type:
|
|
81
|
+
street: { type: String },
|
|
82
|
+
city: { type: String },
|
|
83
|
+
state: { type: String },
|
|
84
|
+
pin: { type: String },
|
|
85
|
+
country: { type: String },
|
|
86
|
+
phone: { type: String },
|
|
90
87
|
},
|
|
91
88
|
shipping: {
|
|
92
|
-
type:
|
|
89
|
+
street: { type: String },
|
|
90
|
+
city: { type: String },
|
|
91
|
+
state: { type: String },
|
|
92
|
+
pin: { type: String },
|
|
93
|
+
country: { type: String },
|
|
94
|
+
phone: { type: String },
|
|
93
95
|
},
|
|
94
96
|
},
|
|
95
97
|
bankDetails: {
|
|
96
|
-
type:
|
|
98
|
+
type: mongoose_1.Schema.Types.Mixed,
|
|
97
99
|
},
|
|
98
100
|
deposits: {
|
|
99
|
-
type:
|
|
101
|
+
type: mongoose_1.Schema.Types.Mixed,
|
|
100
102
|
},
|
|
101
103
|
certificates: {
|
|
102
104
|
msme: [
|
|
103
105
|
{
|
|
104
106
|
files: [
|
|
105
107
|
{
|
|
106
|
-
type: mongoose_1.Schema.Types.ObjectId,
|
|
108
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
107
109
|
ref: "fs.files",
|
|
108
110
|
},
|
|
109
111
|
],
|
|
@@ -113,7 +115,7 @@ const OrganisationSchema = new mongoose_1.Schema({
|
|
|
113
115
|
{
|
|
114
116
|
files: [
|
|
115
117
|
{
|
|
116
|
-
type: mongoose_1.Schema.Types.ObjectId,
|
|
118
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
117
119
|
ref: "fs.files",
|
|
118
120
|
},
|
|
119
121
|
],
|
|
@@ -123,7 +125,7 @@ const OrganisationSchema = new mongoose_1.Schema({
|
|
|
123
125
|
{
|
|
124
126
|
files: [
|
|
125
127
|
{
|
|
126
|
-
type: mongoose_1.Schema.Types.ObjectId,
|
|
128
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
127
129
|
ref: "fs.files",
|
|
128
130
|
},
|
|
129
131
|
],
|
|
@@ -133,7 +135,7 @@ const OrganisationSchema = new mongoose_1.Schema({
|
|
|
133
135
|
{
|
|
134
136
|
files: [
|
|
135
137
|
{
|
|
136
|
-
type: mongoose_1.Schema.Types.ObjectId,
|
|
138
|
+
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
137
139
|
ref: "fs.files",
|
|
138
140
|
},
|
|
139
141
|
],
|
|
@@ -142,9 +144,18 @@ const OrganisationSchema = new mongoose_1.Schema({
|
|
|
142
144
|
},
|
|
143
145
|
customerOrg: {
|
|
144
146
|
type: mongoose_1.default.Schema.Types.ObjectId,
|
|
145
|
-
ref: "
|
|
147
|
+
ref: "Organisation",
|
|
146
148
|
},
|
|
147
149
|
});
|
|
148
|
-
// Export the mongoose model with
|
|
149
|
-
|
|
150
|
+
// Export the mongoose model with generic typing and fallback logic
|
|
151
|
+
let OrganisationModel;
|
|
152
|
+
if (mongoose_1.default.models.Organisation) {
|
|
153
|
+
console.log("Organisation model already exists.");
|
|
154
|
+
OrganisationModel = mongoose_1.default.models.Organisation;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
console.log("Creating Organisation model fallback.");
|
|
158
|
+
OrganisationModel = mongoose_1.default.model("Organisation", OrganisationSchema);
|
|
159
|
+
}
|
|
160
|
+
exports.default = OrganisationModel;
|
|
150
161
|
//# sourceMappingURL=organisation.schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organisation.schema.js","sourceRoot":"","sources":["../../../src/repository/schemas/organisation.schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"organisation.schema.js","sourceRoot":"","sources":["../../../src/repository/schemas/organisation.schema.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import mongoose from 'mongoose';
|
|
1
2
|
type address = {
|
|
2
3
|
shipping: any;
|
|
3
4
|
billing: any;
|
|
@@ -49,7 +50,11 @@ export declare function findOrgById(orgId: string): Promise<{
|
|
|
49
50
|
license: string;
|
|
50
51
|
} | null>;
|
|
51
52
|
export declare function updateorganisation(id: string, data: Partial<OrgProfile>): Promise<any>;
|
|
52
|
-
export declare function findOrgDetails(id: string): Promise<
|
|
53
|
+
export declare function findOrgDetails(id: string): Promise<mongoose.Document<unknown, {}, import("./schemas/organisation.schema").IOrganisation> & import("./schemas/organisation.schema").IOrganisation & Required<{
|
|
54
|
+
_id: unknown;
|
|
55
|
+
}> & {
|
|
56
|
+
__v: number;
|
|
57
|
+
}>;
|
|
53
58
|
export declare function getOrgDetails(searchValue: string, company: string, userId: string, sort: string | null, skip: string | null, limit: string | null): Promise<any>;
|
|
54
59
|
export declare function getCompliancesDetails(searchValue: string, company: string, userId: string, sort: string | null, skip: string | null, limit: string | null): Promise<any[] | Error>;
|
|
55
60
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import mongoose, { Document
|
|
1
|
+
import mongoose, { Document } from "mongoose";
|
|
2
2
|
export interface IExtracted extends Document {
|
|
3
3
|
created_At?: Date;
|
|
4
4
|
updated_At?: Date;
|
|
5
5
|
deleted_At?: Date;
|
|
6
|
-
fileId?:
|
|
7
|
-
data:
|
|
6
|
+
fileId?: mongoose.Types.ObjectId;
|
|
7
|
+
data: Record<string, any>;
|
|
8
8
|
}
|
|
9
|
-
declare
|
|
10
|
-
export default
|
|
9
|
+
declare let ExtractedModel: mongoose.Model<IExtracted> | null;
|
|
10
|
+
export default ExtractedModel;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import mongoose, { Schema, Document } from
|
|
1
|
+
import mongoose, { Schema, Document } from "mongoose";
|
|
2
2
|
export interface ILog extends Document {
|
|
3
3
|
message: string;
|
|
4
4
|
type: string;
|
|
@@ -9,5 +9,5 @@ export interface ILog extends Document {
|
|
|
9
9
|
statuscode?: number;
|
|
10
10
|
}
|
|
11
11
|
export declare const LogSchema: Schema;
|
|
12
|
-
declare
|
|
13
|
-
export default
|
|
12
|
+
declare let LogModal: mongoose.Model<ILog>;
|
|
13
|
+
export default LogModal;
|
|
@@ -9,5 +9,5 @@ export interface INotifications extends Document {
|
|
|
9
9
|
notificationType: string;
|
|
10
10
|
deletedAt?: any;
|
|
11
11
|
}
|
|
12
|
-
declare
|
|
13
|
-
export default
|
|
12
|
+
declare let NotificationsModel: mongoose.Model<INotifications>;
|
|
13
|
+
export default NotificationsModel;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import mongoose from "mongoose";
|
|
2
|
-
import { Document } from 'mongoose';
|
|
1
|
+
import mongoose, { Document } from "mongoose";
|
|
3
2
|
export interface IGSTInformation {
|
|
4
3
|
gsttreatment: string;
|
|
5
4
|
businessgst: string;
|
|
@@ -44,7 +43,7 @@ export interface IOrganisation extends Document {
|
|
|
44
43
|
address: Address;
|
|
45
44
|
gstinformation?: IGSTInformation[];
|
|
46
45
|
customerOrg?: string;
|
|
47
|
-
deposits?:
|
|
46
|
+
deposits?: Record<string, any>;
|
|
48
47
|
}
|
|
49
|
-
declare
|
|
50
|
-
export default
|
|
48
|
+
declare let OrganisationModel: mongoose.Model<IOrganisation>;
|
|
49
|
+
export default OrganisationModel;
|
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
19
|
+
/// <reference types="mongoose/types/session" />
|
|
20
|
+
/// <reference types="mongoose/types/types" />
|
|
21
|
+
/// <reference types="mongoose/types/utility" />
|
|
22
|
+
/// <reference types="mongoose/types/validation" />
|
|
23
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
24
|
+
/// <reference types="mongoose" />
|
|
25
|
+
/// <reference types="passport-local-mongoose" />
|
|
26
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
27
|
+
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
1
28
|
import { Request, Response } from 'express';
|
|
2
29
|
interface UserRequest extends Request {
|
|
3
30
|
user?: {
|
|
@@ -7,7 +34,11 @@ interface UserRequest extends Request {
|
|
|
7
34
|
}
|
|
8
35
|
export declare function createOrganizationService(req: any, res: Response): Promise<any>;
|
|
9
36
|
export declare function getOrgDetailsService(req: UserRequest, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
10
|
-
export declare function findOrgDetailsService(req: UserRequest, res: Response): Promise<
|
|
37
|
+
export declare function findOrgDetailsService(req: UserRequest, res: Response): Promise<(import("mongoose").Document<unknown, {}, import("../../repository/schemas/organisation.schema").IOrganisation> & import("../../repository/schemas/organisation.schema").IOrganisation & Required<{
|
|
38
|
+
_id: unknown;
|
|
39
|
+
}> & {
|
|
40
|
+
__v: number;
|
|
41
|
+
}) | Response<any, Record<string, any>>>;
|
|
11
42
|
export declare function updateOrganisationHandler(req: UserRequest, res: Response): Promise<Response>;
|
|
12
43
|
export declare function getOrganisationService(req: UserRequest, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
13
44
|
export declare function getComplainceCountService(req: UserRequest, res: Response): Promise<Response<any, Record<string, any>>>;
|
package/package.json
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import Document, {IDocument } from "./schemas/document.schema";
|
|
2
2
|
import mongoose from "mongoose";
|
|
3
3
|
import { getUserServiceByLevel } from "../services/authentication/getuser.service";
|
|
4
4
|
import { generateLevels } from "../constants/status.constant";
|
|
5
5
|
import fs from "fs";
|
|
6
6
|
import { deleteAllNotifications } from "./notifications.repository";
|
|
7
7
|
import { findUser } from "./user.repository";
|
|
8
|
-
import { getDocumentModel } from "../setupModal";
|
|
9
|
-
|
|
10
|
-
let Document = getDocumentModel()
|
|
11
8
|
|
|
12
9
|
interface DynamicRoles {
|
|
13
10
|
approvedRoles: string[];
|
|
@@ -141,3 +141,15 @@ export const DocumentSchema: Schema = new mongoose.Schema({
|
|
|
141
141
|
default: {}
|
|
142
142
|
}
|
|
143
143
|
});
|
|
144
|
+
|
|
145
|
+
let DocumentModel: mongoose.Model<IDocument> | null = null;
|
|
146
|
+
|
|
147
|
+
if (mongoose.models.Document) {
|
|
148
|
+
console.log("Document model already exists.");
|
|
149
|
+
DocumentModel = mongoose.models.Document;
|
|
150
|
+
} else {
|
|
151
|
+
console.log("Creating Document model fallback.");
|
|
152
|
+
DocumentModel = mongoose.model<IDocument>("Document", DocumentSchema);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export default DocumentModel
|
|
@@ -1,34 +1,46 @@
|
|
|
1
|
-
import mongoose, { Schema, Document
|
|
1
|
+
import mongoose, { Schema, Document } from "mongoose";
|
|
2
2
|
|
|
3
|
+
// Define the interface for Extracted
|
|
3
4
|
export interface IExtracted extends Document {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
created_At?: Date;
|
|
6
|
+
updated_At?: Date;
|
|
7
|
+
deleted_At?: Date;
|
|
8
|
+
fileId?: mongoose.Types.ObjectId;
|
|
9
|
+
data: Record<string, any>;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
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
|
+
});
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
// Handle model initialization
|
|
36
|
+
let ExtractedModel: mongoose.Model<IExtracted> | null = null;
|
|
34
37
|
|
|
38
|
+
if (mongoose.models.Extracted) {
|
|
39
|
+
console.log("Extracted model already exists.");
|
|
40
|
+
ExtractedModel = mongoose.models.Extracted;
|
|
41
|
+
} else {
|
|
42
|
+
console.log("Creating Extracted model fallback.");
|
|
43
|
+
ExtractedModel = mongoose.model<IExtracted>("Extracted", extractedSchema);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default ExtractedModel;
|
|
@@ -1,49 +1,57 @@
|
|
|
1
|
-
import mongoose, { Schema, Document } from
|
|
1
|
+
import mongoose, { Schema, Document } from "mongoose";
|
|
2
2
|
|
|
3
|
+
// Define interface
|
|
3
4
|
export interface ILog extends Document {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
message: string;
|
|
6
|
+
type: string;
|
|
7
|
+
logtype: string;
|
|
8
|
+
created_At: Date;
|
|
9
|
+
company?: string; // Made optional
|
|
10
|
+
user?: string; // Made optional
|
|
11
|
+
statuscode?: number;
|
|
11
12
|
}
|
|
12
13
|
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
default: Date.now,
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
);
|
|
14
|
+
// Define schema
|
|
15
|
+
export const LogSchema: Schema = new mongoose.Schema({
|
|
16
|
+
statuscode: {
|
|
17
|
+
type: Number,
|
|
18
|
+
},
|
|
19
|
+
message: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: [true, "Message is required"], // Ensure message is required
|
|
22
|
+
},
|
|
23
|
+
type: {
|
|
24
|
+
type: String,
|
|
25
|
+
required: [true, "Type is required"],
|
|
26
|
+
enum: ["log", "error", "warning", "info", "success"],
|
|
27
|
+
},
|
|
28
|
+
logtype: {
|
|
29
|
+
type: String,
|
|
30
|
+
required: [true, "Logtype is required"],
|
|
31
|
+
},
|
|
32
|
+
company: {
|
|
33
|
+
type: mongoose.Types.ObjectId,
|
|
34
|
+
ref: "Organisation",
|
|
35
|
+
},
|
|
36
|
+
user: {
|
|
37
|
+
type: mongoose.Types.ObjectId,
|
|
38
|
+
ref: "Account",
|
|
39
|
+
},
|
|
40
|
+
created_At: {
|
|
41
|
+
type: Date,
|
|
42
|
+
default: Date.now,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
48
45
|
|
|
49
|
-
|
|
46
|
+
// Model initialization safely
|
|
47
|
+
let LogModal: mongoose.Model<ILog>;
|
|
48
|
+
|
|
49
|
+
if (mongoose.models.Log) {
|
|
50
|
+
console.log("Log model already exists.");
|
|
51
|
+
LogModal = mongoose.models.Log;
|
|
52
|
+
} else {
|
|
53
|
+
console.log("Creating Log model fallback.");
|
|
54
|
+
LogModal = mongoose.model<ILog>("Log", LogSchema);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default LogModal;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import mongoose, { Schema, Document } from "mongoose";
|
|
2
2
|
|
|
3
|
+
// Interface for type safety
|
|
3
4
|
export interface INotifications extends Document {
|
|
4
5
|
role?: string;
|
|
5
6
|
user?: string;
|
|
@@ -11,6 +12,7 @@ export interface INotifications extends Document {
|
|
|
11
12
|
deletedAt?: any;
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
// Define Notifications Schema
|
|
14
16
|
const NotificationsSchema: Schema = new mongoose.Schema(
|
|
15
17
|
{
|
|
16
18
|
workflow: {
|
|
@@ -35,9 +37,9 @@ const NotificationsSchema: Schema = new mongoose.Schema(
|
|
|
35
37
|
ref: "Account",
|
|
36
38
|
},
|
|
37
39
|
],
|
|
38
|
-
|
|
40
|
+
notificationType: {
|
|
39
41
|
type: String,
|
|
40
|
-
|
|
42
|
+
required: true,
|
|
41
43
|
},
|
|
42
44
|
documentId: {
|
|
43
45
|
type: String,
|
|
@@ -50,4 +52,15 @@ const NotificationsSchema: Schema = new mongoose.Schema(
|
|
|
50
52
|
{ timestamps: true }
|
|
51
53
|
);
|
|
52
54
|
|
|
53
|
-
|
|
55
|
+
// Safely initialize the Notifications model
|
|
56
|
+
let NotificationsModel: mongoose.Model<INotifications>;
|
|
57
|
+
|
|
58
|
+
if (mongoose.models.notification) {
|
|
59
|
+
console.log("Notification model already exists.");
|
|
60
|
+
NotificationsModel = mongoose.models.notification as mongoose.Model<INotifications>;
|
|
61
|
+
} else {
|
|
62
|
+
console.log("Creating notification model fallback.");
|
|
63
|
+
NotificationsModel = mongoose.model<INotifications>("notification", NotificationsSchema);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default NotificationsModel;
|