orbitx-core-models 11.52.0 → 11.53.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/interfaces/chat.interface.d.ts +10 -9
- package/dist/interfaces/chat.interface.d.ts.map +1 -1
- package/dist/models/chat.model.d.ts.map +1 -1
- package/dist/models/chat.model.js +13 -9
- package/dist/models/counter.model.d.ts +8 -0
- package/dist/models/counter.model.d.ts.map +1 -0
- package/dist/models/counter.model.js +42 -0
- package/package.json +1 -1
|
@@ -1,29 +1,30 @@
|
|
|
1
|
+
import { Types } from "mongoose";
|
|
1
2
|
export interface IChat {
|
|
2
3
|
_id?: string;
|
|
3
4
|
chatNumber?: number;
|
|
4
|
-
companyId:
|
|
5
|
-
visitorId:
|
|
6
|
-
groupId:
|
|
5
|
+
companyId: Types.ObjectId;
|
|
6
|
+
visitorId: Types.ObjectId;
|
|
7
|
+
groupId: Types.ObjectId;
|
|
7
8
|
domain?: string;
|
|
8
|
-
currentOwnerId:
|
|
9
|
+
currentOwnerId: Types.ObjectId;
|
|
9
10
|
ownershipType: "ORBITXPRO" | "CLIENT" | "SHARED";
|
|
10
11
|
participants: Array<{
|
|
11
|
-
userId:
|
|
12
|
+
userId: Types.ObjectId;
|
|
12
13
|
role: "owner" | "viewer";
|
|
13
14
|
ownerType?: "ORBITXPRO" | "CLIENT";
|
|
14
15
|
joinedAt?: Date;
|
|
15
16
|
leftAt?: Date;
|
|
16
17
|
}>;
|
|
17
18
|
joinRequests: Array<{
|
|
18
|
-
requesterId:
|
|
19
|
-
targetId?:
|
|
19
|
+
requesterId: Types.ObjectId;
|
|
20
|
+
targetId?: Types.ObjectId;
|
|
20
21
|
status: "pending" | "approved" | "rejected" | "expired";
|
|
21
22
|
createdAt?: Date;
|
|
22
23
|
resolvedAt?: Date;
|
|
23
24
|
}>;
|
|
24
25
|
transferHistory: Array<{
|
|
25
|
-
fromUserId?:
|
|
26
|
-
toUserId?:
|
|
26
|
+
fromUserId?: Types.ObjectId;
|
|
27
|
+
toUserId?: Types.ObjectId;
|
|
27
28
|
type?: "AGENT_TO_AGENT" | "OXP_TO_CLIENT" | "CLIENT_TAKEOVER";
|
|
28
29
|
at?: Date;
|
|
29
30
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/chat.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"chat.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/chat.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,MAAM,WAAW,KAAK;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC;IAC1B,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC;IAC1B,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,KAAK,CAAC,QAAQ,CAAC;IAC/B,aAAa,EAAE,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACjD,YAAY,EAAE,KAAK,CAAC;QAClB,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC;QACvB,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;QACzB,SAAS,CAAC,EAAE,WAAW,GAAG,QAAQ,CAAC;QACnC,QAAQ,CAAC,EAAE,IAAI,CAAC;QAChB,MAAM,CAAC,EAAE,IAAI,CAAC;KACf,CAAC,CAAC;IACH,YAAY,EAAE,KAAK,CAAC;QAClB,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC;QAC5B,QAAQ,CAA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AAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,IAAI,CAAC;IACjB,SAAS,CAAC,EAAE,IAAI,CAAC;CAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.model.d.ts","sourceRoot":"","sources":["../../src/models/chat.model.ts"],"names":[],"mappings":"AAAA,OAAO,QAAoB,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"chat.model.d.ts","sourceRoot":"","sources":["../../src/models/chat.model.ts"],"names":[],"mappings":"AAAA,OAAO,QAAoB,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAiOrD,eAAO,MAAM,IAAI;;;;OAA4C,CAAC"}
|
|
@@ -32,14 +32,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
exports.Chat = void 0;
|
|
40
37
|
const mongoose_1 = __importStar(require("mongoose"));
|
|
41
|
-
const
|
|
42
|
-
const AutoIncrement = (0, mongoose_sequence_1.default)(mongoose_1.default);
|
|
38
|
+
const counter_model_1 = require("./counter.model");
|
|
43
39
|
const chatSchema = new mongoose_1.Schema({
|
|
44
40
|
// ─────────────────────────────────────────────
|
|
45
41
|
// BASIC
|
|
@@ -206,11 +202,19 @@ const chatSchema = new mongoose_1.Schema({
|
|
|
206
202
|
isDeleted: { type: Boolean, default: false },
|
|
207
203
|
}, { timestamps: true });
|
|
208
204
|
// ─────────────────────────────────────────────
|
|
209
|
-
// AUTO INCREMENT
|
|
205
|
+
// AUTO INCREMENT (NATIVE HOOK)
|
|
210
206
|
// ─────────────────────────────────────────────
|
|
211
|
-
chatSchema.
|
|
212
|
-
|
|
213
|
-
|
|
207
|
+
chatSchema.pre("save", async function () {
|
|
208
|
+
// Only increment if this is a brand new chat document
|
|
209
|
+
if (this.isNew && !this.chatNumber) {
|
|
210
|
+
// Try to increment an existing counter
|
|
211
|
+
let counter = await counter_model_1.Counter.findByIdAndUpdate("chatNumber", { $inc: { seq: 1 } }, { new: true });
|
|
212
|
+
// If it doesn't exist yet, create it with your start_seq of 1000
|
|
213
|
+
if (!counter) {
|
|
214
|
+
counter = await counter_model_1.Counter.create({ _id: "chatNumber", seq: 1000 });
|
|
215
|
+
}
|
|
216
|
+
this.chatNumber = counter.seq;
|
|
217
|
+
}
|
|
214
218
|
});
|
|
215
219
|
// ─────────────────────────────────────────────
|
|
216
220
|
// INDEXES (CRITICAL)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"counter.model.d.ts","sourceRoot":"","sources":["../../src/models/counter.model.ts"],"names":[],"mappings":"AAAA,OAAiB,EAAU,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE7D,UAAU,QAAS,SAAQ,QAAQ;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAOD,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,QAAQ,CAGnC,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.Counter = void 0;
|
|
37
|
+
const mongoose_1 = __importStar(require("mongoose"));
|
|
38
|
+
const counterSchema = new mongoose_1.Schema({
|
|
39
|
+
_id: { type: String, required: true },
|
|
40
|
+
seq: { type: Number, default: 0 },
|
|
41
|
+
});
|
|
42
|
+
exports.Counter = mongoose_1.default.model("Counter", counterSchema);
|