Reorganize repo structure and standards references

This commit is contained in:
david committed 2026-06-29 05:03:42 +02:00
1 parent 3cb93a81be
commit be2054274d
5885 files changed
+2588 -195

No files matched your search

@@ -0,0 +1,58 @@
import { getDbClient } from "./client.server.js";
export type LegacyEventWebhookAttempt = {
id: string;
endpoint: string;
tenantId: string | null;
};
export type LegacyEventWebhookAttemptUpdate = {
startedAt?: Date;
finishedAt?: Date;
success?: boolean;
status?: number;
message?: string;
body?: string;
};
export type LegacyEventWebhookAttemptClient = {
eventWebhookAttempt: {
findUnique(args: {
where: { id: string };
select: { id: true; endpoint: true; event: { select: { tenantId: true } } };
}): Promise<{ id: string; endpoint: string; event: { tenantId: string | null } } | null>;
updateMany(args: {
where: { id: string; event: { tenantId: string | null } };
data: LegacyEventWebhookAttemptUpdate;
}): Promise<{ count: number }>;
};
};
export async function findLegacyEventWebhookAttemptById(
id: string,
client: LegacyEventWebhookAttemptClient = getDbClient(),
): Promise<LegacyEventWebhookAttempt | null> {
const attempt = await client.eventWebhookAttempt.findUnique({
where: { id },
select: {
id: true,
endpoint: true,
event: { select: { tenantId: true } },
},
});
return attempt ? { id: attempt.id, endpoint: attempt.endpoint, tenantId: attempt.event.tenantId } : null;
}
export async function updateLegacyEventWebhookAttempt(
{ id, tenantId }: { id: string; tenantId: string | null },
data: LegacyEventWebhookAttemptUpdate,
client: LegacyEventWebhookAttemptClient = getDbClient(),
): Promise<void> {
const updated = await client.eventWebhookAttempt.updateMany({
where: { id, event: { tenantId } },
data,
});
if (updated.count !== 1) {
throw new Error(`Event webhook attempt ${id} not found`);
}
}