fix(core): update

This commit is contained in:
Philipp Kunz 2020-02-19 18:30:34 +00:00
parent 8e7ad5210f
commit e58fa57525
5 changed files with 30 additions and 41 deletions

35
package-lock.json generated
View File

@ -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",

View File

@ -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",

View File

@ -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<Car> {
class Car extends smartdata.SmartDataDbDoc<Car, Car> {
@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<Car> {
class Truck extends smartdata.SmartDataDbDoc<Car, Car> {
@smartdata.unI()
public id: string = smartunique.shortId();

View File

@ -42,7 +42,7 @@ export class SmartdataCollection<T> {
public smartdataDb: SmartdataDb;
public uniqueIndexes: string[] = [];
constructor(collectedClassArg: T & SmartDataDbDoc<T>, smartDataDbArg: SmartdataDb) {
constructor(collectedClassArg: T & SmartDataDbDoc<T, unknown>, smartDataDbArg: SmartdataDb) {
// tell the collection where it belongs
this.collectionName = collectedClassArg.name;
this.smartdataDb = smartDataDbArg;
@ -103,7 +103,7 @@ export class SmartdataCollection<T> {
/**
* create an object in the database
*/
public async insert(dbDocArg: T & SmartDataDbDoc<T>): Promise<any> {
public async insert(dbDocArg: T & SmartDataDbDoc<T, unknown>): Promise<any> {
await this.init();
await this.checkDoc(dbDocArg);
this.markUniqueIndexes(dbDocArg.uniqueIndexes);
@ -115,7 +115,7 @@ export class SmartdataCollection<T> {
/**
* inserts object into the DbCollection
*/
public async update(dbDocArg: T & SmartDataDbDoc<T>): Promise<any> {
public async update(dbDocArg: T & SmartDataDbDoc<T, unknown>): Promise<any> {
await this.init();
await this.checkDoc(dbDocArg);
const identifiableObject = await dbDocArg.createIdentifiableObject();
@ -134,7 +134,7 @@ export class SmartdataCollection<T> {
);
}
public async delete(dbDocArg: T & SmartDataDbDoc<T>): Promise<any> {
public async delete(dbDocArg: T & SmartDataDbDoc<T, unknown>): Promise<any> {
await this.init();
await this.checkDoc(dbDocArg);
const identifiableObject = await dbDocArg.createIdentifiableObject();

View File

@ -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<any>, key: string) => {
return (target: SmartDataDbDoc<unknown, unknown>, 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<any>, key: string) => {
return (target: SmartDataDbDoc<unknown, unknown>, key: string) => {
console.log('called unI');
// mark the index as unique
@ -41,7 +41,7 @@ export function unI() {
};
}
export class SmartDataDbDoc<T> {
export class SmartDataDbDoc<T, TImplements> {
/**
* the collection object an Doc belongs to
*/
@ -150,9 +150,9 @@ export class SmartDataDbDoc<T> {
* also store any referenced objects to DB
* better for data consistency
*/
public saveDeep(savedMapArg: Objectmap<SmartDataDbDoc<any>> = null) {
public saveDeep(savedMapArg: Objectmap<SmartDataDbDoc<any, any>> = null) {
if (!savedMapArg) {
savedMapArg = new Objectmap<SmartDataDbDoc<any>>();
savedMapArg = new Objectmap<SmartDataDbDoc<any, any>>();
}
savedMapArg.add(this);
this.save();
@ -167,12 +167,12 @@ export class SmartDataDbDoc<T> {
/**
* 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<TImplements> {
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;
}
/**