import { defineWorkflow } from "openworkflow";
export const fetchAllData = defineWorkflow(
{ name: "fetch-all-data" },
async ({ input, step }) => {
const [user, subscription, settings] = await Promise.all([
step.run({ name: "fetch-user" }, async () => {
return await db.users.findOne({ id: input.userId });
}),
step.run({ name: "fetch-subscription" }, async () => {
return await stripe.subscriptions.retrieve(input.subId);
}),
step.run({ name: "fetch-settings" }, async () => {
return await db.settings.findOne({ userId: input.userId });
}),
]);
return { user, subscription, settings };
},
);