apps: updated apps to use consistent %initial update

This commit is contained in:
Logan Allen 2020-05-22 14:21:10 -04:00
parent 63b3c1fd68
commit 4550bc6dc1
25 changed files with 86 additions and 304 deletions

View File

@ -10,15 +10,9 @@
state-two
==
::
+$ state-zero [%0 =inbox:store]
+$ state-one [%1 =inbox:store]
+$ state-two [%2 =inbox:store]
::
+$ diff
$% [%chat-initial inbox:store]
[%chat-configs configs:store]
[%chat-update update:store]
==
+$ state-zero [%0 =inbox]
+$ state-one [%1 =inbox]
+$ state-two [%2 =inbox]
--
::
=| state-two
@ -70,8 +64,7 @@
=/ cards=(list card)
?+ 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 inbox)))
[%all ~] (give %chat-update !>([%initial inbox]))
[%updates ~] ~
[%mailbox @ *]
?> (~(has by inbox) t.path)
@ -92,7 +85,6 @@
^- (unit (unit cage))
?+ path (on-peek:def path)
[%x %all ~] ``noun+!>(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 *]
@ -274,7 +266,6 @@
(update-subscribers [%mailbox pax] upd)
?. |(|(=(%read -.upd) =(%message -.upd)) =(%messages -.upd))
~
(update-subscribers /configs upd)
?. |(=(%create -.upd) =(%delete -.upd))
~
(update-subscribers /keys upd)

View File

@ -73,17 +73,14 @@
:: create inbox with 20 messages max per mailbox and send that along
:: then quit the subscription
:_ this
[%give %fact ~ %json !>((inbox:enjs:store truncated-inbox-scry))]~
?: =(/configs path)
[[%give %fact ~ %json !>(*json)]~ this]
[%give %fact ~ %json !>((update-to-json [%initial truncated-inbox]))]~
(on-watch:def path)
::
++ message-limit 20
::
++ truncated-inbox-scry
^- inbox:store
=/ =inbox:store
.^(inbox:store %gx /=chat-store/(scot %da now.bol)/all/noun)
++ truncated-inbox
^- inbox
=/ =inbox .^(inbox %gx /=chat-store/(scot %da now.bol)/all/noun)
%- ~(run by inbox)
|= =mailbox:store
^- mailbox:store
@ -442,11 +439,7 @@
++ diff-chat-update
|= upd=update:store
^- (list card)
=/ 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)]
==
[%give %fact ~[/primary] %json !>((update-to-json upd))]~
::
:: +utilities
::
@ -489,10 +482,6 @@
^- (list envelope:store)
(scry-for (list envelope:store) %chat-store [%envelopes pax])
::
++ configs-scry
^- configs:store
(scry-for configs:store %chat-store /configs)
::
++ group-scry
|= pax=path
^- (unit group)

View File

@ -84,7 +84,7 @@
|^
=/ cards=(list card)
?+ path (on-watch:def path)
[%all ~] (give %contact-update !>([%rolodex rolodex]))
[%all ~] (give %contact-update !>([%initial rolodex]))
[%updates ~] ~
[%contacts @ *]
%+ give %contact-update

View File

@ -67,7 +67,7 @@
?> (team:title our.bowl src.bowl)
?: ?=([%http-response *] path) [~ this]
?. =(/primary path) (on-watch:def path)
[[%give %fact ~ %json !>((rolodex-to-json all-scry:cc))]~ this]
[[%give %fact ~ %json !>((update-to-json [%initial all-scry:cc]))]~ this]
::
++ on-agent
|= [=wire =sign:agent:gall]

View File

@ -160,9 +160,10 @@
|= diff=group-update
^- (quip card _state)
?- -.diff
%keys [~ state]
%path [~ state]
%bundle [~ state]
%initial [~ state]
%keys [~ state]
%path [~ state]
%bundle [~ state]
%add [(update-subscribers [%group pax.diff] diff) state]
%remove [(update-subscribers [%group pax.diff] diff) state]
::
@ -176,8 +177,9 @@
|= diff=group-update
^- (quip card _state)
?- -.diff
%keys [~ state]
%bundle [~ state]
%initial [~ state]
%keys [~ state]
%bundle [~ state]
%path
:_ state
?~ pax.diff ~

