@xuda.io/account_module 1.2.1330 → 1.2.1332

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 +47 -0
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2775,6 +2775,53 @@ export const update_account_profile = async function (req, job_id, headers) {
2775
2775
  }
2776
2776
  };
2777
2777
 
2778
+ export const update_entity_account_profiles = async function (req, job_id, headers) {
2779
+ const { uid, entity } = req;
2780
+ const app_id = await get_account_default_project_id(uid);
2781
+
2782
+ try {
2783
+ switch (entity) {
2784
+ case 'ai_chat': {
2785
+ break;
2786
+ }
2787
+
2788
+ default:
2789
+ throw new Error('entity not supported');
2790
+ break;
2791
+ }
2792
+
2793
+ let { data: account_profile_doc } = await db_module.get_app_couch_doc(app_id, _id);
2794
+
2795
+ if (account_profile_doc.docType !== 'account_profile') {
2796
+ throw new Error('not account profile doc');
2797
+ }
2798
+
2799
+ let changes_arr = [];
2800
+
2801
+ for (const key of account_profile_properties) {
2802
+ let val = req[key];
2803
+ if (typeof val === 'undefined') continue;
2804
+ if (account_profile_doc[key] !== val) {
2805
+ changes_arr.push(key);
2806
+ account_profile_doc[key] = val;
2807
+ }
2808
+ }
2809
+
2810
+ if (!changes_arr.length) {
2811
+ // throw new Error('no change');
2812
+ return { code: 56, data: 'no change' };
2813
+ }
2814
+
2815
+ account_profile_doc.ts = Date.now();
2816
+
2817
+ const save_ret = await db_module.save_app_couch_doc(app_id, account_profile_doc);
2818
+
2819
+ return { code: 56, data: save_ret };
2820
+ } catch (err) {
2821
+ return { code: -56, data: err.message };
2822
+ }
2823
+ };
2824
+
2778
2825
  export const get_contact = async function (uid, contact_id) {
2779
2826
  const account_profile_info = await get_active_account_profile_info(uid);
2780
2827
  const contact_ret = await db_module.get_app_couch_doc_native(account_profile_info.app_id, contact_id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.1330",
3
+ "version": "1.2.1332",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {