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

/**
 * Field schema for IamTenant, derived from cliter/iam/tenant.aurora.yaml.
 * Used by @Sanitize decorator, @Format decorator and @ApplySchema decorator.
 */
export const IamTenantFieldSchema: FieldSchema[] = [
  {
    name: 'id',
    type: 'id',
    nullable: false,
    maxLength: 36,
  },
  {
    name: 'parentId',
    type: 'id',
    nullable: true,
    maxLength: 36,
  },
  {
    name: 'parent',
    type: 'relation',
    cardinality: 'one',
    target: () => IamTenantFieldSchema,
  },
  {
    name: 'name',
    type: 'varchar',
    nullable: false,
    maxLength: 128,
    rules: { minLength: 1 },
  },
  {
    name: 'code',
    type: 'varchar',
    nullable: true,
    maxLength: 64,
  },
  {
    name: 'logo',
    type: 'jsonb',
    nullable: true,
  },
  {
    name: 'isActive',
    type: 'boolean',
    nullable: false,
  },
  {
    name: 'meta',
    type: 'jsonb',
    nullable: true,
  },
  {
    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,
  },
];
