payservedb 8.8.7 → 8.8.8

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/index.js CHANGED
@@ -249,7 +249,12 @@ const models = {
249
249
  PrivacyPolicy: require("./src/models/privacy_policy"),
250
250
  TermsAndConditions: require("./src/models/terms_and_conditions"),
251
251
  CommunityGuidelines: require("./src/models/community_guidelines"),
252
- WhatsappConversation : require("./src/models/whatsapp_conversation")
252
+ WhatsappConversation : require("./src/models/whatsapp_conversation"),
253
+ CustomerPreference: require("./src/models/customer_preference"),
254
+ MoveinApplication: require("./src/models/movein_application"),
255
+ EmailThread: require("./src/models/email_thread"),
256
+ MoveinLandlord: require("./src/models/movein_landlord"),
257
+ MoveinUser: require("./src/models/movein_user"),
253
258
  };
254
259
 
255
260
  // Function to get models dynamically from a specific database connection
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "8.8.7",
3
+ "version": "8.8.8",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -0,0 +1,52 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const customerPreferenceSchema = new mongoose.Schema(
4
+ {
5
+ userId: {
6
+ type: mongoose.Schema.Types.ObjectId,
7
+ ref: 'User',
8
+ default: null,
9
+ index: true,
10
+ },
11
+ guestId: {
12
+ type: String,
13
+ default: null,
14
+ index: true,
15
+ },
16
+ purpose: {
17
+ type: String,
18
+ enum: ['rent', 'buy', 'any'],
19
+ default: 'any',
20
+ },
21
+ location: {
22
+ type: String,
23
+ default: null,
24
+ trim: true,
25
+ },
26
+ roomTypes: {
27
+ type: [String],
28
+ default: [],
29
+ },
30
+ lifestyle: {
31
+ type: [String],
32
+ default: [],
33
+ },
34
+ budgetMin: {
35
+ type: Number,
36
+ default: null,
37
+ },
38
+ budgetMax: {
39
+ type: Number,
40
+ default: null,
41
+ },
42
+ currency: {
43
+ type: String,
44
+ default: 'KES',
45
+ },
46
+ },
47
+ { timestamps: true }
48
+ );
49
+
50
+ const CustomerPreference = mongoose.model('CustomerPreference', customerPreferenceSchema);
51
+
52
+ module.exports = CustomerPreference;
@@ -90,6 +90,25 @@ const customerSatisfactionSurveySchema = new mongoose.Schema({
90
90
  max: 5,
91
91
  comment: 'Communication clarity rating (1-5 stars)'
92
92
  },
93
+ // Additional 0-5 ratings
94
+ facility_maintenance: {
95
+ type: Number,
96
+ min: 0,
97
+ max: 5,
98
+ comment: 'Rating for overall facility maintenance (0-5)'
99
+ },
100
+ value_for_money: {
101
+ type: Number,
102
+ min: 0,
103
+ max: 5,
104
+ comment: 'Rating for value for money of services (0-5)'
105
+ },
106
+ ease_of_contact: {
107
+ type: Number,
108
+ min: 0,
109
+ max: 5,
110
+ comment: 'How easy it was to reach support (0-5)'
111
+ },
93
112
  // NPS (Net Promoter Score)
94
113
  would_recommend: {
95
114
  type: Number,
@@ -9,13 +9,11 @@ const customerTicketSchema = new mongoose.Schema({
9
9
  },
10
10
  facility_id: {
11
11
  type: mongoose.Schema.Types.ObjectId,
12
- ref: 'Facility',
13
- required: true
12
+ ref: 'Facility'
14
13
  },
15
14
  customer_id: {
16
15
  type: mongoose.Schema.Types.ObjectId,
17
- ref: 'Customer',
18
- required: true
16
+ ref: 'Customer'
19
17
  },
20
18
  unit_id: {
21
19
  type: mongoose.Schema.Types.ObjectId,
@@ -0,0 +1,35 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const emailThreadSchema = new mongoose.Schema({
4
+ message_id: { type: String, unique: true, sparse: true },
5
+ thread_id: { type: String },
6
+ from_email: { type: String },
7
+ from_name: { type: String },
8
+ to_email: { type: String },
9
+ cc_email: { type: String },
10
+ subject: { type: String },
11
+ body_text: { type: String },
12
+ body_html: { type: String },
13
+ in_reply_to: { type: String },
14
+ references: { type: String },
15
+ date: { type: Date },
16
+ is_read: { type: Boolean, default: false },
17
+ is_replied: { type: Boolean, default: false },
18
+ replied_at: { type: Date },
19
+ replied_by: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
20
+ reply_text: { type: String },
21
+ linked_ticket_id: { type: mongoose.Schema.Types.ObjectId, ref: 'CustomerTicket', default: null },
22
+ linked_by: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
23
+ linked_at: { type: Date },
24
+ uid: { type: Number },
25
+ folder: { type: String, default: 'INBOX' },
26
+ mailbox_account: { type: String },
27
+ created_at: { type: Date, default: Date.now }
28
+ });
29
+
30
+ emailThreadSchema.index({ date: -1 });
31
+ emailThreadSchema.index({ thread_id: 1 });
32
+ emailThreadSchema.index({ linked_ticket_id: 1 });
33
+ emailThreadSchema.index({ mailbox_account: 1, date: -1 });
34
+
35
+ module.exports = mongoose.model('EmailThread', emailThreadSchema);
@@ -0,0 +1,29 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const moveInApplicationSchema = new mongoose.Schema(
4
+ {
5
+ unitId: { type: mongoose.Schema.Types.ObjectId, required: true, index: true },
6
+ facilityId: { type: mongoose.Schema.Types.ObjectId, ref: 'Facility', required: true, index: true },
7
+ unitName: { type: String, default: null },
8
+ facilityName: { type: String, default: null },
9
+ tenantId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true, index: true },
10
+ tenantName: { type: String, default: null },
11
+ tenantEmail: { type: String, default: null },
12
+ tenantPhone: { type: String, default: null },
13
+ desiredMoveInDate: { type: Date, default: null },
14
+ message: { type: String, default: null },
15
+ status: {
16
+ type: String,
17
+ enum: ['pending', 'assigned', 'approved', 'rejected', 'completed'],
18
+ default: 'pending',
19
+ index: true,
20
+ },
21
+ adminNote: { type: String, default: null },
22
+ assignedAt: { type: Date, default: null },
23
+ landlordId: { type: mongoose.Schema.Types.ObjectId, ref: 'User', default: null },
24
+ },
25
+ { timestamps: true }
26
+ );
27
+
28
+ const MoveInApplication = mongoose.model('MoveInApplication', moveInApplicationSchema);
29
+ module.exports = MoveInApplication;
@@ -0,0 +1,18 @@
1
+ const mongoose = require('mongoose');
2
+ const ObjectId = mongoose.Schema.Types.ObjectId;
3
+
4
+ // Created in payserve_movein DB when admin assigns the Move-In module to a landlord.
5
+ // landlordId references the payserve_property User — no cross-DB constraint enforced by Mongoose.
6
+ const moveInLandlordSchema = new mongoose.Schema(
7
+ {
8
+ landlordId: { type: ObjectId, required: true, unique: true, index: true },
9
+ isEnabled: { type: Boolean, default: true, index: true },
10
+ assignedBy: { type: ObjectId, default: null }, // core user who assigned
11
+ assignedAt: { type: Date, default: Date.now },
12
+ revokedAt: { type: Date, default: null },
13
+ },
14
+ { timestamps: true }
15
+ );
16
+
17
+ const MoveInLandlord = mongoose.model('MoveInLandlord', moveInLandlordSchema);
18
+ module.exports = MoveInLandlord;
@@ -0,0 +1,15 @@
1
+ const mongoose = require('mongoose');
2
+
3
+ const moveInUserSchema = new mongoose.Schema(
4
+ {
5
+ fullName: { type: String, required: true, trim: true },
6
+ email: { type: String, required: true, unique: true, lowercase: true, trim: true },
7
+ phoneNumber: { type: String, required: true, unique: true },
8
+ password: { type: String, required: true, minlength: 8 },
9
+ isEnabled: { type: Boolean, default: true },
10
+ },
11
+ { timestamps: true }
12
+ );
13
+
14
+ const MoveInUser = mongoose.model('MoveInUser', moveInUserSchema);
15
+ module.exports = MoveInUser;