@researchdatabox/sails-hook-redbox-storage-mongo 1.5.3 → 5.0.0-RC2
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/README.md +20 -5
- package/dist/config/record.d.ts +3 -0
- package/dist/config/record.js +7 -0
- package/dist/config/storage.d.ts +105 -0
- package/dist/config/storage.js +25 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +31 -0
- package/dist/models/DeletedRecord.d.ts +7 -0
- package/dist/models/DeletedRecord.js +37 -0
- package/dist/models/IntegrationAudit.d.ts +22 -0
- package/dist/models/IntegrationAudit.js +112 -0
- package/dist/models/Record.d.ts +13 -0
- package/dist/models/Record.js +64 -0
- package/dist/models/RecordAudit.d.ts +9 -0
- package/dist/models/RecordAudit.js +47 -0
- package/dist/models/index.d.ts +10 -0
- package/dist/models/index.js +32 -0
- package/dist/services/MongoStorageService.d.ts +83 -0
- package/dist/services/MongoStorageService.js +1276 -0
- package/dist/services/index.d.ts +5 -0
- package/dist/services/index.js +51 -0
- package/package.json +66 -32
- package/.github/dependabot.yml +0 -12
- package/api/models/DeletedRecord.js +0 -24
- package/api/models/Record.js +0 -41
- package/api/models/RecordAudit.js +0 -18
- package/api/services/MongoStorageService.js +0 -905
- package/config/record.js +0 -3
- package/config/storage.js +0 -73
- package/index.js +0 -21
- package/test/unit/.mocharc.js +0 -21
- package/test/unit/bootstrap.js +0 -63
- package/test/unit/db/storage.test.js +0 -121
- package/transformer/ExportJSONTransformer.js +0 -47
- package/tsconfig.json +0 -39
- package/typescript/api/services/MongoStorageService.ts +0 -1005
- package/typescript/transformer/ExportJSONTransformer.ts +0 -65
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { Transform } = require('stream');
|
|
4
|
-
import { DateTime } from 'luxon';
|
|
5
|
-
declare var require: any;
|
|
6
|
-
declare var module: any;
|
|
7
|
-
declare let sails, _;
|
|
8
|
-
|
|
9
|
-
class ExportJSONTransformer extends Transform {
|
|
10
|
-
first:boolean = true;
|
|
11
|
-
constructor(recordtype:string, modifiedBefore:string, modifiedAfter:string) {
|
|
12
|
-
super();
|
|
13
|
-
this.push(`{ "recordType": "${recordtype}",\n "dateGenerated": "${DateTime.now().toISO()}",\n`)
|
|
14
|
-
if(!_.isEmpty(modifiedBefore) || !_.isEmpty(modifiedAfter)) {
|
|
15
|
-
this.push(`"dateModifiedRange": ${this.getDateModifiedRangeObject(modifiedBefore, modifiedAfter)},\n`);
|
|
16
|
-
}
|
|
17
|
-
this.push(`"records":[ `)
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
private getDateModifiedRangeObject(modifiedBefore,modifiedAfter) {
|
|
23
|
-
let rangeObject = {};
|
|
24
|
-
if(!_.isEmpty(modifiedAfter)) {
|
|
25
|
-
rangeObject["from"] = modifiedAfter;
|
|
26
|
-
} else {
|
|
27
|
-
rangeObject["from"] = "";
|
|
28
|
-
}
|
|
29
|
-
if(!_.isEmpty(modifiedBefore)) {
|
|
30
|
-
rangeObject["to"] = modifiedBefore;
|
|
31
|
-
} else {
|
|
32
|
-
rangeObject["to"] = "";
|
|
33
|
-
}
|
|
34
|
-
return JSON.stringify(rangeObject)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Main function that send data to the parse to be processed.
|
|
39
|
-
*
|
|
40
|
-
* @param {Buffer} chunk Incoming data
|
|
41
|
-
* @param {String} encoding Encoding of the incoming data. Defaults to 'utf8'
|
|
42
|
-
* @param {Function} done Called when the proceesing of the supplied chunk is done
|
|
43
|
-
*/
|
|
44
|
-
_transform(chunk:object, encoding, done) {
|
|
45
|
-
|
|
46
|
-
let data = chunk.toString();
|
|
47
|
-
|
|
48
|
-
if(!this.first) {
|
|
49
|
-
this.push(",\n");
|
|
50
|
-
|
|
51
|
-
} else {
|
|
52
|
-
this.first = false;
|
|
53
|
-
}
|
|
54
|
-
this.push(data);
|
|
55
|
-
done();
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
_flush(done) {
|
|
59
|
-
this.push("]\n }");
|
|
60
|
-
done();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
module.exports = ExportJSONTransformer;
|