/**
 * @aurora-catalyst-generated
 * @source cliter/o-auth/credential.aurora.yaml
 */
import { IamAccountFieldSchema } from '@app/iam/account';
import { OAuthAccessTokenFieldSchema } from '@app/o-auth/access-token';
import { OAuthRefreshTokenFieldSchema } from '@app/o-auth/refresh-token';
import { FieldSchema } from '@aurorajs.dev/core-back';

/**
 * Field schema for OAuthCredential, derived from cliter/o-auth/credential.aurora.yaml.
 * Used by @Sanitize decorator, @Format decorator and @ApplySchema decorator.
 */
export const OAuthCredentialFieldSchema: FieldSchema[] = [
  {
    name: 'id',
    type: 'id',
    nullable: false,
    maxLength: 36,
  },
  {
    name: 'grantType',
    type: 'enum',
    nullable: false,
    enumOptions: ['PASSWORD', 'REFRESH_TOKEN', 'AUTHORIZATION_CODE'],
  },
  {
    name: 'accountId',
    type: 'id',
    nullable: false,
    maxLength: 36,
  },
  {
    name: 'account',
    type: 'relation',
    cardinality: 'one',
    target: () => IamAccountFieldSchema,
  },
  {
    name: 'accessTokenId',
    type: 'id',
    nullable: true,
    maxLength: 36,
  },
  {
    name: 'accessToken',
    type: 'relation',
    cardinality: 'one',
    target: () => OAuthAccessTokenFieldSchema,
  },
  {
    name: 'refreshTokenId',
    type: 'id',
    nullable: true,
    maxLength: 36,
  },
  {
    name: 'refreshToken',
    type: 'relation',
    cardinality: 'one',
    target: () => OAuthRefreshTokenFieldSchema,
  },
  {
    name: 'ipAddress',
    type: 'varchar',
    nullable: true,
    maxLength: 45,
  },
  {
    name: 'userAgent',
    type: 'varchar',
    nullable: true,
    maxLength: 255,
  },
  {
    name: 'createdAt',
    type: 'timestamp',
    nullable: true,
  },
  {
    name: 'updatedAt',
    type: 'timestamp',
    nullable: true,
  },
  {
    name: 'deletedAt',
    type: 'timestamp',
    nullable: true,
  },
];
