- Add formatError() helper in CLI to safely handle unknown error types - Add uniqueTestId() helper for generating unique test identifiers - Replace String(id) with id.toString() for database ID conversions - Replace String(n) with n.toLocaleString() for user-facing number formatting - Fix TypeScript errors in test files (undefined checks, unused variables) - Update lint commands to include ast-grep scanning Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
51 lines
1.4 KiB
TypeScript
51 lines
1.4 KiB
TypeScript
import type { LocalContext } from "../../context.js";
|
|
import { ORPCError } from "@orpc/client";
|
|
import { buildCommand } from "@stricli/core";
|
|
import { createApiClient } from "../../utils/api-client.js";
|
|
import { formatError } from "../../utils/format-error.js";
|
|
|
|
interface CompleteLoginFlags {
|
|
email: string;
|
|
}
|
|
|
|
async function completeLogin(
|
|
this: LocalContext,
|
|
flags: CompleteLoginFlags,
|
|
): Promise<void> {
|
|
try {
|
|
const api = await createApiClient();
|
|
|
|
await api.admin.auth.completeLogin({
|
|
email: flags.email,
|
|
});
|
|
|
|
console.log(`Completed login request for: ${flags.email}`);
|
|
} catch (error) {
|
|
if (error instanceof ORPCError) {
|
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions -- ORPCError.code is typed as any
|
|
console.error(`Error [${error.code}]:`, error.message);
|
|
} else {
|
|
console.error("Error:", formatError(error));
|
|
}
|
|
this.process.exit(1);
|
|
}
|
|
}
|
|
|
|
export const completeLoginCommand = buildCommand({
|
|
func: completeLogin,
|
|
parameters: {
|
|
flags: {
|
|
email: {
|
|
kind: "parsed",
|
|
parse: String,
|
|
brief: "Email address of user with pending login request",
|
|
},
|
|
},
|
|
},
|
|
docs: {
|
|
brief: "Complete pending login request",
|
|
fullDescription:
|
|
"Completes the most recent pending login request for a user. This is useful for development when email sending is not configured or to bypass email confirmation.",
|
|
},
|
|
});
|