/**
 * @aurora-catalyst-generated
 * @source cliter/o-auth/client.aurora.yaml
 */
import { OAuthAccessTokenFieldSchema } from '@app/o-auth/access-token';
import { OAuthApplicationFieldSchema } from '@app/o-auth/application';
import { FieldSchema } from '@aurorajs.dev/core-back';

/**
 * Field schema for OAuthClient, derived from cliter/o-auth/client.aurora.yaml.
 * Used by @Sanitize decorator, @Format decorator and @ApplySchema decorator.
 */
export const OAuthClientFieldSchema: FieldSchema[] = [
  {
    name: 'id',
    type: 'id',
    nullable: false,
    maxLength: 36,
  },
  {
    name: 'grantType',
    type: 'enum',
    nullable: false,
    enumOptions: ['AUTHORIZATION_CODE', 'CLIENT_CREDENTIALS', 'PASSWORD', 'REFRESH_TOKEN'],
  },
  {
    name: 'applications',
    type: 'relation',
    cardinality: 'many',
    target: () => OAuthApplicationFieldSchema,
  },
  {
    name: 'scopeOptions',
    type: 'array',
    nullable: true,
  },
  {
    name: 'name',
    type: 'varchar',
    nullable: false,
    maxLength: 128,
    rules: { minLength: 1 },
  },
  {
    name: 'isMaster',
    type: 'boolean',
    nullable: false,
  },
  {
    name: 'secret',
    type: 'varchar',
    nullable: false,
    maxLength: 128,
    rules: { minLength: 1 },
  },
  {
    name: 'authUrl',
    type: 'varchar',
    nullable: true,
    maxLength: 2046,
  },
  {
    name: 'redirect',
    type: 'varchar',
    nullable: true,
    maxLength: 2046,
  },
  {
    name: 'accessTokenLifetimeSeconds',
    type: 'int',
    nullable: true,
  },
  {
    name: 'refreshTokenLifetimeSeconds',
    type: 'int',
    nullable: true,
  },
  {
    name: 'isActive',
    type: 'boolean',
    nullable: false,
  },
  {
    name: 'accessTokens',
    type: 'relation',
    cardinality: 'many',
    target: () => OAuthAccessTokenFieldSchema,
  },
  {
    name: 'createdAt',
    type: 'timestamp',
    nullable: true,
  },
  {
    name: 'updatedAt',
    type: 'timestamp',
    nullable: true,
  },
  {
    name: 'deletedAt',
    type: 'timestamp',
    nullable: true,
  },
];
