@xuda.io/account_module 1.2.2051 → 1.2.2053

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_ms.mjs +78 -155
  2. package/package.json +1 -1
package/index_ms.mjs CHANGED
@@ -3,380 +3,303 @@
3
3
  // Queue target : account_module
4
4
  // =====================================================
5
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
-
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
- }, 300000); // 300 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
- try{
66
- global[`_${global.module_in}_ch`].sendToQueue(
67
- 'account_module',
68
- Buffer.from(
69
- JSON.stringify({
70
- ms_method,
71
- data: args,
72
- cb:`_account_module-${global.module_in}_ch`,
73
- queue_id
74
- })
75
- )
76
- );
77
-
78
- }catch(err){
79
- debugger
80
- }
81
- })
82
-
83
- };
84
-
85
- // You must define this somewhere before using these wrappers:
86
- const module_name = 'account_module';
6
+ import path from 'node:path';
7
+
8
+ global.queueName = 'account_module';
9
+ const _ms_broker = await import(path.join(process.env.XUDA_HOME, 'common', 'ms_broker.mjs'));
87
10
 
88
11
  export const update_account_info = async function (...args) {
89
- return await send_to_queue("update_account_info", ...args);
12
+ return await _ms_broker.send_to_queue('update_account_info', ...args);
90
13
  };
91
14
 
92
15
  export const update_account_preferences = async function (...args) {
93
- return await send_to_queue("update_account_preferences", ...args);
16
+ return await _ms_broker.send_to_queue('update_account_preferences', ...args);
94
17
  };
95
18
 
96
19
  export const save_admin_presets = async function (...args) {
97
- return await send_to_queue("save_admin_presets", ...args);
20
+ return await _ms_broker.send_to_queue('save_admin_presets', ...args);
98
21
  };
99
22
 
100
23
  export const increment_account_usage = async function (...args) {
101
- return await send_to_queue("increment_account_usage", ...args);
24
+ return await _ms_broker.send_to_queue('increment_account_usage', ...args);
102
25
  };
103
26
 
104
27
  export const get_account_data = async function (...args) {
105
- return await send_to_queue("get_account_data", ...args);
28
+ return await _ms_broker.send_to_queue('get_account_data', ...args);
106
29
  };
107
30
 
108
31
  export const get_account_projects = async function (...args) {
109
- return await send_to_queue("get_account_projects", ...args);
32
+ return await _ms_broker.send_to_queue('get_account_projects', ...args);
110
33
  };
111
34
 
112
35
  export const get_account_datacenters = async function (...args) {
113
- return await send_to_queue("get_account_datacenters", ...args);
36
+ return await _ms_broker.send_to_queue('get_account_datacenters', ...args);
114
37
  };
115
38
 
116
39
  export const get_account_deployments = async function (...args) {
117
- return await send_to_queue("get_account_deployments", ...args);
40
+ return await _ms_broker.send_to_queue('get_account_deployments', ...args);
118
41
  };
119
42
 
120
43
  export const get_account_instances = async function (...args) {
121
- return await send_to_queue("get_account_instances", ...args);
44
+ return await _ms_broker.send_to_queue('get_account_instances', ...args);
122
45
  };
123
46
 
124
47
  export const get_account_info = async function (...args) {
125
- return await send_to_queue("get_account_info", ...args);
48
+ return await _ms_broker.send_to_queue('get_account_info', ...args);
126
49
  };
127
50
 
128
51
  export const get_active_account_profile_info = async function (...args) {
129
- return await send_to_queue("get_active_account_profile_info", ...args);
52
+ return await _ms_broker.send_to_queue('get_active_account_profile_info', ...args);
130
53
  };
131
54
 
132
55
  export const get_account_name = async function (...args) {
133
- return await send_to_queue("get_account_name", ...args);
56
+ return await _ms_broker.send_to_queue('get_account_name', ...args);
134
57
  };
135
58
 
136
59
  export const account_validate_username = async function (...args) {
137
- return await send_to_queue("account_validate_username", ...args);
60
+ return await _ms_broker.send_to_queue('account_validate_username', ...args);
138
61
  };
139
62
 
140
63
  export const verify_account = async function (...args) {
141
- return await send_to_queue("verify_account", ...args);
64
+ return await _ms_broker.send_to_queue('verify_account', ...args);
142
65
  };
143
66
 
144
67
  export const validate_user_plan = async function (...args) {
145
- return await send_to_queue("validate_user_plan", ...args);
68
+ return await _ms_broker.send_to_queue('validate_user_plan', ...args);
146
69
  };
147
70
 
148
71
  export const get_hosting_plan = async function (...args) {
149
- return await send_to_queue("get_hosting_plan", ...args);
72
+ return await _ms_broker.send_to_queue('get_hosting_plan', ...args);
150
73
  };
