Comparing version 1.13.34 to 1.13.35
@@ -173,6 +173,3 @@ /// <reference types="@fibjs/types" /> | ||
type GraphQLQueryString = string | ||
interface FibAppDbGraphQLHandler { | ||
(query: GraphQLQueryString, req: FibAppHttpRequest): any | ||
} | ||
interface FibAppORM extends FxOrmNS.FibORM { | ||
interface FibAppORM extends FxOrmNS.ORM { | ||
app: FibAppClass | ||
@@ -183,3 +180,3 @@ /* override :start */ | ||
graphql?: FibAppDbGraphQLHandler | ||
graphql<T = any> (query: FibApp.GraphQLQueryString, req: FibApp.FibAppHttpRequest): T | ||
define(name: string, properties: FxOrmModel.ModelPropertyDefinitionHash, opts?: FibAppOrmModelDefOptions): FibAppORMModel; | ||
@@ -301,2 +298,4 @@ } | ||
hooks?: Hooks | ||
hideErrorStack?: boolean | ||
} | ||
@@ -303,0 +302,0 @@ |
@@ -131,2 +131,2 @@ /// <reference types="@fibjs/types" /> | ||
} | ||
} | ||
} |
v1.13.34 / 2019-06-25 | ||
v1.13.35 / 2019-06-28 | ||
================== | ||
* bugfix: typo fix | ||
* feat: add FibAppOpts['hideErrorStack'] | ||
* typo robust. | ||
* bugfix: use 'prepend' instead of 'overwrite' when change models' hook. | ||
* throw Error with error message rather string only. | ||
v1.13.34 / 2019-06-25 | ||
===================== | ||
* Release v1.13.34 | ||
* remove pointless `extends` field in model | ||
@@ -6,0 +16,0 @@ * allow elink auto redirect to epost |
@@ -283,3 +283,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
default: | ||
throw `invalid rel_assoc_info.type ${rel_type}`; | ||
throw new Error(`invalid rel_assoc_info.type ${rel_type}`); | ||
case 'extendsTo': | ||
@@ -286,0 +286,0 @@ robj.base[Helpers.getExtendsToAssociationItemFromInstanceByExtname(robj.base, extend).delAccessor + 'Sync'].call(robj.base); |
@@ -20,3 +20,4 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
catch (e) { | ||
console.error(e.stack); | ||
if (!app.__opts.hideErrorStack) | ||
console.error(e.stack); | ||
return err_info_1.err_info(5000002, { | ||
@@ -23,0 +24,0 @@ function: func, |
@@ -141,3 +141,3 @@ const util = require("util"); | ||
if (!graphqlTypeMap[orig_type]) { | ||
throw `valid type required for model ${m.model_name}'s extended extra field ${extraf}`; | ||
throw new Error(`valid type required for model ${m.model_name}'s extended extra field ${extraf}`); | ||
} | ||
@@ -166,3 +166,3 @@ extra_fields[extraf] = { | ||
if (!graphqlTypeMap[orig_type]) { | ||
throw `valid type required for model ${m.model_name}'s extended extra field ${extraf}`; | ||
throw new Error(`valid type required for model ${m.model_name}'s extended extra field ${extraf}`); | ||
} | ||
@@ -184,3 +184,3 @@ basic_fields[extraf] = { | ||
if (!type) { | ||
throw `valid type required for model ${m.model_name}'s field ${p}`; | ||
throw new Error(`valid type required for model ${m.model_name}'s field ${p}`); | ||
} | ||
@@ -195,3 +195,3 @@ fields[p] = { | ||
if (rel_assoc_info.type !== 'extendsTo' && !rel_assoc_info.association.model) { | ||
throw `association ${f} defined for model ${m.model_name} but no valid related model, detailed information: \n ${JSON.stringify(rel_assoc_info, null, '\t')}`; | ||
throw new Error(`association ${f} defined for model ${m.model_name} but no valid related model, detailed information: \n ${JSON.stringify(rel_assoc_info, null, '\t')}`); | ||
} | ||
@@ -198,0 +198,0 @@ const assoc_model = rel_assoc_info.association.model; |
@@ -13,3 +13,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
if (error_reason) | ||
throw `error occured when finding pre-define orm model ${name}, reason: ${error_reason}`; | ||
throw new Error(`error occured when finding pre-define orm model ${name}, reason: ${error_reason}`); | ||
} | ||
@@ -16,0 +16,0 @@ function int(bool) { |
@@ -28,27 +28,26 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
opts.hooks = opts.hooks || {}; | ||
if (plugin_opts.createdProperty) | ||
prependHook(opts.hooks, 'beforeCreate', function (next) { | ||
const createdProperty = plugin_opts.createdProperty; | ||
const updatedProperty = plugin_opts.updatedProperty; | ||
this[createdProperty] = this[updatedProperty] = new Date(); | ||
next(); | ||
}); | ||
if (plugin_opts.updatedProperty) | ||
prependHook(opts.hooks, 'beforeSave', function (next) { | ||
const createdProperty = plugin_opts.createdProperty; | ||
const updatedProperty = plugin_opts.updatedProperty; | ||
if (this.__opts.changes.length > 0) { | ||
delete this[createdProperty]; | ||
this[updatedProperty] = new Date(); | ||
} | ||
next(); | ||
}); | ||
if (plugin_opts.expireProperty) | ||
prependHook(opts.hooks, 'beforeSave', function (next) { | ||
this[plugin_opts.expireProperty] = plugin_opts.expire(); | ||
next(); | ||
}); | ||
} | ||
return { | ||
beforeDefine: beforeDefine | ||
beforeDefine: beforeDefine, | ||
define(model) { | ||
if (plugin_opts.createdProperty) | ||
model.beforeCreate(function () { | ||
const createdProperty = plugin_opts.createdProperty; | ||
const updatedProperty = plugin_opts.updatedProperty; | ||
this[createdProperty] = this[updatedProperty] = new Date(); | ||
}, { oldhook: 'prepend' }); | ||
if (plugin_opts.updatedProperty) | ||
model.beforeSave(function () { | ||
const createdProperty = plugin_opts.createdProperty; | ||
const updatedProperty = plugin_opts.updatedProperty; | ||
if (this.__opts.changes.length > 0) { | ||
delete this[createdProperty]; | ||
this[updatedProperty] = new Date(); | ||
} | ||
}, { oldhook: 'prepend' }); | ||
if (plugin_opts.expireProperty) | ||
model.beforeSave(function () { | ||
this[plugin_opts.expireProperty] = plugin_opts.expire(); | ||
}, { oldhook: 'prepend' }); | ||
} | ||
}; | ||
@@ -55,0 +54,0 @@ } |
@@ -92,3 +92,4 @@ /// <reference lib="es2016" /> | ||
catch (e) { | ||
console.error(e.stack); | ||
if (!this.__opts.hideErrorStack) | ||
console.error(e.stack); | ||
if (e.type === 'validation') { | ||
@@ -95,0 +96,0 @@ result = { |
@@ -32,3 +32,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
catch (e) { | ||
throw `error occured when trying to set obj['${k}'] = undefined`; | ||
throw new Error(`error occured when trying to set obj['${k}'] = undefined`); | ||
} | ||
@@ -35,0 +35,0 @@ delete obj[k]; |
@@ -64,3 +64,3 @@ /// <reference path="../../@types/index.d.ts" /> | ||
default: | ||
throw `invalid rel_assoc_info.type ${rel_type}`; | ||
throw new Error(`invalid rel_assoc_info.type ${rel_type}`); | ||
case 'extendsTo': | ||
@@ -67,0 +67,0 @@ const assoc_id = assoc.model.id.length > 1 ? assoc.model.id.filter(x => x !== 'id')[0] : assoc.model.id[0]; |
@@ -22,3 +22,3 @@ /// <reference lib="es2017" /> | ||
if (!found_assoc) { | ||
throw `invalid association symbol '${findby.extend}' for model '${exec_model.model_name || exec_model.table}'`; | ||
throw new Error(`invalid association symbol '${findby.extend}' for model '${exec_model.model_name || exec_model.table}'`); | ||
} | ||
@@ -25,0 +25,0 @@ return true; |
{ | ||
"name": "fib-app", | ||
"version": "1.13.34", | ||
"version": "1.13.35", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib", |
4743463
56
3527