@dhyasama/totem-models 12.3.0 → 12.4.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/lib/Account.js +120 -109
- package/lib/Activity.js +23 -13
- package/lib/ApiKey.js +24 -21
- package/lib/CalendarEvent.js +100 -61
- package/lib/CapTable.js +148 -107
- package/lib/Deal.js +409 -364
- package/lib/DiffbotArticle.js +21 -15
- package/lib/DiffbotOrganization.js +21 -15
- package/lib/Document.js +60 -44
- package/lib/Event.js +38 -21
- package/lib/EventAttendee.js +29 -17
- package/lib/Financials.js +400 -367
- package/lib/FinancialsAnalysis.js +49 -38
- package/lib/Flag.js +42 -35
- package/lib/Folder.js +33 -20
- package/lib/Fund.js +103 -74
- package/lib/Interaction.js +182 -141
- package/lib/Investment.js +58 -49
- package/lib/LimitedPartner.js +241 -241
- package/lib/LimitedPartnerCampaign.js +59 -49
- package/lib/LimitedPartnerCommunication.js +91 -77
- package/lib/LimitedPartnerContactGroup.js +31 -33
- package/lib/LimitedPartnerReportGenerator.js +13 -9
- package/lib/List.js +68 -42
- package/lib/Meeting.js +56 -33
- package/lib/Message.js +225 -173
- package/lib/MessageRecipient.js +42 -31
- package/lib/News.js +30 -19
- package/lib/Note.js +40 -33
- package/lib/Organization.js +570 -506
- package/lib/Person.js +281 -246
- package/lib/Rate.js +24 -17
- package/lib/Round.js +309 -311
- package/lib/Snapshot.js +14 -9
- package/lib/Sync.js +19 -11
- package/lib/Webhook.js +8 -3
- package/package.json +1 -1
package/lib/List.js
CHANGED
|
@@ -61,7 +61,7 @@ module.exports = function(mongoose, config) {
|
|
|
61
61
|
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
List.statics.addItem = function(listId, itemId, collection, options, cb) {
|
|
64
|
+
List.statics.addItem = async function(listId, itemId, collection, options, cb) {
|
|
65
65
|
|
|
66
66
|
if (!cb) { throw new Error('cb is required'); }
|
|
67
67
|
if (!listId) { return cb(new Error('listId is required'), null); }
|
|
@@ -73,23 +73,26 @@ module.exports = function(mongoose, config) {
|
|
|
73
73
|
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
74
74
|
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
let query = self.findOne({
|
|
76
|
+
let query = this.findOne({
|
|
78
77
|
'_id': listId,
|
|
79
78
|
'customer': options.CUSTOMER_ID
|
|
80
79
|
});
|
|
81
80
|
|
|
82
|
-
|
|
81
|
+
try {
|
|
82
|
+
const result = await query;
|
|
83
|
+
if (!result) { return cb(null, null); }
|
|
83
84
|
|
|
84
85
|
result[collection].push(itemId);
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
87
|
+
const saved = await result.save();
|
|
88
|
+
return cb(null, saved);
|
|
89
|
+
} catch(err) {
|
|
90
|
+
return cb(err);
|
|
91
|
+
}
|
|
89
92
|
|
|
90
93
|
};
|
|
91
94
|
|
|
92
|
-
List.statics.createList = function(name, items, creator, options, cb) {
|
|
95
|
+
List.statics.createList = async function(name, items, creator, options, cb) {
|
|
93
96
|
|
|
94
97
|
if (!cb) { throw new Error('cb is required'); }
|
|
95
98
|
if (!name) { return cb(new Error('name is required'), null); }
|
|
@@ -99,9 +102,7 @@ module.exports = function(mongoose, config) {
|
|
|
99
102
|
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
100
103
|
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
101
104
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
let list = new self();
|
|
105
|
+
let list = new this();
|
|
105
106
|
list.customer = options.CUSTOMER_ID;
|
|
106
107
|
list.name = name;
|
|
107
108
|
list.createdOn = new Date();
|
|
@@ -113,11 +114,16 @@ module.exports = function(mongoose, config) {
|
|
|
113
114
|
// enforce unique customer/name tuple
|
|
114
115
|
list.key = list.customer + '-' + list.name.split(' ').join('-');
|
|
115
116
|
|
|
116
|
-
|
|
117
|
+
try {
|
|
118
|
+
const result = await list.save();
|
|
119
|
+
return cb(null, result);
|
|
120
|
+
} catch(err) {
|
|
121
|
+
return cb(err);
|
|
122
|
+
}
|
|
117
123
|
|
|
118
124
|
};
|
|
119
125
|
|
|
120
|
-
List.statics.getById = function (id, options, cb) {
|
|
126
|
+
List.statics.getById = async function (id, options, cb) {
|
|
121
127
|
|
|
122
128
|
if (!cb) { throw new Error('cb is required'); }
|
|
123
129
|
if (!id) { return cb(new Error('name is required'), null); }
|
|
@@ -126,9 +132,7 @@ module.exports = function(mongoose, config) {
|
|
|
126
132
|
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
127
133
|
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
128
134
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
let query = self.findOne({
|
|
135
|
+
let query = this.findOne({
|
|
132
136
|
'_id': id,
|
|
133
137
|
'customer': options.CUSTOMER_ID
|
|
134
138
|
});
|
|
@@ -138,30 +142,38 @@ module.exports = function(mongoose, config) {
|
|
|
138
142
|
query.populate('organizations', 'name logoUrl contact');
|
|
139
143
|
query.populate('people', 'name title avatarUrl contact');
|
|
140
144
|
|
|
141
|
-
|
|
145
|
+
try {
|
|
146
|
+
const result = await query;
|
|
147
|
+
return cb(null, result);
|
|
148
|
+
} catch(err) {
|
|
149
|
+
return cb(err);
|
|
150
|
+
}
|
|
142
151
|
|
|
143
152
|
};
|
|
144
153
|
|
|
145
|
-
List.statics.getLists = function(options, cb) {
|
|
154
|
+
List.statics.getLists = async function(options, cb) {
|
|
146
155
|
|
|
147
156
|
if (!cb) { throw new Error('cb is required'); }
|
|
148
157
|
if (!options) { return cb(new Error('options is required'), null); }
|
|
149
158
|
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
150
159
|
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
151
160
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
let query = self.find({ 'customer': options.CUSTOMER_ID });
|
|
161
|
+
let query = this.find({ 'customer': options.CUSTOMER_ID });
|
|
155
162
|
|
|
156
163
|
query.populate('limitedPartners', 'name logoUrl');
|
|
157
164
|
query.populate('organizations', 'name logoUrl');
|
|
158
165
|
query.populate('people', 'name title avatarUrl');
|
|
159
166
|
|
|
160
|
-
|
|
167
|
+
try {
|
|
168
|
+
const result = await query;
|
|
169
|
+
return cb(null, result);
|
|
170
|
+
} catch(err) {
|
|
171
|
+
return cb(err);
|
|
172
|
+
}
|
|
161
173
|
|
|
162
174
|
};
|
|
163
175
|
|
|
164
|
-
List.statics.modifyById = function(id, update, cb) {
|
|
176
|
+
List.statics.modifyById = async function(id, update, cb) {
|
|
165
177
|
|
|
166
178
|
// VERY IMPORTANT NOTE
|
|
167
179
|
// findByIdAndUpdate and findOneAndUpdate do not trigger pre-save hook so that code will not run here
|
|
@@ -170,16 +182,19 @@ module.exports = function(mongoose, config) {
|
|
|
170
182
|
if (!id) { return cb(new Error('id is required'), null); }
|
|
171
183
|
if (!update) { return cb(new Error('update is required'), null); }
|
|
172
184
|
|
|
173
|
-
let self = this;
|
|
174
|
-
|
|
175
185
|
// options runValidators defaults false which is ok since we have upsert false
|
|
176
186
|
// new returns the updated document
|
|
177
187
|
|
|
178
|
-
|
|
188
|
+
try {
|
|
189
|
+
const result = await this.findByIdAndUpdate(id, update, { upsert: false, new: true });
|
|
190
|
+
return cb(null, result);
|
|
191
|
+
} catch(err) {
|
|
192
|
+
return cb(err);
|
|
193
|
+
}
|
|
179
194
|
|
|
180
195
|
};
|
|
181
196
|
|
|
182
|
-
List.statics.remove = function(id, options, cb) {
|
|
197
|
+
List.statics.remove = async function(id, options, cb) {
|
|
183
198
|
|
|
184
199
|
if (!cb) { throw new Error('cb is required'); }
|
|
185
200
|
if (!id) { return cb(new Error('name is required'), null); }
|
|
@@ -188,16 +203,19 @@ module.exports = function(mongoose, config) {
|
|
|
188
203
|
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
189
204
|
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
190
205
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
206
|
+
try {
|
|
207
|
+
const result = await this.findOneAndDelete({
|
|
208
|
+
'_id': id,
|
|
209
|
+
'customer': options.CUSTOMER_ID
|
|
210
|
+
});
|
|
211
|
+
return cb(null, result);
|
|
212
|
+
} catch(err) {
|
|
213
|
+
return cb(err);
|
|
214
|
+
}
|
|
197
215
|
|
|
198
216
|
};
|
|
199
217
|
|
|
200
|
-
List.statics.removeItem = function(listId, itemId, collection, options, cb) {
|
|
218
|
+
List.statics.removeItem = async function(listId, itemId, collection, options, cb) {
|
|
201
219
|
|
|
202
220
|
if (!cb) { throw new Error('cb is required'); }
|
|
203
221
|
if (!listId) { return cb(new Error('listId is required'), null); }
|
|
@@ -209,20 +227,28 @@ module.exports = function(mongoose, config) {
|
|
|
209
227
|
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
210
228
|
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
211
229
|
|
|
212
|
-
const self = this;
|
|
213
|
-
|
|
214
230
|
let update = {};
|
|
215
231
|
update[collection] = itemId;
|
|
216
232
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
233
|
+
try {
|
|
234
|
+
const result = await this.findOneAndUpdate({
|
|
235
|
+
'_id': listId,
|
|
236
|
+
'customer': options.CUSTOMER_ID
|
|
237
|
+
}, { $pull: update }, { new: true });
|
|
238
|
+
return cb(null, result);
|
|
239
|
+
} catch(err) {
|
|
240
|
+
return cb(err);
|
|
241
|
+
}
|
|
221
242
|
|
|
222
243
|
};
|
|
223
244
|
|
|
224
|
-
List.statics.upsert = function (list, cb) {
|
|
225
|
-
|
|
245
|
+
List.statics.upsert = async function (list, cb) {
|
|
246
|
+
try {
|
|
247
|
+
const result = await list.save();
|
|
248
|
+
return cb(null, result);
|
|
249
|
+
} catch(err) {
|
|
250
|
+
return cb(err);
|
|
251
|
+
}
|
|
226
252
|
};
|
|
227
253
|
|
|
228
254
|
List.pre('save', function(next) {
|
package/lib/Meeting.js
CHANGED
|
@@ -9,7 +9,7 @@ module.exports = function(mongoose, config) {
|
|
|
9
9
|
let moment = require('moment');
|
|
10
10
|
|
|
11
11
|
var Meeting = new Schema({
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
customer: { type: Schema.ObjectId, ref: 'Organization', index: true, required: true },
|
|
14
14
|
|
|
15
15
|
provider: { type: String, index: false, required: true },
|
|
@@ -31,11 +31,11 @@ module.exports = function(mongoose, config) {
|
|
|
31
31
|
updatedOn: { type: Date, index: false, required: true },
|
|
32
32
|
|
|
33
33
|
raw: { type: String, index: false, required: true },
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
people: [{ type: Schema.ObjectId, ref: 'Person', index: true }],
|
|
36
36
|
|
|
37
37
|
notes: { type: String, trim: true },
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
analysis: {
|
|
40
40
|
summary: { type: String },
|
|
41
41
|
sentences: [{
|
|
@@ -56,9 +56,7 @@ module.exports = function(mongoose, config) {
|
|
|
56
56
|
try { return JSON.parse(this.raw); } catch (e) { return null; }
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
Meeting.statics.getById = function (id, options, cb) {
|
|
60
|
-
|
|
61
|
-
const self = this;
|
|
59
|
+
Meeting.statics.getById = async function (id, options, cb) {
|
|
62
60
|
|
|
63
61
|
if (!cb) { throw new Error('cb is required'); }
|
|
64
62
|
if (!id) { return cb(new Error('id is required'), null); }
|
|
@@ -67,15 +65,19 @@ module.exports = function(mongoose, config) {
|
|
|
67
65
|
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
68
66
|
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
69
67
|
|
|
70
|
-
let query =
|
|
68
|
+
let query = this.findOne({ '_id': id, customer: options.CUSTOMER_ID });
|
|
71
69
|
if (options.populate === true) { query.populate({ path: 'people', select: 'name title avatarUrl doNotDisplay' }); }
|
|
72
|
-
query.exec().then(function(result) { cb(null, result); }).catch(function(err) { cb(err); });
|
|
73
70
|
|
|
74
|
-
|
|
71
|
+
try {
|
|
72
|
+
const result = await query;
|
|
73
|
+
return cb(null, result);
|
|
74
|
+
} catch(err) {
|
|
75
|
+
return cb(err);
|
|
76
|
+
}
|
|
75
77
|
|
|
76
|
-
|
|
78
|
+
};
|
|
77
79
|
|
|
78
|
-
|
|
80
|
+
Meeting.statics.getByEventId = async function (eventId, options, cb) {
|
|
79
81
|
|
|
80
82
|
if (!cb) { throw new Error('cb is required'); }
|
|
81
83
|
if (!eventId) { return cb(new Error('eventId is required'), null); }
|
|
@@ -83,15 +85,19 @@ module.exports = function(mongoose, config) {
|
|
|
83
85
|
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
84
86
|
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
85
87
|
|
|
86
|
-
let query =
|
|
88
|
+
let query = this.find({ 'eventId': eventId, customer: options.CUSTOMER_ID });
|
|
87
89
|
if (options.populate === true) { query.populate({ path: 'people', select: 'name title avatarUrl doNotDisplay' }); }
|
|
88
|
-
query.exec().then(function(result) { cb(null, result); }).catch(function(err) { cb(err); });
|
|
89
90
|
|
|
90
|
-
|
|
91
|
+
try {
|
|
92
|
+
const result = await query;
|
|
93
|
+
return cb(null, result);
|
|
94
|
+
} catch(err) {
|
|
95
|
+
return cb(err);
|
|
96
|
+
}
|
|
91
97
|
|
|
92
|
-
|
|
98
|
+
};
|
|
93
99
|
|
|
94
|
-
|
|
100
|
+
Meeting.statics.getByUniqueId = async function (uniqueId, options, cb) {
|
|
95
101
|
|
|
96
102
|
if (!cb) { throw new Error('cb is required'); }
|
|
97
103
|
if (!uniqueId) { return cb(new Error('uniqueId is required'), null); }
|
|
@@ -99,15 +105,19 @@ module.exports = function(mongoose, config) {
|
|
|
99
105
|
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
100
106
|
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
101
107
|
|
|
102
|
-
let query =
|
|
108
|
+
let query = this.findOne({ 'uniqueId': uniqueId, customer: options.CUSTOMER_ID });
|
|
103
109
|
if (options.populate === true) { query.populate({ path: 'people', select: 'name title avatarUrl doNotDisplay' }); }
|
|
104
|
-
query.exec().then(function(result) { cb(null, result); }).catch(function(err) { cb(err); });
|
|
105
110
|
|
|
106
|
-
|
|
111
|
+
try {
|
|
112
|
+
const result = await query;
|
|
113
|
+
return cb(null, result);
|
|
114
|
+
} catch(err) {
|
|
115
|
+
return cb(err);
|
|
116
|
+
}
|
|
107
117
|
|
|
108
|
-
|
|
118
|
+
};
|
|
109
119
|
|
|
110
|
-
|
|
120
|
+
Meeting.statics.search = async function (options, cb) {
|
|
111
121
|
|
|
112
122
|
if (!cb) { throw new Error('cb is required'); }
|
|
113
123
|
if (!options) { return cb(new Error('options is required'), null); }
|
|
@@ -119,7 +129,7 @@ module.exports = function(mongoose, config) {
|
|
|
119
129
|
options.before = options.before || moment().toISOString();
|
|
120
130
|
options.after = options.after || moment().subtract(20, 'year').toISOString();
|
|
121
131
|
|
|
122
|
-
let query =
|
|
132
|
+
let query = this.find({ customer: options.CUSTOMER_ID });
|
|
123
133
|
|
|
124
134
|
if (options && Array.isArray(options.personIds) && options.personIds.length > 0) {
|
|
125
135
|
query.where({ 'people': { $in: options.personIds } });
|
|
@@ -132,13 +142,17 @@ module.exports = function(mongoose, config) {
|
|
|
132
142
|
if (options.limit >= 0) { query.limit(options.limit); }
|
|
133
143
|
|
|
134
144
|
if (options.populate === true) { query.populate({ path: 'people', select: 'name title avatarUrl doNotDisplay' }); }
|
|
135
|
-
query.exec().then(function(result) { cb(null, result); }).catch(function(err) { cb(err); });
|
|
136
145
|
|
|
137
|
-
|
|
146
|
+
try {
|
|
147
|
+
const result = await query;
|
|
148
|
+
return cb(null, result);
|
|
149
|
+
} catch(err) {
|
|
150
|
+
return cb(err);
|
|
151
|
+
}
|
|
138
152
|
|
|
139
|
-
|
|
153
|
+
};
|
|
140
154
|
|
|
141
|
-
|
|
155
|
+
Meeting.statics.delete = async function(meetingId, options, cb) {
|
|
142
156
|
|
|
143
157
|
if (!cb) { throw new Error('cb is required'); }
|
|
144
158
|
if (!meetingId) { return cb(new Error('meetingId is required'), null); }
|
|
@@ -147,19 +161,28 @@ module.exports = function(mongoose, config) {
|
|
|
147
161
|
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
148
162
|
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
149
163
|
|
|
150
|
-
|
|
151
|
-
|
|
164
|
+
try {
|
|
165
|
+
let query = this.findOne({ _id: meetingId, customer: options.CUSTOMER_ID });
|
|
166
|
+
const meeting = await query;
|
|
152
167
|
if (!meeting) { return cb(null, null); }
|
|
153
|
-
meeting.deleteOne()
|
|
154
|
-
|
|
168
|
+
await meeting.deleteOne();
|
|
169
|
+
return cb(null, meeting);
|
|
170
|
+
} catch(err) {
|
|
171
|
+
return cb(err);
|
|
172
|
+
}
|
|
155
173
|
};
|
|
156
174
|
|
|
157
|
-
Meeting.statics.upsert = function(meeting, cb) {
|
|
175
|
+
Meeting.statics.upsert = async function(meeting, cb) {
|
|
158
176
|
|
|
159
177
|
if (!cb) { throw new Error('cb is required'); }
|
|
160
178
|
if (!meeting) { return cb(new Error('Meeting is required'), null); }
|
|
161
179
|
|
|
162
|
-
|
|
180
|
+
try {
|
|
181
|
+
const result = await meeting.save();
|
|
182
|
+
return cb(null, result);
|
|
183
|
+
} catch(err) {
|
|
184
|
+
return cb(err);
|
|
185
|
+
}
|
|
163
186
|
|
|
164
187
|
};
|
|
165
188
|
Meeting.set('autoIndex', false);
|
|
@@ -171,4 +194,4 @@ module.exports = function(mongoose, config) {
|
|
|
171
194
|
|
|
172
195
|
mongoose.model('Meeting', Meeting);
|
|
173
196
|
|
|
174
|
-
};
|
|
197
|
+
};
|