2019-11-19 06:28:59 +03:00
|
|
|
/- lens, *sole
|
|
|
|
/+ base64, *server, default-agent
|
2019-05-09 09:59:51 +03:00
|
|
|
/= lens-mark /: /===/mar/lens/command
|
|
|
|
/!noun/
|
2019-04-30 23:38:40 +03:00
|
|
|
=, format
|
|
|
|
|%
|
2019-08-06 02:39:52 +03:00
|
|
|
:: +lens-out: json or named octet-stream
|
|
|
|
::
|
|
|
|
+$ lens-out
|
|
|
|
$% [%json =json]
|
|
|
|
[%mime =mime]
|
|
|
|
==
|
2019-04-30 23:38:40 +03:00
|
|
|
+$ state
|
2019-05-09 09:59:51 +03:00
|
|
|
$% $: %0
|
2019-11-19 06:28:59 +03:00
|
|
|
job=(unit [eyre-id=@ta com=command:lens])
|
2019-04-30 23:38:40 +03:00
|
|
|
==
|
|
|
|
==
|
|
|
|
::
|
|
|
|
--
|
|
|
|
::
|
2019-11-19 06:28:59 +03:00
|
|
|
=| =state
|
2019-11-19 07:36:21 +03:00
|
|
|
|_ =bowl:gall
|
2019-11-19 06:28:59 +03:00
|
|
|
+* this .
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
|
|
|
::
|
|
|
|
++ on-init on-init:def
|
|
|
|
++ on-save !>(state)
|
|
|
|
++ on-load
|
|
|
|
|= old=vase
|
|
|
|
`this(state !<(^state old))
|
|
|
|
::
|
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
2019-11-19 07:36:21 +03:00
|
|
|
^- (quip card:agent:gall _this)
|
2019-11-19 06:28:59 +03:00
|
|
|
?. ?=(%handle-http-request mark)
|
|
|
|
(on-poke:def mark vase)
|
|
|
|
=+ !<([eyre-id=@ta =inbound-request:eyre] vase)
|
|
|
|
?> ?=(~ job.state)
|
2019-04-30 23:38:40 +03:00
|
|
|
::
|
|
|
|
=/ request-line (parse-request-line url.request.inbound-request)
|
|
|
|
=/ site (flop site.request-line)
|
|
|
|
::
|
2019-05-09 09:59:51 +03:00
|
|
|
=/ jon=json
|
|
|
|
(need (de-json:html q:(need body.request.inbound-request)))
|
|
|
|
=/ com=command:lens
|
|
|
|
(json:grab:lens-mark jon)
|
2019-07-16 01:18:28 +03:00
|
|
|
::
|
|
|
|
?: ?=(%export -.source.com)
|
|
|
|
~& [%export app.source.com]
|
2019-11-19 06:28:59 +03:00
|
|
|
:_ this(job.state (some [eyre-id com]))
|
|
|
|
[%pass /export %agent [our.bowl app.source.com] %watch /export]~
|
2019-07-16 23:52:42 +03:00
|
|
|
::
|
|
|
|
?: ?=(%import -.source.com)
|
|
|
|
?~ enc=(de:base64 base64-jam.source.com)
|
2019-11-19 06:28:59 +03:00
|
|
|
!!
|
2019-07-16 23:52:42 +03:00
|
|
|
::
|
|
|
|
=/ c=* (cue q.u.enc)
|
|
|
|
::
|
2019-11-19 06:28:59 +03:00
|
|
|
:_ this(job.state (some [eyre-id com]))
|
|
|
|
[%pass /import %agent [our.bowl app.source.com] %poke %import !>(c)]~
|
|
|
|
::
|
|
|
|
:_ this(job.state (some [eyre-id com]))
|
|
|
|
[%pass /sole %agent [our.bowl %dojo] %watch /sole/[eyre-id]]~
|
|
|
|
::
|
|
|
|
++ on-watch
|
|
|
|
|= =path
|
2019-11-19 07:36:21 +03:00
|
|
|
^- (quip card:agent:gall _this)
|
2019-11-19 06:28:59 +03:00
|
|
|
?: ?=([%http-response *] path)
|
|
|
|
`this
|
|
|
|
(on-watch:def path)
|
|
|
|
::
|
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-peek on-peek:def
|
|
|
|
++ on-agent
|
2019-11-19 07:36:21 +03:00
|
|
|
|= [=wire =sign:agent:gall]
|
|
|
|
^- (quip card:agent:gall _this)
|
2019-11-19 06:28:59 +03:00
|
|
|
|^
|
|
|
|
?+ wire (on-agent:def wire sign)
|
|
|
|
[%import ~]
|
|
|
|
?> ?=(%poke-ack -.sign)
|
|
|
|
?> ?=(^ job.state)
|
|
|
|
:_ this(job.state ~)
|
|
|
|
%+ give-simple-payload:app eyre-id.u.job.state
|
|
|
|
[[200 ~] `(as-octt:mimes:html "\"Imported data\"")]
|
|
|
|
::
|
2020-01-04 00:06:42 +03:00
|
|
|
[%export ~]
|
2019-11-19 06:28:59 +03:00
|
|
|
?+ -.sign (on-agent:def wire sign)
|
|
|
|
%watch-ack
|
|
|
|
?~ p.sign
|
|
|
|
`this
|
|
|
|
?> ?=(^ job.state)
|
|
|
|
:_ this(job.state ~)
|
|
|
|
(give-simple-payload:app eyre-id.u.job.state not-found:gen)
|
2019-08-06 02:39:52 +03:00
|
|
|
::
|
2019-11-19 06:28:59 +03:00
|
|
|
%fact
|
|
|
|
=^ cards this (take-export !<(* q.cage.sign))
|
2020-01-10 23:55:58 +03:00
|
|
|
:_ this(job.state ~)
|
|
|
|
:_ cards
|
2019-11-19 06:28:59 +03:00
|
|
|
?> ?=(^ job.state)
|
|
|
|
?> ?=(%export -.source.com.u.job.state)
|
|
|
|
[%pass /export %agent [our.bowl app.source.com.u.job.state] %leave ~]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
[%sole ~]
|
|
|
|
?+ -.sign (on-agent:def wire sign)
|
|
|
|
%watch-ack
|
|
|
|
?> ?=(^ job.state)
|
|
|
|
?^ p.sign
|
|
|
|
:_ this(job.state ~)
|
|
|
|
(give-simple-payload:app eyre-id.u.job.state not-found:gen)
|
|
|
|
:_ this :_ ~
|
|
|
|
:* %pass /sole
|
|
|
|
%agent [our.bowl %dojo]
|
|
|
|
%poke %lens-command !>
|
|
|
|
[eyre-id.u.job.state com.u.job.state]
|
|
|
|
==
|
2019-08-06 02:39:52 +03:00
|
|
|
::
|
2019-11-19 06:28:59 +03:00
|
|
|
%fact
|
|
|
|
?> ?=(%sole-effect p.cage.sign)
|
|
|
|
=^ cards this (take-sole-effect !<(sole-effect q.cage.sign))
|
|
|
|
[[[%pass /sole %agent [our.bowl %dojo] %leave ~] cards] this]
|
|
|
|
==
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ take-export
|
|
|
|
|= data=*
|
2019-11-19 07:36:21 +03:00
|
|
|
^- (quip card:agent:gall _this)
|
2019-11-19 06:28:59 +03:00
|
|
|
?> ?=(^ job.state)
|
|
|
|
?> ?=(%export -.source.com.u.job.state)
|
|
|
|
=/ app-name=tape (trip app.source.com.u.job.state)
|
|
|
|
=/ output=@t (crip "/{app-name}/jam")
|
2019-08-06 02:39:52 +03:00
|
|
|
::
|
2019-11-19 06:28:59 +03:00
|
|
|
=/ jon=json
|
|
|
|
=/ =atom (jam data)
|
|
|
|
=/ =octs [(met 3 atom) atom]
|
|
|
|
=/ enc (en:base64 octs)
|
|
|
|
(pairs:enjs:format file+s+output data+s+enc ~)
|
2019-08-06 02:39:52 +03:00
|
|
|
::
|
2020-01-10 23:55:58 +03:00
|
|
|
:_ this
|
2019-11-19 06:28:59 +03:00
|
|
|
%+ give-simple-payload:app eyre-id.u.job.state
|
|
|
|
(json-response:gen (json-to-octs jon))
|
|
|
|
::
|
|
|
|
++ take-sole-effect
|
|
|
|
|= fec=sole-effect
|
2019-11-19 07:36:21 +03:00
|
|
|
^- (quip card:agent:gall _this)
|
2019-11-19 06:28:59 +03:00
|
|
|
=/ out
|
|
|
|
|- ^- (unit lens-out)
|
|
|
|
=* loop $
|
|
|
|
?+ -.fec
|
|
|
|
~
|
|
|
|
::
|
|
|
|
%tan
|
|
|
|
%- some
|
|
|
|
:- %json
|
|
|
|
%- wall:enjs:format
|
|
|
|
(turn (flop p.fec) |=(=tank ~(ram re tank)))
|
|
|
|
::
|
|
|
|
%txt
|
|
|
|
(some %json s+(crip p.fec))
|
2019-08-06 02:39:52 +03:00
|
|
|
::
|
2019-11-19 06:28:59 +03:00
|
|
|
%sag
|
|
|
|
%- some
|
|
|
|
[%mime p.fec (as-octs:mimes:html (jam q.fec))]
|
|
|
|
::
|
|
|
|
%sav
|
|
|
|
:: XX use +en:base64 or produce %mime a la %sag
|
|
|
|
::
|
|
|
|
%- some
|
|
|
|
:- %json
|
|
|
|
%- pairs:enjs:format
|
|
|
|
:~ file+s+(crip <`path`p.fec>)
|
|
|
|
data+s+(crip (en-base64:mimes:html q.fec))
|
|
|
|
==
|
|
|
|
::
|
|
|
|
%mor
|
|
|
|
=/ all `(list lens-out)`(murn p.fec |=(a=sole-effect loop(fec a)))
|
|
|
|
?~ all ~
|
|
|
|
~| [%multiple-effects all]
|
|
|
|
?> ?=(~ t.all)
|
|
|
|
(some i.all)
|
2019-08-06 02:39:52 +03:00
|
|
|
==
|
|
|
|
::
|
2019-11-19 06:28:59 +03:00
|
|
|
?~ out
|
|
|
|
[~ this]
|
|
|
|
::
|
|
|
|
?> ?=(^ job.state)
|
|
|
|
:_ this(job.state ~)
|
|
|
|
%+ give-simple-payload:app eyre-id.u.job.state
|
|
|
|
?- -.u.out
|
|
|
|
%json
|
|
|
|
(json-response:gen (json-to-octs json.u.out))
|
|
|
|
::
|
|
|
|
%mime
|
|
|
|
=/ headers
|
|
|
|
:~ ['content-type' 'application/octet-stream']
|
2019-08-06 02:39:52 +03:00
|
|
|
?> ?=([@ @ ~] p.mime.u.out)
|
|
|
|
:- 'content-disposition'
|
|
|
|
^- @t
|
|
|
|
%^ cat 3
|
|
|
|
'attachment; filename='
|
|
|
|
(rap 3 '"' i.p.mime.u.out '.' i.t.p.mime.u.out '"' ~)
|
|
|
|
==
|
2019-11-19 06:28:59 +03:00
|
|
|
[[200 headers] (some q.mime.u.out)]
|
2019-07-16 23:52:42 +03:00
|
|
|
==
|
2019-11-19 06:28:59 +03:00
|
|
|
--
|
2019-04-30 23:38:40 +03:00
|
|
|
::
|
2019-11-19 06:28:59 +03:00
|
|
|
++ on-arvo
|
|
|
|
|= [=wire =sign-arvo]
|
2019-11-19 07:36:21 +03:00
|
|
|
^- (quip card:agent:gall _this)
|
2019-11-19 06:28:59 +03:00
|
|
|
?. ?=(%bound +<.sign-arvo)
|
|
|
|
(on-arvo:def wire sign-arvo)
|
2019-04-30 23:38:40 +03:00
|
|
|
[~ this]
|
|
|
|
::
|
2019-11-19 06:28:59 +03:00
|
|
|
++ on-fail on-fail:def
|
2019-04-30 23:38:40 +03:00
|
|
|
--
|