View File

@ -14,10 +14,7 @@
=groups
==
::
+$ diff
$% [%group-update group-update]
[%group-initial groups]
==
+$ diff [%group-update group-update]
--
::
=| state-zero
@ -56,7 +53,7 @@
|^
=/ cards=(list card)
?+ path (on-watch:def path)
[%all ~] (give %group-initial !>(groups))
[%all ~] (give %group-update !>([%initial groups]))
[%updates ~] ~
[%keys ~] (give %group-update !>([%keys ~(key by groups)]))
[%group *]

View File

@ -44,8 +44,8 @@
^- (quip card _this)
=/ cards=(list card)
?+ path (on-watch:def path)
[%all ~] [%give %fact ~ %invite-initial !>(invites)]~
[%updates ~] ~
[%all ~] [%give %fact ~ %invite-update !>([%initial invites])]~
[%updates ~] ~
[%invitatory *]
=/ inv=invitatory (~(got by invites) t.path)
[%give %fact ~ %invite-update !>([%invitatory inv])]~

View File

@ -338,7 +338,6 @@
=* mark p.cage.sign
=* vase q.cage.sign
?+ mark ~|([dap.bowl %unexpected-mark mark] !!)
%group-initial [~ state] ::NOTE initial handled using metadata
%group-update (handle-group-update !<(group-update:group-store vase))
==
==
@ -346,6 +345,7 @@
++ handle-group-update
|= upd=group-update:group-store
^- (quip card _state)
:: NOTE initial handled using metadata
?. ?=(?(%path %add %remove) -.upd)
[~ state]
=/ socs=(list app-path)

View File

@ -145,6 +145,7 @@
|= diff=group-update
^- (quip card _state)
?- -.diff
%initial [~ state]
%keys [~ state]
%bundle [~ state]
::

View File

@ -51,8 +51,8 @@
|^
=/ cards=(list card)
?+ path (on-watch:def path)
[%all ~] (give %permission-initial !>(permissions))
[%updates ~] ~
[%all ~] (give %permission-update !>([%initial permissions]))
[%updates ~] ~
[%permission @ *]
=/ =vase !>([%create t.path (~(got by permissions) t.path)])
(give %permission-update vase)

View File

