import { BaseModel } from './base.model'; export class ObjectDefinition extends BaseModel { static tableName = 'object_definitions'; id: string; apiName: string; label: string; pluralLabel?: string; description?: string; isSystem: boolean; isCustom: boolean; orgWideDefault: 'private' | 'public_read' | 'public_read_write'; createdAt: Date; updatedAt: Date; fields?: any[]; rolePermissions?: any[]; static get jsonSchema() { return { type: 'object', required: ['apiName', 'label'], properties: { id: { type: 'string' }, apiName: { type: 'string' }, label: { type: 'string' }, pluralLabel: { type: 'string' }, description: { type: 'string' }, isSystem: { type: 'boolean' }, isCustom: { type: 'boolean' }, orgWideDefault: { type: 'string', enum: ['private', 'public_read', 'public_read_write'] }, }, }; } static get relationMappings() { const { FieldDefinition } = require('./field-definition.model'); const { RoleObjectPermission } = require('./role-object-permission.model'); return { fields: { relation: BaseModel.HasManyRelation, modelClass: FieldDefinition, join: { from: 'object_definitions.id', to: 'field_definitions.objectDefinitionId', }, }, rolePermissions: { relation: BaseModel.HasManyRelation, modelClass: RoleObjectPermission, join: { from: 'object_definitions.id', to: 'role_object_permissions.objectDefinitionId', }, }, }; } }