From d7a5499b9a2be5fe9679a1ba73d6e5ea877db8ba Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Thu, 30 Apr 2020 09:04:29 +1000 Subject: [PATCH] chat: expose types with libs --- pkg/arvo/app/chat-cli.hoon | 6 +-- pkg/arvo/app/chat-hook.hoon | 7 ++-- pkg/arvo/app/chat-store.hoon | 11 +++-- pkg/arvo/app/chat-view.hoon | 20 ++++----- pkg/arvo/lib/chat-hook.hoon | 1 - pkg/arvo/lib/chat-store.hoon | 66 ++++++++++++++++++++---------- pkg/arvo/lib/chat-view.hoon | 1 - pkg/arvo/lib/chat/eval.hoon | 23 ----------- pkg/arvo/mar/chat/action.hoon | 2 - pkg/arvo/mar/chat/config.hoon | 1 - pkg/arvo/mar/chat/configs.hoon | 1 - pkg/arvo/mar/chat/hook-action.hoon | 1 - pkg/arvo/mar/chat/hook-update.hoon | 1 - pkg/arvo/mar/chat/initial.hoon | 1 - pkg/arvo/mar/chat/update.hoon | 1 - pkg/arvo/mar/chat/view-action.hoon | 1 - 16 files changed, 64 insertions(+), 80 deletions(-) delete mode 100644 pkg/arvo/lib/chat/eval.hoon diff --git a/pkg/arvo/app/chat-cli.hoon b/pkg/arvo/app/chat-cli.hoon index 5ae875d6c5..2d3db35b82 100644 --- a/pkg/arvo/app/chat-cli.hoon +++ b/pkg/arvo/app/chat-cli.hoon @@ -9,10 +9,10 @@ :: we concat the ship onto the head of the path, :: and trust it to take care of the rest. :: -/- store=chat-store, view=chat-view, hook=chat-hook, +/- view=chat-view, hook=chat-hook, *permission-store, *group-store, *invite-store, *rw-security, sole-sur=sole -/+ sole-lib=sole, chat-eval, default-agent, verb, dbug, +/+ sole-lib=sole, default-agent, verb, dbug, store=chat-store, auto=language-server-complete :: |% @@ -978,7 +978,7 @@ :: ++ eval |= [txt=cord exe=hoon] - (say %code txt (eval:chat-eval bowl exe)) + (say %code txt (eval:store bowl exe)) :: +lookup-glyph: print glyph info for all, glyph or target :: ++ lookup-glyph diff --git a/pkg/arvo/app/chat-hook.hoon b/pkg/arvo/app/chat-hook.hoon index 81455d46f9..c582ea5505 100644 --- a/pkg/arvo/app/chat-hook.hoon +++ b/pkg/arvo/app/chat-hook.hoon @@ -5,9 +5,8 @@ /- *permission-store, *invite-store, *metadata-store, *permission-hook, *group-store, *permission-group-hook, ::TMP for upgrade hook=chat-hook, - store=chat-store, view=chat-view -/+ *chat-eval, default-agent, verb, dbug, store-lib=chat-store +/+ default-agent, verb, dbug, store=chat-store ~% %chat-hook-top ..is ~ |% +$ card card:agent:gall @@ -301,7 +300,7 @@ ++ poke-json |= jon=json ^- (quip card _state) - (poke-chat-action (action:dejs:store-lib jon)) + (poke-chat-action (action:dejs:store jon)) :: ++ poke-chat-action |= act=action:store @@ -315,7 +314,7 @@ =* letter letter.envelope.act =? letter &(?=(%code -.letter) ?=(~ output.letter)) =/ =hoon (ream expression.letter) - letter(output (eval bol hoon)) + letter(output (eval:store bol hoon)) =/ ship (~(got by synced) path.act) =/ appl ?:(=(ship our.bol) %chat-store %chat-hook) [%pass / %agent [ship appl] %poke %chat-action !>(act)]~ diff --git a/pkg/arvo/app/chat-store.hoon b/pkg/arvo/app/chat-store.hoon index ca8d62e514..ab4d3e6a68 100644 --- a/pkg/arvo/app/chat-store.hoon +++ b/pkg/arvo/app/chat-store.hoon @@ -1,7 +1,6 @@ :: chat-store: data store that holds linear sequences of chat messages :: -/- store=chat-store -/+ store-lib=chat-store, *chat-eval, default-agent, verb, dbug +/+ store=chat-store, default-agent, verb, dbug ~% %chat-store-top ..is ~ |% +$ card card:agent:gall @@ -72,7 +71,7 @@ ?+ path (on-watch:def path) [%keys ~] (give %chat-update !>([%keys ~(key by inbox)])) [%all ~] (give %chat-initial !>(inbox)) - [%configs ~] (give %chat-configs !>((inbox-to-configs:store-lib inbox))) + [%configs ~] (give %chat-configs !>((inbox-to-configs:store inbox))) [%updates ~] ~ [%mailbox @ *] ?> (~(has by inbox) t.path) @@ -93,7 +92,7 @@ ^- (unit (unit cage)) ?+ path (on-peek:def path) [%x %all ~] ``noun+!>(inbox) - [%x %configs ~] ``noun+!>((inbox-to-configs:store-lib inbox)) + [%x %configs ~] ``noun+!>((inbox-to-configs:store inbox)) [%x %keys ~] ``noun+!>(~(key by inbox)) [%x %envelopes *] (peek-x-envelopes:cc t.t.path) [%x %mailbox *] @@ -160,7 +159,7 @@ ++ poke-json |= jon=json ^- (quip card _state) - (poke-chat-action (action:dejs:store-lib jon)) + (poke-chat-action (action:dejs:store jon)) :: ++ poke-chat-action |= =action:store @@ -249,7 +248,7 @@ (team:title our.bol author) == =/ =hoon (ream expression.letter) - letter(output (eval bol hoon)) + letter(output (eval:store bol hoon)) letter :: ++ prepend-envelope diff --git a/pkg/arvo/app/chat-view.hoon b/pkg/arvo/app/chat-view.hoon index a13bd6565a..19145afae9 100644 --- a/pkg/arvo/app/chat-view.hoon +++ b/pkg/arvo/app/chat-view.hoon @@ -10,12 +10,10 @@ *chat-hook, *metadata-hook, *rw-security, - store=chat-store, - hook=chat-hook, - view=chat-view + hook=chat-hook /+ *server, default-agent, verb, dbug, - store-lib=chat-store, - view-lib=chat-view + store=chat-store, + view=chat-view /= index /^ octs /; as-octs:mimes:html @@ -95,7 +93,7 @@ :: %json :_ this - (poke-chat-view-action:cc (action:dejs:view-lib !<(json vase))) + (poke-chat-view-action:cc (action:dejs:view !<(json vase))) :: %chat-view-action :_ this @@ -114,7 +112,7 @@ :: create inbox with 20 messages max per mailbox and send that along :: then quit the subscription :_ this - [%give %fact ~ %json !>((inbox:enjs:store-lib truncated-inbox-scry))]~ + [%give %fact ~ %json !>((inbox:enjs:store truncated-inbox-scry))]~ ?: =(/configs path) [[%give %fact ~ %json !>(*json)]~ this] (on-watch:def path) @@ -190,7 +188,7 @@ =/ envelopes (envelope-scry [(scot %ud start) (scot %ud end) pax]) %- json-response:gen %- json-to-octs - %- update:enjs:store-lib + %- update:enjs:store [%messages pax start end envelopes] :: [%'~chat' *] (html-response:gen index) @@ -200,7 +198,7 @@ |= jon=json ^- (list card) ?> (team:title our.bol src.bol) - (poke-chat-view-action (action:dejs:view-lib jon)) + (poke-chat-view-action (action:dejs:view jon)) :: ++ poke-chat-view-action |= act=action:view @@ -487,8 +485,8 @@ ++ diff-chat-update |= upd=update:store ^- (list card) - =/ updates-json (update:enjs:store-lib upd) - =/ configs-json (configs:enjs:store-lib configs-scry) + =/ updates-json (update:enjs:store upd) + =/ configs-json (configs:enjs:store configs-scry) :~ [%give %fact ~[/primary] %json !>(updates-json)] [%give %fact ~[/configs] %json !>(configs-json)] == diff --git a/pkg/arvo/lib/chat-hook.hoon b/pkg/arvo/lib/chat-hook.hoon index ce2fb9858b..11ed66009e 100644 --- a/pkg/arvo/lib/chat-hook.hoon +++ b/pkg/arvo/lib/chat-hook.hoon @@ -1,5 +1,4 @@ /- *chat-hook -^? |% :: ++ enjs diff --git a/pkg/arvo/lib/chat-store.hoon b/pkg/arvo/lib/chat-store.hoon index f136cdeba4..8c21d8d45d 100644 --- a/pkg/arvo/lib/chat-store.hoon +++ b/pkg/arvo/lib/chat-store.hoon @@ -1,32 +1,31 @@ /- *chat-store -^? |% ++ enjs =, enjs:format |% :: ++ letter - |= =^letter - ^- json - =, enjs:format - ?- -.letter - %text - (frond %text s+text.letter) - :: - %url - (frond %url s+url.letter) - :: - %code - %+ frond %code - %- pairs - :~ [%expression s+expression.letter] - [%output a+(turn output.letter tank)] - == - :: - %me - (frond %me s+narrative.letter) - :: - == + |= =^letter + ^- json + =, enjs:format + ?- -.letter + %text + (frond %text s+text.letter) + :: + %url + (frond %url s+url.letter) + :: + %code + %+ frond %code + %- pairs + :~ [%expression s+expression.letter] + [%output a+(turn output.letter tank)] + == + :: + %me + (frond %me s+narrative.letter) + :: + == :: ++ envelope |= =^envelope @@ -200,6 +199,7 @@ :: -- -- +:: ++ inbox-to-configs |= =inbox ^- configs @@ -207,4 +207,26 @@ |= =mailbox ^- config config.mailbox +:: +++ eval + |= [=bowl:gall =hoon] + ^- (list tank) + =/ fowl=[our=@p now=@da eny=@uvJ] + :+ our.bowl + now.bowl + (shaz (cat 3 (mix [now eny]:bowl) %eny)) + :: + =/ subject [fowl ..zuse] + =/ minted=(each [=type =nock] (list tank)) + %- mule |. + (~(mint ut -:!>(subject)) %noun hoon) + ?: ?=(%| -.minted) p.minted + =/ =toon + (mock [subject nock.p.minted] |=(^ ~)) + ?- -.toon + %0 [(sell type.p.minted p.toon) ~] + %1 :- leaf+".^ unsupported in chat eval" + (turn ;;((list path) p.toon) smyt) + %2 [leaf+"crash!" p.toon] + == -- diff --git a/pkg/arvo/lib/chat-view.hoon b/pkg/arvo/lib/chat-view.hoon index bcbdd9e4c3..2b4cdc96ea 100644 --- a/pkg/arvo/lib/chat-view.hoon +++ b/pkg/arvo/lib/chat-view.hoon @@ -1,5 +1,4 @@ /- *chat-view, *rw-security -^? |% ++ dejs |% diff --git a/pkg/arvo/lib/chat/eval.hoon b/pkg/arvo/lib/chat/eval.hoon deleted file mode 100644 index 456d1d6fac..0000000000 --- a/pkg/arvo/lib/chat/eval.hoon +++ /dev/null @@ -1,23 +0,0 @@ -|% -++ eval - |= [=bowl:gall =hoon] - ^- (list tank) - =/ fowl=[our=@p now=@da eny=@uvJ] - :+ our.bowl - now.bowl - (shaz (cat 3 (mix [now eny]:bowl) %eny)) - :: - =/ subject [fowl ..zuse] - =/ minted=(each [=type =nock] (list tank)) - %- mule |. - (~(mint ut -:!>(subject)) %noun hoon) - ?: ?=(%| -.minted) p.minted - =/ =toon - (mock [subject nock.p.minted] |=(^ ~)) - ?- -.toon - %0 [(sell type.p.minted p.toon) ~] - %1 :- leaf+".^ unsupported in chat eval" - (turn ;;((list path) p.toon) smyt) - %2 [leaf+"crash!" p.toon] - == --- diff --git a/pkg/arvo/mar/chat/action.hoon b/pkg/arvo/mar/chat/action.hoon index 96a009bab2..1f6f8cc5ba 100644 --- a/pkg/arvo/mar/chat/action.hoon +++ b/pkg/arvo/mar/chat/action.hoon @@ -1,6 +1,4 @@ -/- *chat-store /+ *chat-store -=, dejs:format |_ act=action ++ grab |% diff --git a/pkg/arvo/mar/chat/config.hoon b/pkg/arvo/mar/chat/config.hoon index 4bdeff05a6..7f28d43cce 100644 --- a/pkg/arvo/mar/chat/config.hoon +++ b/pkg/arvo/mar/chat/config.hoon @@ -1,4 +1,3 @@ -/- *chat-store /+ *chat-store |_ cfg=config :: diff --git a/pkg/arvo/mar/chat/configs.hoon b/pkg/arvo/mar/chat/configs.hoon index 2a3583fcd4..2b5717a3d6 100644 --- a/pkg/arvo/mar/chat/configs.hoon +++ b/pkg/arvo/mar/chat/configs.hoon @@ -1,4 +1,3 @@ -/- *chat-store /+ *chat-store |_ cfg=configs :: diff --git a/pkg/arvo/mar/chat/hook-action.hoon b/pkg/arvo/mar/chat/hook-action.hoon index 72caa11968..19e80101c1 100644 --- a/pkg/arvo/mar/chat/hook-action.hoon +++ b/pkg/arvo/mar/chat/hook-action.hoon @@ -1,4 +1,3 @@ -/- *chat-hook /+ *chat-hook |_ act=action ++ grab diff --git a/pkg/arvo/mar/chat/hook-update.hoon b/pkg/arvo/mar/chat/hook-update.hoon index 61a13dfe0e..7a52fa154b 100644 --- a/pkg/arvo/mar/chat/hook-update.hoon +++ b/pkg/arvo/mar/chat/hook-update.hoon @@ -1,4 +1,3 @@ -/- *chat-hook /+ *chat-hook |_ upd=update ++ grow diff --git a/pkg/arvo/mar/chat/initial.hoon b/pkg/arvo/mar/chat/initial.hoon index 7e4b0b3899..1455aee185 100644 --- a/pkg/arvo/mar/chat/initial.hoon +++ b/pkg/arvo/mar/chat/initial.hoon @@ -1,4 +1,3 @@ -/- *chat-store /+ *chat-store |_ box=inbox :: diff --git a/pkg/arvo/mar/chat/update.hoon b/pkg/arvo/mar/chat/update.hoon index eb4a9eaf0e..59a14653ef 100644 --- a/pkg/arvo/mar/chat/update.hoon +++ b/pkg/arvo/mar/chat/update.hoon @@ -1,4 +1,3 @@ -/- *chat-store /+ *chat-store |_ upd=update ++ grow diff --git a/pkg/arvo/mar/chat/view-action.hoon b/pkg/arvo/mar/chat/view-action.hoon index 402411333e..1306f25625 100644 --- a/pkg/arvo/mar/chat/view-action.hoon +++ b/pkg/arvo/mar/chat/view-action.hoon @@ -1,4 +1,3 @@ -/- *chat-view /+ *chat-view |_ act=action ++ grab