import { z } from "zod";
import { DynaBridgeEntity } from 'dynabridge';

export const DOOR_ALIAS_SK = "alias";

export const DoorAliasSchema = z.object({
  // keys
  PK: z.string(), // phone number (buzzer number)
  SK: z.literal(DOOR_ALIAS_SK).default(DOOR_ALIAS_SK),
  name: z.string(),
});

export const getDoorAliasID = (buzzer: string): string[] => {
  return [buzzer, DOOR_ALIAS_SK];
}

export type DoorAlias = z.infer<typeof DoorAliasSchema>;

export const DoorAliasEntity: DynaBridgeEntity<DoorAlias> = {
  tableName: "doorman",
  id: ["PK", "SK"],
};