151
74
 
152
75
  export const get_cpu = async function (...args) {
153
- return await send_to_queue("get_cpu", ...args);
76
+ return await _ms_broker.send_to_queue('get_cpu', ...args);
154
77
  };
155
78
 
156
79
  export const add_account_log_util = async function (...args) {
157
- return await send_to_queue("add_account_log_util", ...args);
80
+ return await _ms_broker.send_to_queue('add_account_log_util', ...args);
158
81
  };
159
82
 
160
83
  export const save_ssh_key = async function (...args) {
161
- return await send_to_queue("save_ssh_key", ...args);
84
+ return await _ms_broker.send_to_queue('save_ssh_key', ...args);
162
85
  };
163
86
 
164
87
  export const delete_ssh_key = async function (...args) {
165
- return await send_to_queue("delete_ssh_key", ...args);
88
+ return await _ms_broker.send_to_queue('delete_ssh_key', ...args);
166
89
  };
167
90
 
168
91
  export const get_ssh_keys = async function (...args) {
169
- return await send_to_queue("get_ssh_keys", ...args);
92
+ return await _ms_broker.send_to_queue('get_ssh_keys', ...args);
170
93
  };
171
94
 
172
95
  export const search_users = async function (...args) {
173
- return await send_to_queue("search_users", ...args);
96
+ return await _ms_broker.send_to_queue('search_users', ...args);
174
97
  };
175
98
 
176
99
  export const find_contact_duplicates = async function (...args) {
177
- return await send_to_queue("find_contact_duplicates", ...args);
100
+ return await _ms_broker.send_to_queue('find_contact_duplicates', ...args);
178
101
  };
179
102
 
180
103
  export const merge_contact = async function (...args) {
181
- return await send_to_queue("merge_contact", ...args);
104
+ return await _ms_broker.send_to_queue('merge_contact', ...args);
182
105
  };
183
106
 
184
107
  export const get_contact_info = async function (...args) {
185
- return await send_to_queue("get_contact_info", ...args);
108
+ return await _ms_broker.send_to_queue('get_contact_info', ...args);
186
109
  };
187
110
 
188
111
  export const get_pending_contact_out = async function (...args) {
189
- return await send_to_queue("get_pending_contact_out", ...args);
112
+ return await _ms_broker.send_to_queue('get_pending_contact_out', ...args);
190
113
  };
191
114
 
192
115
  export const get_pending_contact_in = async function (...args) {
193
- return await send_to_queue("get_pending_contact_in", ...args);
116
+ return await _ms_broker.send_to_queue('get_pending_contact_in', ...args);
194
117
  };
195
118
 
196
119
  export const get_pending_share_contact_in = async function (...args) {
197
- return await send_to_queue("get_pending_share_contact_in", ...args);
120
+ return await _ms_broker.send_to_queue('get_pending_share_contact_in', ...args);
198
121
  };
199
122
 
200
123
  export const update_contact = async function (...args) {
201
- return await send_to_queue("update_contact", ...args);
124
+ return await _ms_broker.send_to_queue('update_contact', ...args);
202
125
  };
203
126
 
204
127
  export const get_account_rt_info = async function (...args) {
205
- return await send_to_queue("get_account_rt_info", ...args);
128
+ return await _ms_broker.send_to_queue('get_account_rt_info', ...args);
206
129
  };
207
130
 
208
131
  export const validate_account_topup = async function (...args) {
209
- return await send_to_queue("validate_account_topup", ...args);
132
+ return await _ms_broker.send_to_queue('validate_account_topup', ...args);
210
133
  };
211
134
 
212
135
  export const create_account_oauth_link = async function (...args) {
213
- return await send_to_queue("create_account_oauth_link", ...args);
136
+ return await _ms_broker.send_to_queue('create_account_oauth_link', ...args);
214
137
  };
215
138
 
216
139
  export const get_default_project_account_doc = async function (...args) {
217
- return await send_to_queue("get_default_project_account_doc", ...args);
140
+ return await _ms_broker.send_to_queue('get_default_project_account_doc', ...args);
218
141
  };
219
142
 
220
143
  export const get_account_default_project_id = async function (...args) {
221
- return await send_to_queue("get_account_default_project_id", ...args);
144
+ return await _ms_broker.send_to_queue('get_account_default_project_id', ...args);
222
145
  };
223
146
 
224
147
  export const get_user_name = async function (...args) {
225
- return await send_to_queue("get_user_name", ...args);
148
+ return await _ms_broker.send_to_queue('get_user_name', ...args);
226
149
  };
227
150
 
