# @aurora-catalyst-generated
# @source cliter/o-auth/application.aurora.yaml

type OAuthApplication {
  """
  Unique identifier for the application. UUID v4 format, generated automatically on creation.
  """
  id: ID!
  """
  Auto-incrementing row identifier. Used for internal ordering and as a numeric alternative to UUID.
  """
  rowId: GraphQLInt!
  """
  Unique code identifier for the application. Used as the client_id in OAuth flows. Convention: Lowercase, hyphen-separated (e.g., my-app, mobile-client).
  """
  code: GraphQLString!
  """
  Human-readable name for the application. Displayed in authorization prompts and admin interfaces.
  """
  name: GraphQLString!
  """
  Application secret used for authentication. SECURITY: Must be stored securely, hashed, and never exposed to clients. Used as client_secret in confidential OAuth flows.
  """
  secret: GraphQLString!
  """
  Indicates whether this is a master application with elevated privileges. Master applications typically have access to all scopes and bypass certain restrictions.
  """
  isMaster: GraphQLBoolean!
  """
  Many-to-many relationship with OAuth clients. An application can have multiple clients representing different grant types or deployment environments.
  """
  clients: [OAuthClient]
  """
  Timestamp when the application was created. Automatically set on creation.
  """
  createdAt: GraphQLTimestamp
  """
  Timestamp when the application was last updated. Automatically updated on modification.
  """
  updatedAt: GraphQLTimestamp
  """
  Soft delete timestamp. NULL means active application. When set, application is excluded from normal queries but preserved for audit trail.
  """
  deletedAt: GraphQLTimestamp
}

input OAuthCreateApplicationInput {
  id: ID!
  code: GraphQLString!
  name: GraphQLString!
  secret: GraphQLString!
  isMaster: GraphQLBoolean!
  clientIds: [ID]
}

input OAuthUpdateApplicationByIdInput {
  id: ID!
  code: GraphQLString
  name: GraphQLString
  secret: GraphQLString
  isMaster: GraphQLBoolean
  clientIds: [ID]
}

input OAuthUpdateApplicationsInput {
  id: ID
  code: GraphQLString
  name: GraphQLString
  secret: GraphQLString
  isMaster: GraphQLBoolean
  clientIds: [ID]
}
type Query {
  oAuthFindApplication(query: QueryStatement, constraint: QueryStatement): OAuthApplication

  oAuthFindApplicationById(id: ID, constraint: QueryStatement): OAuthApplication

  oAuthGetApplications(query: QueryStatement, constraint: QueryStatement): [OAuthApplication]!

  oAuthPaginateApplications(query: QueryStatement, constraint: QueryStatement): Pagination!
}

type Mutation {
  oAuthCreateApplication(payload: OAuthCreateApplicationInput!): OAuthApplication

  oAuthUpdateApplicationById(
    payload: OAuthUpdateApplicationByIdInput!
    constraint: QueryStatement
  ): OAuthApplication

  oAuthDeleteApplicationById(id: ID!, constraint: QueryStatement): OAuthApplication
}
