@worldsibu/convector-core-model
Advanced tools
Comparing version 1.2.1-0-alpha.57ce2bb4 to 1.2.1-0-alpha.619b2e94
@@ -30,3 +30,3 @@ import * as yup from 'yup'; | ||
}>; | ||
static getOne<T extends ConvectorModel<any>>(this: new (content: any) => T, id: string, type?: new (content: any) => T): Promise<T>; | ||
static getOne<T extends ConvectorModel<any>>(this: new (content: any) => T, id: string, type?: new (content: any) => T, storageOptions?: any): Promise<T>; | ||
static query<T>(type: new (content: any) => T, ...args: any[]): Promise<T | T[]>; | ||
@@ -44,5 +44,5 @@ static getAll<T extends ConvectorModel<any>>(this: new (content: any) => T, type?: string): Promise<T[]>; | ||
}): Promise<void>; | ||
fetch(): Promise<void>; | ||
fetch(storageOptions?: any): Promise<void>; | ||
history(): Promise<History<T>[]>; | ||
save(): Promise<void>; | ||
save(storageOptions?: any): Promise<void>; | ||
clone(): T; | ||
@@ -52,4 +52,4 @@ toJSON(skipEmpty?: boolean): { | ||
}; | ||
delete(): Promise<void>; | ||
delete(storageOptions?: any): Promise<void>; | ||
private assign(content, defaults?); | ||
} |
@@ -25,3 +25,3 @@ "use strict"; | ||
}; | ||
ConvectorModel.getOne = function (id, type) { | ||
ConvectorModel.getOne = function (id, type, storageOptions) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
@@ -33,7 +33,7 @@ var content, model; | ||
type = type || this; | ||
return [4, convector_core_storage_1.BaseStorage.current.get(id)]; | ||
return [4, convector_core_storage_1.BaseStorage.current.get(id, storageOptions)]; | ||
case 1: | ||
content = _a.sent(); | ||
model = new type(content); | ||
if (content.type !== model.type) { | ||
if ((content && model) && content.type !== model.type) { | ||
throw new Error("Possible ID collision, element " + id + " of type " + content.type + " is not " + model.type); | ||
@@ -94,3 +94,3 @@ } | ||
}; | ||
ConvectorModel.prototype.fetch = function () { | ||
ConvectorModel.prototype.fetch = function (storageOptions) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
@@ -100,3 +100,3 @@ var content; | ||
switch (_a.label) { | ||
case 0: return [4, convector_core_storage_1.BaseStorage.current.get(this.id)]; | ||
case 0: return [4, convector_core_storage_1.BaseStorage.current.get(this.id, storageOptions)]; | ||
case 1: | ||
@@ -131,3 +131,3 @@ content = _a.sent(); | ||
}; | ||
ConvectorModel.prototype.save = function () { | ||
ConvectorModel.prototype.save = function (storageOptions) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
@@ -147,3 +147,3 @@ return tslib_1.__generator(this, function (_a) { | ||
convector_core_errors_1.InvalidIdError.test(this.id); | ||
return [4, convector_core_storage_1.BaseStorage.current.set(this.id, this)]; | ||
return [4, convector_core_storage_1.BaseStorage.current.set(this.id, this, storageOptions)]; | ||
case 1: | ||
@@ -193,7 +193,7 @@ _a.sent(); | ||
}; | ||
ConvectorModel.prototype.delete = function () { | ||
ConvectorModel.prototype.delete = function (storageOptions) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, convector_core_storage_1.BaseStorage.current.delete(this.id)]; | ||
case 0: return [4, convector_core_storage_1.BaseStorage.current.delete(this.id, storageOptions)]; | ||
case 1: | ||
@@ -200,0 +200,0 @@ _a.sent(); |
@@ -24,5 +24,11 @@ "use strict"; | ||
return Object.keys(required) | ||
.every(function (k) { return !required[k] || obj[k] !== undefined; }); | ||
.every(function (k) { | ||
var res = !required[k] || obj[k] !== undefined; | ||
if (!res) { | ||
console.log("Validation error. Field " + k + " is required but was not found."); | ||
} | ||
return res; | ||
}); | ||
} | ||
exports.ensureRequired = ensureRequired; | ||
//# sourceMappingURL=required.decorator.js.map |
@@ -21,3 +21,9 @@ "use strict"; | ||
setter = !setter || setter === getSet.set ? (function (v) { return v; }) : setter; | ||
this["_" + key] = schema.validateSync(setter.call(this, newVal)); | ||
try { | ||
this["_" + key] = schema.validateSync(setter.call(this, newVal)); | ||
} | ||
catch (ex) { | ||
ex.message = "Error for field '" + key + "' with val '" + JSON.stringify(newVal) + "' " + ex.message; | ||
throw ex; | ||
} | ||
}, | ||
@@ -24,0 +30,0 @@ enumerable: true, |
{ | ||
"name": "@worldsibu/convector-core-model", | ||
"version": "1.2.1-0-alpha.57ce2bb4", | ||
"version": "1.2.1-0-alpha.619b2e94", | ||
"description": "Convector Model base class", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/hyperledger-labs/convector/tree/develop/%40worldsibu/convector-core-model" | ||
}, | ||
"homepage": "https://worldsibu.tech/convector/convector-smart-contracts/", | ||
"main": "./dist/src/index.js", | ||
@@ -35,4 +40,4 @@ "typings": "./dist/src/index.d.ts", | ||
"dependencies": { | ||
"@worldsibu/convector-core-errors": "1.2.1-0-alpha.57ce2bb4", | ||
"@worldsibu/convector-core-storage": "1.2.1-0-alpha.57ce2bb4", | ||
"@worldsibu/convector-core-errors": "1.2.1-0-alpha.619b2e94", | ||
"@worldsibu/convector-core-storage": "1.2.1-0-alpha.619b2e94", | ||
"tslib": "^1.9.0", | ||
@@ -39,0 +44,0 @@ "yup": "^0.26.10" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
43118
430
1
0
+ Added@worldsibu/convector-core-errors@1.2.1-0-alpha.619b2e94(transitive)
+ Added@worldsibu/convector-core-storage@1.2.1-0-alpha.619b2e94(transitive)
- Removed@worldsibu/convector-core-errors@1.2.1-0-alpha.57ce2bb4(transitive)
- Removed@worldsibu/convector-core-storage@1.2.1-0-alpha.57ce2bb4(transitive)
Updated@worldsibu/convector-core-errors@1.2.1-0-alpha.619b2e94
Updated@worldsibu/convector-core-storage@1.2.1-0-alpha.619b2e94