Skip to content

Commit

Permalink
fix: replace 'makeProjectFlagSet' with simple 'new FlagSetBuilder'
Browse files Browse the repository at this point in the history
  • Loading branch information
tillwestpfahl committed Aug 28, 2024
1 parent ed9bdf6 commit 2310072
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/commands/mail/deliverybox/update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 4 additions & 19 deletions src/lib/resources/mail/flags.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -29,22 +30,6 @@ export const {
flags: mailDeliveryBoxFlags,
args: mailDeliveryBoxArgs,
withId: withDeliveryBoxId,
} = makeProjectFlagSet("maildeliverybox", "d", {
normalize: async (apiClient, projectId, id): Promise<string> => {
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();

0 comments on commit 2310072

Please sign in to comment.