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