reactivedb
Advanced tools
Comparing version 0.9.16 to 0.9.17-alpha.1-lazyexception
{ | ||
"name": "reactivedb", | ||
"version": "0.9.16", | ||
"version": "0.9.17-alpha.1-lazyexception", | ||
"description": "Reactive ORM for Lovefield", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -43,3 +43,3 @@ import { Observable } from 'rxjs/Observable' | ||
const schema = this.schemas.get(name) | ||
assert(schema, Exception.NonExistentTable(name)) | ||
assert(schema, () => Exception.NonExistentTable(name)) | ||
return schema! | ||
@@ -54,7 +54,7 @@ } | ||
const advanced = !this.schemaDefs.has(tableName) && !this.connected | ||
assert(advanced, Exception.UnmodifiableTable()) | ||
assert(advanced, () => Exception.UnmodifiableTable()) | ||
const hasPK = Object.keys(schema) | ||
.some((key: string) => schema[key].primaryKey === true) | ||
assert(hasPK, Exception.PrimaryKeyNotProvided()) | ||
assert(hasPK, () => Exception.PrimaryKeyNotProvided()) | ||
@@ -95,3 +95,3 @@ this.schemaDefs.set(tableName, schema) | ||
load(data: any) { | ||
assert(!this.connected, Exception.DatabaseIsNotEmpty()) | ||
assert(!this.connected, () => Exception.DatabaseIsNotEmpty()) | ||
@@ -362,3 +362,3 @@ return this.database$ | ||
if (def.primaryKey) { | ||
assert(!primaryKey[0], Exception.PrimaryKeyConflict()) | ||
assert(!primaryKey[0], () => Exception.PrimaryKeyConflict()) | ||
primaryKey.push(key) | ||
@@ -526,3 +526,3 @@ } | ||
.every(key => contains(key, navigators)) | ||
assert(!onlyNavigator, Exception.InvalidQuery()) | ||
assert(!onlyNavigator, () => Exception.InvalidQuery()) | ||
@@ -547,3 +547,3 @@ if (!hasKey) { | ||
columns.push(...ret.columns) | ||
assert(!rootDefinition[key], Exception.AliasConflict(key, tableName)) | ||
assert(!rootDefinition[key], () => Exception.AliasConflict(key, tableName)) | ||
@@ -640,3 +640,3 @@ if ((defs as ColumnDef).column) { | ||
const pkVal = compoundEntites[pk] | ||
assert(pkVal !== undefined, Exception.PrimaryKeyNotProvided()) | ||
assert(pkVal !== undefined, () => Exception.PrimaryKeyNotProvided()) | ||
@@ -643,0 +643,0 @@ const [ table ] = Database.getTables(db, tableName) |
@@ -70,3 +70,3 @@ import * as lf from 'lovefield' | ||
private toUpdater() { | ||
assert(this.meta, Exception.PrimaryKeyNotProvided()) | ||
assert(this.meta, () => Exception.PrimaryKeyNotProvided()) | ||
@@ -89,3 +89,3 @@ const query = this.db.update(this.table) | ||
private toRow() { | ||
assert(this.meta, Exception.PrimaryKeyNotProvided()) | ||
assert(this.meta, () => Exception.PrimaryKeyNotProvided()) | ||
@@ -92,0 +92,0 @@ return { |
@@ -26,3 +26,3 @@ import { Observable } from 'rxjs/Observable' | ||
values(): Observable<T[]> { | ||
assert(!this.consumed, TokenConsumed()) | ||
assert(!this.consumed, () => TokenConsumed()) | ||
@@ -36,3 +36,3 @@ this.consumed = true | ||
changes(): Observable<T[]> { | ||
assert(!this.consumed, TokenConsumed()) | ||
assert(!this.consumed, () => TokenConsumed()) | ||
@@ -39,0 +39,0 @@ this.consumed = true |
@@ -22,3 +22,3 @@ import { Observer } from 'rxjs/Observer' | ||
const nextSkip = acc.skip! + acc.limit! | ||
assert(current.skip === nextSkip, Exception.TokenConcatFailed(` | ||
assert(current.skip === nextSkip, () => Exception.TokenConcatFailed(` | ||
skip should be serial, | ||
@@ -50,3 +50,3 @@ expect: ${JSON.stringify(acc, null, 2)} | ||
dist.values = () => { | ||
assert(!dist.consumed, Exception.TokenConsumed()) | ||
assert(!dist.consumed, () => Exception.TokenConsumed()) | ||
dist.consumed = true | ||
@@ -218,3 +218,3 @@ return Observable.from(metaDatas) | ||
) | ||
assert(equal, Exception.TokenConcatFailed()) | ||
assert(equal, () => Exception.TokenConcatFailed()) | ||
@@ -221,0 +221,0 @@ return Selector.concatFactory(this, ...selectors) |
@@ -1,2 +0,2 @@ | ||
export function assert(condition: any, error: Error | string) { | ||
export function assert(condition: any, produceError: () => Error | string) { | ||
if (condition) { | ||
@@ -6,2 +6,4 @@ return | ||
const error = produceError() | ||
if (error instanceof Error) { | ||
@@ -8,0 +10,0 @@ throw error |
@@ -1,1 +0,1 @@ | ||
export default '0.9.16' | ||
export default '0.9.17-alpha.1-lazyexception' |
@@ -39,3 +39,3 @@ "use strict"; | ||
var schema = _this.schemas.get(name); | ||
utils_1.assert(schema, Exception.NonExistentTable(name)); | ||
utils_1.assert(schema, function () { return Exception.NonExistentTable(name); }); | ||
return schema; | ||
@@ -59,6 +59,6 @@ }; | ||
var advanced = !this.schemaDefs.has(tableName) && !this.connected; | ||
utils_1.assert(advanced, Exception.UnmodifiableTable()); | ||
utils_1.assert(advanced, function () { return Exception.UnmodifiableTable(); }); | ||
var hasPK = Object.keys(schema) | ||
.some(function (key) { return schema[key].primaryKey === true; }); | ||
utils_1.assert(hasPK, Exception.PrimaryKeyNotProvided()); | ||
utils_1.assert(hasPK, function () { return Exception.PrimaryKeyNotProvided(); }); | ||
this.schemaDefs.set(tableName, schema); | ||
@@ -79,3 +79,3 @@ return this; | ||
var _this = this; | ||
utils_1.assert(!this.connected, Exception.DatabaseIsNotEmpty()); | ||
utils_1.assert(!this.connected, function () { return Exception.DatabaseIsNotEmpty(); }); | ||
return this.database$ | ||
@@ -313,3 +313,3 @@ .concatMap(function (db) { | ||
if (def.primaryKey) { | ||
utils_1.assert(!primaryKey[0], Exception.PrimaryKeyConflict()); | ||
utils_1.assert(!primaryKey[0], function () { return Exception.PrimaryKeyConflict(); }); | ||
primaryKey.push(key); | ||
@@ -442,3 +442,3 @@ } | ||
.every(function (key) { return utils_1.contains(key, navigators); }); | ||
utils_1.assert(!onlyNavigator, Exception.InvalidQuery()); | ||
utils_1.assert(!onlyNavigator, function () { return Exception.InvalidQuery(); }); | ||
if (!hasKey) { | ||
@@ -459,3 +459,3 @@ // 保证主键一定比关联字段更早的被遍历到 | ||
columns.push.apply(columns, ret.columns); | ||
utils_1.assert(!rootDefinition[key], Exception.AliasConflict(key, tableName)); | ||
utils_1.assert(!rootDefinition[key], function () { return Exception.AliasConflict(key, tableName); }); | ||
if (defs.column) { | ||
@@ -531,3 +531,3 @@ rootDefinition[key] = defs; | ||
var pkVal = compoundEntites[pk]; | ||
utils_1.assert(pkVal !== undefined, Exception.PrimaryKeyNotProvided()); | ||
utils_1.assert(pkVal !== undefined, function () { return Exception.PrimaryKeyNotProvided(); }); | ||
var table = Database.getTables(db, tableName)[0]; | ||
@@ -534,0 +534,0 @@ var identifier = symbols_1.fieldIdentifier(tableName, pkVal); |
@@ -51,3 +51,3 @@ "use strict"; | ||
var _this = this; | ||
utils_1.assert(this.meta, Exception.PrimaryKeyNotProvided()); | ||
utils_1.assert(this.meta, function () { return Exception.PrimaryKeyNotProvided(); }); | ||
var query = this.db.update(this.table); | ||
@@ -67,3 +67,3 @@ query.where(this.table[this.meta.key].eq(this.meta.val)); | ||
Mutation.prototype.toRow = function () { | ||
utils_1.assert(this.meta, Exception.PrimaryKeyNotProvided()); | ||
utils_1.assert(this.meta, function () { return Exception.PrimaryKeyNotProvided(); }); | ||
return { | ||
@@ -70,0 +70,0 @@ table: this.table, |
@@ -19,3 +19,3 @@ "use strict"; | ||
QueryToken.prototype.values = function () { | ||
assert_1.assert(!this.consumed, token_1.TokenConsumed()); | ||
assert_1.assert(!this.consumed, function () { return token_1.TokenConsumed(); }); | ||
this.consumed = true; | ||
@@ -27,3 +27,3 @@ return this.selector$ | ||
QueryToken.prototype.changes = function () { | ||
assert_1.assert(!this.consumed, token_1.TokenConsumed()); | ||
assert_1.assert(!this.consumed, function () { return token_1.TokenConsumed(); }); | ||
this.consumed = true; | ||
@@ -30,0 +30,0 @@ return this.selector$ |
@@ -40,3 +40,3 @@ "use strict"; | ||
var nextSkip = acc.skip + acc.limit; | ||
utils_1.assert(current.skip === nextSkip, Exception.TokenConcatFailed("\n skip should be serial,\n expect: " + JSON.stringify(acc, null, 2) + "\n actual: " + nextSkip + "\n ")); | ||
utils_1.assert(current.skip === nextSkip, function () { return Exception.TokenConcatFailed("\n skip should be serial,\n expect: " + JSON.stringify(acc, null, 2) + "\n actual: " + nextSkip + "\n "); }); | ||
return current; | ||
@@ -64,3 +64,3 @@ }); | ||
dist.values = function () { | ||
utils_1.assert(!dist.consumed, Exception.TokenConsumed()); | ||
utils_1.assert(!dist.consumed, function () { return Exception.TokenConsumed(); }); | ||
dist.consumed = true; | ||
@@ -211,3 +211,3 @@ return Observable_1.Observable.from(metaDatas) | ||
}); | ||
utils_1.assert(equal, Exception.TokenConcatFailed()); | ||
utils_1.assert(equal, function () { return Exception.TokenConcatFailed(); }); | ||
return Selector.concatFactory.apply(Selector, [this].concat(selectors)); | ||
@@ -214,0 +214,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
export declare function assert(condition: any, error: Error | string): void; | ||
export declare function assert(condition: any, produceError: () => Error | string): void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function assert(condition, error) { | ||
function assert(condition, produceError) { | ||
if (condition) { | ||
return; | ||
} | ||
var error = produceError(); | ||
if (error instanceof Error) { | ||
@@ -8,0 +9,0 @@ throw error; |
@@ -1,2 +0,2 @@ | ||
declare const _default: "0.9.16"; | ||
declare const _default: "0.9.17-alpha.1-lazyexception"; | ||
export default _default; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = '0.9.16'; | ||
exports.default = '0.9.17-alpha.1-lazyexception'; | ||
//# sourceMappingURL=version.js.map |
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
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
269876
4779