import { AccessRule, type AccessRuleSchema } from './AccessRule.js'

/**
 * The action is allowed for any authenticated user.
 * This rule does not impose any additional restrictions based on user properties or resource ownership.
 * It is used for resources that should be accessible to all logged-in users.
 */
export interface AllowAuthenticatedAccessRuleSchema extends AccessRuleSchema {
  type: 'allowAuthenticated'
}

/**
 * The action is allowed for any authenticated user.
 * This rule does not impose any additional restrictions based on user properties or resource ownership.
 * It is used for resources that should be accessible to all logged-in users.
 */
export class AllowAuthenticatedAccessRule extends AccessRule implements AllowAuthenticatedAccessRuleSchema {
  override readonly type: 'allowAuthenticated'

  constructor(state: Partial<AllowAuthenticatedAccessRuleSchema> = {}) {
    super(state)
    this.type = 'allowAuthenticated'
  }
}
