@xuda.io/drive_module 1.1.1403 → 1.1.1405

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 +70 -140
  2. package/package.json +1 -1
package/index_ms.mjs CHANGED
@@ -3,341 +3,271 @@
3
3
  // Queue target : drive_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(`_drive_module-${global.module_in}_ch`, { durable: false });
15
-
16
- channel.consume(`_drive_module-${global.module_in}_ch`, async (msg) => {
17
- try {
18
- if (msg === null) {
19
- console.log('Consumer cancelled by server');
20
- return;
21
- }
22
-
23
- const content = JSON.parse(msg.content.toString());
24
-
25
- queue[content.queue_id].resolve(content.ret);
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
- });
34
-
35
- const send_to_queue = async function (ms_method, ...args) {
36
- const queue_id = randomUUID();
37
- return new Promise((resolve, reject) => {
38
- queue[queue_id] = { resolve, reject };
39
-
40
- // Set timeout to prevent hanging
41
- const timeout = setTimeout(() => {
42
- delete queue[queue_id];
43
- reject(new Error(`Queue timeout for ${ms_method}`));
44
- }, 300000); // 300 second timeout
45
-
46
- // Wrap resolve to clean up
47
- queue[queue_id].resolve = (value) => {
48
- clearTimeout(timeout);
49
- delete queue[queue_id];
50
- resolve(value);
51
- };
52
-
53
- // Wrap reject to clean up
54
- queue[queue_id].reject = (error) => {
55
- clearTimeout(timeout);
56
- delete queue[queue_id];
57
- reject(error);
58
- };
59
-
60
- try {
61
- global[`_${global.module_in}_ch`].sendToQueue(
62
- 'drive_module',
63
- Buffer.from(
64
- JSON.stringify({
65
- ms_method,
66
- data: args,
67
- cb: `_drive_module-${global.module_in}_ch`,
68
- queue_id,
69
- }),
70
- ),
71
- );
72
- } catch (err) {
73
- debugger;
74
- }
75
- });
76
- };
77
-
78
- // You must define this somewhere before using these wrappers:
79
- const module_name = 'drive_module';
6
+ import path from 'node:path';
7
+
8
+ global.queueName = 'drive_module';
9
+ const _ms_broker = await import(path.join(process.env.XUDA_HOME, 'common', 'ms_broker.mjs'));
80
10
 
81
11
  export const get_drive_files = async function (...args) {
82
- return await send_to_queue('get_drive_files', ...args);
12
+ return await _ms_broker.send_to_queue('get_drive_files', ...args);
83
13
  };
84
14
 
85
15
  export const get_drive_file_info = async function (...args) {
86
- return await send_to_queue('get_drive_file_info', ...args);
16
+ return await _ms_broker.send_to_queue('get_drive_file_info', ...args);
87
17
  };
88
18
 
89
19
  export const delete_drive_files = async function (...args) {
90
- return await send_to_queue('delete_drive_files', ...args);
20
+ return await _ms_broker.send_to_queue('delete_drive_files', ...args);
91
21
  };
92
22
 
93
23
  export const update_drive_file = async function (...args) {
94
- return await send_to_queue('update_drive_file', ...args);
24
+ return await _ms_broker.send_to_queue('update_drive_file', ...args);
95
25
  };
96
26
 
97
27
  export const create_drive_folder = async function (...args) {
98
- return await send_to_queue('create_drive_folder', ...args);
28
+ return await _ms_broker.send_to_queue('create_drive_folder', ...args);
99
29
  };
100
30
 
101
31
  export const rename_drive_file = async function (...args) {
102
- return await send_to_queue('rename_drive_file', ...args);
32
+ return await _ms_broker.send_to_queue('rename_drive_file', ...args);
103
33
  };
104
34
 
105
35
  export const rename_drive_folder = async function (...args) {
106
- return await send_to_queue('rename_drive_folder', ...args);
36
+ return await _ms_broker.send_to_queue('rename_drive_folder', ...args);
107
37
  };
108
38
 
109
39
  export const update_drive_file_sharing_mode = async function (...args) {
110
- return await send_to_queue('update_drive_file_sharing_mode', ...args);
40
+ return await _ms_broker.send_to_queue('update_drive_file_sharing_mode', ...args);
111
41
  };
112
42
 
113
43
  export const extract_drive_file = async function (...args) {
114
- return await send_to_queue('extract_drive_file', ...args);
44
+ return await _ms_broker.send_to_queue('extract_drive_file', ...args);
115
45
  };
116
46
 
117
47
  export const delete_file_bulk = async function (...args) {
118
- return await send_to_queue('delete_file_bulk', ...args);
48
+ return await _ms_broker.send_to_queue('delete_file_bulk', ...args);
119
49
  };
120
50
 
121
51
  export const upload_drive_file = async function (...args) {
122
- return await send_to_queue('upload_drive_file', ...args);
52
+ return await _ms_broker.send_to_queue('upload_drive_file', ...args);
123
53
  };
124
54
 
125
55
  export const check_drive_file = async function (...args) {
126
- return await send_to_queue('check_drive_file', ...args);
56
+ return await _ms_broker.send_to_queue('check_drive_file', ...args);
127
57
  };
128
58
 
129
59
  export const run_drive_pending_ocr = async function (...args) {
130
- return await send_to_queue('run_drive_pending_ocr', ...args);
60
+ return await _ms_broker.send_to_queue('run_drive_pending_ocr', ...args);
131
61
  };
132
62
 
133
63
  export const get_drive_size = async function (...args) {
134
- return await send_to_queue('get_drive_size', ...args);
64
+ return await _ms_broker.send_to_queue('get_drive_size', ...args);
135
65
  };
136
66
 
137
67
  export const copy_file_to_another_bucket = async function (...args) {
138
- return await send_to_queue('copy_file_to_another_bucket', ...args);
68
+ return await _ms_broker.send_to_queue('copy_file_to_another_bucket', ...args);
139
69
  };
140
70
 
141
71
  export const delete_file_from_bucket = async function (...args) {
142
- return await send_to_queue('delete_file_from_bucket', ...args);
72
+ return await _ms_broker.send_to_queue('delete_file_from_bucket', ...args);
143
73
  };
144
74
 
145
75
  export const update_drive_file_tags = async function (...args) {
146
- return await send_to_queue('update_drive_file_tags', ...args);
76
+ return await _ms_broker.send_to_queue('update_drive_file_tags', ...args);
147
77
  };
148
78
 
149
79
  export const compile_javascript_program_in_studio_drive = async function (...args) {
150
- return await send_to_queue('compile_javascript_program_in_studio_drive', ...args);
80
+ return await _ms_broker.send_to_queue('compile_javascript_program_in_studio_drive', ...args);
151
81
  };
152
82
 
153
83
  export const update_drive_addons = async function (...args) {
154
- return await send_to_queue('update_drive_addons', ...args);
84
+ return await _ms_broker.send_to_queue('update_drive_addons', ...args);
155
85
  };
156
86
 
157
87
  export const get_drive_files_workspace = async function (...args) {
158
- return await send_to_queue('get_drive_files_workspace', ...args);
88
+ return await _ms_broker.send_to_queue('get_drive_files_workspace', ...args);
159
89
  };
160
90
 
161
91
  export const get_drive_files_studio = async function (...args) {
162
- return await send_to_queue('get_drive_files_studio', ...args);
92
+ return await _ms_broker.send_to_queue('get_drive_files_studio', ...args);
163
93
  };
164
94
 
165
95
  export const get_drive_files_user = async function (...args) {
166
- return await send_to_queue('get_drive_files_user', ...args);
96
+ return await _ms_broker.send_to_queue('get_drive_files_user', ...args);
167
97
  };
168
98
 
169
99
  export const get_drive_file_info_workspace = async function (...args) {
170
- return await send_to_queue('get_drive_file_info_workspace', ...args);
100
+ return await _ms_broker.send_to_queue('get_drive_file_info_workspace', ...args);
171
101
  };
172
102
 
173
103
  export const get_drive_file_info_studio = async function (...args) {
174
- return await send_to_queue('get_drive_file_info_studio', ...args);
104
+ return await _ms_broker.send_to_queue('get_drive_file_info_studio', ...args);
175
105
  };
176
106
 
177
107
  export const get_drive_file_info_user = async function (...args) {
178
- return await send_to_queue('get_drive_file_info_user', ...args);
108
+ return await _ms_broker.send_to_queue('get_drive_file_info_user', ...args);
179
109
  };
180
110
 
181
111
  export const delete_drive_files_workspace = async function (...args) {
182
- return await send_to_queue('delete_drive_files_workspace', ...args);
112
+ return await _ms_broker.send_to_queue('delete_drive_files_workspace', ...args);
183
113
  };
184
114
 
185
115
  export const delete_drive_files_studio = async function (...args) {
186
- return await send_to_queue('delete_drive_files_studio', ...args);
116
+ return await _ms_broker.send_to_queue('delete_drive_files_studio', ...args);
187
117
  };
188
118
 
189
119
  export const delete_drive_files_user = async function (...args) {
190
- return await send_to_queue('delete_drive_files_user', ...args);
120
+ return await _ms_broker.send_to_queue('delete_drive_files_user', ...args);
191
121
  };
192
122
 
193
123
  export const extract_drive_file_workspace = async function (...args) {
194
- return await send_to_queue('extract_drive_file_workspace', ...args);
124
+ return await _ms_broker.send_to_queue('extract_drive_file_workspace', ...args);
195
125
  };
196
126
 
197
127
  export const extract_drive_file_studio = async function (...args) {
198
- return await send_to_queue('extract_drive_file_studio', ...args);
128
+ return await _ms_broker.send_to_queue('extract_drive_file_studio', ...args);
199
129
  };
200
130
 
201
131
  export const extract_drive_file_user = async function (...args) {
202
- return await send_to_queue('extract_drive_file_user', ...args);
132
+ return await _ms_broker.send_to_queue('extract_drive_file_user', ...args);
203
133
  };
204
134
 
205
135
  export const upload_drive_file_workspace = async function (...args) {
206
- return await send_to_queue('upload_drive_file_workspace', ...args);
136
+ return await _ms_broker.send_to_queue('upload_drive_file_workspace', ...args);
207
137
  };
208
138
 
209
139
  export const upload_drive_file_studio = async function (...args) {
210
- return await send_to_queue('upload_drive_file_studio', ...args);
140
+ return await _ms_broker.send_to_queue('upload_drive_file_studio', ...args);
211
141
  };
212
142
 
213
143
  export const upload_drive_file_user = async function (...args) {
214
- return await send_to_queue('upload_drive_file_user', ...args);
144
+ return await _ms_broker.send_to_queue('upload_drive_file_user', ...args);
215
145
  };
216
146
 
217
147
  export const update_drive_file_workspace = async function (...args) {
218
- return await send_to_queue('update_drive_file_workspace', ...args);
148
+ return await _ms_broker.send_to_queue('update_drive_file_workspace', ...args);
219
149
  };
220
150
 
221
151
  export const update_drive_file_studio = async function (...args) {
222
- return await send_to_queue('update_drive_file_studio', ...args);
152
+ return await _ms_broker.send_to_queue('update_drive_file_studio', ...args);
223
153
  };
224
154
 
225
155
  export const update_drive_file_user = async function (...args) {
226
- return await send_to_queue('update_drive_file_user', ...args);
156
+ return await _ms_broker.send_to_queue('update_drive_file_user', ...args);
227
157
  };
228
158
 
229
159
  export const create_drive_folder_workspace = async function (...args) {
230
- return await send_to_queue('create_drive_folder_workspace', ...args);
160
+ return await _ms_broker.send_to_queue('create_drive_folder_workspace', ...args);
231
161
  };
232
162
 
233
163
  export const create_drive_folder_studio = async function (...args) {
234
- return await send_to_queue('create_drive_folder_studio', ...args);
164
+ return await _ms_broker.send_to_queue('create_drive_folder_studio', ...args);
235
165
  };
236
166
 
237
167
  export const create_drive_folder_user = async function (...args) {
238
- return await send_to_queue('create_drive_folder_user', ...args);
168
+ return await _ms_broker.send_to_queue('create_drive_folder_user', ...args);
239
169
  };
240
170
 
241
171
  export const rename_drive_file_workspace = async function (...args) {
242
- return await send_to_queue('rename_drive_file_workspace', ...args);
172
+ return await _ms_broker.send_to_queue('rename_drive_file_workspace', ...args);
243
173
  };
244
174
 
245
175
  export const rename_drive_file_studio = async function (...args) {
246
- return await send_to_queue('rename_drive_file_studio', ...args);
176
+ return await _ms_broker.send_to_queue('rename_drive_file_studio', ...args);
247
177
  };
248
178
 
249
179
  export const rename_drive_file_user = async function (...args) {
250
- return await send_to_queue('rename_drive_file_user', ...args);
180
+ return await _ms_broker.send_to_queue('rename_drive_file_user', ...args);
251
181
  };
252
182
 
253
183
  export const rename_drive_folder_workspace = async function (...args) {
254
- return await send_to_queue('rename_drive_folder_workspace', ...args);
184
+ return await _ms_broker.send_to_queue('rename_drive_folder_workspace', ...args);
255
185
  };
256
186
 
257
187
  export const rename_drive_folder_studio = async function (...args) {
258
- return await send_to_queue('rename_drive_folder_studio', ...args);
188
+ return await _ms_broker.send_to_queue('rename_drive_folder_studio', ...args);
259
189
  };
260
190
 
261
191
  export const rename_drive_folder_user = async function (...args) {
262
- return await send_to_queue('rename_drive_folder_user', ...args);
192
+ return await _ms_broker.send_to_queue('rename_drive_folder_user', ...args);
263
193
  };
264
194
 
265
195
  export const update_drive_file_sharing_mode_workspace = async function (...args) {
266
- return await send_to_queue('update_drive_file_sharing_mode_workspace', ...args);
196
+ return await _ms_broker.send_to_queue('update_drive_file_sharing_mode_workspace', ...args);
267
197
  };
268
198
 
269
199
  export const update_drive_file_sharing_mode_studio = async function (...args) {
270
- return await send_to_queue('update_drive_file_sharing_mode_studio', ...args);
200
+ return await _ms_broker.send_to_queue('update_drive_file_sharing_mode_studio', ...args);
271
201
  };
272
202
 
273
203
  export const update_drive_file_sharing_mode_user = async function (...args) {
274
- return await send_to_queue('update_drive_file_sharing_mode_user', ...args);
204
+ return await _ms_broker.send_to_queue('update_drive_file_sharing_mode_user', ...args);
275
205
  };
276
206
 
277
207
  export const delete_file_bulk_workspace = async function (...args) {
278
- return await send_to_queue('delete_file_bulk_workspace', ...args);
208
+ return await _ms_broker.send_to_queue('delete_file_bulk_workspace', ...args);
279
209
  };
280
210
 
281
211
  export const delete_file_bulk_studio = async function (...args) {
282
- return await send_to_queue('delete_file_bulk_studio', ...args);
212
+ return await _ms_broker.send_to_queue('delete_file_bulk_studio', ...args);
283
213
  };
284
214
 
285
215
  export const delete_file_bulk_user = async function (...args) {
286
- return await send_to_queue('delete_file_bulk_user', ...args);
216
+ return await _ms_broker.send_to_queue('delete_file_bulk_user', ...args);
287
217
  };
288
218
 
289
219
  export const check_drive_file_workspace = async function (...args) {
290
- return await send_to_queue('check_drive_file_workspace', ...args);
220
+ return await _ms_broker.send_to_queue('check_drive_file_workspace', ...args);
291
221
  };
292
222
 
293
223
  export const check_drive_file_studio = async function (...args) {
294
- return await send_to_queue('check_drive_file_studio', ...args);
224
+ return await _ms_broker.send_to_queue('check_drive_file_studio', ...args);
295
225
  };
296
226
 
297
227
  export const check_drive_file_user = async function (...args) {
298
- return await send_to_queue('check_drive_file_user', ...args);
228
+ return await _ms_broker.send_to_queue('check_drive_file_user', ...args);
299
229
  };
300
230
 
301
231
  export const update_drive_file_tags_workspace = async function (...args) {
302
- return await send_to_queue('update_drive_file_tags_workspace', ...args);
232
+ return await _ms_broker.send_to_queue('update_drive_file_tags_workspace', ...args);
303
233
  };
304
234
 
305
235
  export const update_drive_file_tags_studio = async function (...args) {
306
- return await send_to_queue('update_drive_file_tags_studio', ...args);
236
+ return await _ms_broker.send_to_queue('update_drive_file_tags_studio', ...args);
307
237
  };
308
238
 
309
239
  export const update_drive_file_tags_user = async function (...args) {
310
- return await send_to_queue('update_drive_file_tags_user', ...args);
240
+ return await _ms_broker.send_to_queue('update_drive_file_tags_user', ...args);
311
241
  };
312
242
 
313
243
  export const update_drive_addons_workspace = async function (...args) {
314
- return await send_to_queue('update_drive_addons_workspace', ...args);
244
+ return await _ms_broker.send_to_queue('update_drive_addons_workspace', ...args);
315
245
  };
316
246
 
317
247
  export const update_drive_addons_studio = async function (...args) {
318
- return await send_to_queue('update_drive_addons_studio', ...args);
248
+ return await _ms_broker.send_to_queue('update_drive_addons_studio', ...args);
319
249
  };
320
250
 
321
251
  export const update_drive_addons_user = async function (...args) {
322
- return await send_to_queue('update_drive_addons_user', ...args);
252
+ return await _ms_broker.send_to_queue('update_drive_addons_user', ...args);
323
253
  };
324
254
 
325
255
  export const getExtensionFromUrl = async function (...args) {
326
- return await send_to_queue('getExtensionFromUrl', ...args);
256
+ return await _ms_broker.send_to_queue('getExtensionFromUrl', ...args);
327
257
  };
328
258
 
329
259
  export const get_user_drive_file = async function (...args) {
330
- return await send_to_queue('get_user_drive_file', ...args);
260
+ return await _ms_broker.send_to_queue('get_user_drive_file', ...args);
331
261
  };
332
262
 
333
263
  export const save_user_drive_file = async function (...args) {
334
- return await send_to_queue('save_user_drive_file', ...args);
264
+ return await _ms_broker.send_to_queue('save_user_drive_file', ...args);
335
265
  };
336
266
 
337
267
  export const find_contact_query = async function (...args) {
338
- return await send_to_queue('find_contact_query', ...args);
268
+ return await _ms_broker.send_to_queue('find_contact_query', ...args);
339
269
  };
340
270
 
341
271
  export const file_upload_validator = async function (...args) {
342
- return await send_to_queue('file_upload_validator', ...args);
272
+ return await _ms_broker.send_to_queue('file_upload_validator', ...args);
343
273
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/drive_module",
3
- "version": "1.1.1403",
3
+ "version": "1.1.1405",
4
4
  "description": "Xuda Drive Server Module",
5
5
  "main": "index.mjs",
6
6
  "dependencies": {