228
151
  export const get_user_card = async function (...args) {
229
- return await send_to_queue("get_user_card", ...args);
152
+ return await _ms_broker.send_to_queue('get_user_card', ...args);
230
153
  };
231
154
 
232
155
  export const onboarding_completed = async function (...args) {
233
- return await send_to_queue("onboarding_completed", ...args);
156
+ return await _ms_broker.send_to_queue('onboarding_completed', ...args);
234
157
  };
235
158
 
236
159
  export const ts_contact = async function (...args) {
237
- return await send_to_queue("ts_contact", ...args);
160
+ return await _ms_broker.send_to_queue('ts_contact', ...args);
238
161
  };
239
162
 
240
163
  export const get_account_ai_usage = async function (...args) {
241
- return await send_to_queue("get_account_ai_usage", ...args);
164
+ return await _ms_broker.send_to_queue('get_account_ai_usage', ...args);
242
165
  };
243
166
 
244
167
  export const add_contact = async function (...args) {
245
- return await send_to_queue("add_contact", ...args);
168
+ return await _ms_broker.send_to_queue('add_contact', ...args);
246
169
  };
247
170
 
248
171
  export const get_contacts = async function (...args) {
249
- return await send_to_queue("get_contacts", ...args);
172
+ return await _ms_broker.send_to_queue('get_contacts', ...args);
250
173
  };
251
174
 
252
175
  export const archive_contact = async function (...args) {
253
- return await send_to_queue("archive_contact", ...args);
176
+ return await _ms_broker.send_to_queue('archive_contact', ...args);
254
177
  };
255
178
 
256
179
  export const delete_contact = async function (...args) {
257
- return await send_to_queue("delete_contact", ...args);
180
+ return await _ms_broker.send_to_queue('delete_contact', ...args);
258
181
  };
259
182
 
260
183
  export const unarchive_contact = async function (...args) {
261
- return await send_to_queue("unarchive_contact", ...args);
184
+ return await _ms_broker.send_to_queue('unarchive_contact', ...args);
262
185
  };
263
186
 
264
187
  export const unfriend_contact = async function (...args) {
265
- return await send_to_queue("unfriend_contact", ...args);
188
+ return await _ms_broker.send_to_queue('unfriend_contact', ...args);
266
189
  };
267
190
 
268
191
  export const pin_contact = async function (...args) {
269
- return await send_to_queue("pin_contact", ...args);
192
+ return await _ms_broker.send_to_queue('pin_contact', ...args);
270
193
  };
271
194
 
272
195
  export const set_contact_deep_research = async function (...args) {
273
- return await send_to_queue("set_contact_deep_research", ...args);
196
+ return await _ms_broker.send_to_queue('set_contact_deep_research', ...args);
274
197
  };
275
198
 
276
199
  export const unpin_contact = async function (...args) {
277
- return await send_to_queue("unpin_contact", ...args);
200
+ return await _ms_broker.send_to_queue('unpin_contact', ...args);
278
201
  };
279
202
 
280
203
  export const not_spam_contact = async function (...args) {
281
- return await send_to_queue("not_spam_contact", ...args);
204
+ return await _ms_broker.send_to_queue('not_spam_contact', ...args);
282
205
  };
283
206
 
284
207
  export const generate_contact_avatar = async function (...args) {
285
- return await send_to_queue("generate_contact_avatar", ...args);
208
+ return await _ms_broker.send_to_queue('generate_contact_avatar', ...args);
286
209
  };
287
210
 
288
211
  export const set_deep_research_contact = async function (...args) {
289
- return await send_to_queue("set_deep_research_contact", ...args);
212
+ return await _ms_broker.send_to_queue('set_deep_research_contact', ...args);
290
213
  };
291
214
 
292
215
  export const unset_deep_research_contact = async function (...args) {
293
- return await send_to_queue("unset_deep_research_contact", ...args);
216
+ return await _ms_broker.send_to_queue('unset_deep_research_contact', ...args);
294
217
  };
295
218
 
296
219
  export const get_pending_share_profile_in = async function (...args) {
297
- return await send_to_queue("get_pending_share_profile_in", ...args);
220
+ return await _ms_broker.send_to_queue('get_pending_share_profile_in', ...args);
298
221
  };
299
222
 
300
223
  export const get_account_profile_info = async function (...args) {
301
- return await send_to_queue("get_account_profile_info", ...args);
224
+ return await _ms_broker.send_to_queue('get_account_profile_info', ...args);
302
225
  };
303
226
 
304
227
  export const get_account_profiles = async function (...args) {
305
- return await send_to_queue("get_account_profiles", ...args);
228
+ return await _ms_broker.send_to_queue('get_account_profiles', ...args);
306
229
  };
307
230
 