@ -1,4 +1,3 @@
::
/- *publish,
*group-store,
*group-hook,
@ -11,35 +10,6 @@
*rw-security
/+ *server, *publish, cram, default-agent, dbug
::
/= index
/^ $-(json manx)
/: /===/app/publish/index /!noun/
::
/= js
/^ octs
/; as-octs:mimes:html
/| /: /===/app/publish/js/index /js/
/~ ~
==
::
/= css
/^ octs
/; as-octs:mimes:html
/| /: /===/app/publish/css/index /css/
/~ ~
==
::
/= tile-js
/^ octs
/; as-octs:mimes:html
/| /: /===/app/publish/js/tile /js/
/~ ~
==
::
/= images
/^ (map knot @)
/: /===/app/publish/img /_ /png/
::
~% %publish ..is ~
|%
+$ card card:agent:gall
@ -101,7 +71,7 @@
^- (quip card _this)
=/ rav [%sing %t [%da now.bol] /app/publish/notebooks]
:_ this
:~ [%pass /bind %arvo %e %connect [~ /'~publish'] %publish]
:~ [%pass /bind %arvo %e %connect [~ /'publish-view'] %publish]
[%pass /read/paths %arvo %c %warp our.bol q.byk.bol `rav]
[%pass /permissions %agent [our.bol %permission-store] %watch /updates]
(invite-poke:main [%create /publish])
@ -125,8 +95,6 @@
?: ?=(%| -.old-state)
=/ zero !<(state-zero old)
=/ rav [%next %t [%da now.bol] /app/publish/notebooks]
=/ tile-json
(frond:enjs:format %notifications (numb:enjs:format 0))
=/ init-cards=(list card)
:~ [%pass /read/paths %arvo %c %warp our.bol q.byk.bol `rav]
:* %pass /permissions %agent [our.bol %permission-store] %watch
@ -136,7 +104,6 @@
:* %pass /invites %agent [our.bol %invite-store] %watch
/invitatory/publish
==
[%give %fact [/publishtile]~ %json !>(tile-json)]
==
=+ ^- [kick-cards=(list card) old-subs=(jug @tas @p)] kick-subs
=/ inv-scry-pax
@ -359,19 +326,11 @@
^- (quip card _this)
?+ pax (on-watch:def pax)
[%http-response *] [~ this]
::
[%primary ~] [~ this]
[%notebook @ ~]
=^ cards state
(watch-notebook:main pax)
[cards this]
::
[%primary ~] [~ this]
::
[%publishtile ~]
=/ jon=json
(frond:enjs:format %notifications (numb:enjs:format tile-num))
:_ this
[%give %fact ~ %json !>(jon)]~
==
::
++ on-leave on-leave:def
@ -379,7 +338,6 @@
|= pax=path
^- (unit (unit cage))
?+ pax (on-peek:def pax)
::
[%t %limbo ~]
:^ ~ ~ %noun
!> ^- (list path)
@ -917,40 +875,20 @@
[~ state]
::
%delete
=/ scry-pax
/(scot %p our.bol)/invite-store/(scot %da now.bol)/invitatory/publish/noun
=/ inv=(unit invitatory) .^((unit invitatory) %gx scry-pax)
?~ inv
[~ state]
=. tile-num (sub tile-num ~(wyt by u.inv))
=/ jon=json (frond:enjs:format %notifications (numb:enjs:format tile-num))
:_ state
[%give %fact [/publishtile]~ %json !>(jon)]~
[~ state]
::
%invite
=. tile-num +(tile-num)
=/ jon=json (frond:enjs:format %notifications (numb:enjs:format tile-num))
:_ state
[%give %fact [/publishtile]~ %json !>(jon)]~
[~ state]
::
%decline
=? tile-num (gth tile-num 0)
(dec tile-num)
=/ jon=json (frond:enjs:format %notifications (numb:enjs:format tile-num))
:_ state
[%give %fact [/publishtile]~ %json !>(jon)]~
[~ state]
::
%accepted
?> ?=([%notebook @ ~] path.invite.upd)
=/ book i.t.path.invite.upd
=/ wir=wire /subscribe/(scot %p ship.invite.upd)/[book]
=? tile-num (gth tile-num 0)
(dec tile-num)
=/ jon=json (frond:enjs:format %notifications (numb:enjs:format tile-num))
:_ state
:~ [%pass wir %agent [ship.invite.upd %publish] %watch path.invite.upd]
[%give %fact [/publishtile]~ %json !>(jon)]
==
[%pass wir %agent [ship.invite.upd %publish] %watch path.invite.upd]~
==
::
++ watch-notebook
@ -1718,12 +1656,8 @@
=. read.u.not %.y
=. notes.u.book (~(put by notes.u.book) note.act u.not)
=. books (~(put by books) [who.act book.act] u.book)
=/ jon=json
(frond:enjs:format %notifications (numb:enjs:format tile-num))
:_ state
:~ [%give %fact [/primary]~ %publish-primary-delta !>(act)]
[%give %fact [/publishtile]~ %json !>(jon)]
==
[%give %fact [/primary]~ %publish-primary-delta !>(act)]~
:: %groupify
::
%groupify
@ -1847,11 +1781,7 @@
:~ [%give %fact [/notebook/[book-name]]~ %publish-notebook-delta !>(del)]
[%give %fact [/primary]~ %publish-primary-delta !>(del)]
==
=/ jon=json
(frond:enjs:format %notifications (numb:enjs:format tile-num))
:~ [%give %fact [/primary]~ %publish-primary-delta !>(del)]
[%give %fact [/publishtile]~ %json !>(jon)]
==
[%give %fact [/primary]~ %publish-primary-delta !>(del)]~
::
++ metadata-poke
|= act=metadata-action
@ -1943,7 +1873,7 @@
^- (quip card _state)
?- -.del
%add-book
=. tile-num (add tile-num (get-unread data.del))
::=. tile-num (add tile-num (get-unread data.del))
?: =(our.bol host.del)
=^ cards state
(emit-updates-and-state host.del book.del data.del del sty)
@ -1976,8 +1906,8 @@
?~ book
[~ sty]
=. read.data.del =(our.bol author.data.del)
=? tile-num.sty !read.data.del
+(tile-num.sty)
::=? tile-num.sty !read.data.del
:: +(tile-num.sty)
=. notes.u.book (~(put by notes.u.book) note.del data.del)
(emit-updates-and-state host.del book.del u.book del sty)
::
@ -2073,15 +2003,8 @@
?~ book [~ sty]
:_ sty(books (~(del by books.sty) host.del book.del))
?. =(our.bol host.del)
=. tile-num
%+ sub tile-num
(get-unread (~(got by books) host.del book.del))
=/ jon=json
(frond:enjs:format %notifications (numb:enjs:format tile-num.sty))
%+ welp
:~ [%give %fact [/primary]~ %publish-primary-delta !>(del)]
[%give %fact [/publishtile]~ %json !>(jon)]
==
[%give %fact [/primary]~ %publish-primary-delta !>(del)]~
?: (is-managed writers.u.book) ~
[(metadata-hook-poke [%remove writers.u.book])]~
%- zing
@ -2102,8 +2025,8 @@
=/ not=(unit note) (~(get by notes.u.book) note.del)
?~ not
[~ sty]
=? tile-num &(!read.u.not (gth tile-num 0))
(dec tile-num)
::=? tile-num &(!read.u.not (gth tile-num 0))
:: (dec tile-num)
=. notes.u.book (~(del by notes.u.book) note.del)
(emit-updates-and-state host.del book.del u.book del sty)
::
@ -2189,35 +2112,19 @@
|= req=inbound-request:eyre
^- simple-payload:http
=/ url (parse-request-line url.request.req)
?+ url
not-found:gen
::
[[[~ %png] [%'~publish' @t ~]] ~]
=/ filename=@t i.t.site.url
=/ img=(unit @t) (~(get by images) filename)
?~ img
not-found:gen
(png-response:gen (as-octs:mimes:html u.img))
::
[[[~ %css] [%'~publish' %index ~]] ~]
(css-response:gen css)
::
[[[~ %js] [%'~publish' %index ~]] ~]
(js-response:gen js)
::
[[[~ %js] [%'~publish' %tile ~]] ~]
(js-response:gen tile-js)
?+ url not-found:gen
::
:: pagination endpoints
::
:: all notebooks, short form
[[[~ %json] [%'~publish' %notebooks ~]] ~]
[[[~ %json] [%'publish-view' %notebooks ~]] ~]
%- json-response:gen
%- json-to-octs
(notebooks-map:enjs our.bol books)
%+ frond:enjs:format %publish-response
(notebooks-map-json our.bol books)
::
:: notes pagination
[[[~ %json] [%'~publish' %notes @ @ @ @ ~]] ~]
[[[~ %json] [%'publish-view' %notes @ @ @ @ ~]] ~]
=/ host=(unit @p) (slaw %p i.t.t.site.url)
?~ host
not-found:gen
@ -2233,11 +2140,12 @@
not-found:gen
%- json-response:gen
%- json-to-octs
%+ frond:enjs:format %publish-response
:- %o
(notes-page:enjs notes.u.book u.start u.length)
::
:: comments pagination
[[[~ %json] [%'~publish' %comments @ @ @ @ @ ~]] ~]
[[[~ %json] [%'publish-view' %comments @ @ @ @ @ ~]] ~]
=/ host=(unit @p) (slaw %p i.t.t.site.url)
?~ host
not-found:gen
@ -2257,97 +2165,42 @@
not-found:gen
%- json-response:gen
%- json-to-octs
(comments-page:enjs comments.u.note u.start u.length)
%+ frond:enjs:format %publish-response
(comments-page comments.u.note u.start u.length)
::
:: single notebook with initial 50 notes in short form, as json
[[[~ %json] [%'~publish' @ @ ~]] ~]
[[[~ %json] [%'publish-view' @ @ ~]] ~]
=, enjs:format
=/ host=(unit @p) (slaw %p i.t.site.url)
?~ host
not-found:gen
?~ host not-found:gen
=/ book-name i.t.t.site.url
=/ book=(unit notebook) (~(get by books) u.host book-name)
?~ book
not-found:gen
=/ notebook-json (notebook-full:enjs u.host book-name u.book)
?~ book not-found:gen
=/ notebook-json (notebook-full-json u.host book-name u.book)
?> ?=(%o -.notebook-json)
=. p.notebook-json
(~(uni by p.notebook-json) (notes-page:enjs notes.u.book 0 50))
=. p.notebook-json
(~(put by p.notebook-json) %subscribers (get-subscribers-json book-name))
=/ jon=json (pairs notebook+notebook-json ~)
=/ jon=json
(frond:enjs:format %publish-response (pairs notebook+notebook-json ~))
(json-response:gen (json-to-octs jon))
::
:: single note, with initial 50 comments, as json
[[[~ %json] [%'~publish' @ @ @ ~]] ~]
[[[~ %json] [%'publish-view' @ @ @ ~]] ~]
=, enjs:format
=/ host=(unit @p) (slaw %p i.t.site.url)
?~ host
not-found:gen
?~ host not-found:gen
=/ book-name i.t.t.site.url
=/ book=(unit notebook) (~(get by books) u.host book-name)
?~ book
not-found:gen
?~ book not-found:gen
=/ note-name i.t.t.t.site.url
=/ note=(unit note) (~(get by notes.u.book) note-name)
?~ note
not-found:gen
=/ jon=json o+(note-presentation:enjs u.book note-name u.note)
?~ note not-found:gen
=/ jon=json
%+ frond %publish-response:enjs:format
o+(note-presentation-json u.book note-name u.note)
(json-response:gen (json-to-octs jon))
::
:: presentation endpoints
::
:: all notebooks, short form, wrapped in html
[[~ [%'~publish' ?(~ [%join *] [%new ~])]] ~]
=, enjs:format
=/ jon=json (pairs notebooks+(notebooks-map:enjs our.bol books) ~)
(manx-response:gen (index jon))
::
:: single notebook, with initial 50 notes in short form, wrapped in html
[[~ [%'~publish' %notebook @ @ *]] ~]
=/ host=(unit @p) (slaw %p i.t.t.site.url)
?~ host
not-found:gen
=/ book-name i.t.t.t.site.url
=/ book-json=(unit json) (get-notebook-json u.host book-name)
?~ book-json
not-found:gen
(manx-response:gen (index u.book-json))
::
:: single notebook, with initial 50 notes in short form, wrapped in html
[[~ [%'~publish' %popout %notebook @ @ *]] ~]
=/ host=(unit @p) (slaw %p i.t.t.t.site.url)
?~ host
not-found:gen
=/ book-name i.t.t.t.t.site.url
=/ book-json=(unit json) (get-notebook-json u.host book-name)
?~ book-json
not-found:gen
(manx-response:gen (index u.book-json))
::
:: single note, with initial 50 comments, wrapped in html
[[~ [%'~publish' %note @ @ @ *]] ~]
=/ host=(unit @p) (slaw %p i.t.t.site.url)
?~ host
not-found:gen
=/ book-name i.t.t.t.site.url
=/ note-name i.t.t.t.t.site.url
=/ note-json=(unit json) (get-note-json u.host book-name note-name)
?~ note-json
not-found:gen
(manx-response:gen (index u.note-json))
::
:: single note, with initial 50 comments, wrapped in html
[[~ [%'~publish' %popout %note @ @ @ *]] ~]
=/ host=(unit @p) (slaw %p i.t.t.t.site.url)
?~ host
not-found:gen
=/ book-name i.t.t.t.t.site.url
=/ note-name i.t.t.t.t.t.site.url
=/ note-json=(unit json) (get-note-json u.host book-name note-name)
?~ note-json
not-found:gen
(manx-response:gen (index u.note-json))
==
::
--

