backend-manager 5.0.94 → 5.0.96

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "backend-manager",
3
- "version": "5.0.94",
3
+ "version": "5.0.96",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -5,11 +5,11 @@
5
5
  const { sendOrderEmail, formatDate } = require('../send-email.js');
6
6
 
7
7
  module.exports = async function ({ before, after, order, uid, userDoc, assistant }) {
8
- assistant.log(`Transition [one-time/purchase-completed]: uid=${uid}, resourceId=${after.payment.resourceId}`);
8
+ assistant.log(`Transition [one-time/purchase-completed]: uid=${uid}, resourceId=${after.payment?.resourceId}`);
9
9
 
10
10
  sendOrderEmail({
11
11
  template: 'main/order/confirmation',
12
- subject: 'Your order is confirmed!',
12
+ subject: `Your order is confirmed! #${order?.id || ''}`,
13
13
  categories: ['order/confirmation'],
14
14
  userDoc,
15
15
  assistant,
@@ -5,11 +5,11 @@
5
5
  const { sendOrderEmail, formatDate } = require('../send-email.js');
6
6
 
7
7
  module.exports = async function ({ before, after, order, uid, userDoc, assistant }) {
8
- assistant.log(`Transition [subscription/cancellation-requested]: uid=${uid}, product=${after.product.id}, cancelDate=${after.cancellation.date?.timestamp}`);
8
+ assistant.log(`Transition [subscription/cancellation-requested]: uid=${uid}, product=${after.product?.id}, cancelDate=${after.cancellation?.date?.timestamp}`);
9
9
 
10
10
  sendOrderEmail({
11
11
  template: 'main/order/cancellation-requested',
12
- subject: 'Your subscription cancellation is confirmed',
12
+ subject: `Your subscription cancellation is confirmed #${order?.id || ''}`,
13
13
  categories: ['order/cancellation-requested'],
14
14
  userDoc,
15
15
  assistant,
@@ -7,12 +7,13 @@ const { sendOrderEmail, formatDate } = require('../send-email.js');
7
7
 
8
8
  module.exports = async function ({ before, after, order, uid, userDoc, assistant }) {
9
9
  const isTrial = after.trial?.claimed === true;
10
+ const brandName = assistant.Manager.config.brand?.name || '';
10
11
 
11
- assistant.log(`Transition [subscription/new-subscription]: uid=${uid}, product=${after.product.id}, frequency=${after.payment.frequency}, trial=${isTrial}`);
12
+ assistant.log(`Transition [subscription/new-subscription]: uid=${uid}, product=${after.product?.id}, frequency=${after.payment?.frequency}, trial=${isTrial}`);
12
13
 
13
14
  sendOrderEmail({
14
15
  template: 'main/order/confirmation',
15
- subject: isTrial ? 'Your free trial has started!' : 'Your subscription is confirmed!',
16
+ subject: `Your order from ${brandName} #${order?.id || ''}`,
16
17
  categories: ['order/confirmation'],
17
18
  userDoc,
18
19
  assistant,
@@ -5,11 +5,11 @@
5
5
  const { sendOrderEmail, formatDate } = require('../send-email.js');
6
6
 
7
7
  module.exports = async function ({ before, after, order, uid, userDoc, assistant }) {
8
- assistant.log(`Transition [subscription/payment-failed]: uid=${uid}, product=${after.product.id}, previousStatus=${before?.status}`);
8
+ assistant.log(`Transition [subscription/payment-failed]: uid=${uid}, product=${after.product?.id}, previousStatus=${before?.status}`);
9
9
 
10
10
  sendOrderEmail({
11
11
  template: 'main/order/payment-failed',
12
- subject: 'Your payment failed',
12
+ subject: `Your payment failed #${order?.id || ''}`,
13
13
  categories: ['order/payment-failed'],
14
14
  userDoc,
15
15
  assistant,
@@ -5,11 +5,11 @@
5
5
  const { sendOrderEmail, formatDate } = require('../send-email.js');
6
6
 
7
7
  module.exports = async function ({ before, after, order, uid, userDoc, assistant }) {
8
- assistant.log(`Transition [subscription/payment-recovered]: uid=${uid}, product=${after.product.id}`);
8
+ assistant.log(`Transition [subscription/payment-recovered]: uid=${uid}, product=${after.product?.id}`);
9
9
 
10
10
  sendOrderEmail({
11
11
  template: 'main/order/payment-recovered',
12
- subject: 'Your payment was successful',
12
+ subject: `Your payment was successful #${order?.id || ''}`,
13
13
  categories: ['order/payment-recovered'],
14
14
  userDoc,
15
15
  assistant,
@@ -5,12 +5,12 @@
5
5
  const { sendOrderEmail, formatDate } = require('../send-email.js');
6
6
 
7
7
  module.exports = async function ({ before, after, order, uid, userDoc, assistant }) {
8
- const direction = after.product.id > before.product.id ? 'upgrade' : 'downgrade';
9
- assistant.log(`Transition [subscription/plan-changed]: uid=${uid}, ${before.product.id} → ${after.product.id} (${direction})`);
8
+ const direction = (after.product?.id || '') > (before.product?.id || '') ? 'upgrade' : 'downgrade';
9
+ assistant.log(`Transition [subscription/plan-changed]: uid=${uid}, ${before.product?.id} → ${after.product?.id} (${direction})`);
10
10
 
11
11
  sendOrderEmail({
12
12
  template: 'main/order/plan-changed',
13
- subject: 'Your subscription plan has been updated',
13
+ subject: `Your subscription plan has been updated #${order?.id || ''}`,
14
14
  categories: ['order/plan-changed'],
15
15
  userDoc,
16
16
  assistant,
@@ -12,7 +12,7 @@ module.exports = async function ({ before, after, order, uid, userDoc, assistant
12
12
 
13
13
  sendOrderEmail({
14
14
  template: 'main/order/cancelled',
15
- subject: 'Your subscription has been cancelled',
15
+ subject: `Your subscription has been cancelled #${order?.id || ''}`,
16
16
  categories: ['order/cancelled'],
17
17
  userDoc,
18
18
  assistant,
@@ -70,10 +70,7 @@ module.exports = async ({ assistant, user, settings, libraries }) => {
70
70
  assistant.log(`signup(): Writing user record for ${uid}`, userRecord);
71
71
 
72
72
  await admin.firestore().doc(`users/${uid}`)
73
- .set(userRecord, { merge: true })
74
- .catch((e) => {
75
- assistant.error(`signup(): Failed to update user record:`, e);
76
- });
73
+ .set(userRecord, { merge: true });
77
74
 
78
75
  // 5. Process affiliate referral (writes to referrer's doc, not this user's)
79
76
  await processAffiliate(assistant, uid, settings);