/**
 * @aurora-catalyst-generated
 * @source cliter/iam/role.aurora.yaml
 */
import { IamAccountFieldSchema } from '@app/iam/account';
import { IamPermissionFieldSchema } from '@app/iam/permission';
import { FieldSchema } from '@aurorajs.dev/core-back';

/**
 * Field schema for IamRole, derived from cliter/iam/role.aurora.yaml.
 * Used by @Sanitize decorator, @Format decorator and @ApplySchema decorator.
 */
export const IamRoleFieldSchema: FieldSchema[] = [
  {
    name: 'id',
    type: 'id',
    nullable: false,
    maxLength: 36,
  },
  {
    name: 'name',
    type: 'varchar',
    nullable: false,
    maxLength: 128,
    rules: { minLength: 1 },
  },
  {
    name: 'code',
    type: 'varchar',
    nullable: true,
    maxLength: 64,
  },
  {
    name: 'defaultRedirection',
    type: 'varchar',
    nullable: true,
    maxLength: 2046,
  },
  {
    name: 'hasHiddenVerticalNavigation',
    type: 'boolean',
    nullable: true,
  },
  {
    name: 'isMaster',
    type: 'boolean',
    nullable: false,
  },
  {
    name: 'permissions',
    type: 'relation',
    cardinality: 'many',
    target: () => IamPermissionFieldSchema,
  },
  {
    name: 'accounts',
    type: 'relation',
    cardinality: 'many',
    target: () => IamAccountFieldSchema,
  },
  {
    name: 'createdAt',
    type: 'timestamp',
    nullable: true,
  },
  {
    name: 'updatedAt',
    type: 'timestamp',
    nullable: true,
  },
  {
    name: 'deletedAt',
    type: 'timestamp',
    nullable: true,
  },
];
