orbitx-core-models 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/interfaces/chat.interface.d.ts +29 -0
- package/dist/interfaces/chat.interface.d.ts.map +1 -0
- package/dist/interfaces/chat.interface.js +2 -0
- package/dist/interfaces/message.interface.d.ts +11 -0
- package/dist/interfaces/message.interface.d.ts.map +1 -0
- package/dist/interfaces/message.interface.js +2 -0
- package/dist/interfaces/user.interface.d.ts +14 -0
- package/dist/interfaces/user.interface.d.ts.map +1 -0
- package/dist/interfaces/user.interface.js +2 -0
- package/dist/models/chat.model.d.ts +4 -0
- package/dist/models/chat.model.d.ts.map +1 -0
- package/dist/models/chat.model.js +51 -0
- package/dist/models/message.model.d.ts +4 -0
- package/dist/models/message.model.d.ts.map +1 -0
- package/dist/models/message.model.js +19 -0
- package/dist/models/user.model.d.ts +4 -0
- package/dist/models/user.model.d.ts.map +1 -0
- package/dist/models/user.model.js +23 -0
- package/package.json +37 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type mongoose from "mongoose";
|
|
2
|
+
export * from "./interfaces/user.interface";
|
|
3
|
+
export * from "./interfaces/chat.interface";
|
|
4
|
+
export * from "./interfaces/message.interface";
|
|
5
|
+
export declare function initModels(mongooseInstance: typeof mongoose): {
|
|
6
|
+
User: mongoose.Model<import("./interfaces/user.interface").IUser, {}, {}, {}, mongoose.Document<unknown, {}, import("./interfaces/user.interface").IUser, {}, {}> & import("./interfaces/user.interface").IUser & Required<{
|
|
7
|
+
_id: unknown;
|
|
8
|
+
}> & {
|
|
9
|
+
__v: number;
|
|
10
|
+
}, any>;
|
|
11
|
+
Chat: mongoose.Model<import("./interfaces/chat.interface").IChat, {}, {}, {}, mongoose.Document<unknown, {}, import("./interfaces/chat.interface").IChat, {}, {}> & import("./interfaces/chat.interface").IChat & Required<{
|
|
12
|
+
_id: unknown;
|
|
13
|
+
}> & {
|
|
14
|
+
__v: number;
|
|
15
|
+
}, any>;
|
|
16
|
+
Message: mongoose.Model<import("./interfaces/message.interface").IMessage, {}, {}, {}, mongoose.Document<unknown, {}, import("./interfaces/message.interface").IMessage, {}, {}> & import("./interfaces/message.interface").IMessage & Required<{
|
|
17
|
+
_id: unknown;
|
|
18
|
+
}> & {
|
|
19
|
+
__v: number;
|
|
20
|
+
}, any>;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AAKrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAE/C,wBAAgB,UAAU,CAAC,gBAAgB,EAAE,OAAO,QAAQ;;;;;;;;;;;;;;;;EAM3D"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.initModels = initModels;
|
|
18
|
+
const user_model_1 = require("./models/user.model");
|
|
19
|
+
const chat_model_1 = require("./models/chat.model");
|
|
20
|
+
const message_model_1 = require("./models/message.model");
|
|
21
|
+
__exportStar(require("./interfaces/user.interface"), exports);
|
|
22
|
+
__exportStar(require("./interfaces/chat.interface"), exports);
|
|
23
|
+
__exportStar(require("./interfaces/message.interface"), exports);
|
|
24
|
+
function initModels(mongooseInstance) {
|
|
25
|
+
const User = (0, user_model_1.createUserModel)(mongooseInstance);
|
|
26
|
+
const Chat = (0, chat_model_1.createChatModel)(mongooseInstance);
|
|
27
|
+
const Message = (0, message_model_1.createMessageModel)(mongooseInstance);
|
|
28
|
+
return { User, Chat, Message };
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Document, Types } from "mongoose";
|
|
2
|
+
export interface IChat extends Document {
|
|
3
|
+
chatNumber?: number;
|
|
4
|
+
userId: Types.ObjectId;
|
|
5
|
+
company: string;
|
|
6
|
+
domain: string;
|
|
7
|
+
status: "open" | "closed" | "active" | "inactive" | "shelved";
|
|
8
|
+
leadStatus: "none" | "sent" | "unsent";
|
|
9
|
+
messages: Types.ObjectId[];
|
|
10
|
+
isDeleted: boolean;
|
|
11
|
+
leadData?: {
|
|
12
|
+
email?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
companyName?: string;
|
|
15
|
+
leadType?: string;
|
|
16
|
+
phone?: string;
|
|
17
|
+
category?: string;
|
|
18
|
+
city?: string;
|
|
19
|
+
address?: string;
|
|
20
|
+
state?: string;
|
|
21
|
+
zipCode?: string;
|
|
22
|
+
otherReason?: string;
|
|
23
|
+
};
|
|
24
|
+
ipAddress?: string;
|
|
25
|
+
note?: string;
|
|
26
|
+
createdAt?: Date;
|
|
27
|
+
updatedAt?: Date;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=chat.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/chat.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,KAAM,SAAQ,QAAQ;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;IAC9D,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE;QACT,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Document, Types } from "mongoose";
|
|
2
|
+
export interface IMessage extends Document {
|
|
3
|
+
senderId: Types.ObjectId;
|
|
4
|
+
macro?: Types.ObjectId;
|
|
5
|
+
senderType: "user" | "agent-chat";
|
|
6
|
+
message: string;
|
|
7
|
+
isDeleted: boolean;
|
|
8
|
+
createdAt?: Date;
|
|
9
|
+
updatedAt?: Date;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=message.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/message.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,QAAS,SAAQ,QAAQ;IACxC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC;IACvB,UAAU,EAAE,MAAM,GAAG,YAAY,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Document, Types } from "mongoose";
|
|
2
|
+
export interface IUser extends Document {
|
|
3
|
+
name?: string;
|
|
4
|
+
email?: string;
|
|
5
|
+
password?: string;
|
|
6
|
+
profile: string;
|
|
7
|
+
role: "user" | "account-manager" | "manager-ops" | "admin" | "agent-chat";
|
|
8
|
+
company?: Types.ObjectId;
|
|
9
|
+
ipAddress?: string;
|
|
10
|
+
currentStatus: string;
|
|
11
|
+
lastLogin?: Date;
|
|
12
|
+
compare: (inputPassword: string) => Promise<boolean>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=user.interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/user.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAE3C,MAAM,WAAW,KAAM,SAAQ,QAAQ;IACrC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,aAAa,GAAG,OAAO,GAAG,YAAY,CAAC;IAC1E,OAAO,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,OAAO,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat.model.d.ts","sourceRoot":"","sources":["../../src/models/chat.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAGrD,wBAAgB,eAAe,CAC7B,gBAAgB,EAAE,cAAc,UAAU,CAAC,GAC1C,KAAK,CAAC,KAAK,CAAC,CAmDd"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createChatModel = createChatModel;
|
|
7
|
+
const mongoose_1 = require("mongoose");
|
|
8
|
+
const mongoose_sequence_1 = __importDefault(require("mongoose-sequence"));
|
|
9
|
+
function createChatModel(mongooseInstance) {
|
|
10
|
+
const AutoIncrement = (0, mongoose_sequence_1.default)(mongooseInstance);
|
|
11
|
+
const chatSchema = new mongoose_1.Schema({
|
|
12
|
+
chatNumber: { type: Number, unique: true },
|
|
13
|
+
userId: { type: mongoose_1.Schema.Types.ObjectId, ref: "User", required: true },
|
|
14
|
+
company: { type: String, required: [true, "Company is required"] },
|
|
15
|
+
domain: { type: String, required: [true, "Domain is required"] },
|
|
16
|
+
status: {
|
|
17
|
+
type: String,
|
|
18
|
+
enum: ["open", "closed", "active", "inactive", "shelved"],
|
|
19
|
+
default: "active",
|
|
20
|
+
},
|
|
21
|
+
leadStatus: {
|
|
22
|
+
type: String,
|
|
23
|
+
enum: ["none", "sent", "unsent"],
|
|
24
|
+
default: "none",
|
|
25
|
+
},
|
|
26
|
+
messages: [{ type: mongoose_1.Schema.Types.ObjectId, ref: "Message" }],
|
|
27
|
+
isDeleted: { type: Boolean, default: false },
|
|
28
|
+
leadData: {
|
|
29
|
+
email: String,
|
|
30
|
+
name: String,
|
|
31
|
+
companyName: String,
|
|
32
|
+
leadType: String,
|
|
33
|
+
phone: String,
|
|
34
|
+
category: String,
|
|
35
|
+
city: String,
|
|
36
|
+
address: String,
|
|
37
|
+
state: String,
|
|
38
|
+
zipCode: String,
|
|
39
|
+
otherReason: String,
|
|
40
|
+
},
|
|
41
|
+
ipAddress: String,
|
|
42
|
+
note: String,
|
|
43
|
+
}, { timestamps: true });
|
|
44
|
+
chatSchema.plugin(AutoIncrement, {
|
|
45
|
+
inc_field: "chatNumber",
|
|
46
|
+
start_seq: 1000,
|
|
47
|
+
});
|
|
48
|
+
chatSchema.index({ userId: 1, company: 1, domain: 1 });
|
|
49
|
+
return (mongooseInstance.models.Chat ||
|
|
50
|
+
mongooseInstance.model("Chat", chatSchema));
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.model.d.ts","sourceRoot":"","sources":["../../src/models/message.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,wBAAgB,kBAAkB,CAChC,gBAAgB,EAAE,cAAc,UAAU,CAAC,GAC1C,KAAK,CAAC,QAAQ,CAAC,CAoBjB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMessageModel = createMessageModel;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
function createMessageModel(mongooseInstance) {
|
|
6
|
+
const messageSchema = new mongoose_1.Schema({
|
|
7
|
+
senderId: { type: mongoose_1.Schema.Types.ObjectId, ref: "User", required: true },
|
|
8
|
+
macro: { type: mongoose_1.Schema.Types.ObjectId, ref: "Macro" },
|
|
9
|
+
senderType: {
|
|
10
|
+
type: String,
|
|
11
|
+
enum: ["user", "agent-chat"],
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
message: { type: String, required: true },
|
|
15
|
+
isDeleted: { type: Boolean, default: false },
|
|
16
|
+
}, { timestamps: true });
|
|
17
|
+
return (mongooseInstance.models.Message ||
|
|
18
|
+
mongooseInstance.model("Message", messageSchema));
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.model.d.ts","sourceRoot":"","sources":["../../src/models/user.model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAkBrD,wBAAgB,eAAe,CAC7B,gBAAgB,EAAE,cAAc,UAAU,CAAC,GAC1C,KAAK,CAAC,KAAK,CAAC,CAKd"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createUserModel = createUserModel;
|
|
4
|
+
const mongoose_1 = require("mongoose");
|
|
5
|
+
const userSchema = new mongoose_1.Schema({
|
|
6
|
+
name: String,
|
|
7
|
+
email: String,
|
|
8
|
+
password: { type: String, select: false },
|
|
9
|
+
profile: { type: String, default: "default.jpg" },
|
|
10
|
+
role: {
|
|
11
|
+
type: String,
|
|
12
|
+
enum: ["user", "account-manager", "manager-ops", "admin", "agent-chat"],
|
|
13
|
+
default: "user",
|
|
14
|
+
},
|
|
15
|
+
company: { type: mongoose_1.Schema.Types.ObjectId, ref: "Company" },
|
|
16
|
+
ipAddress: String,
|
|
17
|
+
currentStatus: { type: String, default: "Offline" },
|
|
18
|
+
lastLogin: Date,
|
|
19
|
+
});
|
|
20
|
+
function createUserModel(mongooseInstance) {
|
|
21
|
+
return (mongooseInstance.models.User ||
|
|
22
|
+
mongooseInstance.model("User", userSchema));
|
|
23
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "orbitx-core-models",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Shared Mongoose models and interfaces for OrbitX services",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prepare": "npm run build",
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"mongoose",
|
|
14
|
+
"models",
|
|
15
|
+
"typescript",
|
|
16
|
+
"orbitx",
|
|
17
|
+
"shared"
|
|
18
|
+
],
|
|
19
|
+
"author": "OrbitX",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"argon2": "^0.44.0",
|
|
23
|
+
"mongoose": "^8.19.2",
|
|
24
|
+
"mongoose-sequence": "^6.0.1"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/mongoose-sequence": "^3.0.11",
|
|
28
|
+
"@types/node": "^24.9.1",
|
|
29
|
+
"typescript": "^5.9.3"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
}
|
|
37
|
+
}
|