@xuda.io/account_module 1.2.983 → 1.2.985

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.mjs +26 -22
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -482,27 +482,6 @@ export const get_account_data = async function (req) {
482
482
  try {
483
483
  const { data: acc_obj } = await db_module.get_couch_doc('xuda_accounts', uid);
484
484
 
485
- const app_id = await get_account_default_project_id(uid);
486
-
487
- const d = new Date(); // directly use milliseconds
488
-
489
- const month = Number(String(d.getMonth() + 1).padStart(2, '0')); // months are 0-based
490
- const year = d.getFullYear();
491
-
492
- const ai_usage = await db_module.get_app_couch_view(app_id, 'ai_chat_usage', {
493
- startkey: [year, month, 0],
494
- endkey: [year, month, 99],
495
- reduce: true,
496
- group_level: 999,
497
- });
498
- console.log('ai_usage', ai_usage.rows);
499
- for (const row of ai_usage.rows) {
500
- }
501
-
502
- let membership_plan = 0;
503
- let ai_workspace_plan = 0;
504
- let contact_connection = 0;
505
-
506
485
  var ret = { code: 1 };
507
486
  ret.data = {
508
487
  _id: acc_obj._id,
@@ -540,7 +519,7 @@ export const get_account_data = async function (req) {
540
519
  project_data_size: acc_obj.project_data_size || 0,
541
520
  total_drive_size: acc_obj.total_drive_size || 0,
542
521
  },
543
- ai_credits: { credits: [{ membership_plan }, { ai_workspace_plan }, { contact_connection }], usage: { profile: [], projects: [] } },
522
+
544
523
  stripe_connect_account_id: acc_obj?.stripe_connect_account_obj?.id,
545
524
  stripe_connect_account_status: acc_obj?.stripe_connect_account_status,
546
525
  };
@@ -2419,3 +2398,28 @@ export const ts_contact = async function (contact_id) {
2419
2398
  console.error(err);
2420
2399
  }
2421
2400
  };
2401
+
2402
+ export const get_ai_usage = async function (req, job_id, headers) {
2403
+ const app_id = await get_account_default_project_id(uid);
2404
+
2405
+ const d = new Date(); // directly use milliseconds
2406
+
2407
+ const month = Number(String(d.getMonth() + 1).padStart(2, '0')); // months are 0-based
2408
+ const year = d.getFullYear();
2409
+
2410
+ const ai_usage = await db_module.get_app_couch_view(app_id, 'ai_chat_usage', {
2411
+ startkey: [year, month, 0],
2412
+ endkey: [year, month, 99],
2413
+ reduce: true,
2414
+ group_level: 999,
2415
+ });
2416
+ console.log('ai_usage', ai_usage.rows);
2417
+ for (const row of ai_usage.rows) {
2418
+ }
2419
+
2420
+ let membership_plan = 0;
2421
+ let ai_workspace_plan = 0;
2422
+ let contact_connection = 0;
2423
+
2424
+ let ai_credits = { credits: [{ membership_plan }, { ai_workspace_plan }, { contact_connection }], usage: { profile: [], projects: [] } };
2425
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.983",
3
+ "version": "1.2.985",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {