@dhyasama/totem-models 12.36.0 → 12.38.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/Financials.js CHANGED
@@ -114,7 +114,7 @@ module.exports = function(mongoose, config) {
114
114
  _id: false,
115
115
  model: {
116
116
  type: String,
117
- enum: ['Document', 'Meeting', 'Message', 'Note']
117
+ enum: ['Document', 'Meeting', 'Message', 'News', 'Note']
118
118
  },
119
119
  ref: {
120
120
  type: Schema.Types.ObjectId,
@@ -174,7 +174,7 @@ module.exports = function(mongoose, config) {
174
174
  scale: { type: Number, enum: [1, 1000, 1000000, 1000000000, 1000000000000] },
175
175
  sources: [{
176
176
  _id: false,
177
- model: { type: String, enum: ['Document', 'Meeting', 'Message', 'Note'] },
177
+ model: { type: String, enum: ['Document', 'Meeting', 'Message', 'News', 'Note'] },
178
178
  ref: { type: Schema.Types.ObjectId },
179
179
  group: { type: String, trim: true },
180
180
  position: {
package/lib/News.js CHANGED
@@ -16,6 +16,8 @@ module.exports = function(mongoose, config) {
16
16
 
17
17
  text: { type: String, required: false, default: null },
18
18
 
19
+ html: { type: String, required: false, default: null },
20
+
19
21
  summary: { type: String, required: false, default: null },
20
22
 
21
23
  pageUrl: { type: String, required: false, default: null },
@@ -28,6 +30,13 @@ module.exports = function(mongoose, config) {
28
30
 
29
31
  sentiment: { type: Number, required: false, default: null },
30
32
 
33
+ analysis: {
34
+ insights: [{
35
+ text: { type: String },
36
+ category: { type: String, enum: ['highlight', 'lowlight', 'goal', 'ask'] }
37
+ }]
38
+ },
39
+
31
40
  diffbotUri: { type: String, required: true, unique: true },
32
41
 
33
42
  org: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "12.36.0",
3
+ "version": "12.38.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",
@@ -63,6 +63,24 @@ describe('Financials', function() {
63
63
  metric.previous.sources[0].position.should.deepEqual(position);
64
64
  });
65
65
 
66
+ it('validates News references on current and previous metric sources', function() {
67
+ var source = { model: 'News', ref: new mongoose.Types.ObjectId() };
68
+ var f = new Financials({
69
+ organization: orgA,
70
+ customer: customerA,
71
+ snapshots: [{
72
+ uuid: 'news-source-evidence', year: 2025, period: 'FY',
73
+ metrics: [{
74
+ name: 'Revenue', scenario: 'actual', value: 9,
75
+ sources: [source],
76
+ previous: { value: 8, sources: [source] }
77
+ }]
78
+ }]
79
+ });
80
+
81
+ should.not.exist(f.validateSync());
82
+ });
83
+
66
84
  before(function(done) {
67
85
  databaseHelpers.connect(mongoose, done);
68
86
  });
package/test/News.js CHANGED
@@ -25,12 +25,23 @@ describe('News', function() {
25
25
  news.createdBy = 'Jason';
26
26
  news.createdOn = Date.now();
27
27
  news.title = 'Google';
28
+ news.html = '<p>Google announced quarterly revenue.</p>';
29
+ news.analysis = {
30
+ insights: [{
31
+ text: 'Quarterly revenue reached a new high.',
32
+ category: 'highlight'
33
+ }]
34
+ };
28
35
  news.link = 'http://google.com';
29
36
  news.internal = false;
30
37
 
31
38
  News.upsert(news, function(err, item) {
32
39
  should.not.exist(err);
33
40
  should.exist(item);
41
+ item.html.should.equal('<p>Google announced quarterly revenue.</p>');
42
+ item.analysis.insights.should.have.length(1);
43
+ item.analysis.insights[0].text.should.equal('Quarterly revenue reached a new high.');
44
+ item.analysis.insights[0].category.should.equal('highlight');
34
45
  news = item;
35
46
  done();
36
47
  });