@xuda.io/account_module 1.2.5 → 1.2.16

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