@worldsibu/convector-core-model
Advanced tools
Comparing version 1.1.9-0-alpha.50c901dc to 1.1.9-0-alpha.6b057fa0
@@ -5,2 +5,7 @@ import * as yup from 'yup'; | ||
}; | ||
export interface History<T> { | ||
value: T; | ||
txId: string; | ||
timestamp: number; | ||
} | ||
export declare abstract class ConvectorModel<T extends ConvectorModel<any>> { | ||
@@ -24,2 +29,3 @@ static schema<T extends ConvectorModel<any>>(this: new (...args: any[]) => T): yup.ObjectSchema<FlatConvectorModel<T> & { | ||
fetch(): Promise<void>; | ||
history(): Promise<History<T>[]>; | ||
save(): Promise<void>; | ||
@@ -26,0 +32,0 @@ clone(): T; |
@@ -106,2 +106,20 @@ "use strict"; | ||
}; | ||
ConvectorModel.prototype.history = function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var _this = this; | ||
var history; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, convector_core_storage_1.BaseStorage.current.history(this.id)]; | ||
case 1: | ||
history = _a.sent(); | ||
return [2, history.map(function (item) { return ({ | ||
txId: item.tx_id, | ||
value: new _this.constructor(item.value), | ||
timestamp: item.timestamp | ||
}); })]; | ||
} | ||
}); | ||
}); | ||
}; | ||
ConvectorModel.prototype.save = function () { | ||
@@ -114,3 +132,3 @@ return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
if (!required_decorator_1.ensureRequired(this)) { | ||
throw new Error("Model " + this.type + " is not complete\n" + this.toJSON()); | ||
throw new Error("Model " + this.type + " is not complete\n" + JSON.stringify(this)); | ||
} | ||
@@ -127,3 +145,3 @@ convector_core_errors_1.InvalidIdError.test(this.id); | ||
ConvectorModel.prototype.clone = function () { | ||
return Object.assign({}, this); | ||
return new this.constructor(Object.assign({}, this)); | ||
}; | ||
@@ -130,0 +148,0 @@ ConvectorModel.prototype.toJSON = function (skipEmpty) { |
{ | ||
"name": "@worldsibu/convector-core-model", | ||
"version": "1.1.9-0-alpha.50c901dc", | ||
"version": "1.1.9-0-alpha.6b057fa0", | ||
"description": "Convector Model base class", | ||
@@ -35,4 +35,4 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@worldsibu/convector-core-errors": "1.1.9-0-alpha.50c901dc", | ||
"@worldsibu/convector-core-storage": "1.1.9-0-alpha.50c901dc", | ||
"@worldsibu/convector-core-errors": "1.1.9-0-alpha.6b057fa0", | ||
"@worldsibu/convector-core-storage": "1.1.9-0-alpha.6b057fa0", | ||
"tslib": "^1.9.0", | ||
@@ -39,0 +39,0 @@ "yup": "^0.24.1" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38262
374
+ Added@worldsibu/convector-core-errors@1.1.9-0-alpha.6b057fa0(transitive)
+ Added@worldsibu/convector-core-storage@1.1.9-0-alpha.6b057fa0(transitive)
- Removed@worldsibu/convector-core-errors@1.1.9-0-alpha.50c901dc(transitive)
- Removed@worldsibu/convector-core-storage@1.1.9-0-alpha.50c901dc(transitive)
Updated@worldsibu/convector-core-errors@1.1.9-0-alpha.6b057fa0
Updated@worldsibu/convector-core-storage@1.1.9-0-alpha.6b057fa0