308
231
  export const archive_account_profile = async function (...args) {
309
- return await send_to_queue("archive_account_profile", ...args);
232
+ return await _ms_broker.send_to_queue('archive_account_profile', ...args);
310
233
  };
311
234
 
312
235
  export const delete_account_profile = async function (...args) {
313
- return await send_to_queue("delete_account_profile", ...args);
236
+ return await _ms_broker.send_to_queue('delete_account_profile', ...args);
314
237
  };
315
238
 
316
239
  export const unarchive_account_profile = async function (...args) {
317
- return await send_to_queue("unarchive_account_profile", ...args);
240
+ return await _ms_broker.send_to_queue('unarchive_account_profile', ...args);
318
241
  };
319
242
 
320
243
  export const create_account_profile = async function (...args) {
321
- return await send_to_queue("create_account_profile", ...args);
244
+ return await _ms_broker.send_to_queue('create_account_profile', ...args);
322
245
  };
323
246
 
324
247
  export const update_account_profile = async function (...args) {
325
- return await send_to_queue("update_account_profile", ...args);
248
+ return await _ms_broker.send_to_queue('update_account_profile', ...args);
326
249
  };
327
250
 
328
251
  export const update_entity_account_profiles = async function (...args) {
329
- return await send_to_queue("update_entity_account_profiles", ...args);
252
+ return await _ms_broker.send_to_queue('update_entity_account_profiles', ...args);
330
253
  };
331
254
 
332
255
  export const get_contact = async function (...args) {
333
- return await send_to_queue("get_contact", ...args);
256
+ return await _ms_broker.send_to_queue('get_contact', ...args);
334
257
  };
335
258
 
336
259
  export const save_contact = async function (...args) {
337
- return await send_to_queue("save_contact", ...args);
260
+ return await _ms_broker.send_to_queue('save_contact', ...args);
338
261
  };
339
262
 
340
263
  export const find_contact_query = async function (...args) {
341
- return await send_to_queue("find_contact_query", ...args);
264
+ return await _ms_broker.send_to_queue('find_contact_query', ...args);
342
265
  };
343
266
 
344
267
  export const delete_xuda_cache = async function (...args) {
345
- return await send_to_queue("delete_xuda_cache", ...args);
268
+ return await _ms_broker.send_to_queue('delete_xuda_cache', ...args);
346
269
  };
347
270
 
348
271
  export const save_xuda_cache = async function (...args) {
349
- return await send_to_queue("save_xuda_cache", ...args);
272
+ return await _ms_broker.send_to_queue('save_xuda_cache', ...args);
350
273
  };
351
274
 
352
275
  export const get_xuda_cache = async function (...args) {
353
- return await send_to_queue("get_xuda_cache", ...args);
276
+ return await _ms_broker.send_to_queue('get_xuda_cache', ...args);
354
277
  };
355
278
 
356
279
  export const save_cache_hit = async function (...args) {
357
- return await send_to_queue("save_cache_hit", ...args);
280
+ return await _ms_broker.send_to_queue('save_cache_hit', ...args);
358
281
  };
359
282
 
360
283
  export const record_ai_usage = async function (...args) {
361
- return await send_to_queue("record_ai_usage", ...args);
284
+ return await _ms_broker.send_to_queue('record_ai_usage', ...args);
362
285
  };
363
286
 
364
287
  export const record_ai_credit = async function (...args) {
365
- return await send_to_queue("record_ai_credit", ...args);
288
+ return await _ms_broker.send_to_queue('record_ai_credit', ...args);
366
289
  };
367
290
 
368
291
  export const add_ai_credits_to_active_accounts = async function (...args) {
369
- return await send_to_queue("add_ai_credits_to_active_accounts", ...args);
292
+ return await _ms_broker.send_to_queue('add_ai_credits_to_active_accounts', ...args);
370
293
  };
371
294
 
372
295
  export const archive_expire_ai_credits = async function (...args) {
373
- return await send_to_queue("archive_expire_ai_credits", ...args);
296
+ return await _ms_broker.send_to_queue('archive_expire_ai_credits', ...args);
374
297
  };
375
298
 
376
299
  export const read_accounts_emails = async function (...args) {
377
- return await send_to_queue("read_accounts_emails", ...args);
300
+ return await _ms_broker.send_to_queue('read_accounts_emails', ...args);
378
301
  };
379
302
 
380
303
  export const process_accounts_emails = async function (...args) {
381
- return await send_to_queue("process_accounts_emails", ...args);
304
+ return await _ms_broker.send_to_queue('process_accounts_emails', ...args);
382
305
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/account_module",
3
- "version": "1.2.2051",
3
+ "version": "1.2.2053",
4
4
  "description": "Xuda Account Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {