@xuda.io/account_module 1.2.4 → 1.2.15

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.
Files changed (2) hide show
  1. package/index.js +75 -59
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -277,6 +277,9 @@ exports.increment_account_usage = async function (req) {
277
277
  });
278
278
  if (size_ret.code > -1)
279
279
  account_data.plugins_drive_size += size_ret.data;
280
+
281
+ // db data
282
+ account_data.project_data_size += 0;
280
283
  }
281
284
 
282
285
  const usage_id = await _common.xuda_get_uuid("usage");
@@ -418,6 +421,7 @@ exports.increment_account_usage = async function (req) {
418
421
  account_data.workspace_drive_size = 0;
419
422
  account_data.plugins_drive_size = 0;
420
423
  account_data.builds_drive_size = 0;
424
+ account_data.project_data_size = 0;
421
425
 
422
426
  await run_account_apps(account_data);
423
427
  await run_account_drive(account_data);
@@ -427,75 +431,87 @@ exports.increment_account_usage = async function (req) {
427
431
  account_data.studio_drive_size +
428
432
  account_data.workspace_drive_size +
429
433
  account_data.plugins_drive_size +
430
- account_data.builds_drive_size;
434
+ account_data.builds_drive_size +
435
+ account_data.project_data_size;
431
436
  await db_module.save_couch_doc("xuda_accounts", account_data);
432
437
  }
433
438
  };
434
439
 
435
440
  exports.get_account_data = async function (req) {
436
441
  var { uid, enforce_usage } = req;
437
- const get_info = async function () {
438
- // const get_stripe_subscription = async function (subscription_id) {
439
- // if (!subscription_id) {
440
- // return { code: -1, data: "subscription_id missing" };
441
- // }
442
- // try {
443
- // const ret = await stripe.subscriptions.retrieve(subscription_id);
442
+ // const get_info = async function () {
443
+ // const get_stripe_subscription = async function (subscription_id) {
444
+ // if (!subscription_id) {
445
+ // return { code: -1, data: "subscription_id missing" };
446
+ // }
447
+ // try {
448
+ // const ret = await stripe.subscriptions.retrieve(subscription_id);
449
+
450
+ // return { code: 1, data: ret };
451
+ // } catch (err) {
452
+ // return { code: -400, data: err };
453
+ // }
454
+ // };
444
455
 
445
- // return { code: 1, data: ret };
446
- // } catch (err) {
447
- // return { code: -400, data: err };
448
- // }
449
- // };
450
-
451
- try {
452
- const account_ret = await db_module.get_couch_doc("xuda_accounts", uid);
453
- const { acc_obj = data } = account_ret;
454
- // const account_obj= account_ret.data
455
- var ret = { code: 1 };
456
- ret.data = {
457
- _id: account_ret.data._id,
458
- account_info: account_ret.data.account_info,
459
- usage: account_ret.data.activity_usage,
460
- plan: account_ret.data.plan,
461
- plan_changed: account_ret.data.plan_changed,
462
- plan_info: account_ret.data.plan_info,
463
- support_plan: account_ret.data.support_plan,
464
- support_plan_changed: account_ret.data.support_plan_changed,
465
- support_plan_info: account_ret.data.support_plan_info,
466
- prices_info: account_ret.data.prices_info,
467
- activity_usage: account_ret.data.activity_usage,
468
- uid: account_ret.data._id,
469
- stat: account_ret.data.stat,
470
- preferences: account_ret.data.preferences || {},
471
- billing_status: {
472
- account_suspension_status: account_ret.data.account_suspension_status,
473
- account_suspension_data: account_ret.data.account_suspension_data,
474
- account_billing_hold_status:
475
- account_ret.data.account_billing_hold_status,
476
- account_billing_hold_data: account_ret.data.account_billing_hold_date,
477
- account_termination_status:
478
- account_ret.data.account_termination_status,
479
- account_termination_data: account_ret.data.account_termination_data,
480
- },
481
- };
456
+ try {
457
+ const { data: acc_obj } = await db_module.get_couch_doc(
458
+ "xuda_accounts",
459
+ uid
460
+ );
461
+ // const account_obj= account_ret.data
462
+ var ret = { code: 1 };
463
+ ret.data = {
464
+ _id: acc_obj._id,
465
+ account_info: acc_obj.account_info,
466
+ usage: acc_obj.activity_usage,
467
+ plan: acc_obj.plan,
468
+ plan_changed: acc_obj.plan_changed,
469
+ plan_info: acc_obj.plan_info,
470
+ support_plan: acc_obj.support_plan,
471
+ support_plan_changed: acc_obj.support_plan_changed,
472
+ storage_plan: acc_obj.storage_plan,
473
+ storage_plan_changed: acc_obj.storage_plan_changed,
474
+
475
+ prices_info: acc_obj.prices_info,
476
+ activity_usage: acc_obj.activity_usage,
477
+ uid: acc_obj._id,
478
+ stat: acc_obj.stat,
479
+ preferences: acc_obj.preferences || {},
480
+ billing_status: {
481
+ account_suspension_status: acc_obj.account_suspension_status,
482
+ account_suspension_data: acc_obj.account_suspension_data,
483
+ account_billing_hold_status: acc_obj.account_billing_hold_status,
484
+ account_billing_hold_data: acc_obj.account_billing_hold_date,
485
+ account_termination_status: acc_obj.account_termination_status,
486
+ account_termination_data: acc_obj.account_termination_data,
487
+ },
488
+ drive_usage: {
489
+ user_drive_size: acc_obj.user_drive_size || 0,
490
+ studio_drive_size: acc_obj.studio_drive_size || 0,
491
+ workspace_drive_size: acc_obj.workspace_drive_size || 0,
492
+ plugins_drive_size: acc_obj.plugins_drive_size || 0,
493
+ builds_drive_size: acc_obj.builds_drive_size || 0,
494
+ project_data_size: acc_obj.project_data_size || 0,
495
+ total_drive_size: acc_obj.total_drive_size || 0,
496
+ },
497
+ };
482
498
 
483
- // if (account_ret.data.stripe_membership_subscription_id) {
484
- // const subscription_ret = await get_stripe_subscription(
485
- // account_ret.data.stripe_membership_subscription_id
486
- // );
499
+ // if (account_ret.data.stripe_membership_subscription_id) {
500
+ // const subscription_ret = await get_stripe_subscription(
501
+ // account_ret.data.stripe_membership_subscription_id
502
+ // );
487
503
 
488
- // if (subscription_ret.code > 0) {
489
- // ret.data.stripe_membership_subscription_id = subscription_ret.data.id;
490
- // }
491
- // }
492
- return ret;
493
- } catch (error) {
494
- return { code: -1, data: error };
495
- }
496
- };
504
+ // if (subscription_ret.code > 0) {
505
+ // ret.data.stripe_membership_subscription_id = subscription_ret.data.id;
506
+ // }
507
+ // }
508
+ return ret;
509
+ } catch (error) {
510
+ return { code: -1, data: error };
511
+ }
512
+ // };
497
513
 
498
- return get_info();
514
+ // return get_info();
499
515
  };
500
516
 
501
517
  exports.get_user_projects = async function (req) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.4",
3
+ "version": "1.2.15",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.js",
6
6
  "dependencies": {