@xuda.io/xuda-worker-bundle-min 1.3.381 → 1.3.383
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.js +41 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -366,10 +366,49 @@ func.common.db = async function (
|
|
|
366
366
|
const perform_rpi_request_from_pouch = async function (serviceP) {
|
|
367
367
|
const db = await func.utils.connect_pouchdb(SESSION_ID);
|
|
368
368
|
let _data = _.cloneDeep(dataP);
|
|
369
|
+
|
|
370
|
+
function cleanString(json) {
|
|
371
|
+
let str = JSON.stringify(json);
|
|
372
|
+
// Replace all non-alphanumeric characters with an empty string
|
|
373
|
+
return str.replace(/[^a-zA-Z0-9]/g, "");
|
|
374
|
+
}
|
|
375
|
+
|
|
369
376
|
delete _data.fields;
|
|
370
377
|
delete _data.viewSourceDesc;
|
|
371
|
-
|
|
372
|
-
|
|
378
|
+
if (_data.skip === null) {
|
|
379
|
+
delete _data.skip;
|
|
380
|
+
}
|
|
381
|
+
const rep_id = cleanString(_data);
|
|
382
|
+
|
|
383
|
+
////// validate existence of whole table request
|
|
384
|
+
|
|
385
|
+
try {
|
|
386
|
+
let table_req_id = cleanString({
|
|
387
|
+
table_id: _data.table_id,
|
|
388
|
+
limit: 99999999,
|
|
389
|
+
key: _data.table_id,
|
|
390
|
+
});
|
|
391
|
+
const doc = await db.get(table_req_id);
|
|
392
|
+
/// delete all requests
|
|
393
|
+
|
|
394
|
+
let ret = await db.find({
|
|
395
|
+
selector: {
|
|
396
|
+
docType: "rep_request",
|
|
397
|
+
"udfData.udffileid": _data.table_id,
|
|
398
|
+
},
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
for (let doc of ret.docs) {
|
|
402
|
+
console.log("to remove", doc);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
if (doc.stat < 3) {
|
|
406
|
+
return await perform_rpi_request(serviceP);
|
|
407
|
+
}
|
|
408
|
+
} catch (err) {}
|
|
409
|
+
|
|
410
|
+
///////////////////////////
|
|
411
|
+
|
|
373
412
|
try {
|
|
374
413
|
const doc = await db.get(rep_id);
|
|
375
414
|
if (doc.stat < 3) throw "replication not ready";
|