@xompass/sdk-cloud-api
Version:
Xompass Client for cloud-api
134 lines (128 loc) • 2.85 kB
text/typescript
import {ModelDefinition} from './BaseModels';
import {Log} from './Log';
import {AssetType} from './AssetType';
declare var Object: any;
export interface ToolInterface {
name?: string;
description?: string;
logo?: string;
icon?: string;
module: string;
created?: Date;
modified?: Date;
deleted?: Date;
id?: any;
assetTypeIds?: Array<any>;
trackingLogs?: Log[];
assetTypes?: AssetType[];
}
export class Tool implements ToolInterface {
name: string;
description: string;
logo: string;
icon: string;
module: string;
created: Date;
modified: Date;
deleted: Date;
id: any;
assetTypeIds: Array<any> = [];
trackingLogs?: Log[];
assetTypes?: AssetType[];
constructor(data?: ToolInterface) {
Object.assign(this, data);
}
/**
* The name of the model represented by this $resource,
* i.e. `Tool`.
*/
public static getModelName(): string {
return 'Tool';
}
/**
* @method factory
* @author Jonathan Casarrubias
* @license MIT
* This method creates an instance of Tool for dynamic purposes.
*/
public static factory(data: ToolInterface): Tool{
return new Tool(data);
}
/**
* @method getModelDefinition
* @author Julien Ledun
* @license MIT
* This method returns an object that represents some of the model
* definitions.
*/
public static getModelDefinition(): ModelDefinition {
return {
name: 'Tool',
plural: 'Tools',
path: 'Tools',
idName: 'id',
properties: {
name: {
name: 'name',
type: 'string'
},
description: {
name: 'description',
type: 'string'
},
logo: {
name: 'logo',
type: 'string'
},
icon: {
name: 'icon',
type: 'string'
},
module: {
name: 'module',
type: 'string'
},
created: {
name: 'created',
type: 'Date'
},
modified: {
name: 'modified',
type: 'Date'
},
deleted: {
name: 'deleted',
type: 'Date',
default: undefined
},
id: {
name: 'id',
type: 'any'
},
assetTypeIds: {
name: 'assetTypeIds',
type: 'Array<any>',
default: []
},
},
relations: {
trackingLogs: {
name: 'trackingLogs',
type: 'Log[]',
model: 'Log',
relationType: 'hasMany',
keyFrom: 'id',
keyTo: 'trackingModelId'
},
assetTypes: {
name: 'assetTypes',
type: 'AssetType[]',
model: 'AssetType',
relationType: 'referencesMany',
keyFrom: 'assetTypeIds',
keyTo: 'id'
},
}
};
}
}