export const TECHNICAL_ALIASES = ['@last', '@first', '@upload'] as const;

export const RESERVED_ALIASES = [
  ...TECHNICAL_ALIASES,
  '@all',
  '@latest',
  '@oldest',
  '@random',
  '@next',
  '@prev',
  '@previous',
] as const;

export const ALIAS_PATTERN = /^@[a-zA-Z0-9_-]+$/;

export const ALIAS_MAX_LENGTH = 50;

export type TechnicalAlias = (typeof TECHNICAL_ALIASES)[number];
export type ReservedAlias = (typeof RESERVED_ALIASES)[number];

export const isTechnicalAlias = (alias: string): alias is TechnicalAlias => {
  return TECHNICAL_ALIASES.includes(alias as TechnicalAlias);
};

export const isReservedAlias = (alias: string): alias is ReservedAlias => {
  return RESERVED_ALIASES.includes(alias as ReservedAlias);
};

export const isValidAliasFormat = (alias: string): boolean => {
  return ALIAS_PATTERN.test(alias) && alias.length <= ALIAS_MAX_LENGTH;
};
