2019-08-06 02:39:52 +03:00
|
|
|
/- lens, *sole
|
|
|
|
/+ base64, *server
|
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]
|
|
|
|
==
|
|
|
|
:: +move: output effect
|
2019-04-30 23:38:40 +03:00
|
|
|
::
|
|
|
|
+$ move [bone card]
|
2019-08-06 02:39:52 +03:00
|
|
|
:: +card: output effect payload
|
2019-04-30 23:38:40 +03:00
|
|
|
::
|
|
|
|
+$ card
|
2019-07-04 09:09:44 +03:00
|
|
|
$% [%connect wire binding:eyre term]
|
2019-04-30 23:38:40 +03:00
|
|
|
[%http-response =http-event:http]
|
2019-07-16 02:43:38 +03:00
|
|
|
[%peer wire dock path]
|
2019-08-06 02:39:52 +03:00
|
|
|
[%peer wire dock path]
|
2019-04-30 23:38:40 +03:00
|
|
|
[%poke wire dock poke]
|
2019-05-09 09:59:51 +03:00
|
|
|
[%pull wire dock ~]
|
2019-04-30 23:38:40 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ poke
|
2019-05-09 09:59:51 +03:00
|
|
|
$% [%lens-command command:lens]
|
2019-07-16 23:52:42 +03:00
|
|
|
[%import *]
|
2019-04-30 23:38:40 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
+$ state
|
2019-05-09 09:59:51 +03:00
|
|
|
$% $: %0
|
|
|
|
job=(unit [=bone com=command:lens])
|
2019-04-30 23:38:40 +03:00
|
|
|
==
|
|
|
|
==
|
|
|
|
::
|
|
|
|
--
|
|
|
|
::
|
2019-05-09 09:59:51 +03:00
|
|
|
|_ [bow=bowl:gall state=state]
|
2019-04-30 23:38:40 +03:00
|
|
|
::
|
|
|
|
++ this .
|
|
|
|
::
|
|
|
|
++ prep
|
|
|
|
|= old=(unit *)
|
|
|
|
^- (quip move _this)
|
|
|
|
[~ this]
|
|
|
|
::
|
|
|
|
:: alerts us that we were bound. we need this because the vane calls back.
|
|
|
|
::
|
|
|
|
++ bound
|
2019-07-04 09:09:44 +03:00
|
|
|
|= [wir=wire success=? binding=binding:eyre]
|
2019-04-30 23:38:40 +03:00
|
|
|
^- (quip move _this)
|
|
|
|
[~ this]
|
|
|
|
::
|
|
|
|
++ poke-handle-http-request
|
|
|
|
%- (require-authorization:app ost.bow move this)
|
2019-07-04 09:09:44 +03:00
|
|
|
|= =inbound-request:eyre
|
2019-04-30 23:38:40 +03:00
|
|
|
^- (quip move _this)
|
2019-07-19 20:27:11 +03:00
|
|
|
::
|
2019-05-09 09:59:51 +03:00
|
|
|
?^ job.state
|
|
|
|
:_ this
|
|
|
|
[ost.bow %http-response %start [%500 ~] ~ %.y]~
|
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-07-16 23:52:42 +03:00
|
|
|
:_ this(job.state (some [ost.bow com]))
|
2019-07-16 20:40:11 +03:00
|
|
|
[ost.bow %peer /export [our.bow app.source.com] /export]~
|
2019-07-16 23:52:42 +03:00
|
|
|
::
|
|
|
|
?: ?=(%import -.source.com)
|
|
|
|
?~ enc=(de:base64 base64-jam.source.com)
|
|
|
|
:_ this
|
|
|
|
[ost.bow %http-response %start [%500 ~] ~ %.y]~
|
|
|
|
::
|
|
|
|
=/ c=* (cue q.u.enc)
|
|
|
|
::
|
|
|
|
:_ this(job.state (some [ost.bow com]))
|
|
|
|
[ost.bow %poke /import [our.bow app.source.com] %import c]~
|
|
|
|
::
|
|
|
|
:_ this(job.state (some [ost.bow com]))
|
2019-08-06 02:39:52 +03:00
|
|
|
[ost.bow %peer /sole [our.bow %dojo] /sole]~
|
2019-05-09 09:59:51 +03:00
|
|
|
::
|
2019-08-06 02:39:52 +03:00
|
|
|
++ diff-sole-effect
|
|
|
|
|= [=wire fec=sole-effect]
|
2019-05-09 09:59:51 +03:00
|
|
|
^- (quip move _this)
|
2019-08-06 02:39:52 +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))
|
|
|
|
::
|
|
|
|
%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)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
?~ out
|
2019-05-09 09:59:51 +03:00
|
|
|
[~ this]
|
|
|
|
?> ?=(^ job.state)
|
|
|
|
:_ this(job.state ~)
|
2019-08-06 02:39:52 +03:00
|
|
|
:_ ~
|
|
|
|
:+ bone.u.job.state
|
|
|
|
%http-response
|
|
|
|
?- -.u.out
|
|
|
|
%json
|
|
|
|
(json-response:app (json-to-octs json.u.out))
|
|
|
|
::
|
|
|
|
%mime
|
|
|
|
:* %start
|
|
|
|
:~ 200
|
|
|
|
['content-type' 'application/octet-stream']
|
|
|
|
?> ?=([@ @ ~] p.mime.u.out)
|
|
|
|
:- 'content-disposition'
|
|
|
|
^- @t
|
|
|
|
%^ cat 3
|
|
|
|
'attachment; filename='
|
|
|
|
(rap 3 '"' i.p.mime.u.out '.' i.t.p.mime.u.out '"' ~)
|
|
|
|
==
|
|
|
|
(some q.mime.u.out)
|
|
|
|
%.y
|
|
|
|
==
|
|
|
|
==
|
2019-05-09 09:59:51 +03:00
|
|
|
::
|
2019-07-16 02:43:38 +03:00
|
|
|
++ diff-export
|
|
|
|
|= [=wire data=*]
|
|
|
|
^- (quip move _this)
|
|
|
|
::
|
|
|
|
?> ?=(^ job.state)
|
2019-07-19 20:27:11 +03:00
|
|
|
:: herb will do whatever we tell it to, so by convention have it write to an
|
|
|
|
:: app name based on the file name.
|
2019-07-16 02:43:38 +03:00
|
|
|
::
|
2019-07-16 20:40:11 +03:00
|
|
|
?> ?=(%export -.source.com.u.job.state)
|
|
|
|
=/ app-name=tape (trip app.source.com.u.job.state)
|
|
|
|
=/ output=@t (crip "/{app-name}/jam")
|
2019-07-16 02:43:38 +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 ~)
|
|
|
|
::
|
|
|
|
:_ this(job.state ~)
|
2019-07-22 20:48:45 +03:00
|
|
|
:~ [bone.u.job.state %http-response (json-response:app (json-to-octs jon))]
|
|
|
|
[ost.bow %pull /export [our.bow app.source.com.u.job.state] ~]
|
|
|
|
==
|
2019-07-16 02:43:38 +03:00
|
|
|
::
|
2019-05-09 09:59:51 +03:00
|
|
|
++ quit
|
|
|
|
|= =wire
|
|
|
|
^- (quip move _this)
|
|
|
|
~& [%quit wire]
|
|
|
|
[~ this]
|
|
|
|
::
|
|
|
|
++ reap
|
|
|
|
|= [=wire saw=(unit tang)]
|
|
|
|
^- (quip move _this)
|
2019-07-23 23:43:42 +03:00
|
|
|
::
|
2019-07-16 20:40:11 +03:00
|
|
|
?: =([%export ~] wire)
|
|
|
|
[~ this]
|
|
|
|
::
|
2019-05-09 09:59:51 +03:00
|
|
|
?^ saw
|
|
|
|
[((slog u.saw) ~) this]
|
|
|
|
?> ?=(^ job.state)
|
2019-04-30 23:38:40 +03:00
|
|
|
:_ this
|
2019-05-09 09:59:51 +03:00
|
|
|
:~ [ost.bow %poke /sole [our.bow %dojo] %lens-command com.u.job.state]
|
2019-08-06 02:39:52 +03:00
|
|
|
:: XX move to +diff-sole-effect?
|
|
|
|
::
|
2019-05-09 09:59:51 +03:00
|
|
|
[ost.bow %pull /sole [our.bow %dojo] ~]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ coup
|
|
|
|
|= [=wire saw=(unit tang)]
|
|
|
|
^- (quip move _this)
|
2019-07-23 23:43:42 +03:00
|
|
|
::
|
2019-07-16 23:52:42 +03:00
|
|
|
?: =([%import ~] wire)
|
|
|
|
?> ?=(^ job.state)
|
|
|
|
:_ this(job.state ~)
|
|
|
|
:_ ~
|
|
|
|
:* bone.u.job.state
|
|
|
|
%http-response
|
|
|
|
%start
|
|
|
|
[%200 ~]
|
|
|
|
[~ (as-octt:mimes:html "\"Imported data\"")]
|
|
|
|
%.y
|
|
|
|
==
|
|
|
|
::
|
2019-05-09 09:59:51 +03:00
|
|
|
?^ saw
|
|
|
|
[((slog u.saw) ~) this]
|
|
|
|
[~ this]
|
2019-04-30 23:38:40 +03:00
|
|
|
::
|
|
|
|
:: +poke-handle-http-cancel: received when a connection was killed
|
|
|
|
::
|
|
|
|
++ poke-handle-http-cancel
|
2019-07-04 09:09:44 +03:00
|
|
|
|= =inbound-request:eyre
|
2019-04-30 23:38:40 +03:00
|
|
|
^- (quip move _this)
|
|
|
|
:: the only long lived connections we keep state about are the stream ones.
|
|
|
|
::
|
|
|
|
[~ this]
|
|
|
|
::
|
|
|
|
++ poke-noun
|
|
|
|
|= a=*
|
|
|
|
^- (quip move _this)
|
|
|
|
~& poke+a
|
|
|
|
[~ this]
|
|
|
|
::
|
|
|
|
--
|