backend-manager 3.1.10 → 3.1.11

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": "3.1.10",
3
+ "version": "3.1.11",
4
4
  "description": "Quick tools for developing Firebase functions",
5
5
  "main": "src/manager/index.js",
6
6
  "bin": {
@@ -11,6 +11,7 @@
11
11
  "_test": "npm run prepare && ./node_modules/mocha/bin/mocha test/ --recursive --timeout=10000",
12
12
  "test": "./node_modules/mocha/bin/mocha test/ --recursive --timeout=10000",
13
13
  "test:usage": "./node_modules/mocha/bin/mocha test/usage.js --timeout=10000",
14
+ "test:payment-resolver": "./node_modules/mocha/bin/mocha test/payment-resolver.js --timeout=10000",
14
15
  "start": "node src/index.js"
15
16
  },
16
17
  "engines": {
@@ -41,7 +42,7 @@
41
42
  "cors": "^2.8.5",
42
43
  "dotenv": "^16.3.1",
43
44
  "firebase-admin": "^11.11.1",
44
- "firebase-functions": "^4.5.0",
45
+ "firebase-functions": "^4.6.0",
45
46
  "fs-jetpack": "^5.1.0",
46
47
  "hcaptcha": "^0.1.1",
47
48
  "inquirer": "^8.2.5",
@@ -14,6 +14,8 @@ function SubscriptionResolver(Manager, profile, resource) {
14
14
  SubscriptionResolver.prototype.resolve = function (options) {
15
15
  const self = this;
16
16
 
17
+ const datePast = moment(0);
18
+
17
19
  const resolved = {
18
20
  status: '',
19
21
  frequency: '',
@@ -25,28 +27,32 @@ SubscriptionResolver.prototype.resolve = function (options) {
25
27
  refunded: false,
26
28
  },
27
29
  start: {
28
- timestamp: moment(0),
29
- timestampUNIX: moment(0),
30
+ timestamp: datePast,
31
+ timestampUNIX: datePast,
30
32
  },
31
33
  expires: {
32
- timestamp: moment(0),
33
- timestampUNIX: moment(0),
34
+ timestamp: datePast,
35
+ timestampUNIX: datePast,
34
36
  },
35
37
  cancelled: {
36
- timestamp: moment(0),
37
- timestampUNIX: moment(0),
38
+ timestamp: datePast,
39
+ timestampUNIX: datePast,
38
40
  },
39
41
  lastPayment: {
40
42
  amount: 0,
41
43
  date: {
42
- timestamp: moment(0),
43
- timestampUNIX: moment(0),
44
+ timestamp: datePast,
45
+ timestampUNIX: datePast,
44
46
  }
45
47
  },
46
48
  trial: {
47
49
  claimed: false,
48
50
  active: false,
49
51
  daysLeft: 0,
52
+ expires: {
53
+ timestamp: datePast,
54
+ timestampUNIX: datePast,
55
+ },
50
56
  },
51
57
  details: {
52
58
  message: '',
@@ -178,6 +184,7 @@ SubscriptionResolver.prototype.resolve = function (options) {
178
184
  // Set days left
179
185
  if (resolved.trial.active) {
180
186
  resolved.trial.daysLeft = Math.abs(resolved.expires.timestamp.diff(options.today, 'days'));
187
+ resolved.trial.expires.timestamp = moment(resolved.start.timestamp).add(14, 'days');
181
188
  }
182
189
 
183
190
  // Set expiration
@@ -240,6 +247,9 @@ SubscriptionResolver.prototype.resolve = function (options) {
240
247
  resolved.cancelled.timestampUNIX = resolved.cancelled.timestamp.unix();
241
248
  resolved.cancelled.timestamp = resolved.cancelled.timestamp.toISOString();
242
249
 
250
+ resolved.trial.expires.timestampUNIX = resolved.trial.expires.timestamp.unix();
251
+ resolved.trial.expires.timestamp = resolved.trial.expires.timestamp.toISOString();
252
+
243
253
  // Fix trial days
244
254
  resolved.trial.daysLeft = resolved.trial.daysLeft < 0 ? 0 : resolved.trial.daysLeft;
245
255