@xuda.io/ai_module 1.1.4098 → 1.1.4100
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 +3 -3
- package/old.mjs +133 -0
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -2807,7 +2807,7 @@ export const get_apps = async function (req, job_id, headers) {
|
|
|
2807
2807
|
break;
|
|
2808
2808
|
}
|
|
2809
2809
|
case 'shared': {
|
|
2810
|
-
opt.selector['studio_meta.shared_from_uid'] = { $gt: null };
|
|
2810
|
+
// opt.selector['studio_meta.shared_from_uid'] = { $gt: null };
|
|
2811
2811
|
break;
|
|
2812
2812
|
}
|
|
2813
2813
|
|
|
@@ -2872,8 +2872,8 @@ export const get_apps = async function (req, job_id, headers) {
|
|
|
2872
2872
|
|
|
2873
2873
|
let requests_from = { docs: [], total_docs: 0 };
|
|
2874
2874
|
if (!mini_app_id) {
|
|
2875
|
-
if (filter_type
|
|
2876
|
-
const from_opt = { selector: { docType: 'team_request', access_type: 'miniapp', team_req_stat: 2, team_req_to_uid: uid }, fields: ['_id', 'team_req_date', 'sender_account_info.email', 'team_req_from_uid', 'share_item_id'] };
|
|
2875
|
+
if (filter_type !== 'mine') {
|
|
2876
|
+
const from_opt = { selector: { docType: 'team_request', access_type: 'miniapp', team_req_stat: filter_type === 'pending' ? 2 : 3, team_req_to_uid: uid }, fields: ['_id', 'team_req_date', 'sender_account_info.email', 'team_req_from_uid', 'share_item_id'] };
|
|
2877
2877
|
const requests_from_res = await db_module.find_couch_query('xuda_team', from_opt);
|
|
2878
2878
|
|
|
2879
2879
|
for await (let e of requests_from_res.docs) {
|
package/old.mjs
CHANGED
|
@@ -1688,3 +1688,136 @@ async function testTool(app_id, uid) {
|
|
|
1688
1688
|
// );
|
|
1689
1689
|
// break;
|
|
1690
1690
|
// }
|
|
1691
|
+
|
|
1692
|
+
export const get_apps = async function (req, job_id, headers) {
|
|
1693
|
+
let { uid, _id, search, filter_type = 'all', limit, skip, mini_app_id } = req;
|
|
1694
|
+
|
|
1695
|
+
try {
|
|
1696
|
+
if (_id) return await get_studio_doc({ _id, uid });
|
|
1697
|
+
///////////////
|
|
1698
|
+
let opt = {
|
|
1699
|
+
selector: {
|
|
1700
|
+
docType: 'studio',
|
|
1701
|
+
stat: 3,
|
|
1702
|
+
'studio_meta.miniApp': true,
|
|
1703
|
+
},
|
|
1704
|
+
limit: limit || 9999,
|
|
1705
|
+
skip: skip || 0,
|
|
1706
|
+
sort: [{ ts: 'desc' }],
|
|
1707
|
+
};
|
|
1708
|
+
|
|
1709
|
+
switch (filter_type) {
|
|
1710
|
+
case 'archived': {
|
|
1711
|
+
opt.selector.stat = 5;
|
|
1712
|
+
break;
|
|
1713
|
+
}
|
|
1714
|
+
case 'shared': {
|
|
1715
|
+
opt.selector['studio_meta.shared_from_uid'] = { $gt: null };
|
|
1716
|
+
break;
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1719
|
+
case 'mine': {
|
|
1720
|
+
opt.selector.uid = uid;
|
|
1721
|
+
|
|
1722
|
+
break;
|
|
1723
|
+
}
|
|
1724
|
+
|
|
1725
|
+
default:
|
|
1726
|
+
break;
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
if (search) {
|
|
1730
|
+
opt.selector = {
|
|
1731
|
+
...opt.selector,
|
|
1732
|
+
$or: [
|
|
1733
|
+
{
|
|
1734
|
+
'properties.menuName': {
|
|
1735
|
+
$regex: `(?i)${search}`,
|
|
1736
|
+
},
|
|
1737
|
+
},
|
|
1738
|
+
{
|
|
1739
|
+
'properties.description': {
|
|
1740
|
+
$regex: `(?i)${search}`,
|
|
1741
|
+
},
|
|
1742
|
+
},
|
|
1743
|
+
{
|
|
1744
|
+
_id: {
|
|
1745
|
+
$regex: `(?i)${search}`,
|
|
1746
|
+
},
|
|
1747
|
+
},
|
|
1748
|
+
],
|
|
1749
|
+
};
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
if (mini_app_id) {
|
|
1753
|
+
opt.selector._id = mini_app_id;
|
|
1754
|
+
}
|
|
1755
|
+
//////////////
|
|
1756
|
+
|
|
1757
|
+
const app_id = await account_module.get_account_default_project_id(uid);
|
|
1758
|
+
|
|
1759
|
+
let user_apps = { docs: [], total_docs: 0 };
|
|
1760
|
+
if (filter_type !== 'pending') {
|
|
1761
|
+
user_apps = await db_module.find_app_couch_query(app_id, opt);
|
|
1762
|
+
if (!limit || mini_app_id) {
|
|
1763
|
+
user_apps.total_docs = user_apps.docs.length;
|
|
1764
|
+
} else {
|
|
1765
|
+
delete opt.sort;
|
|
1766
|
+
delete opt.skip;
|
|
1767
|
+
opt.limit = 9999;
|
|
1768
|
+
opt.fields = ['_id'];
|
|
1769
|
+
|
|
1770
|
+
const counter = await db_module.find_app_couch_query(app_id, opt);
|
|
1771
|
+
user_apps.total_docs = counter.docs.length;
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
///////////////
|
|
1776
|
+
////// FROM - IN
|
|
1777
|
+
|
|
1778
|
+
let requests_from = { docs: [], total_docs: 0 };
|
|
1779
|
+
if (!mini_app_id) {
|
|
1780
|
+
if (filter_type === 'pending') {
|
|
1781
|
+
const from_opt = { selector: { docType: 'team_request', access_type: 'miniapp', team_req_stat: 2, team_req_to_uid: uid }, fields: ['_id', 'team_req_date', 'sender_account_info.email', 'team_req_from_uid', 'share_item_id'] };
|
|
1782
|
+
const requests_from_res = await db_module.find_couch_query('xuda_team', from_opt);
|
|
1783
|
+
|
|
1784
|
+
for await (let e of requests_from_res.docs) {
|
|
1785
|
+
//account_info
|
|
1786
|
+
let doc = { ts: e.team_req_date, pending: true, properties: {}, studio_meta: { createdByUid: e.team_req_from_uid }, team_req_id: e._id };
|
|
1787
|
+
|
|
1788
|
+
if (e.team_req_from_uid) {
|
|
1789
|
+
doc.user_contact = await account_module.get_user_card(uid, e.team_req_from_uid);
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
//share_item_id
|
|
1793
|
+
const app_id = await account_module.get_account_default_project_id(e.team_req_from_uid);
|
|
1794
|
+
const miniapp_ret = await db_module.get_app_couch_doc_native(app_id, e.share_item_id);
|
|
1795
|
+
doc.properties.menuName = miniapp_ret.properties.menuName;
|
|
1796
|
+
doc.studio_meta.agent_image = miniapp_ret.studio_meta.agent_image;
|
|
1797
|
+
|
|
1798
|
+
requests_from.docs.push(doc);
|
|
1799
|
+
}
|
|
1800
|
+
requests_from.total_docs = requests_from.docs.length;
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
//////////////
|
|
1804
|
+
|
|
1805
|
+
let docs = [];
|
|
1806
|
+
for (let doc of user_apps.docs) {
|
|
1807
|
+
let reference_doc;
|
|
1808
|
+
if (doc.studio_meta.shared_from_uid) {
|
|
1809
|
+
reference_doc = _.cloneDeep(doc);
|
|
1810
|
+
doc = await db_module.get_app_couch_doc_native(reference_doc.studio_meta.shared_from_app_id, reference_doc.studio_meta.share_item_id);
|
|
1811
|
+
doc.reference_doc = reference_doc;
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
doc.user_contact = await account_module.get_user_card(uid, doc.studio_meta.createdByUid);
|
|
1815
|
+
|
|
1816
|
+
docs.push(doc);
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
return { code: 2, data: { docs: [...requests_from.docs, ...docs], total_docs: user_apps.total_docs + requests_from.total_docs } };
|
|
1820
|
+
} catch (err) {
|
|
1821
|
+
return { code: -11, data: err.message };
|
|
1822
|
+
}
|
|
1823
|
+
};
|