34 lines
727 B
TypeScript
34 lines
727 B
TypeScript
import { getDbClient } from "./client.server.js";
|
|
|
|
export type LegacyWidget = {
|
|
id: string;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
tenantId: string | null;
|
|
name: string;
|
|
appearance: string;
|
|
metadata: string;
|
|
};
|
|
|
|
export type LegacyWidgetReaderClient = {
|
|
widget: {
|
|
findFirst(args: {
|
|
where: { id: string; tenantId: string };
|
|
}): Promise<LegacyWidget | null>;
|
|
};
|
|
};
|
|
|
|
export type LegacyWidgetLookup = {
|
|
widgetId: string;
|
|
tenantId: string;
|
|
};
|
|
|
|
export async function findLegacyWidgetById(
|
|
{ widgetId, tenantId }: LegacyWidgetLookup,
|
|
client: LegacyWidgetReaderClient = getDbClient(),
|
|
): Promise<LegacyWidget | null> {
|
|
return client.widget.findFirst({
|
|
where: { id: widgetId, tenantId },
|
|
});
|
|
}
|