View File

@ -21,7 +21,6 @@
|= rolo=rolodex
=, enjs:format
^- json
%+ frond %contact-initial
%- pairs
%+ turn ~(tap by rolo)
|= [pax=^path =contacts]
@ -90,6 +89,8 @@
%+ frond %contact-update
%- pairs
:~
?: ?=(%initial -.upd)
[%initial (rolodex-to-json rolodex.upd)]
?: ?=(%create -.upd)
[%create (pairs [%path (path path.upd)]~)]
?: ?=(%delete -.upd)

View File

@ -4,7 +4,6 @@
|= grp=groups
^- json
=, enjs:format
%+ frond %group-initial
%- pairs
%+ turn ~(tap by grp)
|= [pax=^path =group]

View File

@ -10,7 +10,6 @@
++ invites-to-json
|= inv=invites
^- json
%+ frond:enjs:format %invite-initial
%- pairs:enjs:format
%+ turn ~(tap by inv)
|= [=path =invitatory]
@ -46,6 +45,9 @@
%+ frond %invite-update
%- pairs
:~
?: =(%initial -.upd)
?> ?=(%initial -.upd)
[%initial (invites-to-json invites.upd)]
?: =(%create -.upd)
?> ?=(%create -.upd)
[%create (pairs [%path (path path.upd)]~)]

