@dhyasama/totem-models 12.21.0 → 12.23.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/Brief.js CHANGED
@@ -112,12 +112,24 @@ module.exports = function(mongoose, config) {
112
112
  };
113
113
 
114
114
  // Writes the finished html + references and flips status to 'ready'.
115
- Brief.statics.saveResult = async function(customerId, entity, html, references) {
115
+ //
116
+ // `generatedOn` is optional. The caller (the ai-brief Lambda) should pass the
117
+ // date of the most recent source the brief cites, so the stamp reflects how
118
+ // current the underlying material is rather than when the html was rendered.
119
+ // When omitted (or not a valid date) it falls back to now, preserving the
120
+ // previous behavior for older callers.
121
+ Brief.statics.saveResult = async function(customerId, entity, html, references, generatedOn) {
116
122
  validateCustomerId(customerId);
117
123
  validateEntity(entity);
118
124
  if (!html || typeof html !== 'string') throw new Error('html is required');
119
125
  if (!Array.isArray(references)) throw new Error('references must be an array');
120
126
 
127
+ var stamp = new Date();
128
+ if (generatedOn != null) {
129
+ var parsed = (generatedOn instanceof Date) ? generatedOn : new Date(generatedOn);
130
+ if (!isNaN(parsed.getTime())) stamp = parsed;
131
+ }
132
+
121
133
  return this.findOneAndUpdate(
122
134
  entityFilter(customerId, entity),
123
135
  {
@@ -125,7 +137,7 @@ module.exports = function(mongoose, config) {
125
137
  status: 'ready',
126
138
  html,
127
139
  references,
128
- generatedOn: new Date()
140
+ generatedOn: stamp
129
141
  },
130
142
  $setOnInsert: { customer: customerId, entity: { id: entity.id, model: entity.model } }
131
143
  },
@@ -225,6 +225,13 @@ module.exports = function(mongoose, config) {
225
225
  active: { type: Boolean, default: false }
226
226
  },
227
227
 
228
+ // Granola native REST API integration. When active, webhooks polls this
229
+ // customer's Granola notes using apiKey (see webhooks/src/granola).
230
+ granola: {
231
+ active: { type: Boolean, default: false },
232
+ apiKey: { type: String, trim: true }
233
+ },
234
+
228
235
  sheet: {
229
236
  id: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
230
237
  format: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "12.21.0",
3
+ "version": "12.23.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",