<commit_before>import {Record, Schema} from 'js-data';

import {Cluster} from './cluster';
import {Membership} from './membership';
import * as _ from 'lodash';

export class User extends Record {
    public id: number;
    public photo;
    public clusters_id:number[];
    public last_login: Date;
    public email: string;
    public lastname: string;
    public firstname: string;
    public phone: string;
    public is_active: boolean;
    public last_modified: Date;
    public join_date: Date;

    // Relational fields
    public clusters: number[]; // clusters ids returned by REST API
    public user_clusters: UserCluster[]; // client-side only relational objects 'user_cluster'
    public memberships:Membership[];

    constructor (props?) {
        super(props);
        this.last_login = new Date();
        this.last_modified = new Date();
        this.join_date = new Date();
    }

    // Returns the clusters list as JSData Records list
    public getClusters(): Cluster[] {
        return _.reduce(this.user_clusters, c => c['cluster'], []);
    }
}

export class UserCluster extends Record {
    public user_id: number;
    public cluster_id: number;
    public user: User;
    public cluster: Cluster;

    constructor(props) {
        super(props);
    }
}

export const userSchema = new Schema({
    properties: {
        id: {type: 'integer'},
        clusters_id : {type : 'array', items: {type: 'integer'}},
        lastname: {type: 'string'},
        firstname: {type: 'string'},
        email: {type: 'string', format: 'email'},
        phone: {type: 'string'},
        is_active: {type: 'boolean'},
        last_login: {type: 'string', format: 'date-time'},
        last_modified: {type: 'string', format: 'date-time'},
        join_date: {type: 'string', format: 'date-time'}
    }
});

export const userRelations = {
    hasMany: {
        user_cluster: {
            foreignKey: 'user_id',
            localField: 'user_clusters'
        },
        membership: {
            foreignKey: 'user_id',
            localField: 'memberships'
        }
    }
};

export const userActions = {
    'me': {
        adapter: 'http',
        pathname: 'me',
        response: (u) => { return new User(u.data); }
    }
};<commit_msg>Bugfix : typescript semantic error solved by enforcing type<commit_after>import {Record, Schema} from 'js-data';
import {IActionOpts} from 'js-data-http';

import {Cluster} from './cluster';
import {Membership} from './membership';
import * as _ from 'lodash';

export class User extends Record {
    public id: number;
    public photo;
    public clusters_id:number[];
    public last_login: Date;
    public email: string;
    public lastname: string;
    public firstname: string;
    public phone: string;
    public is_active: boolean;
    public last_modified: Date;
    public join_date: Date;

    // Relational fields
    public clusters: number[]; // clusters ids returned by REST API
    public user_clusters: UserCluster[]; // client-side only relational objects 'user_cluster'
    public memberships:Membership[];

    constructor (props?) {
        super(props);
        this.last_login = new Date();
        this.last_modified = new Date();
        this.join_date = new Date();
    }

    // Returns the clusters list as JSData Records list
    public getClusters(): Cluster[] {
        return _.reduce(this.user_clusters, c => c['cluster'], []);
    }
}

export class UserCluster extends Record {
    public user_id: number;
    public cluster_id: number;
    public user: User;
    public cluster: Cluster;

    constructor(props) {
        super(props);
    }
}

export const userSchema = new Schema({
    properties: {
        id: {type: 'integer'},
        clusters_id : {type : 'array', items: {type: 'integer'}},
        lastname: {type: 'string'},
        firstname: {type: 'string'},
        email: {type: 'string', format: 'email'},
        phone: {type: 'string'},
        is_active: {type: 'boolean'},
        last_login: {type: 'string', format: 'date-time'},
        last_modified: {type: 'string', format: 'date-time'},
        join_date: {type: 'string', format: 'date-time'}
    }
});

export const userRelations = {
    hasMany: {
        user_cluster: {
            foreignKey: 'user_id',
            localField: 'user_clusters'
        },
        membership: {
            foreignKey: 'user_id',
            localField: 'memberships'
        }
    }
};

export const userActions : { [key: string]: IActionOpts; } = {
    'me': {
        adapter: 'http',
        pathname: 'me',
        response: (u) => { return new User(u.data); }
    }
};
{'fraction_non_alphanumeric': 0.13218142548596112, 'fraction_numerical': 0.0, 'mean_word_length': 2.6151444184231067, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '3075324', 'n_tokens_mistral': 1364, 'n_tokens_neox': 1351, 'n_words': 402}