ures;
use Scalar::Util qw( blessed );
use Yancy::Util qw( load_backend );
use Mojo::JSON qw( encode_json decode_json );
use Mojo::Loader qw( find_modules load_class );
use Mojo::File qw( curfile );
us
# XXX: Make Yancy support this basic CRUD with relationships?
# XXX: Otherwise, add custom JSON API
$self->routes->get( '/plan/create' )
->to( 'plan#edit_plan' )->name( 'zapp.create
'task_id' } ),
];
for my $task ( @$tasks ) {
$task->{input} = decode_json( $task->{input} );
}
my $inputs = $plan->{inputs} = [
$self->yancy->
ken
#pod
#pod =head1 SEE ALSO
#pod
#pod =cut
use Mojo::Base 'Zapp::Task', -signatures;
use Mojo::JSON qw( false true );
use Mojo::Util qw( b64_encode );
sub schema( $class ) {
return {
i
response will be a JSON document. On success (200 OK) it will contain
# the token. On failure (400 Bad Request) it will describe the
# error.
my $json = $tx->res->json;
my %output = (
if ( $output{is_success} ) {
return $self->finish({
%output,
$json->%{qw( access_token token_type expires_in refresh_token )},
# If scope is omitted, it
t
#pod and an output template to display its output. Task input and output are
#pod declared with JSON Schema (see the L</schema> method), and input will be
#pod processed with L<Zapp::Formula> before
e 'Minion::Job', -signatures;
use List::Util qw( uniq );
use Time::Piece;
use Mojo::JSON qw( decode_json encode_json );
use Zapp::Util qw( get_path_from_data get_path_from_schema );
use Yancy::Util qw
cessible from
# $self->app->zapp->run()
has _context => sub( $self ) {
my $run_input = decode_json( $self->zapp_run->{ input } );
my %context;
for my $input ( @$run_input ) {
my $t
ALSO
#pod
#pod L<Zapp>
#pod
#pod =cut
use Mojo::Base -base, -signatures;
use Mojo::JSON qw( decode_json encode_json );
use Scalar::Util qw( blessed );
use Mojo::Loader qw( data_section );
#pod =attr
{state} //= "inactive";
# XXX: Auto-encode JSON in Yancy
$data->{config} = encode_json( $data->{config} // {} );
$data->{input} = encode_json( $data->{input} // {} );
return $self->ap
, $trigger_id, $data ) {
# XXX: Auto-encode JSON in Yancy
$data->{config} &&= encode_json( $data->{config} );
$data->{input} &&= encode_json( $data->{input} );
return $self->app->yancy
package Test::Zapp;
use Mojo::Base 'Test::Mojo';
use Mojo::JSON qw( encode_json );
use Mojo::File qw( tempdir );
use Mojo::Home;
use Zapp;
use Scalar::Util qw( blessed );
use Test::More;
sub new {
name => $task_class,
class => $task_class,
input => encode_json( $input ),
},
],
inputs => $context,
});
my $run = $self->{za
lot;
}
#pod =sub get_path_from_schema
#pod
#pod Get the schema for a given path out of the given JSON Schema. Will traverse
#pod object C<properties> and array C<items> to find the schema.
#pod
#pod
of the given data.
=head2 get_path_from_schema
Get the schema for a given path out of the given JSON Schema. Will traverse
object C<properties> and array C<items> to find the schema.
=head2 prefix_
od =head1 SEE ALSO
#pod
#pod =cut
use Mojo::Base 'Zapp::Trigger', -signatures;
use Mojo::JSON qw( decode_json );
use Scalar::Util qw( blessed );
use Yancy::Util qw( currym );
sub install( $self, $ap
$hook;
# XXX: Yancy has no JSON query capability...
for my $h ( $c->yancy->list( zapp_triggers => { type => $self->moniker } ) ) {
# XXX: Auto-decode JSON fields in Yancy
my $c
- The HTTP message (like "OK" or "Not Found")
#pod json - If the response was JSON, the decoded JSON structure
#pod file - If the response was a file
=head1 SEE ALSO
#pod
#pod =cut
use Mojo::Base 'Zapp::Task', -signatures;
use Mojo::JSON qw( false true encode_json );
sub schema( $class ) {
return {
input => {
type => 'obj
type => 'string',
enum => ['', qw( application/octet-stream application/json )],
default => '',
},
# XXX: Query params / F
::Controller::Run;
use Mojo::Base 'Mojolicious::Controller', -signatures;
use Mojo::JSON qw( decode_json encode_json );
use Mojo::Loader qw( data_section );
use Time::Piece;
use Zapp::Task;
use Zapp::
app_runs => $run_id ) || {};
my $input = decode_json( $run->{input} );
my %context = (
(
map { $_->{name} => decode_json( $_->{output} ) }
grep { $_->{state} eq
$task ( @tasks ) {
$task->{input} = decode_json( $task->{input} );
if ( $task->{output} ) {
$task->{output} = decode_json( $task->{output} );
}
if ( $task-
rigger management
use Mojo::Base 'Mojolicious::Controller', -signatures;
use Mojo::JSON qw( decode_json encode_json );
use Zapp::Util qw( build_data_from_params );
#pod =method edit
#pod
#pod Create
aram( 'plan_id' ),
};
}
# XXX: Auto-decode JSON in Yancy
$trigger->{config} &&= decode_json( $trigger->{config} );
my $plan = $self->app->get_plan( $trigge
);
}
my $trigger = build_data_from_params( $self );
$trigger->{$_} &&= encode_json( $trigger->{$_} ) for qw( config input );
my $trigger_id = $self->param( 'trigger_id' );
:Controller::Plan;
use Mojo::Base 'Mojolicious::Controller', -signatures;
use Mojo::JSON qw( decode_json encode_json );
use List::Util qw( uniqstr );
use Zapp::Util qw( build_data_from_params );
# Za
# XXX: Auto-encode/-decode JSON fields in Yancy schema
for my $json_field ( qw( input ) ) {
$task->{ $json_field } = encode_json( $task->{ $json_field } );
}
: Auto-encode/-decode JSON fields in Yancy schema
for my $json_field ( qw( value config ) ) {
$form_input->{ $json_field } = encode_json( $form_input->{ $json_field } );
}
FALSE()
#pod
#pod Returns a false value.
#pod
#pod =cut
sub _func_false( $f ) {
return Mojo::JSON->false;
}
#pod =head3 IF
#pod
#pod =IF( <expression>, <true_result>, <false_result> )
#pod
#
=TRUE()
#pod
#pod Returns a true value.
#pod
#pod =cut
sub _func_true( $f ) {
return Mojo::JSON->true;
}
#pod =head3 XOR
#pod
#pod =XOR( <expression>... )
#pod
#pod Returns C<TRUE> if one