@dhyasama/totem-models 9.54.0 → 9.55.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.
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(mongoose, config) {
|
|
4
|
+
|
|
5
|
+
const
|
|
6
|
+
|
|
7
|
+
Schema = mongoose.Schema,
|
|
8
|
+
_ = require('underscore');
|
|
9
|
+
|
|
10
|
+
const LimitedPartnerCommunication = new Schema({
|
|
11
|
+
|
|
12
|
+
// name of the communication, e.g., "2022 Annual Audit"
|
|
13
|
+
name: { type: String, trim: true, required: true },
|
|
14
|
+
|
|
15
|
+
// customer sending this communication
|
|
16
|
+
customer: { type: Schema.ObjectId, ref: 'Organization', required: true },
|
|
17
|
+
|
|
18
|
+
// date and time to send
|
|
19
|
+
sendOn: { type: Date, required: true },
|
|
20
|
+
|
|
21
|
+
// email subject
|
|
22
|
+
subject: { type: String, trim: true, required: true },
|
|
23
|
+
|
|
24
|
+
// email body
|
|
25
|
+
body: { type: String, trim: true, required: true },
|
|
26
|
+
|
|
27
|
+
// job was added to queue to send individual emails
|
|
28
|
+
sentToQueue: { type: Boolean, required: true, default: false },
|
|
29
|
+
|
|
30
|
+
documents: [{
|
|
31
|
+
|
|
32
|
+
// the lp this doc is for
|
|
33
|
+
limitedPartner: { type: Schema.ObjectId, ref: 'LimitedPartner', required: true },
|
|
34
|
+
|
|
35
|
+
// unique id for this document
|
|
36
|
+
uuid: { type: String, trim: true, required: true },
|
|
37
|
+
|
|
38
|
+
// email of recipient for notification and access
|
|
39
|
+
email: { type: String, trim: true, required: true },
|
|
40
|
+
|
|
41
|
+
// attach document to email
|
|
42
|
+
attachToEmail: { type: Boolean, required: true, default: false },
|
|
43
|
+
|
|
44
|
+
// when notification was sent
|
|
45
|
+
sentOn: { type: Date, required: false },
|
|
46
|
+
|
|
47
|
+
// email reference
|
|
48
|
+
postmarkMessageId: { type: String, trim: true, required: false },
|
|
49
|
+
|
|
50
|
+
emailStatus: { type: String, enum: [null, 'Sent', 'Bounced', 'Delivered', 'Opened', 'Clicked'], required: false },
|
|
51
|
+
|
|
52
|
+
// OTP used to access the document
|
|
53
|
+
oneTimePassword: { type: String, trim: true, required: true },
|
|
54
|
+
|
|
55
|
+
// OTP only good for limited time and then a new one must be requested
|
|
56
|
+
oneTimePasswordExpiration: { type: Date, trim: true, required: true },
|
|
57
|
+
|
|
58
|
+
fileName: { type: String, trim: true, required: true },
|
|
59
|
+
|
|
60
|
+
// file type
|
|
61
|
+
contentType: { type: String, trim: true, required: true },
|
|
62
|
+
|
|
63
|
+
// file size
|
|
64
|
+
contentLength: { type: String, trim: true, required: true },
|
|
65
|
+
|
|
66
|
+
// where to find in s3
|
|
67
|
+
s3: {
|
|
68
|
+
bucket: { type: String, required: true, trim: true },
|
|
69
|
+
key: { type: String, required: true, trim: true }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}]
|
|
73
|
+
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// Get a full communication for a customer
|
|
77
|
+
// Use 1: Customer can use while setting up or viewing a batch
|
|
78
|
+
// Use 2: Also, use this to get doc when an lp requests it. Use comm id from url to get it here,
|
|
79
|
+
// then in BLL use the uuid from url to select the doc. At that point, we can serve up
|
|
80
|
+
// the doc or go through the OTP process.
|
|
81
|
+
LimitedPartnerCommunication.statics.getById = function getById(id, options, cb) {
|
|
82
|
+
|
|
83
|
+
const self = this;
|
|
84
|
+
|
|
85
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
86
|
+
if (!id) { return cb(new Error('id is required'), null); }
|
|
87
|
+
if (!mongoose.Types.ObjectId.isValid(id)) { return cb(new Error('id is not a valid ObjectId'), null); }
|
|
88
|
+
if (!options) { return cb(new Error('options is required'), null); }
|
|
89
|
+
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
90
|
+
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
91
|
+
|
|
92
|
+
let query = self.findOne({
|
|
93
|
+
'_id': id,
|
|
94
|
+
'customer': options.CUSTOMER_ID
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
query.populate('customer');
|
|
98
|
+
query.populate('documents.limitedPartner', 'name');
|
|
99
|
+
|
|
100
|
+
query.exec(cb);
|
|
101
|
+
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Get all communications for a customer
|
|
105
|
+
LimitedPartnerCommunication.statics.getForCustomer = function getForCustomer(customerId, options, cb) {
|
|
106
|
+
|
|
107
|
+
const self = this;
|
|
108
|
+
|
|
109
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
110
|
+
if (!customerId) { return cb(new Error('customerId is required'), null); }
|
|
111
|
+
if (!mongoose.Types.ObjectId.isValid(customerId)) { return cb(new Error('customerId is not a valid ObjectId'), null); }
|
|
112
|
+
|
|
113
|
+
let query = self.find({
|
|
114
|
+
'customer': customerId
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
query.exec(cb);
|
|
118
|
+
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// Get all batches that haven't been sent but are scheduled to go
|
|
122
|
+
// Use case 1: Worker pulls this list and sends docs to lps
|
|
123
|
+
LimitedPartnerCommunication.statics.getReadyToSend = function getReadyToSend(options, cb) {
|
|
124
|
+
|
|
125
|
+
const self = this;
|
|
126
|
+
const now = new Date();
|
|
127
|
+
|
|
128
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
129
|
+
|
|
130
|
+
let query = self.find({
|
|
131
|
+
'sentToQueue': false,
|
|
132
|
+
'sendOn': { $lte: now }
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
query.exec(cb);
|
|
136
|
+
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
LimitedPartnerCommunication.statics.upsert = function upsert(doc, options, cb) {
|
|
140
|
+
|
|
141
|
+
if (!doc) { return cb(new Error('doc is required'), null); }
|
|
142
|
+
|
|
143
|
+
doc.save(cb);
|
|
144
|
+
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
///////////////////////////////////////////////////////////////////////////////////////
|
|
149
|
+
// CONFIG
|
|
150
|
+
///////////////////////////////////////////////////////////////////////////////////////
|
|
151
|
+
|
|
152
|
+
LimitedPartnerCommunication.set('usePushEach', true);
|
|
153
|
+
LimitedPartnerCommunication.set('toJSON', { virtuals: true });
|
|
154
|
+
LimitedPartnerCommunication.set('autoIndex', false);
|
|
155
|
+
LimitedPartnerCommunication.set('usePushEach', true);
|
|
156
|
+
|
|
157
|
+
LimitedPartnerCommunication.on('index', function(err) { console.log('error building LimitedPartnerCommunication indexes: ' + err); });
|
|
158
|
+
|
|
159
|
+
mongoose.model('LimitedPartnerCommunication', LimitedPartnerCommunication);
|
|
160
|
+
|
|
161
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(mongoose, config) {
|
|
4
|
+
|
|
5
|
+
const Schema = mongoose.Schema;
|
|
6
|
+
|
|
7
|
+
const LimitedPartnerContactGroup = new Schema({
|
|
8
|
+
|
|
9
|
+
// name of group, e.g., "K1" or "Audit"
|
|
10
|
+
name: { type: String, trim: true, required: true },
|
|
11
|
+
|
|
12
|
+
// customer the group belongs to
|
|
13
|
+
customer: { type: Schema.ObjectId, ref: 'Organization', required: true },
|
|
14
|
+
|
|
15
|
+
// emails for each lp in the group
|
|
16
|
+
contacts: [{
|
|
17
|
+
|
|
18
|
+
// the lp
|
|
19
|
+
limitedPartner: { type: Schema.ObjectId, ref: 'LimitedPartner', required: true },
|
|
20
|
+
|
|
21
|
+
// one or more emails to send to
|
|
22
|
+
emails: [{ type: String, trim: true, required: true }]
|
|
23
|
+
|
|
24
|
+
}]
|
|
25
|
+
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Get a contact group
|
|
29
|
+
LimitedPartnerContactGroup.statics.getById = function (id, options, cb) {
|
|
30
|
+
|
|
31
|
+
const self = this;
|
|
32
|
+
|
|
33
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
34
|
+
if (!id) { return cb(new Error('id is required'), null); }
|
|
35
|
+
if (!mongoose.Types.ObjectId.isValid(id)) { return cb(new Error('id is not a valid ObjectId'), null); }
|
|
36
|
+
if (!options) { return cb(new Error('options is required'), null); }
|
|
37
|
+
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
38
|
+
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
39
|
+
|
|
40
|
+
let query = self.findOne({
|
|
41
|
+
'_id': id,
|
|
42
|
+
'customer': options.CUSTOMER_ID
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
query.populate('contacts.limitedPartner', 'name');
|
|
46
|
+
|
|
47
|
+
query.exec(cb);
|
|
48
|
+
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// Get all contact groups for a customer
|
|
52
|
+
LimitedPartnerContactGroup.statics.getForCustomer = function (customerId, options, cb) {
|
|
53
|
+
|
|
54
|
+
const self = this;
|
|
55
|
+
|
|
56
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
57
|
+
if (!customerId) { return cb(new Error('customerId is required'), null); }
|
|
58
|
+
if (!mongoose.Types.ObjectId.isValid(customerId)) { return cb(new Error('customerId is not a valid ObjectId'), null); }
|
|
59
|
+
|
|
60
|
+
let query = self.find({
|
|
61
|
+
'customer': customerId
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
query.exec(cb);
|
|
65
|
+
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
LimitedPartnerContactGroup.statics.upsert = function upsert(doc, options, cb) {
|
|
69
|
+
|
|
70
|
+
if (!doc) { return cb(new Error('doc is required'), null); }
|
|
71
|
+
|
|
72
|
+
doc.save(cb);
|
|
73
|
+
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
///////////////////////////////////////////////////////////////////////////////////////
|
|
78
|
+
// CONFIG
|
|
79
|
+
///////////////////////////////////////////////////////////////////////////////////////
|
|
80
|
+
|
|
81
|
+
LimitedPartnerContactGroup.set('usePushEach', true);
|
|
82
|
+
LimitedPartnerContactGroup.set('toJSON', { virtuals: true });
|
|
83
|
+
LimitedPartnerContactGroup.set('autoIndex', false);
|
|
84
|
+
LimitedPartnerContactGroup.set('usePushEach', true);
|
|
85
|
+
|
|
86
|
+
LimitedPartnerContactGroup.on('index', function(err) { console.log('error building LimitedPartnerContactGroup indexes: ' + err); });
|
|
87
|
+
|
|
88
|
+
mongoose.model('LimitedPartnerContactGroup', LimitedPartnerContactGroup);
|
|
89
|
+
|
|
90
|
+
};
|
package/lib/Round.js
CHANGED
|
@@ -112,7 +112,9 @@ module.exports = function(mongoose, config) {
|
|
|
112
112
|
logoUrl: rounds[0].organization.logoUrl,
|
|
113
113
|
description: rounds[0].organization.description,
|
|
114
114
|
status: rounds[0].organization.status,
|
|
115
|
-
|
|
115
|
+
contact: rounds[0].organization.contact,
|
|
116
|
+
websites: websites,
|
|
117
|
+
rounds: rounds
|
|
116
118
|
};
|
|
117
119
|
|
|
118
120
|
var performance = calculatePerformance(rounds);
|