@xuda.io/account_module 1.2.2051 → 1.2.2052

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