View File

@ -1,14 +0,0 @@
/+ *chat-store
|_ cfg=config
::
++ grow
|%
++ json (config:enjs cfg)
--
::
++ grab
|%
++ noun config
--
::
--

View File

@ -1,14 +0,0 @@
/+ *chat-store
|_ cfg=configs
::
++ grow
|%
++ json (configs:dejs cfg)
--
::
++ grab
|%
++ noun configs
--
::
--

View File

@ -1,14 +0,0 @@
/+ *chat-store
|_ box=inbox
::
++ grow
|%
++ json (inbox:enjs box)
--
::
++ grab
|%
++ noun inbox
--
::
--

View File

@ -1,14 +0,0 @@
/+ *group-json
|_ grp=groups
::
++ grow
|%
++ json (groups-to-json grp)
--
::
++ grab
|%
++ noun groups
--
::
--

View File

@ -12,6 +12,10 @@
%+ frond %group-update
%- pairs
:~
?: =(%initial -.upd)
?> ?=(%initial -.upd)
:- %initial
(groups-to-json grp)
::
:: %add
?: =(%add -.upd)

View File

@ -1,14 +0,0 @@
/+ *invite-json
|_ inv=invites
::
++ grow
|%
++ json (invites-to-json inv)
--
::
++ grab
|%
++ noun invites
--
::
--

