<commit_before>
import * as rev from 'rev-models';
import * as api from '../index';

// EXAMPLE:
// import * as rev from 'rev-models'

export class Person {

    @rev.TextField({label: 'First Name'})
        first_name: string;
    @rev.TextField({label: 'Last Name'})
        last_name: string;
    @rev.IntegerField({label: 'Age', required: false })
        age: number;
    @rev.EmailField({label: 'Email'})
        email: string;
    @rev.BooleanField({label: 'Registered for Newsletter?'})
        newsletter: boolean;
    @rev.BooleanField({label: 'Date Registered'})
        date_registered: Date;
}

rev.register(Person);

api.register(Person, {
    operations: ['read'],
    methods: [
        {
           name: 'unsubscribe',
           args: ['email'],
           handler: async (context, email) => {
               console.log('Unsubscribe requested for', email);
               return 'Unsubscribed';
           }
        }
    ]
});
<commit_msg>Add further api method example using field object args<commit_after>
import * as rev from 'rev-models';
import * as api from '../index';

// EXAMPLE:
// import * as rev from 'rev-models';
// import * as api from 'rev-api';

export class Person {

    @rev.TextField({label: 'First Name'})
        first_name: string;
    @rev.TextField({label: 'Last Name'})
        last_name: string;
    @rev.IntegerField({label: 'Age', required: false })
        age: number;
    @rev.EmailField({label: 'Email'})
        email: string;
    @rev.BooleanField({label: 'Registered for Newsletter?'})
        newsletter: boolean;
    @rev.BooleanField({label: 'Date Registered'})
        date_registered: Date;
}

rev.register(Person);

api.register(Person, {
    operations: ['read'],
    methods: [
        {
           name: 'unsubscribe',
           args: ['email'],
           handler: async (context, email) => {
               console.log('Unsubscribe requested for', email);
               return 'Unsubscribed';
           }
        },
        {
            name: 'randomMember',
            args: [
                new rev.fields.TextField('name'),
                new rev.fields.IntegerField('minAge', {minValue: 16})
            ],
            handler: async (context, name) => {
               console.log('Getting a random member named', name);
               return {
                   first_name: 'Bob',
                   age: 21
               };
           }
        }
    ]
});

{'fraction_non_alphanumeric': 0.1429156429156429, 'fraction_numerical': 0.001638001638001638, 'mean_word_length': 1.9975460122699387, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1213013', 'n_tokens_mistral': 706, 'n_tokens_neox': 688, 'n_words': 177}