/**
 * @aurora-catalyst-generated
 * @source cliter/o-auth/authorization-code.aurora.yaml
 */
import { OAuthClientFieldSchema } from '@app/o-auth/client';
import { FieldSchema } from '@aurorajs.dev/core-back';

/**
 * Field schema for OAuthAuthorizationCode, derived from cliter/o-auth/authorization-code.aurora.yaml.
 * Used by @Sanitize decorator, @Format decorator and @ApplySchema decorator.
 */
export const OAuthAuthorizationCodeFieldSchema: FieldSchema[] = [
  {
    name: 'id',
    type: 'id',
    nullable: false,
    maxLength: 36,
  },
  {
    name: 'code',
    type: 'varchar',
    nullable: false,
    maxLength: 64,
    rules: { minLength: 1 },
  },
  {
    name: 'clientId',
    type: 'id',
    nullable: false,
    maxLength: 36,
  },
  {
    name: 'client',
    type: 'relation',
    cardinality: 'one',
    target: () => OAuthClientFieldSchema,
  },
  {
    name: 'accountId',
    type: 'id',
    nullable: false,
    maxLength: 36,
  },
  {
    name: 'redirectUri',
    type: 'varchar',
    nullable: false,
    maxLength: 2046,
    rules: { minLength: 1 },
  },
  {
    name: 'scopes',
    type: 'json',
    nullable: true,
  },
  {
    name: 'codeChallenge',
    type: 'varchar',
    nullable: true,
    maxLength: 128,
  },
  {
    name: 'codeChallengeMethod',
    type: 'varchar',
    nullable: true,
    maxLength: 16,
  },
  {
    name: 'expiresAt',
    type: 'timestamp',
    nullable: false,
  },
  {
    name: 'isUsed',
    type: 'boolean',
    nullable: false,
  },
  {
    name: 'createdAt',
    type: 'timestamp',
    nullable: true,
  },
  {
    name: 'updatedAt',
    type: 'timestamp',
    nullable: true,
  },
  {
    name: 'deletedAt',
    type: 'timestamp',
    nullable: true,
  },
];