View File

@ -12,6 +12,7 @@
++ grow
|%
++ json
%+ frond:enjs:format %publish-update
%+ frond:enjs:format -.del
?- -.del
%add-book

View File

@ -29,9 +29,13 @@
::
+$ inbox (map path mailbox)
::
<<<<<<< HEAD
+$ configs (map path config)
::
+$ diff
=======
+$ chat-base
>>>>>>> 51f0e5eb3... apps: updated apps to use consistent %initial update
$% [%create =path] :: %create: create a mailbox at path
[%delete =path] :: %delete: delete a mailbox at path
[%message =path =envelope] :: %message: append a message to mailbox
@ -45,9 +49,15 @@
diff
==
::
<<<<<<< HEAD
+$ update
$% [%keys keys=(set path)]
[%config =path =config]
=======
+$ chat-update
$% [%initial =inbox]
[%keys keys=(set path)]
>>>>>>> 51f0e5eb3... apps: updated apps to use consistent %initial update
[%messages =path start=@ud end=@ud envelopes=(list envelope)]
diff
==

View File

@ -36,7 +36,7 @@
==
::
+$ contact-update
$% [%rolodex =rolodex]
$% [%initial =rolodex]
[%contacts =path =contacts]
contact-action
==

View File

@ -9,7 +9,8 @@
==
::
+$ group-update
$% [%keys keys=(set path)] :: keys have changed
$% [%initial =groups]
[%keys keys=(set path)] :: keys have changed
[%path members=group pax=path]
group-action
==

View File

@ -32,6 +32,7 @@
::
+$ invite-update
$% invite-base
[%initial =invites]
[%invitatory =invitatory] :: receive invitatory
[%accepted =path uid=serial =invite] :: an invite has been accepted
==