@xuda.io/account_module 1.2.2027 → 1.2.2028

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 (3) hide show
  1. package/index.mjs +2 -2
  2. package/index_ms.mjs +378 -0
  3. package/package.json +1 -1
package/index.mjs CHANGED
@@ -42,6 +42,7 @@ const _utils = await import(path.join(process.env.XUDA_HOME, 'common', 'xuda-cpi
42
42
  // Module Paths
43
43
  const module_path = path.join(process.env.XUDA_HOME, 'cpi') + (!_conf.is_debug ? '/node_modules/@xuda.io' : '');
44
44
  const db_module = await import(`${module_path}/db_module/index.mjs`);
45
+ const ai_ms = await import(`${module_path}/db_module/index_ms.mjs`);
45
46
 
46
47
  export const update_account_info = async function (req, job_id, headers) {
47
48
  const marketplace_module = await import(`${module_path}/marketplace_module/index.mjs`);
@@ -1292,7 +1293,6 @@ function formatPhoneWithFlag(phoneString, country = 'US') {
1292
1293
  }
1293
1294
 
1294
1295
  export const get_contact_info = async function (uid, contact_doc, _id) {
1295
- // const ai_module = await import(`${module_path}/ai_module/index.mjs`);
1296
1296
  let doc = contact_doc;
1297
1297
  if (_id) {
1298
1298
  doc = await get_contact(uid, _id);
@@ -3180,7 +3180,7 @@ export const get_account_profile_info = async function (uid, contact_profile_doc
3180
3180
 
3181
3181
  // doc.border = account_info_ret.data.active_account_profile_id === doc._id ? 'yellow' : ''; //'#1a3557';
3182
3182
  // doc.border = stringToColour(doc.shared_from_uid || doc.uid);
3183
-
3183
+ debugger;
3184
3184
  const chats_ret = await ai_module.get_ai_chats({ uid, reference_id: doc._id });
3185
3185
 
3186
3186
  doc.card_background = `linear-gradient(145deg, #242480 0%, #060619 100%)`;
package/index_ms.mjs ADDED
@@ -0,0 +1,378 @@
1
+ // =====================================================
2
+ // Queue wrapper – generated from index.mjs
3
+ // Queue target : account_module
4
+ // =====================================================
5
+
6
+ import amqplib from 'amqplib';
7
+ import { randomUUID } from 'crypto';
8
+
9
+ let queue={}
10
+
11
+ // --- AMQP Connection & Channel ---
12
+ const conn = await amqplib.connect('amqp://localhost');
13
+ const channel = await conn.createChannel();
14
+ await channel.assertQueue(`_account_module-${global.module_in}_ch`, { durable: false });
15
+
16
+ channel.consume(`_account_module-${global.module_in}_ch`, async (msg) => {
17
+ try{
18
+
19
+ debugger;
20
+ if (msg === null) {
21
+ console.log('Consumer cancelled by server');
22
+ return;
23
+ }
24
+
25
+ const content = JSON.parse(msg.content.toString());
26
+
27
+ queue[content.queue_id].resolve(content.ret)
28
+
29
+ channel.ack(msg);
30
+ } catch (err) {
31
+ channel.ack(msg); // Acknowledge to prevent requeue loops on error
32
+ console.error(module_in, content.method, err.message, err);
33
+ // debugger;
34
+ }
35
+ });
36
+
37
+
38
+ const send_to_queue =async function(ms_method, ...args) {
39
+
40
+ const queue_id = randomUUID();
41
+ return new Promise((resolve,reject)=>{
42
+
43
+ queue[queue_id] = { resolve, reject };
44
+
45
+ // Set timeout to prevent hanging
46
+ const timeout = setTimeout(() => {
47
+ delete queue[queue_id];
48
+ reject(new Error(`Queue timeout for ${ms_method}`));
49
+ }, 30000); // 30 second timeout
50
+
51
+ // Wrap resolve to clean up
52
+ queue[queue_id].resolve = (value) => {
53
+ clearTimeout(timeout);
54
+ delete queue[queue_id];
55
+ resolve(value);
56
+ };
57
+
58
+ // Wrap reject to clean up
59
+ queue[queue_id].reject = (error) => {
60
+ clearTimeout(timeout);
61
+ delete queue[queue_id];
62
+ reject(error);
63
+ };
64
+
65
+ global[`_${global.module_in}_ch`].sendToQueue(
66
+ 'account_module',
67
+ Buffer.from(
68
+ JSON.stringify({
69
+ ms_method,
70
+ data: args,
71
+ cb:`_account_module-${global.module_in}_ch`,
72
+ queue_id
73
+ })
74
+ )
75
+ );
76
+
77
+ })
78
+
79
+ };
80
+
81
+ // You must define this somewhere before using these wrappers:
82
+ const module_name = 'account_module';
83
+
84
+ export const update_account_info = async function (...args) {
85
+ return await send_to_queue("update_account_info", ...args);
86
+ };
87
+
88
+ export const update_account_preferences = async function (...args) {
89
+ return await send_to_queue("update_account_preferences", ...args);
90
+ };
91
+
92
+ export const save_admin_presets = async function (...args) {
93
+ return await send_to_queue("save_admin_presets", ...args);
94
+ };
95
+
96
+ export const increment_account_usage = async function (...args) {
97
+ return await send_to_queue("increment_account_usage", ...args);
98
+ };
99
+
100
+ export const get_account_data = async function (...args) {
101
+ return await send_to_queue("get_account_data", ...args);
102
+ };
103
+
104
+ export const get_account_projects = async function (...args) {
105
+ return await send_to_queue("get_account_projects", ...args);
106
+ };
107
+
108
+ export const get_account_datacenters = async function (...args) {
109
+ return await send_to_queue("get_account_datacenters", ...args);
110
+ };
111
+
112
+ export const get_account_deployments = async function (...args) {
113
+ return await send_to_queue("get_account_deployments", ...args);
114
+ };
115
+
116
+ export const get_account_instances = async function (...args) {
117
+ return await send_to_queue("get_account_instances", ...args);
118
+ };
119
+
120
+ export const get_account_info = async function (...args) {
121
+ return await send_to_queue("get_account_info", ...args);
122
+ };
123
+
124
+ export const get_active_account_profile_info = async function (...args) {
125
+ return await send_to_queue("get_active_account_profile_info", ...args);
126
+ };
127
+
128
+ export const get_account_name = async function (...args) {
129
+ return await send_to_queue("get_account_name", ...args);
130
+ };
131
+
132
+ export const account_validate_username = async function (...args) {
133
+ return await send_to_queue("account_validate_username", ...args);
134
+ };
135
+
136
+ export const verify_account = async function (...args) {
137
+ return await send_to_queue("verify_account", ...args);
138
+ };
139
+
140
+ export const validate_user_plan = async function (...args) {
141
+ return await send_to_queue("validate_user_plan", ...args);
142
+ };
143
+
144
+ export const get_hosting_plan = async function (...args) {
145
+ return await send_to_queue("get_hosting_plan", ...args);
146
+ };
147
+
148
+ export const get_cpu = async function (...args) {
149
+ return await send_to_queue("get_cpu", ...args);
150
+ };
151
+
152
+ export const add_account_log_util = async function (...args) {
153
+ return await send_to_queue("add_account_log_util", ...args);
154
+ };
155
+
156
+ export const save_ssh_key = async function (...args) {
157
+ return await send_to_queue("save_ssh_key", ...args);
158
+ };
159
+
160
+ export const delete_ssh_key = async function (...args) {
161
+ return await send_to_queue("delete_ssh_key", ...args);
162
+ };
163
+
164
+ export const get_ssh_keys = async function (...args) {
165
+ return await send_to_queue("get_ssh_keys", ...args);
166
+ };
167
+
168
+ export const search_users = async function (...args) {
169
+ return await send_to_queue("search_users", ...args);
170
+ };
171
+
172
+ export const find_contact_duplicates = async function (...args) {
173
+ return await send_to_queue("find_contact_duplicates", ...args);
174
+ };
175
+
176
+ export const merge_contact = async function (...args) {
177
+ return await send_to_queue("merge_contact", ...args);
178
+ };
179
+
180
+ export const get_contact_info = async function (...args) {
181
+ return await send_to_queue("get_contact_info", ...args);
182
+ };
183
+
184
+ export const get_pending_contact_out = async function (...args) {
185
+ return await send_to_queue("get_pending_contact_out", ...args);
186
+ };
187
+
188
+ export const get_pending_contact_in = async function (...args) {
189
+ return await send_to_queue("get_pending_contact_in", ...args);
190
+ };
191
+
192
+ export const get_pending_share_contact_in = async function (...args) {
193
+ return await send_to_queue("get_pending_share_contact_in", ...args);
194
+ };
195
+
196
+ export const update_contact = async function (...args) {
197
+ return await send_to_queue("update_contact", ...args);
198
+ };
199
+
200
+ export const get_account_rt_info = async function (...args) {
201
+ return await send_to_queue("get_account_rt_info", ...args);
202
+ };
203
+
204
+ export const validate_account_topup = async function (...args) {
205
+ return await send_to_queue("validate_account_topup", ...args);
206
+ };
207
+
208
+ export const create_account_oauth_link = async function (...args) {
209
+ return await send_to_queue("create_account_oauth_link", ...args);
210
+ };
211
+
212
+ export const get_default_project_account_doc = async function (...args) {
213
+ return await send_to_queue("get_default_project_account_doc", ...args);
214
+ };
215
+
216
+ export const get_account_default_project_id = async function (...args) {
217
+ return await send_to_queue("get_account_default_project_id", ...args);
218
+ };
219
+
220
+ export const get_user_name = async function (...args) {
221
+ return await send_to_queue("get_user_name", ...args);
222
+ };
223
+
224
+ export const get_user_card = async function (...args) {
225
+ return await send_to_queue("get_user_card", ...args);
226
+ };
227
+
228
+ export const onboarding_completed = async function (...args) {
229
+ return await send_to_queue("onboarding_completed", ...args);
230
+ };
231
+
232
+ export const ts_contact = async function (...args) {
233
+ return await send_to_queue("ts_contact", ...args);
234
+ };
235
+
236
+ export const get_account_ai_usage = async function (...args) {
237
+ return await send_to_queue("get_account_ai_usage", ...args);
238
+ };
239
+
240
+ export const add_contact = async function (...args) {
241
+ return await send_to_queue("add_contact", ...args);
242
+ };
243
+
244
+ export const get_contacts = async function (...args) {
245
+ return await send_to_queue("get_contacts", ...args);
246
+ };
247
+
248
+ export const archive_contact = async function (...args) {
249
+ return await send_to_queue("archive_contact", ...args);
250
+ };
251
+
252
+ export const delete_contact = async function (...args) {
253
+ return await send_to_queue("delete_contact", ...args);
254
+ };
255
+
256
+ export const unarchive_contact = async function (...args) {
257
+ return await send_to_queue("unarchive_contact", ...args);
258
+ };
259
+
260
+ export const unfriend_contact = async function (...args) {
261
+ return await send_to_queue("unfriend_contact", ...args);
262
+ };
263
+
264
+ export const pin_contact = async function (...args) {
265
+ return await send_to_queue("pin_contact", ...args);
266
+ };
267
+
268
+ export const set_contact_deep_research = async function (...args) {
269
+ return await send_to_queue("set_contact_deep_research", ...args);
270
+ };
271
+
272
+ export const unpin_contact = async function (...args) {
273
+ return await send_to_queue("unpin_contact", ...args);
274
+ };
275
+
276
+ export const not_spam_contact = async function (...args) {
277
+ return await send_to_queue("not_spam_contact", ...args);
278
+ };
279
+
280
+ export const generate_contact_avatar = async function (...args) {
281
+ return await send_to_queue("generate_contact_avatar", ...args);
282
+ };
283
+
284
+ export const set_deep_research_contact = async function (...args) {
285
+ return await send_to_queue("set_deep_research_contact", ...args);
286
+ };
287
+
288
+ export const unset_deep_research_contact = async function (...args) {
289
+ return await send_to_queue("unset_deep_research_contact", ...args);
290
+ };
291
+
292
+ export const get_pending_share_profile_in = async function (...args) {
293
+ return await send_to_queue("get_pending_share_profile_in", ...args);
294
+ };
295
+
296
+ export const get_account_profile_info = async function (...args) {
297
+ return await send_to_queue("get_account_profile_info", ...args);
298
+ };
299
+
300
+ export const get_account_profiles = async function (...args) {
301
+ return await send_to_queue("get_account_profiles", ...args);
302
+ };
303
+
304
+ export const archive_account_profile = async function (...args) {
305
+ return await send_to_queue("archive_account_profile", ...args);
306
+ };
307
+
308
+ export const delete_account_profile = async function (...args) {
309
+ return await send_to_queue("delete_account_profile", ...args);
310
+ };
311
+
312
+ export const unarchive_account_profile = async function (...args) {
313
+ return await send_to_queue("unarchive_account_profile", ...args);
314
+ };
315
+
316
+ export const create_account_profile = async function (...args) {
317
+ return await send_to_queue("create_account_profile", ...args);
318
+ };
319
+
320
+ export const update_account_profile = async function (...args) {
321
+ return await send_to_queue("update_account_profile", ...args);
322
+ };
323
+
324
+ export const update_entity_account_profiles = async function (...args) {
325
+ return await send_to_queue("update_entity_account_profiles", ...args);
326
+ };
327
+
328
+ export const get_contact = async function (...args) {
329
+ return await send_to_queue("get_contact", ...args);
330
+ };
331
+
332
+ export const save_contact = async function (...args) {
333
+ return await send_to_queue("save_contact", ...args);
334
+ };
335
+
336
+ export const find_contact_query = async function (...args) {
337
+ return await send_to_queue("find_contact_query", ...args);
338
+ };
339
+
340
+ export const delete_xuda_cache = async function (...args) {
341
+ return await send_to_queue("delete_xuda_cache", ...args);
342
+ };
343
+
344
+ export const save_xuda_cache = async function (...args) {
345
+ return await send_to_queue("save_xuda_cache", ...args);
346
+ };
347
+
348
+ export const get_xuda_cache = async function (...args) {
349
+ return await send_to_queue("get_xuda_cache", ...args);
350
+ };
351
+
352
+ export const save_cache_hit = async function (...args) {
353
+ return await send_to_queue("save_cache_hit", ...args);
354
+ };
355
+
356
+ export const record_ai_usage = async function (...args) {
357
+ return await send_to_queue("record_ai_usage", ...args);
358
+ };
359
+
360
+ export const record_ai_credit = async function (...args) {
361
+ return await send_to_queue("record_ai_credit", ...args);
362
+ };
363
+
364
+ export const add_ai_credits_to_active_accounts = async function (...args) {
365
+ return await send_to_queue("add_ai_credits_to_active_accounts", ...args);
366
+ };
367
+
368
+ export const archive_expire_ai_credits = async function (...args) {
369
+ return await send_to_queue("archive_expire_ai_credits", ...args);
370
+ };
371
+
372
+ export const read_accounts_emails = async function (...args) {
373
+ return await send_to_queue("read_accounts_emails", ...args);
374
+ };
375
+
376
+ export const process_accounts_emails = async function (...args) {
377
+ return await send_to_queue("process_accounts_emails", ...args);
378
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.2027",
3
+ "version": "1.2.2028",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {