{"action":"created","issue":{"url":"https://api.github.com/repos/feathersjs/feathers-hooks-common/issues/75","repository_url":"https://api.github.com/repos/feathersjs/feathers-hooks-common","labels_url":"https://api.github.com/repos/feathersjs/feathers-hooks-common/issues/75/labels{/name}","comments_url":"https://api.github.com/repos/feathersjs/feathers-hooks-common/issues/75/comments","events_url":"https://api.github.com/repos/feathersjs/feathers-hooks-common/issues/75/events","html_url":"https://github.com/feathersjs/feathers-hooks-common/pull/75","id":196190761,"number":75,"title":"Created support for event filter and permission hooks. Reorganized service hooks because of this.","user":{"login":"eddyystop","id":1553311,"avatar_url":"https://avatars.githubusercontent.com/u/1553311?v=3","gravatar_id":"","url":"https://api.github.com/users/eddyystop","html_url":"https://github.com/eddyystop","followers_url":"https://api.github.com/users/eddyystop/followers","following_url":"https://api.github.com/users/eddyystop/following{/other_user}","gists_url":"https://api.github.com/users/eddyystop/gists{/gist_id}","starred_url":"https://api.github.com/users/eddyystop/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eddyystop/subscriptions","organizations_url":"https://api.github.com/users/eddyystop/orgs","repos_url":"https://api.github.com/users/eddyystop/repos","events_url":"https://api.github.com/users/eddyystop/events{/privacy}","received_events_url":"https://api.github.com/users/eddyystop/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2016-12-17T02:29:10Z","updated_at":"2016-12-30T19:07:12Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/feathersjs/feathers-hooks-common/pulls/75","html_url":"https://github.com/feathersjs/feathers-hooks-common/pull/75","diff_url":"https://github.com/feathersjs/feathers-hooks-common/pull/75.diff","patch_url":"https://github.com/feathersjs/feathers-hooks-common/pull/75.patch"},"body":"[Edited for simplification and clarity]\r\n\r\n- Eric needs some of the service hooks to work for event filters, especially the conditionals.\r\n- I felt the conditional hooks should work for permissions as well.\r\n- Duck typing would not work as service and permission hook funcs both have a signature of (hook).\r\n- Filter and permission hooks were therefore implemented using higher order constructs.\r\n- The service hooks in the repo were re-grouped into files which made sense.\r\n\r\n**hooks = require('feathers-hooks-common')**\r\n- Runs same code as it has previously. Nothing new introduced.\r\n\r\n**filterHooks = require('feathers-hooks-common/filters')**\r\n- Provides `filterHooks.iffElse(predicate, [trueFilters], [falseFilters]);`\r\nas well as iff, iff.else, when, unless and ifNot\r\n- Provides filterHooks.some(...trueFalse) and every.\r\n- Provides filterHooks.remove(), .pluck(), traverse() and the new setFilteredAt()\r\n- These hooks, the predicate and [trueFilters] have signature (data, connection, hook).\r\n- The [trueFilters] are dispatched one after another using the same code as\r\nhttps://github.com/feathersjs/feathers-socket-commons/blob/master/src/events.js#L41-L70\r\n- The hooks return 'false' or modified data.\r\n\r\n**permissionHooks = require('feathers-hooks-common/permissions')**\r\n- Provides `permissionHooks.iffElse(predicate, [truePermissions], [falsePermissions]);`\r\nas well as iff, iff.else, when, unless and ifNot\r\n- Provides permissionHooks.some(...trueFalse) and every.\r\n- These hooks, the predicate and [truePermissions] have signature (hook).\r\n- some and every may be used as either the predicate or [truePermissions].\r\n- The [truePermissions] are dispatched in parallel. The result is true if they all returned true,\r\ni.e. they work file every().\r\n- The hooks return a boolean.\r\n\r\n**hooks = require('feathers-hooks-common/hooks')**\r\n- All the same hooks as feathers-hooks-common but using the same same common code as filter\r\nand permission hooks.\r\n- Code for hooks and tests now sensibly organized.\r\n- The reorganization was cut/paste. The 350+ tests are detailed. I feel comfortable with the result.\r\n\r\n**Outstanding**\r\n- Do we leave the filter and permission hooks here or bundle them from elsewhere?\r\n- Export https://github.com/feathersjs/feathers-socket-commons/blob/master/src/events.js#L41-L70 so a copy of this code in src/filters/conditional.js can be replaced by an import. That'll keep filter dispatching DRY.\r\n\r\n**Which hooks to use?**\r\n- I suggest we change feathers-hooks-common/index.js to require feathers-hooks-common/hooks.\r\n- The existing hooks are packaged the way they are for historical reasons. Not logically.\r\n- The tests are a bag of files.\r\n- The hooks were repackaged to support the filer and permission higher order functions.\r\nThe packaging is sensible and follows the layout of the docs.\r\n- The reganization was cut/paste. The 350+ tests are detailed. I feel comfortable with the reorganization.\r\n"},"comment":{"url":"https://api.github.com/repos/feathersjs/feathers-hooks-common/issues/comments/269809777","html_url":"https://github.com/feathersjs/feathers-hooks-common/pull/75#issuecomment-269809777","issue_url":"https://api.github.com/repos/feathersjs/feathers-hooks-common/issues/75","id":269809777,"user":{"login":"ekryski","id":599019,"avatar_url":"https://avatars.githubusercontent.com/u/599019?v=3","gravatar_id":"","url":"https://api.github.com/users/ekryski","html_url":"https://github.com/ekryski","followers_url":"https://api.github.com/users/ekryski/followers","following_url":"https://api.github.com/users/ekryski/following{/other_user}","gists_url":"https://api.github.com/users/ekryski/gists{/gist_id}","starred_url":"https://api.github.com/users/ekryski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ekryski/subscriptions","organizations_url":"https://api.github.com/users/ekryski/orgs","repos_url":"https://api.github.com/users/ekryski/repos","events_url":"https://api.github.com/users/ekryski/events{/privacy}","received_events_url":"https://api.github.com/users/ekryski/received_events","type":"User","site_admin":false},"created_at":"2016-12-30T19:07:12Z","updated_at":"2016-12-30T19:07:12Z","body":"I'm looking this afternoon for real. Will come back with comments. @daffl from what I can see the majority of the changes are just restructuring."}}
{"actor":{"display_login":"ekryski"}}