Comparing version 1.13.33 to 1.13.34
@@ -1,2 +0,2 @@ | ||
/// <reference types="fibjs" /> | ||
/// <reference types="@fibjs/types" /> | ||
/// <reference path="common.d.ts" /> | ||
@@ -3,0 +3,0 @@ |
@@ -1,2 +0,2 @@ | ||
/// <reference types="fibjs" /> | ||
/// <reference types="@fibjs/types" /> | ||
/// <reference types="@fxjs/orm" /> | ||
@@ -8,3 +8,3 @@ /// <reference types="fib-session" /> | ||
/// <reference path="test.d.ts" /> | ||
/// <reference path="orm-patch.d.ts" /> | ||
/// <reference path="orm.d.ts" /> | ||
@@ -31,4 +31,9 @@ declare namespace FibApp { | ||
interface GraphQLResolverArgs { | ||
[k: string]: { | ||
type: Function | ||
} | ||
} | ||
// constant type | ||
interface FibAppApiCommnPayload_hasManyArgs { | ||
interface FibAppApiCommnPayload_hasManyArgs extends GraphQLResolverArgs { | ||
where: { type: Function } | ||
@@ -101,3 +106,3 @@ join_where: { type: Function } | ||
interface FibAppIneternalApiFunction__Epost { | ||
(req: FibAppReq, db: FibAppORM, cls: FxOrmNS.Model, id: AppIdType | FxOrmInstance.Instance, extend: FibAppACL.ACLExtendModelNameType, data: FibDataPayload): FibAppApiFunctionResponse; | ||
(req: FibAppReq, db: FibAppORM, cls: FxOrmNS.Model, id: AppIdType | FxOrmInstance.Instance, extend: FibAppACL.ACLExtendModelNameType, data: FibApp.IdPayloadVar | FibDataPayload): FibAppApiFunctionResponse; | ||
} | ||
@@ -209,2 +214,3 @@ | ||
error?: FibAppFinalError | ||
session: FibSessionNS.SessionProxy | ||
} | ||
@@ -295,4 +301,10 @@ | ||
batchPathPrefix?: string | ||
hooks?: Hooks | ||
} | ||
interface Hooks { | ||
beforeSetupRoute?: FxOrmHook.HookActionCallback | ||
} | ||
interface GetTestRoutingOptions { | ||
@@ -299,0 +311,0 @@ appPath?: string |
@@ -1,2 +0,2 @@ | ||
/// <reference types="fibjs" /> | ||
/// <reference types="@fibjs/types" /> | ||
/// <reference types="@fxjs/orm" /> | ||
@@ -8,3 +8,3 @@ /// <reference types="fib-session" /> | ||
/// <reference path="./req.d.ts" /> | ||
/// <reference path="./orm-patch.d.ts" /> | ||
/// <reference path="./orm.d.ts" /> | ||
@@ -11,0 +11,0 @@ /// <reference path="./app.d.ts" /> |
@@ -1,2 +0,2 @@ | ||
/// <reference types="fibjs" /> | ||
/// <reference types="@fibjs/types" /> | ||
@@ -3,0 +3,0 @@ /// <reference path="common.d.ts" /> |
v1.13.33 / 2019-04-15 | ||
v1.13.34 / 2019-06-25 | ||
================== | ||
* remove pointless `extends` field in model | ||
* allow elink auto redirect to epost | ||
* use @fxjs/orm@1.10.2 | ||
* use `model_define_opts.webx` as FibAppORMModel's webx first-class config source, whose options' fallback to field in`model_define_opts` | ||
* upgrade fib-pool | ||
* support Hooks | ||
* upgrade dependencies; mark 'fib-session' to devDependencies. | ||
* typo fix. | ||
* use latest @fxjs/orm, replace '@types/fibjs' with '@fibjs/types' | ||
* upgrade @fxjs/orm; add test script. | ||
v1.13.33 / 2019-04-15 | ||
===================== | ||
* Release v1.13.33 | ||
* code clean. | ||
@@ -6,0 +21,0 @@ * upgrade @fxjs/orm to fix probabel fatal error. |
const mq = require("mq"); | ||
const util = require("util"); | ||
const setupApis = require("./http"); | ||
@@ -12,4 +13,5 @@ const setupTest = require("./testkits"); | ||
super(); | ||
const dbSetupOpts = arguments[arguments.length - 1]; | ||
const appOpts = (arguments[1] === dbSetupOpts ? null : arguments[1]) || {}; | ||
const args = Array.prototype.slice.apply(arguments); | ||
const dbSetupOpts = util.last(args); | ||
const appOpts = (args[1] === dbSetupOpts ? null : args[1]) || {}; | ||
Object.defineProperty(this, '__opts', { | ||
@@ -22,2 +24,3 @@ value: filterFibAppOptions(appOpts), | ||
this.ormPool = setupDb(this, connStr, dbSetupOpts); | ||
appOpts.hooks = appOpts.hooks || {}; | ||
setupApis.bind(this); | ||
@@ -24,0 +27,0 @@ setupTest.bind(this); |
@@ -14,2 +14,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
const common_1 = require("../utils/common"); | ||
const obj_1 = require("../utils/obj"); | ||
function setup(app) { | ||
@@ -95,3 +96,3 @@ const api = app.api; | ||
}; | ||
api.epost = (req, orm, cls, id, extend, data) => { | ||
api.epost = (req, orm, cls, id, extend, data_or_id) => { | ||
const rel_assoc_info = cls.associations[extend]; | ||
@@ -114,2 +115,6 @@ if (rel_assoc_info === undefined) | ||
} | ||
// TODO: add test about epost redirect to elink | ||
if (!util.isObject(data_or_id)) | ||
return api.elink(req, orm, cls, obj.inst.id, extend, { id: data_or_id }); | ||
const data = data_or_id; | ||
ormUtils.attach_internal_api_requestinfo_to_instance(obj.inst, { data: null, req_info: req }); | ||
@@ -138,3 +143,3 @@ const acl = checkout_acl_1.checkout_obj_acl(req.session, 'create', obj.inst, extend); | ||
if (dextra) | ||
orm_assoc_1.addHiddenProperty(ro, '$extra', dextra); | ||
obj_1.addHiddenProperty(ro, '$extra', dextra); | ||
const linkers_after_host_save = []; | ||
@@ -141,0 +146,0 @@ if (_createBy !== undefined) { |
@@ -10,2 +10,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
const batch_request_1 = require("../utils/batch-request"); | ||
const Hook = require("./hook"); | ||
function bind(app) { | ||
@@ -59,29 +60,33 @@ // bind it firstly | ||
} | ||
if (!apiPathPrefix && viewPathPrefix) { | ||
setupViewRoute(); | ||
setupApiRoute(); | ||
} | ||
else { | ||
setupApiRoute(); | ||
setupViewRoute(); | ||
} | ||
/* setup graphql :start */ | ||
const mergeRootAndGraphqlRoot = !graphQLPathPrefix || graphQLPathPrefix === '/'; | ||
if (!mergeRootAndGraphqlRoot) | ||
app.post(graphQLPathPrefix, (req) => { | ||
if (!graphql_1.is_graphql_request(req)) | ||
return err_info_1.fill_error(req, err_info_1.err_info(4000005)); | ||
graphql_1.run_graphql(app, req); | ||
Hook.wait(app, app.__opts.hooks.beforeSetupRoute, function (err) { | ||
if (err) | ||
throw err; | ||
if (!apiPathPrefix && viewPathPrefix) { | ||
setupViewRoute(); | ||
setupApiRoute(); | ||
} | ||
else { | ||
setupApiRoute(); | ||
setupViewRoute(); | ||
} | ||
/* setup graphql :start */ | ||
const mergeRootAndGraphqlRoot = !graphQLPathPrefix || graphQLPathPrefix === '/'; | ||
if (!mergeRootAndGraphqlRoot) | ||
app.post(graphQLPathPrefix, (req) => { | ||
if (!graphql_1.is_graphql_request(req)) | ||
return err_info_1.fill_error(req, err_info_1.err_info(4000005)); | ||
graphql_1.run_graphql(app, req); | ||
}); | ||
/* setup graphql :end */ | ||
/* setup batch task :end */ | ||
const mergeRootAndBatchRoot = !batchPathPrefix || batchPathPrefix === '/'; | ||
if (!mergeRootAndBatchRoot) | ||
app.post(batchPathPrefix, (req) => batch_request_1.run_batch(app, req)); | ||
/* setup batch task :end */ | ||
/* finally, root setup */ | ||
app.post('/', (req) => { | ||
if (graphql_1.is_graphql_request(req)) | ||
return mergeRootAndGraphqlRoot && graphql_1.run_graphql(app, req); | ||
mergeRootAndBatchRoot && batch_request_1.run_batch(app, req); | ||
}); | ||
/* setup graphql :end */ | ||
/* setup batch task :end */ | ||
const mergeRootAndBatchRoot = !batchPathPrefix || batchPathPrefix === '/'; | ||
if (!mergeRootAndBatchRoot) | ||
app.post(batchPathPrefix, (req) => batch_request_1.run_batch(app, req)); | ||
/* setup batch task :end */ | ||
/* finally, root setup */ | ||
app.post('/', (req) => { | ||
if (graphql_1.is_graphql_request(req)) | ||
return mergeRootAndGraphqlRoot && graphql_1.run_graphql(app, req); | ||
mergeRootAndBatchRoot && batch_request_1.run_batch(app, req); | ||
}); | ||
@@ -88,0 +93,0 @@ } |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const util = require("util"); | ||
const obj_1 = require("../utils/obj"); | ||
const error_reasons = [ | ||
@@ -29,12 +31,28 @@ '', | ||
const definition = orm_definition_hash[name]; | ||
m.cid = cls_id++; | ||
Object.defineProperty(m, 'model_name', { value: name }); | ||
const orm_define_opts = definition.opts; | ||
m.ACL = orm_define_opts.ACL; | ||
m.OACL = orm_define_opts.OACL; | ||
m.functions = orm_define_opts.functions || {}; | ||
m.viewFunctions = orm_define_opts.viewFunctions || {}; | ||
m.viewServices = orm_define_opts.viewServices || {}; | ||
if (m.ACL === undefined) | ||
m.ACL = { | ||
const orm_define_opts = definition.opts || {}; | ||
/** | ||
* @compatibility | ||
* allow webx config option from top-level definition, | ||
* as those options from `opts.webx[xxx]` recommended | ||
*/ | ||
const webx_config_opts = util.extend({ | ||
ACL: orm_define_opts.ACL, | ||
OACL: orm_define_opts.OACL, | ||
functions: orm_define_opts.functions, | ||
viewFunctions: orm_define_opts.viewFunctions, | ||
viewServices: orm_define_opts.viewServices, | ||
no_graphql: orm_define_opts.no_graphql, | ||
}, orm_define_opts.webx); | ||
m.$webx = m.$webx || { | ||
ACL: webx_config_opts.ACL, | ||
OACL: webx_config_opts.OACL, | ||
functions: webx_config_opts.functions || {}, | ||
viewFunctions: webx_config_opts.viewFunctions || {}, | ||
viewServices: webx_config_opts.viewServices || {}, | ||
no_graphql: !(webx_config_opts.no_graphql === undefined || webx_config_opts.no_graphql === false) | ||
}; | ||
m.$webx.cid = cls_id++; | ||
m.$webx.model_name = name; | ||
if (m.$webx.ACL === undefined) | ||
m.$webx.ACL = { | ||
"*": { | ||
@@ -49,4 +67,2 @@ "*": true, | ||
}; | ||
var { no_graphql = false } = orm_define_opts || {}; | ||
m.no_graphql = no_graphql; | ||
compatSetup(m); | ||
@@ -62,68 +78,13 @@ return m; | ||
/** | ||
* @warning would deprecated in > 1.13, never use `m.extends` | ||
* @warning would deprecated in > 1.13, use `m.$webx.extends` rather than `m.extends` | ||
*/ | ||
function compatSetup(m) { | ||
m.extends = {}; | ||
var _hasOne = m.hasOne; | ||
m.hasOne = function (extend_name) { | ||
var model = arguments[1]; | ||
var orm_hasOne_opts = arguments[2]; | ||
if (arguments[1] && !arguments[1].table) { | ||
orm_hasOne_opts = arguments[1]; | ||
model = arguments[1] = null; | ||
} | ||
var assoc_model = null; | ||
m.extends[extend_name] = { | ||
type: 'hasOne', | ||
model: model, | ||
get assoc_model() { | ||
return assoc_model; | ||
}, | ||
// it's pointless, just keep same format with `hasMany` | ||
model_associated_models: {} | ||
}; | ||
if (orm_hasOne_opts !== undefined && orm_hasOne_opts.reversed) | ||
m.extends[extend_name].reversed = true; | ||
return (assoc_model = _hasOne.apply(this, slice.call(arguments))); | ||
}; | ||
var _hasMany = m.hasMany; | ||
m.hasMany = function (extend_name, model) { | ||
var model_associated_models = {}, orm_hasMany_opts = {}; | ||
if (arguments.length >= 4) { | ||
model_associated_models = arguments[2]; | ||
orm_hasMany_opts = arguments[3]; | ||
} | ||
else { | ||
model_associated_models = {}; | ||
orm_hasMany_opts = arguments[2]; | ||
} | ||
var assoc_model = null; | ||
m.extends[extend_name] = { | ||
type: 'hasMany', | ||
model: model, | ||
get assoc_model() { | ||
return assoc_model; | ||
}, | ||
model_associated_models: model_associated_models | ||
}; | ||
if (orm_hasMany_opts && orm_hasMany_opts.reversed) | ||
m.extends[extend_name].reversed = true; | ||
return (assoc_model = _hasMany.apply(this, slice.call(arguments))); | ||
}; | ||
var _extendsTo = m.extendsTo; | ||
m.extendsTo = function (extend_name, assoc_props, orm_extendsTo_opts) { | ||
orm_extendsTo_opts = orm_extendsTo_opts || {}; | ||
orm_extendsTo_opts.hooks = orm_extendsTo_opts.hooks || {}; | ||
var assoc_model = null; | ||
m.extends[extend_name] = { | ||
type: 'extendsTo', | ||
// it's pointless, just keep same format with `hasMany` | ||
model: null, | ||
get assoc_model() { | ||
return assoc_model; | ||
}, | ||
model_associated_models: {} | ||
}; | ||
return (assoc_model = _extendsTo.apply(this, slice.call(arguments))); | ||
}; | ||
obj_1.addReadonlyHiddenProperty(m, 'cid', () => m.$webx.cid); | ||
obj_1.addReadonlyHiddenProperty(m, 'model_name', () => m.$webx.model_name); | ||
obj_1.addReadonlyHiddenProperty(m, 'ACL', () => m.$webx.ACL); | ||
obj_1.addReadonlyHiddenProperty(m, 'OACL', () => m.$webx.OACL); | ||
obj_1.addReadonlyHiddenProperty(m, 'functions', () => m.$webx.functions); | ||
obj_1.addReadonlyHiddenProperty(m, 'viewFunctions', () => m.$webx.viewFunctions); | ||
obj_1.addReadonlyHiddenProperty(m, 'viewServices', () => m.$webx.viewServices); | ||
obj_1.addReadonlyHiddenProperty(m, 'no_graphql', () => m.$webx.no_graphql); | ||
} |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function default_1(orm, plugin_opts) { | ||
function beforeDefine(name, properties, opts) { | ||
if (opts.extension && !properties.id) { | ||
if ((opts.extension || opts.__for_extension) && !properties.id) { | ||
opts.__webx_use_uuid = true; | ||
@@ -6,0 +6,0 @@ } |
@@ -7,3 +7,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
return new mq.Routing({ | ||
'/set_session': req => { | ||
'/set_session': (req) => { | ||
var data = req.json(); | ||
@@ -10,0 +10,0 @@ req.session.id = data.id; |
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/// <reference types="@fxjs/orm" /> | ||
const util = require("util"); | ||
const obj_1 = require("./obj"); | ||
function check_hasmanyassoc_with_extraprops(instance, extend_name) { | ||
@@ -63,13 +64,5 @@ var has_many_association = instance.__opts.many_associations.find(a => a.name === extend_name); | ||
exports.getOneMergeIdFromAssocExtendsTo = getOneMergeIdFromAssocExtendsTo; | ||
function addHiddenProperty(instance, p, v) { | ||
Object.defineProperty(instance, p, { | ||
value: v, | ||
writable: true, | ||
enumerable: false | ||
}); | ||
} | ||
exports.addHiddenProperty = addHiddenProperty; | ||
function addHiddenLazyLinker__AfterSave(instance, linkers = []) { | ||
linkers = (instance.$webx_lazy_linkers_after_save || []).concat(linkers); | ||
addHiddenProperty(instance, '$webx_lazy_linkers_after_save', linkers); | ||
obj_1.addHiddenProperty(instance, '$webx_lazy_linkers_after_save', linkers); | ||
} | ||
@@ -79,3 +72,3 @@ exports.addHiddenLazyLinker__AfterSave = addHiddenLazyLinker__AfterSave; | ||
linkers = (instance.$webx_lazy_linkers_before_save || []).concat(linkers); | ||
addHiddenProperty(instance, '$webx_lazy_linkers_before_save', linkers); | ||
obj_1.addHiddenProperty(instance, '$webx_lazy_linkers_before_save', linkers); | ||
} | ||
@@ -82,0 +75,0 @@ exports.addHiddenLazyLinker__BeforeSave = addHiddenLazyLinker__BeforeSave; |
@@ -171,3 +171,3 @@ /// <reference lib="es2017" /> | ||
function is_valid_string_tuple(tuple) { | ||
return tuple.every(x => typeof x === 'string'); | ||
return tuple.every((x) => typeof x === 'string'); | ||
} | ||
@@ -174,0 +174,0 @@ function filter_exist_item_link(exist_item) { |
{ | ||
"name": "fib-app", | ||
"version": "1.13.33", | ||
"version": "1.13.34", | ||
"description": "", | ||
"main": "./lib", | ||
"types": "@types/index.d.ts", | ||
"repository": "git://github.com/fibjs/fib-app.git", | ||
"scripts": { | ||
@@ -12,2 +13,4 @@ "build": "fib-typify src -o lib", | ||
"ci": "npm run build && npm run test", | ||
"ci-mysql": "npm run build && npm run test", | ||
"ci-sqlite": "npm run build && cross-env WEBX_TEST_SQLITE=1 npm run test", | ||
"prepublishOnly": "npm run build" | ||
@@ -25,7 +28,6 @@ }, | ||
"dependencies": { | ||
"@fxjs/orm": "^1.9.7", | ||
"@types/fibjs": "^0.26.5", | ||
"@fibjs/types": "0.0.3", | ||
"@fxjs/orm": "^1.10.2", | ||
"fib-graphql": "^1.0.0", | ||
"fib-pool": "^1.5.2", | ||
"fib-session": "^0.4.0", | ||
"fib-pool": "^1.5.3", | ||
"graphql-iso-date": "^3.4.0", | ||
@@ -39,2 +41,3 @@ "graphql-type-json": "^0.1.4", | ||
"cheerio": "^1.0.0-rc.3", | ||
"cross-env": "^5.2.0", | ||
"ejs": "^2.6.1", | ||
@@ -44,6 +47,8 @@ "faker": "^4.1.0", | ||
"fib-push": "^1.4.1", | ||
"fib-typify": "^0.5.2" | ||
"fib-session": "^0.4.1", | ||
"fib-typify": "^0.6.0" | ||
}, | ||
"peerDependencies": { | ||
"@fxjs/orm": ">= 1.9.7 < 2" | ||
"@fxjs/orm": ">= 1.10.2 < 2", | ||
"fib-session": ">= 0.4.0 < 0.5" | ||
}, | ||
@@ -50,0 +55,0 @@ "ci": { |
@@ -760,2 +760,9 @@ # fib-app | ||
}) | ||
// right | ||
setTimeout(() => { | ||
app.dbPool(new_orm => { | ||
doSomethingSync(orm) | ||
}) | ||
}) | ||
}) | ||
@@ -762,0 +769,0 @@ |
@@ -5,4 +5,12 @@ { | ||
"module": "commonjs", | ||
"noImplicitUseStrict": true | ||
"noImplicitAny": true, | ||
"noImplicitUseStrict": true, | ||
"inlineSourceMap": false, | ||
"types": [ | ||
"@fibjs/types" | ||
], | ||
"typeRoots": [ | ||
"@types/index.d.ts" | ||
] | ||
} | ||
} |
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
184552
53
3529
782
10
+ Added@fibjs/types@0.0.3
+ Added@fibjs/types@0.0.3(transitive)
- Removed@types/fibjs@^0.26.5
- Removedfib-session@^0.4.0
- Removed@types/fibjs@0.26.12(transitive)
Updated@fxjs/orm@^1.10.2
Updatedfib-pool@^1.5.3