@xuda.io/ai_module 1.1.4165 → 1.1.4167
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/index.mjs +34 -31
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2649,16 +2649,16 @@ export const unarchive_ai_agent = async function (req) {
|
|
|
2649
2649
|
};
|
|
2650
2650
|
export const archive_ai_agent = async function (req) {
|
|
2651
2651
|
let { agent_id, uid } = req;
|
|
2652
|
-
|
|
2652
|
+
const account_profile_info = await account_module.get_active_account_profile_info(uid);
|
|
2653
2653
|
const app_id = await account_module.get_account_default_project_id(uid);
|
|
2654
2654
|
try {
|
|
2655
2655
|
const team_module = await import(`${module_path}/team_module/index.mjs`);
|
|
2656
2656
|
await team_module.validate_share_exist(uid, 'ai_agent', agent_id);
|
|
2657
2657
|
|
|
2658
|
-
let agent_doc = await db_module.get_app_couch_doc_native(app_id, agent_id);
|
|
2658
|
+
let agent_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, agent_id);
|
|
2659
2659
|
agent_doc.stat = 5;
|
|
2660
2660
|
agent_doc.ts = Date.now();
|
|
2661
|
-
const save_ret = await db_module.save_app_couch_doc(app_id, agent_doc);
|
|
2661
|
+
const save_ret = await db_module.save_app_couch_doc(account_profile_info.app_id, agent_doc);
|
|
2662
2662
|
|
|
2663
2663
|
return save_ret;
|
|
2664
2664
|
} catch (err) {
|
|
@@ -2669,15 +2669,16 @@ export const archive_ai_agent = async function (req) {
|
|
|
2669
2669
|
export const archive_mini_app = async function (req) {
|
|
2670
2670
|
let { prog_id, uid } = req;
|
|
2671
2671
|
|
|
2672
|
+
const account_profile_info = await account_module.get_active_account_profile_info(uid);
|
|
2672
2673
|
const app_id = await account_module.get_account_default_project_id(uid);
|
|
2673
2674
|
try {
|
|
2674
2675
|
const team_module = await import(`${module_path}/team_module/index.mjs`);
|
|
2675
2676
|
await team_module.validate_share_exist(uid, 'miniapp', prog_id);
|
|
2676
2677
|
|
|
2677
|
-
let prog_doc = await db_module.get_app_couch_doc_native(app_id, prog_id);
|
|
2678
|
+
let prog_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, prog_id);
|
|
2678
2679
|
prog_doc.stat = 5;
|
|
2679
2680
|
prog_doc.ts = Date.now();
|
|
2680
|
-
const save_ret = await db_module.save_app_couch_doc(app_id, prog_doc);
|
|
2681
|
+
const save_ret = await db_module.save_app_couch_doc(account_profile_info.app_id, prog_doc);
|
|
2681
2682
|
|
|
2682
2683
|
return save_ret;
|
|
2683
2684
|
} catch (err) {
|
|
@@ -2688,9 +2689,10 @@ export const archive_mini_app = async function (req) {
|
|
|
2688
2689
|
export const unarchive_mini_app = async function (req) {
|
|
2689
2690
|
let { prog_id, uid } = req;
|
|
2690
2691
|
|
|
2692
|
+
const account_profile_info = await account_module.get_active_account_profile_info(uid);
|
|
2691
2693
|
const app_id = await account_module.get_account_default_project_id(uid);
|
|
2692
2694
|
try {
|
|
2693
|
-
let prog_doc = await db_module.get_app_couch_doc_native(app_id, prog_id);
|
|
2695
|
+
let prog_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, prog_id);
|
|
2694
2696
|
|
|
2695
2697
|
if (prog_doc.stat !== 5) {
|
|
2696
2698
|
throw new Error('mini app is not archived');
|
|
@@ -2698,7 +2700,7 @@ export const unarchive_mini_app = async function (req) {
|
|
|
2698
2700
|
|
|
2699
2701
|
prog_doc.stat = 3;
|
|
2700
2702
|
prog_doc.ts = Date.now();
|
|
2701
|
-
const save_ret = await db_module.save_app_couch_doc(app_id, prog_doc);
|
|
2703
|
+
const save_ret = await db_module.save_app_couch_doc(account_profile_info.app_id, prog_doc);
|
|
2702
2704
|
|
|
2703
2705
|
return save_ret;
|
|
2704
2706
|
} catch (err) {
|
|
@@ -2709,9 +2711,10 @@ export const unarchive_mini_app = async function (req) {
|
|
|
2709
2711
|
export const delete_mini_app = async function (req) {
|
|
2710
2712
|
let { prog_id, uid } = req;
|
|
2711
2713
|
|
|
2714
|
+
const account_profile_info = await account_module.get_active_account_profile_info(uid);
|
|
2712
2715
|
const app_id = await account_module.get_account_default_project_id(uid);
|
|
2713
2716
|
try {
|
|
2714
|
-
let prog_doc = await db_module.get_app_couch_doc_native(app_id, prog_id);
|
|
2717
|
+
let prog_doc = await db_module.get_app_couch_doc_native(account_profile_info.app_id, prog_id);
|
|
2715
2718
|
|
|
2716
2719
|
if (prog_doc.stat !== 5) {
|
|
2717
2720
|
throw new Error('A document can only be deleted after it has been archived');
|
|
@@ -2725,7 +2728,7 @@ export const delete_mini_app = async function (req) {
|
|
|
2725
2728
|
} else {
|
|
2726
2729
|
prog_doc.stat = 4;
|
|
2727
2730
|
prog_doc.ts = Date.now();
|
|
2728
|
-
save_ret = await db_module.save_app_couch_doc(app_id, prog_doc);
|
|
2731
|
+
save_ret = await db_module.save_app_couch_doc(account_profile_info.app_id, prog_doc);
|
|
2729
2732
|
delete_depended_chats(uid, prog_id);
|
|
2730
2733
|
}
|
|
2731
2734
|
return save_ret;
|
|
@@ -2778,29 +2781,29 @@ export const update_ai_agent = async function (req, job_id, headers) {
|
|
|
2778
2781
|
}
|
|
2779
2782
|
};
|
|
2780
2783
|
|
|
2781
|
-
export const install_ai_agent = async function (req) {
|
|
2782
|
-
|
|
2784
|
+
// export const install_ai_agent = async function (req) {
|
|
2785
|
+
// let { agent_id, agent_uid, uid } = req;
|
|
2783
2786
|
|
|
2784
|
-
|
|
2785
|
-
|
|
2787
|
+
// const source_project_db = await get_account_project_db(agent_uid);
|
|
2788
|
+
// const target_project_db = await get_account_project_db(uid);
|
|
2786
2789
|
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2790
|
+
// try {
|
|
2791
|
+
// let agent_doc = await source_project_db.get(agent_id);
|
|
2792
|
+
// if (agent_doc.agentConfig.agent_visibility === 'private') {
|
|
2793
|
+
// throw new Error('agent is private');
|
|
2794
|
+
// }
|
|
2795
|
+
// const t = Date.now();
|
|
2796
|
+
// agent_doc.ts = t;
|
|
2797
|
+
// agent_doc.studio_meta.installed_ts = t;
|
|
2798
|
+
// agent_doc.studio_meta.installed_from_app_id = await account_module.get_account_default_project_id(agent_uid);
|
|
2796
2799
|
|
|
2797
|
-
|
|
2800
|
+
// const data = await target_project_db.insert(agent_doc);
|
|
2798
2801
|
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
};
|
|
2802
|
+
// return { code: 10, data };
|
|
2803
|
+
// } catch (err) {
|
|
2804
|
+
// return { code: -10, data: err.message };
|
|
2805
|
+
// }
|
|
2806
|
+
// };
|
|
2804
2807
|
|
|
2805
2808
|
export const get_apps = async function (req, job_id, headers) {
|
|
2806
2809
|
let { uid, _id, search, filter_type = 'all', limit, skip, mini_app_id } = req;
|
|
@@ -2867,12 +2870,12 @@ export const get_apps = async function (req, job_id, headers) {
|
|
|
2867
2870
|
opt.selector._id = mini_app_id;
|
|
2868
2871
|
}
|
|
2869
2872
|
//////////////
|
|
2870
|
-
|
|
2873
|
+
const account_profile_info = await account_module.get_active_account_profile_info(uid);
|
|
2871
2874
|
const app_id = await account_module.get_account_default_project_id(uid);
|
|
2872
2875
|
|
|
2873
2876
|
let user_apps = { docs: [], total_docs: 0 };
|
|
2874
2877
|
if (filter_type !== 'pending') {
|
|
2875
|
-
user_apps = await db_module.find_app_couch_query(app_id, opt);
|
|
2878
|
+
user_apps = await db_module.find_app_couch_query(account_profile_info.app_id, opt);
|
|
2876
2879
|
if (!limit || mini_app_id) {
|
|
2877
2880
|
user_apps.total_docs = user_apps.docs.length;
|
|
2878
2881
|
} else {
|
|
@@ -2881,7 +2884,7 @@ export const get_apps = async function (req, job_id, headers) {
|
|
|
2881
2884
|
opt.limit = 9999;
|
|
2882
2885
|
opt.fields = ['_id'];
|
|
2883
2886
|
|
|
2884
|
-
const counter = await db_module.find_app_couch_query(app_id, opt);
|
|
2887
|
+
const counter = await db_module.find_app_couch_query(account_profile_info.app_id, opt);
|
|
2885
2888
|
user_apps.total_docs = counter.docs.length;
|
|
2886
2889
|
}
|
|
2887
2890
|
}
|