diff --git a/package-lock.json b/package-lock.json index 5cd453b..82903fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -137,9 +137,9 @@ } }, "@pushrocks/lik": { - "version": "3.0.17", - "resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.17.tgz", - "integrity": "sha512-Ip56GDuW/ReBPhRVIhaqosqXu12SBW1DT3GkY8hOTiF1YNdKxiaw13QOPva6KPeTffb9DTThOu352KvjMrfxRw==", + "version": "3.0.19", + "resolved": "https://verdaccio.lossless.one/@pushrocks%2flik/-/lik-3.0.19.tgz", + "integrity": "sha512-N9uTtQmTJ/iZ/V7LMCKbVx/ZAmP+b8uId0pxV9Au9T0Ulu9wcg3vNpyTQARgdWfG+tI9Qc0NHgOEa9H5mbDcDA==", "requires": { "@pushrocks/smartdelay": "^2.0.6", "@pushrocks/smartpromise": "^3.0.6", @@ -149,16 +149,6 @@ "@types/minimatch": "^3.0.3", "minimatch": "^3.0.4", "symbol-tree": "^3.2.4" - }, - "dependencies": { - "@pushrocks/smartdelay": { - "version": "2.0.6", - "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.6.tgz", - "integrity": "sha512-4wUnzWNhRPODpaaL5GuRaje/C5dg+TMhBxmr57PKc2fqYpy6azWJwonf/s5xpcbJLCPJRbj1x8M5MqgCFq2uvg==", - "requires": { - "@pushrocks/smartpromise": "^3.0.6" - } - } } }, "@pushrocks/qenv": { @@ -198,7 +188,6 @@ "version": "2.0.6", "resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartdelay/-/smartdelay-2.0.6.tgz", "integrity": "sha512-4wUnzWNhRPODpaaL5GuRaje/C5dg+TMhBxmr57PKc2fqYpy6azWJwonf/s5xpcbJLCPJRbj1x8M5MqgCFq2uvg==", - "dev": true, "requires": { "@pushrocks/smartpromise": "^3.0.6" } @@ -646,9 +635,9 @@ } }, "@types/mongodb": { - "version": "3.3.15", - "resolved": "https://verdaccio.lossless.one/@types%2fmongodb/-/mongodb-3.3.15.tgz", - "integrity": "sha512-q2dL0VEdFdE9iS0xrTP0NSgJJBFH4hBvt3beglCwU3qMWrz7dCuu/CrRjPB4+R8jLjCi/Gik2Mkd+lU0sYsZgQ==", + "version": "3.3.16", + "resolved": "https://verdaccio.lossless.one/@types%2fmongodb/-/mongodb-3.3.16.tgz", + "integrity": "sha512-i1Ov36BXdp+urtPsaSvrNfCdsaVn4Ukq1m1kGyzdWB1+eg3gJ68unXU5LNmnF4EAMRFY6FXZzA7/W3NST40b8g==", "requires": { "@types/bson": "*", "@types/node": "*" @@ -664,9 +653,9 @@ } }, "@types/node": { - "version": "13.7.0", - "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-13.7.0.tgz", - "integrity": "sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ==" + "version": "13.7.2", + "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-13.7.2.tgz", + "integrity": "sha512-uvilvAQbdJvnSBFcKJ2td4016urcGvsiR+N4dHGU87ml8O2Vl6l+ErOi9w0kXSPiwJ1AYlIW+0pDXDWWMOiWbw==" }, "@types/shortid": { "version": "0.0.29", @@ -1747,9 +1736,9 @@ } }, "mongodb": { - "version": "3.5.2", - "resolved": "https://verdaccio.lossless.one/mongodb/-/mongodb-3.5.2.tgz", - "integrity": "sha512-Lxt4th2tK2MxmkDBR5cMik+xEnkvhwg0BC5kGcHm9RBwaNEsrIryvV5istGXOHbnif5KslMpY1FbX6YbGJ/Trg==", + "version": "3.5.3", + "resolved": "https://verdaccio.lossless.one/mongodb/-/mongodb-3.5.3.tgz", + "integrity": "sha512-II7P7A3XUdPiXRgcN96qIoRa1oesM6qLNZkzfPluNZjVkgQk3jnQwOT6/uDk4USRDTTLjNFw2vwfmbRGTA7msg==", "requires": { "bl": "^2.2.0", "bson": "^1.1.1", diff --git a/package.json b/package.json index a034863..fd4f03b 100644 --- a/package.json +++ b/package.json @@ -21,15 +21,15 @@ }, "homepage": "https://gitlab.com/pushrocks/smartdata#README", "dependencies": { - "@pushrocks/lik": "^3.0.17", + "@pushrocks/lik": "^3.0.19", "@pushrocks/smartlog": "^2.0.21", "@pushrocks/smartpromise": "^3.0.6", "@pushrocks/smartstring": "^3.0.18", "@pushrocks/smartunique": "^3.0.1", "@types/lodash": "^4.14.149", - "@types/mongodb": "^3.3.15", + "@types/mongodb": "^3.3.16", "lodash": "^4.17.15", - "mongodb": "^3.5.2", + "mongodb": "^3.5.3", "runtime-type-checks": "0.0.4" }, "devDependencies": { @@ -38,7 +38,7 @@ "@pushrocks/qenv": "^4.0.6", "@pushrocks/tapbundle": "^3.2.0", "@types/mongodb-memory-server": "^2.3.0", - "@types/node": "^13.7.0", + "@types/node": "^13.7.2", "@types/shortid": "0.0.29", "mongodb-memory-server": "^6.2.4", "tslint": "^6.0.0", diff --git a/test/test.ts b/test/test.ts index 2c304f7..ad7bad4 100644 --- a/test/test.ts +++ b/test/test.ts @@ -44,7 +44,7 @@ tap.test('should establish a connection to the rethink Db cluster', async () => @smartdata.Collection(() => { return testDb; }) -class Car extends smartdata.SmartDataDbDoc { +class Car extends smartdata.SmartDataDbDoc { @smartdata.unI() public index: string = smartunique.shortId(); @@ -107,7 +107,7 @@ tap.test('should be able to delete an instance of car', async () => { @smartdata.Collection(() => { return testDb; }) -class Truck extends smartdata.SmartDataDbDoc { +class Truck extends smartdata.SmartDataDbDoc { @smartdata.unI() public id: string = smartunique.shortId(); diff --git a/ts/smartdata.classes.collection.ts b/ts/smartdata.classes.collection.ts index 2604b91..9b52ed4 100644 --- a/ts/smartdata.classes.collection.ts +++ b/ts/smartdata.classes.collection.ts @@ -42,7 +42,7 @@ export class SmartdataCollection { public smartdataDb: SmartdataDb; public uniqueIndexes: string[] = []; - constructor(collectedClassArg: T & SmartDataDbDoc, smartDataDbArg: SmartdataDb) { + constructor(collectedClassArg: T & SmartDataDbDoc, smartDataDbArg: SmartdataDb) { // tell the collection where it belongs this.collectionName = collectedClassArg.name; this.smartdataDb = smartDataDbArg; @@ -103,7 +103,7 @@ export class SmartdataCollection { /** * create an object in the database */ - public async insert(dbDocArg: T & SmartDataDbDoc): Promise { + public async insert(dbDocArg: T & SmartDataDbDoc): Promise { await this.init(); await this.checkDoc(dbDocArg); this.markUniqueIndexes(dbDocArg.uniqueIndexes); @@ -115,7 +115,7 @@ export class SmartdataCollection { /** * inserts object into the DbCollection */ - public async update(dbDocArg: T & SmartDataDbDoc): Promise { + public async update(dbDocArg: T & SmartDataDbDoc): Promise { await this.init(); await this.checkDoc(dbDocArg); const identifiableObject = await dbDocArg.createIdentifiableObject(); @@ -134,7 +134,7 @@ export class SmartdataCollection { ); } - public async delete(dbDocArg: T & SmartDataDbDoc): Promise { + public async delete(dbDocArg: T & SmartDataDbDoc): Promise { await this.init(); await this.checkDoc(dbDocArg); const identifiableObject = await dbDocArg.createIdentifiableObject(); diff --git a/ts/smartdata.classes.doc.ts b/ts/smartdata.classes.doc.ts index 456f10c..6da08ce 100644 --- a/ts/smartdata.classes.doc.ts +++ b/ts/smartdata.classes.doc.ts @@ -11,7 +11,7 @@ export type TDocCreation = 'db' | 'new' | 'mixed'; * saveable - saveable decorator to be used on class properties */ export function svDb() { - return (target: SmartDataDbDoc, key: string) => { + return (target: SmartDataDbDoc, key: string) => { console.log(`called svDb() on ${key}`); if (!target.saveableProperties) { target.saveableProperties = []; @@ -24,7 +24,7 @@ export function svDb() { * unique index - decorator to mark a unique index */ export function unI() { - return (target: SmartDataDbDoc, key: string) => { + return (target: SmartDataDbDoc, key: string) => { console.log('called unI'); // mark the index as unique @@ -41,7 +41,7 @@ export function unI() { }; } -export class SmartDataDbDoc { +export class SmartDataDbDoc { /** * the collection object an Doc belongs to */ @@ -150,9 +150,9 @@ export class SmartDataDbDoc { * also store any referenced objects to DB * better for data consistency */ - public saveDeep(savedMapArg: Objectmap> = null) { + public saveDeep(savedMapArg: Objectmap> = null) { if (!savedMapArg) { - savedMapArg = new Objectmap>(); + savedMapArg = new Objectmap>(); } savedMapArg.add(this); this.save(); @@ -167,12 +167,12 @@ export class SmartDataDbDoc { /** * creates a saveable object so the instance can be persisted as json in the database */ - public async createSavableObject() { - const saveableObject: any = {}; // is not exposed to outside, so any is ok here + public async createSavableObject(): Promise { + const saveableObject: unknown = {}; // is not exposed to outside, so any is ok here for (const propertyNameString of this.saveableProperties) { saveableObject[propertyNameString] = this[propertyNameString]; } - return saveableObject; + return saveableObject as TImplements; } /**