diff --git a/src/commands/mail/deliverybox/update.tsx b/src/commands/mail/deliverybox/update.tsx index 77da7b19..2fd7299d 100644 --- a/src/commands/mail/deliverybox/update.tsx +++ b/src/commands/mail/deliverybox/update.tsx @@ -9,11 +9,11 @@ import { Text } from "ink"; import { Success } from "../../../rendering/react/components/Success.js"; import { ReactNode } from "react"; import { ProcessRenderer } from "../../../rendering/process/process.js"; +import { generateRandomPassword } from "../../../lib/resources/mail/commons.js"; import { mailDeliveryBoxArgs, withDeliveryBoxId, } from "../../../lib/resources/mail/flags.js"; -import { generateRandomPassword } from "../../../lib/resources/mail/commons.js"; type UpdateResult = { generatedPassword: string | null; diff --git a/src/lib/resources/mail/flags.ts b/src/lib/resources/mail/flags.ts index 2f6fb3be..6438afc7 100644 --- a/src/lib/resources/mail/flags.ts +++ b/src/lib/resources/mail/flags.ts @@ -1,6 +1,7 @@ import { makeProjectFlagSet } from "../project/flags.js"; import { assertStatus } from "@mittwald/api-client-commons"; import { validate as validateUuid } from "uuid"; +import FlagSetBuilder from "../../context/FlagSetBuilder.js"; export const { flags: mailAddressFlags, @@ -29,22 +30,6 @@ export const { flags: mailDeliveryBoxFlags, args: mailDeliveryBoxArgs, withId: withDeliveryBoxId, -} = makeProjectFlagSet("maildeliverybox", "d", { - normalize: async (apiClient, projectId, id): Promise => { - if (validateUuid(id)) { - return id; - } - - const response = await apiClient.mail.listDeliveryBoxes({ projectId }); - assertStatus(response, 200); - - const deliveryBox = response.data.find( - (deliveryBox) => deliveryBox.id === id, - ); - if (!deliveryBox) { - throw new Error(`mail delivery box with id "${id}" not found`); - } - - return deliveryBox.id; - }, -}); +} = new FlagSetBuilder("maildeliverybox", "d", { + retrieveFromContext: false, +}).build();