backend-manager 5.0.94 → 5.0.95

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.95",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -5,7 +5,7 @@
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',
@@ -5,7 +5,7 @@
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',
@@ -8,7 +8,7 @@ const { sendOrderEmail, formatDate } = require('../send-email.js');
8
8
  module.exports = async function ({ before, after, order, uid, userDoc, assistant }) {
9
9
  const isTrial = after.trial?.claimed === true;
10
10
 
11
- assistant.log(`Transition [subscription/new-subscription]: uid=${uid}, product=${after.product.id}, frequency=${after.payment.frequency}, trial=${isTrial}`);
11
+ assistant.log(`Transition [subscription/new-subscription]: uid=${uid}, product=${after.product?.id}, frequency=${after.payment?.frequency}, trial=${isTrial}`);
12
12
 
13
13
  sendOrderEmail({
14
14
  template: 'main/order/confirmation',
@@ -5,7 +5,7 @@
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',
@@ -5,7 +5,7 @@
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',
@@ -5,8 +5,8 @@
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',
@@ -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);