backend-manager 5.0.151 → 5.0.153

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/CHANGELOG.md CHANGED
@@ -14,6 +14,27 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
14
14
  - `Fixed` for any bug fixes.
15
15
  - `Security` in case of vulnerabilities.
16
16
 
17
+ # [5.0.152] - 2026-03-16
18
+ ### Fixed
19
+ - Email queue documents all stored at `emails-queue/NaN` — `powertools.random()` doesn't support string generation, replaced with `pushid()`
20
+
21
+ # [5.0.151] - 2026-03-16
22
+ ### Fixed
23
+ - AI contact inference was silently broken — `ai.request()` returns `{content, tokens, ...}` but code read `result.firstName` instead of `result.content.firstName`, so AI was never used
24
+ - OpenAI API key not passed to AI library — now explicitly passes `BACKEND_MANAGER_OPENAI_API_KEY`
25
+
26
+ ### Added
27
+ - `POST /admin/infer-contact` route for testing/debugging contact inference (admin-only, supports batch)
28
+ - `user_personal_company` custom field in FIELDS constant for marketing provider sync
29
+ - Company passthrough in `Marketing.add()` → SendGrid and Beehiiv providers
30
+ - Test suite for admin/infer-contact route
31
+ - Standalone test script (`scripts/test-infer-contact.js`)
32
+
33
+ ### Changed
34
+ - Improved AI prompt: rejects placeholders/gibberish, always infers company from domain, preserves hyphenated name capitalization
35
+ - Disabled regex fallback — returns empty when AI can't infer a real name
36
+ - All 3 inferContact callsites (marketing/contact, user/signup, legacy add-marketing-contact) now extract and pass company
37
+
17
38
  # [5.0.150] - 2026-03-16
18
39
  ### Added
19
40
  - `marketing` config section in `backend-manager-config.json` — per-brand control over SendGrid and Beehiiv provider availability
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "5.0.151",
3
+ "version": "5.0.153",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -13,6 +13,7 @@
13
13
  */
14
14
  const _ = require('lodash');
15
15
  const moment = require('moment');
16
+ const pushid = require('pushid');
16
17
  const MarkdownIt = require('markdown-it');
17
18
  const md = new MarkdownIt({
18
19
  html: true,
@@ -482,8 +483,7 @@ function normalizeSendAt(sendAt) {
482
483
  * build pipeline when the cron picks it up.
483
484
  */
484
485
  async function saveToEmailQueue(settings, sendAt, admin, assistant) {
485
- const powertools = require('node-powertools');
486
- const emailId = powertools.random(32, { type: 'alphanumeric' });
486
+ const emailId = pushid();
487
487
 
488
488
  // Clone and clean undefined values for Firestore
489
489
  const settingsCloned = _.cloneDeepWith(settings, (value) => {
@@ -361,7 +361,7 @@ OpenAI.prototype.request = function (options) {
361
361
  .catch((e) => e);
362
362
 
363
363
  // Check for moderation flag
364
- if (moderation.flagged) {
364
+ if (moderation?.flagged) {
365
365
  return reject(assistant.errorify(`This request is inappropriate`, {code: 451}));
366
366
  }
367
367
  }