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

/**
 * Field schema for OAuthAccessToken, derived from cliter/o-auth/access-token.aurora.yaml.
 * Used by @Sanitize decorator, @Format decorator and @ApplySchema decorator.
 */
export const OAuthAccessTokenFieldSchema: FieldSchema[] = [
  {
    name: 'id',
    type: 'id',
    nullable: false,
    maxLength: 36,
  },
  {
    name: 'clientId',
    type: 'id',
    nullable: false,
    maxLength: 36,
  },
  {
    name: 'client',
    type: 'relation',
    cardinality: 'one',
    target: () => OAuthClientFieldSchema,
  },
  {
    name: 'accountId',
    type: 'id',
    nullable: true,
    maxLength: 36,
  },
  {
    name: 'token',
    type: 'text',
    nullable: false,
    rules: { minLength: 1 },
  },
  {
    name: 'name',
    type: 'varchar',
    nullable: true,
    maxLength: 128,
  },
  {
    name: 'isRevoked',
    type: 'boolean',
    nullable: false,
  },
  {
    name: 'expiresAt',
    type: 'timestamp',
    nullable: true,
  },
  {
    name: 'refreshToken',
    type: 'relation',
    cardinality: 'one',
    target: () => OAuthRefreshTokenFieldSchema,
  },
  {
    name: 'createdAt',
    type: 'timestamp',
    nullable: true,
  },
  {
    name: 'updatedAt',
    type: 'timestamp',
    nullable: true,
  },
  {
    name: 'deletedAt',
    type: 'timestamp',
    nullable: true,
  },
];
