{"action":"created","comment":{"url":"https://api.github.com/repos/keybase/keybase-chat-bot/pulls/comments/236058452","pull_request_review_id":178066991,"id":236058452,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNjA1ODQ1Mg==","diff_hunk":"@@ -170,12 +199,60 @@ export type AllChatOptions =\n   | ChatOptionsDownload\n   | ChatOptionsAttachment\n \n-/**\n+/*\n+ * Chat API Function Signatures\n  */\n-export type ChatReadMessage = any\n-/**\n+\n+export type Init = InitOptions => Promise<void>\n+\n+export type Deinit = () => Promise<void>\n+\n+export type MyInfo = () => ?DeviceUsernamePair\n+\n+export type List = ChatOptionsList => Promise<void | ChatConversation[]>\n+\n+export type Read = ChatOptionsRead => Promise<any>\n+\n+export type Send = ChatOptionsSend => Promise<void>\n+\n+export type Delete = ChatOptionsDelete => Promise<void>","path":"lib/types.js","position":248,"original_position":248,"commit_id":"9e4c8ebb62f7921aa15f220fc3a34a56afc9d89b","original_commit_id":"9e4c8ebb62f7921aa15f220fc3a34a56afc9d89b","user":{"login":"nathunsmitty","id":5677971,"node_id":"MDQ6VXNlcjU2Nzc5NzE=","avatar_url":"https://avatars1.githubusercontent.com/u/5677971?v=4","gravatar_id":"","url":"https://api.github.com/users/nathunsmitty","html_url":"https://github.com/nathunsmitty","followers_url":"https://api.github.com/users/nathunsmitty/followers","following_url":"https://api.github.com/users/nathunsmitty/following{/other_user}","gists_url":"https://api.github.com/users/nathunsmitty/gists{/gist_id}","starred_url":"https://api.github.com/users/nathunsmitty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nathunsmitty/subscriptions","organizations_url":"https://api.github.com/users/nathunsmitty/orgs","repos_url":"https://api.github.com/users/nathunsmitty/repos","events_url":"https://api.github.com/users/nathunsmitty/events{/privacy}","received_events_url":"https://api.github.com/users/nathunsmitty/received_events","type":"User","site_admin":false},"body":"How do these types relate to the function type signatures in `chat/index.js`? `deleteMessage` has a return type of `Promise<any>` over there. These look to be the more authoritative ones since they're used in the \"with store\" functions, but does that mean we have to duplicate function signatures?","created_at":"2018-11-25T02:00:22Z","updated_at":"2018-11-25T02:16:26Z","html_url":"https://github.com/keybase/keybase-chat-bot/pull/43#discussion_r236058452","pull_request_url":"https://api.github.com/repos/keybase/keybase-chat-bot/pulls/43","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/keybase/keybase-chat-bot/pulls/comments/236058452"},"html":{"href":"https://github.com/keybase/keybase-chat-bot/pull/43#discussion_r236058452"},"pull_request":{"href":"https://api.github.com/repos/keybase/keybase-chat-bot/pulls/43"}}},"pull_request":{"url":"https://api.github.com/repos/keybase/keybase-chat-bot/pulls/43","id":233349914,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMzMzQ5OTE0","html_url":"https://github.com/keybase/keybase-chat-bot/pull/43","diff_url":"https://github.com/keybase/keybase-chat-bot/pull/43.diff","patch_url":"https://github.com/keybase/keybase-chat-bot/pull/43.patch","issue_url":"https://api.github.com/repos/keybase/keybase-chat-bot/issues/43","number":43,"state":"open","locked":false,"title":"🤓 Functional Restructure","user":{"login":"thebearjew","id":5200812,"node_id":"MDQ6VXNlcjUyMDA4MTI=","avatar_url":"https://avatars2.githubusercontent.com/u/5200812?v=4","gravatar_id":"","url":"https://api.github.com/users/thebearjew","html_url":"https://github.com/thebearjew","followers_url":"https://api.github.com/users/thebearjew/followers","following_url":"https://api.github.com/users/thebearjew/following{/other_user}","gists_url":"https://api.github.com/users/thebearjew/gists{/gist_id}","starred_url":"https://api.github.com/users/thebearjew/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thebearjew/subscriptions","organizations_url":"https://api.github.com/users/thebearjew/orgs","repos_url":"https://api.github.com/users/thebearjew/repos","events_url":"https://api.github.com/users/thebearjew/events{/privacy}","received_events_url":"https://api.github.com/users/thebearjew/received_events","type":"User","site_admin":false},"body":"### Goals\r\n\r\nThe purpose of restructuring is to transition the module into a general keybase bot as outlined in #18. The approach taken draws from functional programming with the hopes of improving usability, testing, and development.\r\n\r\n- Improve future unit + integration testing by refactoring each API into functions rather than classes\r\n- Make bot state transitions predictable and pure with a \"redux\"-like store\r\n- Writing tests for multiple concurrent bots should be easy.\r\n- Spinning up a bot into any possible state combination should be easy\r\n\r\n### Overview\r\n\r\n1. Define `chat/` `base/` and `team/` modules\r\n2. Define a state solution, `store/` which uses pure functions to update state\r\n    - `createStore(reducer, initialState)`\r\n    - `store.getState()`\r\n    - `store.dispatch(action())`\r\n    - `withStore()`\r\n    - `withGuards()`\r\n3. Define function `withGuards([guardFn1, guardFn2])` that takes an arbitrary number of guard functions and waits for all to resolve.\r\n4. Define a helper `withState(store, withGuards(guards))(wrappedApiFunc)` which composes and `apiFunc` to be able to use `store` without changing its function signature. If `guards` is provided, then all guards must resolve before calling `apiFunc`.\r\n5. Lots of Flow type updates for better typing\r\n6. Update `rollup.config.js` to use Node/NPM modole resolution - this means that it will use `index.js` as the default export of a directory.\r\n7. Update JSDOC syntax to use `@namespace` to structure module hierarchy.\r\n\r\n### Bot API\r\n\r\nThe Bot API is mostly the same but included the discussed changed in #18.\r\n\r\n```js\r\nconst Bot = require('keybase-chat-bot')\r\nconst bot = new Bot()\r\n// Base\r\nbot.init({username: '', paperkey: '', verbose: false})\r\nbot.myInfo()\r\nbot.deinit()\r\n\r\n// Chat\r\nbot.chat.list( ... )\r\nbot.chat.read( ... )\r\nbot.chat.send( ... )\r\nbot.chat.delete( ... )\r\nbot.chat.watchChannelForNewMessages( ... )\r\nbot.chat.watchAllChannelsForNewMessages( ... )\r\n```\r\n\r\nHowever when Bots are initialized they create a functional `store` and pass that to each API function using `withStore`.\r\nI kept object instantiation to maintain the same API for now. The alternative would have been `const newBot = require('keybase-chat-bot')` and that seemed a bit off.\r\n\r\n\r\n### Tests\r\n\r\nWith API functions being able to have closure over `store`, we will be able to write tests that do the following:\r\n\r\n1. Test a bot in any state by defining the state as an object\r\n2. When running tests we can test any API function without having to call `init()` first because we can use `withStore()` and pass a testing store in.\r\n3. Start with any testing store, run `N` API commands, and check to make sure the store is correct\r\n4. Create two stores, two bots that communicate together,  and run `N` API commands on bot 1 and `N` API commands on bot 2 and check to make sure that the store is correct.","created_at":"2018-11-25T01:26:41Z","updated_at":"2018-11-25T02:16:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0d9bdda1d88bf834a669aa72056b27171729c355","assignee":null,"assignees":[],"requested_reviewers":[{"login":"malgorithms","id":614943,"node_id":"MDQ6VXNlcjYxNDk0Mw==","avatar_url":"https://avatars0.githubusercontent.com/u/614943?v=4","gravatar_id":"","url":"https://api.github.com/users/malgorithms","html_url":"https://github.com/malgorithms","followers_url":"https://api.github.com/users/malgorithms/followers","following_url":"https://api.github.com/users/malgorithms/following{/other_user}","gists_url":"https://api.github.com/users/malgorithms/gists{/gist_id}","starred_url":"https://api.github.com/users/malgorithms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malgorithms/subscriptions","organizations_url":"https://api.github.com/users/malgorithms/orgs","repos_url":"https://api.github.com/users/malgorithms/repos","events_url":"https://api.github.com/users/malgorithms/events{/privacy}","received_events_url":"https://api.github.com/users/malgorithms/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/keybase/keybase-chat-bot/pulls/43/commits","review_comments_url":"https://api.github.com/repos/keybase/keybase-chat-bot/pulls/43/comments","review_comment_url":"https://api.github.com/repos/keybase/keybase-chat-bot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/keybase/keybase-chat-bot/issues/43/comments","statuses_url":"https://api.github.com/repos/keybase/keybase-chat-bot/statuses/9e4c8ebb62f7921aa15f220fc3a34a56afc9d89b","head":{"label":"keybase:thebearjew/restructure-functional","ref":"thebearjew/restructure-functional","sha":"9e4c8ebb62f7921aa15f220fc3a34a56afc9d89b","user":{"login":"keybase","id":5400834,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0MDA4MzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5400834?v=4","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"repo":{"id":74394434,"node_id":"MDEwOlJlcG9zaXRvcnk3NDM5NDQzNA==","name":"keybase-chat-bot","full_name":"keybase/keybase-chat-bot","private":false,"owner":{"login":"keybase","id":5400834,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0MDA4MzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5400834?v=4","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/keybase/keybase-chat-bot","description":"exploration with the keybase chat API","fork":false,"url":"https://api.github.com/repos/keybase/keybase-chat-bot","forks_url":"https://api.github.com/repos/keybase/keybase-chat-bot/forks","keys_url":"https://api.github.com/repos/keybase/keybase-chat-bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/keybase/keybase-chat-bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/keybase/keybase-chat-bot/teams","hooks_url":"https://api.github.com/repos/keybase/keybase-chat-bot/hooks","issue_events_url":"https://api.github.com/repos/keybase/keybase-chat-bot/issues/events{/number}","events_url":"https://api.github.com/repos/keybase/keybase-chat-bot/events","assignees_url":"https://api.github.com/repos/keybase/keybase-chat-bot/assignees{/user}","branches_url":"https://api.github.com/repos/keybase/keybase-chat-bot/branches{/branch}","tags_url":"https://api.github.com/repos/keybase/keybase-chat-bot/tags","blobs_url":"https://api.github.com/repos/keybase/keybase-chat-bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/keybase/keybase-chat-bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/keybase/keybase-chat-bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/keybase/keybase-chat-bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/keybase/keybase-chat-bot/statuses/{sha}","languages_url":"https://api.github.com/repos/keybase/keybase-chat-bot/languages","stargazers_url":"https://api.github.com/repos/keybase/keybase-chat-bot/stargazers","contributors_url":"https://api.github.com/repos/keybase/keybase-chat-bot/contributors","subscribers_url":"https://api.github.com/repos/keybase/keybase-chat-bot/subscribers","subscription_url":"https://api.github.com/repos/keybase/keybase-chat-bot/subscription","commits_url":"https://api.github.com/repos/keybase/keybase-chat-bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/keybase/keybase-chat-bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/keybase/keybase-chat-bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/keybase/keybase-chat-bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/keybase/keybase-chat-bot/contents/{+path}","compare_url":"https://api.github.com/repos/keybase/keybase-chat-bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/keybase/keybase-chat-bot/merges","archive_url":"https://api.github.com/repos/keybase/keybase-chat-bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/keybase/keybase-chat-bot/downloads","issues_url":"https://api.github.com/repos/keybase/keybase-chat-bot/issues{/number}","pulls_url":"https://api.github.com/repos/keybase/keybase-chat-bot/pulls{/number}","milestones_url":"https://api.github.com/repos/keybase/keybase-chat-bot/milestones{/number}","notifications_url":"https://api.github.com/repos/keybase/keybase-chat-bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/keybase/keybase-chat-bot/labels{/name}","releases_url":"https://api.github.com/repos/keybase/keybase-chat-bot/releases{/id}","deployments_url":"https://api.github.com/repos/keybase/keybase-chat-bot/deployments","created_at":"2016-11-21T18:40:51Z","updated_at":"2018-11-25T01:02:12Z","pushed_at":"2018-11-25T01:26:41Z","git_url":"git://github.com/keybase/keybase-chat-bot.git","ssh_url":"git@github.com:keybase/keybase-chat-bot.git","clone_url":"https://github.com/keybase/keybase-chat-bot.git","svn_url":"https://github.com/keybase/keybase-chat-bot","homepage":null,"size":505,"stargazers_count":47,"watchers_count":47,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":15,"license":null,"forks":8,"open_issues":15,"watchers":47,"default_branch":"master"}},"base":{"label":"keybase:master","ref":"master","sha":"0d8c2abefc0f6bbbdcf291757b4664bb83262c30","user":{"login":"keybase","id":5400834,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0MDA4MzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5400834?v=4","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"repo":{"id":74394434,"node_id":"MDEwOlJlcG9zaXRvcnk3NDM5NDQzNA==","name":"keybase-chat-bot","full_name":"keybase/keybase-chat-bot","private":false,"owner":{"login":"keybase","id":5400834,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU0MDA4MzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/5400834?v=4","gravatar_id":"","url":"https://api.github.com/users/keybase","html_url":"https://github.com/keybase","followers_url":"https://api.github.com/users/keybase/followers","following_url":"https://api.github.com/users/keybase/following{/other_user}","gists_url":"https://api.github.com/users/keybase/gists{/gist_id}","starred_url":"https://api.github.com/users/keybase/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keybase/subscriptions","organizations_url":"https://api.github.com/users/keybase/orgs","repos_url":"https://api.github.com/users/keybase/repos","events_url":"https://api.github.com/users/keybase/events{/privacy}","received_events_url":"https://api.github.com/users/keybase/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/keybase/keybase-chat-bot","description":"exploration with the keybase chat API","fork":false,"url":"https://api.github.com/repos/keybase/keybase-chat-bot","forks_url":"https://api.github.com/repos/keybase/keybase-chat-bot/forks","keys_url":"https://api.github.com/repos/keybase/keybase-chat-bot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/keybase/keybase-chat-bot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/keybase/keybase-chat-bot/teams","hooks_url":"https://api.github.com/repos/keybase/keybase-chat-bot/hooks","issue_events_url":"https://api.github.com/repos/keybase/keybase-chat-bot/issues/events{/number}","events_url":"https://api.github.com/repos/keybase/keybase-chat-bot/events","assignees_url":"https://api.github.com/repos/keybase/keybase-chat-bot/assignees{/user}","branches_url":"https://api.github.com/repos/keybase/keybase-chat-bot/branches{/branch}","tags_url":"https://api.github.com/repos/keybase/keybase-chat-bot/tags","blobs_url":"https://api.github.com/repos/keybase/keybase-chat-bot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/keybase/keybase-chat-bot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/keybase/keybase-chat-bot/git/refs{/sha}","trees_url":"https://api.github.com/repos/keybase/keybase-chat-bot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/keybase/keybase-chat-bot/statuses/{sha}","languages_url":"https://api.github.com/repos/keybase/keybase-chat-bot/languages","stargazers_url":"https://api.github.com/repos/keybase/keybase-chat-bot/stargazers","contributors_url":"https://api.github.com/repos/keybase/keybase-chat-bot/contributors","subscribers_url":"https://api.github.com/repos/keybase/keybase-chat-bot/subscribers","subscription_url":"https://api.github.com/repos/keybase/keybase-chat-bot/subscription","commits_url":"https://api.github.com/repos/keybase/keybase-chat-bot/commits{/sha}","git_commits_url":"https://api.github.com/repos/keybase/keybase-chat-bot/git/commits{/sha}","comments_url":"https://api.github.com/repos/keybase/keybase-chat-bot/comments{/number}","issue_comment_url":"https://api.github.com/repos/keybase/keybase-chat-bot/issues/comments{/number}","contents_url":"https://api.github.com/repos/keybase/keybase-chat-bot/contents/{+path}","compare_url":"https://api.github.com/repos/keybase/keybase-chat-bot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/keybase/keybase-chat-bot/merges","archive_url":"https://api.github.com/repos/keybase/keybase-chat-bot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/keybase/keybase-chat-bot/downloads","issues_url":"https://api.github.com/repos/keybase/keybase-chat-bot/issues{/number}","pulls_url":"https://api.github.com/repos/keybase/keybase-chat-bot/pulls{/number}","milestones_url":"https://api.github.com/repos/keybase/keybase-chat-bot/milestones{/number}","notifications_url":"https://api.github.com/repos/keybase/keybase-chat-bot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/keybase/keybase-chat-bot/labels{/name}","releases_url":"https://api.github.com/repos/keybase/keybase-chat-bot/releases{/id}","deployments_url":"https://api.github.com/repos/keybase/keybase-chat-bot/deployments","created_at":"2016-11-21T18:40:51Z","updated_at":"2018-11-25T01:02:12Z","pushed_at":"2018-11-25T01:26:41Z","git_url":"git://github.com/keybase/keybase-chat-bot.git","ssh_url":"git@github.com:keybase/keybase-chat-bot.git","clone_url":"https://github.com/keybase/keybase-chat-bot.git","svn_url":"https://github.com/keybase/keybase-chat-bot","homepage":null,"size":505,"stargazers_count":47,"watchers_count":47,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"archived":false,"open_issues_count":15,"license":null,"forks":8,"open_issues":15,"watchers":47,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/keybase/keybase-chat-bot/pulls/43"},"html":{"href":"https://github.com/keybase/keybase-chat-bot/pull/43"},"issue":{"href":"https://api.github.com/repos/keybase/keybase-chat-bot/issues/43"},"comments":{"href":"https://api.github.com/repos/keybase/keybase-chat-bot/issues/43/comments"},"review_comments":{"href":"https://api.github.com/repos/keybase/keybase-chat-bot/pulls/43/comments"},"review_comment":{"href":"https://api.github.com/repos/keybase/keybase-chat-bot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/keybase/keybase-chat-bot/pulls/43/commits"},"statuses":{"href":"https://api.github.com/repos/keybase/keybase-chat-bot/statuses/9e4c8ebb62f7921aa15f220fc3a34a56afc9d89b"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"nathunsmitty"}}