/**
 * @aurora-catalyst-generated
 * @source cliter/iam/permission.aurora.yaml
 */
import { IamBoundedContextFieldSchema } from '@app/iam/bounded-context';
import { IamRoleFieldSchema } from '@app/iam/role';
import { FieldSchema } from '@aurorajs.dev/core-back';

/**
 * Field schema for IamPermission, derived from cliter/iam/permission.aurora.yaml.
 * Used by @Sanitize decorator, @Format decorator and @ApplySchema decorator.
 */
export const IamPermissionFieldSchema: FieldSchema[] = [
  {
    name: 'id',
    type: 'id',
    nullable: false,
    maxLength: 36,
  },
  {
    name: 'name',
    type: 'varchar',
    nullable: false,
    maxLength: 128,
    rules: { minLength: 1 },
  },
  {
    name: 'boundedContextId',
    type: 'id',
    nullable: false,
    maxLength: 36,
  },
  {
    name: 'boundedContext',
    type: 'relation',
    cardinality: 'one',
    target: () => IamBoundedContextFieldSchema,
  },
  {
    name: 'roles',
    type: 'relation',
    cardinality: 'many',
    target: () => IamRoleFieldSchema,
  },
  {
    name: 'createdAt',
    type: 'timestamp',
    nullable: true,
  },
  {
    name: 'updatedAt',
    type: 'timestamp',
    nullable: true,
  },
  {
    name: 'deletedAt',
    type: 'timestamp',
    nullable: true,
  },
];
